incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dongjun zong <zongdj...@gmail.com>
Subject Re: Is this a UNO API bug?
Date Tue, 21 Aug 2012 08:58:09 GMT
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 <Oliver.Brinzing@gmx.de>

> > 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
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message