Oliver,
I found that if page is more than 2, it will has problem. Would you pls
help try a 3 page exist odt sample for this issue?
2012/8/21 Oliver Brinzing <[email protected]>
> > The strange thing is this API can works fine for doc sample file.
>
> the following code works for me with a new doc, output is: Hello 1 World!!!
>
> public class TextfieldProblem {
> public void setTextfield(XComponent component) {
> XMultiServiceFactory serviceFactory =
> UnoRuntime.queryInterface(
> XMultiServiceFactory.class, component);
> XTextField pageNumberFiled = null;
> try {
> pageNumberFiled = UnoRuntime
> .queryInterface(
> XTextField.class,
> serviceFactory
>
> .createInstance("com.sun.star.text.textfield.PageNumber"));
> XPropertySet props =
> UnoRuntime.queryInterface(XPropertySet.class,
> pageNumberFiled);
> props.setPropertyValue("NumberingType",
>
> com.sun.star.style.NumberingType.ARABIC);
> props.setPropertyValue("SubType",
>
> com.sun.star.text.PageNumberType.CURRENT);
> } catch (Exception e) {
> e.printStackTrace();
> }
> XTextDocument document =
> UnoRuntime.queryInterface(XTextDocument.class,
> component);
> try {
>
> document.getText().insertString(document.getText().getStart(),
> "Hello ", true);
>
> document.getText().insertTextContent(document.getText().getEnd(),
> pageNumberFiled, true);
>
> document.getText().insertString(document.getText().getEnd(),
> " World!!!", true);
> } catch (IllegalArgumentException e) {
> e.printStackTrace();
> }
> getTextfield(document);
> }
>
> public void getTextfield(XComponent xComponent) {
> XTextDocument document =
> UnoRuntime.queryInterface(XTextDocument.class,
> xComponent);
> String documentString = document.getText().getString();
> System.out.println(documentString);
> }
> }
>
>
>
> Regards
>
> Oliver
> --
>
> GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45
>
>