OK, I had to look...
For a text field, see if you can call update. This may not work if the
document has not finished repaginating. I have heard of cases where a
document had not finished doing that before someone tried to do stuff to
it. The solution was to tell the document to full refresh (probably
using a dispatch).
On 08/21/2012 02:30 AM, Andrew Douglas Pitonyak wrote:
Did you successfully insert the text field? If yes, then after you
insert a text field, it has probably not yet refreshed its value. Off
hand, I don't remember exactly what you need to refresh first.... I
would need to look it up and I really need to run but figured it might
help you a bit and you can look for the various refresh items (I think
that you can refresh each index and for fields I think there may be a
single master field refresh but I don't remember... have not done it
in a long time.).
On 08/20/2012 03:32 AM, dongjun zong wrote:
Hi All,
Using UNO API I do below operation.
1.Launch a odt document,
2.Create a page number field and insert into this docment
3.Get the document text
But in the step3, page number is not contained in the get text. But if I
launch a doc document, I can get the page number in step 3. I think
this is
a UNO API bug, can some body help confirm? Below is my main code pieces.
XMultiServiceFactory sevriceFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
XTextField pageNumberFiled =
(XTextField)UnoRuntime.queryInterface(XTextField.class,
sevriceFactory.createInstance("com.sun.star.text.textfield.PageNumber"));
XPropertySet props =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
pageNumberFiled);
props.setPropertyValue("NumberingType", 4);//Set page number
display as Arabic
XTextCursor xTextCursor =
document.getText().createTextCursor();
xTextCursor.gotoEnd(false);
document.getText().insertTextContent(document.getText().getEnd(),
pageNumberFiled, true);
String documentString = document.getText().getString();
System.out.println(documentString);
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php