xTextField change text with UNO C++

Hello!

Is there any way to change text in the xTextField? For example I added a custom xTextField in the .odt document, it called “Title” and I want to change the text in it with C++.

Something like

Reference xText = Reference(current_field, UNO_QUERY);
xText.setText(new_text);

doesn’t work. Any suggestions?

UPD:

My exact the same question on StackOverflow:

I posted the answer at c++ - Libreoffice API (UNO) : text and data from xTextField - Stack Overflow. If you ask in more than one place, please add links so people can follow your question.

done! I added a link. thanks for an advice