My expectation is that this is not a bug.

I think that this is probably a timing problem based on the speed of the computer, the size of the document, how busy your CPU is, etc. If you do not have a number, then the values have probably not updated yet. Remember that the data model has no idea what page number it really is. This value must be updated by the view model / current controller (or something similar). If you have a value, then it just so happens that the values updated immediately. If you insert the value using the GUI, that code is smart enough to then trigger the update before it returns.

On 08/21/2012 03:23 AM, dongjun zong wrote:
The strange thing is this API can works fine for doc sample file. I guess
this is a bug.

2012/8/21 Andrew Douglas Pitonyak <and...@pitonyak.org>

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<http://www.pitonyak.org/AndrewMacro.odt>
Info:  http://www.pitonyak.org/oo.php



--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php

Reply via email to