Is there any proper way to change text in the user's created xTextField using C++ UNO? These fields names are com.sun.star.text.fieldmaster.User.[FIELD NAME]
I tried this before, but it didn't help: Libreoffice API (UNO) : text and data from xTextField
Also I've tried something like this but still didn't help:
// current_field - xTextField I got before
Reference<XText> xText = Reference<XText>(current_field, UNO_QUERY);
if (!xText.is())
{
qDebug() << "XText FROM xTextField IS NULL!";
return;
}
OUStringBuffer bufText;
bufText.append( new_value.utf16() );
std::stringstream textStr;
textStr << bufText.toString();
xText->setString( bufText.toString() );
Any suggestions?
Did you read section 5.18 of Andrew's Macro Document as recommended in my other answer? Here is Listing 5.49 translated into C++. It seems there is a bug in that listing because I had to add
"."
to make it work.If this code is run on a blank document, the newly created field can be seen by going to Insert -> Fields -> More Fields, Variables, User Field.