incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dongjun zong <zongdj...@gmail.com>
Subject Is there difference of Author Field create by UNO API and UI Insert->Fields->Author
Date Thu, 23 Aug 2012 05:58:47 GMT
Hi All,
      I am tring to use UNO API create  and load an Author field, I found
below difference.
1. Author Field created by UNO API, after save the document od MS Doc
format, field will be lost
2. Author Field create by UI Insert->Fields->Author, when access the field
by UNO API, there is no Property  Name "Content" but has Porpety Name
"Author"

Is this a UNO API bug?

 Property Name list of Author Field created by UI
AnchorTypes=[Lcom.sun.star.text.TextContentAnchorType;@27391d
IsFixed=false
TextWrap=com.sun.star.text.WrapTextMode@1b1aa65
CurrentPresentation=Author AOO
IsFieldUsed=true
IsFieldDisplayed=true
AnchorType=com.sun.star.text.TextContentAnchorType@af8358
Author=Author AOO

Propoerty Name List of Author Field Created by UNO API

AnchorTypes=[Lcom.sun.star.text.TextContentAnchorType;@29428e
IsFixed=true
TextWrap=com.sun.star.text.WrapTextMode@3901c6
CurrentPresentation=Author Test AOO
IsFieldUsed=true
IsFieldDisplayed=true
AnchorType=com.sun.star.text.TextContentAnchorType@edc3a2
FullName=false
Content=Author Test AOO


Below is my code:
public void createAndLoadAuthorField(XComponent component, String author) {
        XMultiServiceFactory sevriceFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, component);
        XTextField authorField;
        try {
            authorField =
(XTextField)UnoRuntime.queryInterface(XTextField.class,
sevriceFactory.createInstance("com.sun.star.text.textfield.Author"));
            XPropertySet props =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, authorField);
            props.setPropertyValue("Content", author);



 document.getText().insertTextContent(document.getText().getEnd(),
                     authorField, true);
             XTextFieldsSupplier fieldsSupplier =
UnoRuntime.queryInterface(XTextFieldsSupplier.class, document);
             XEnumerationAccess xEnumeratedFields =
fieldsSupplier.getTextFields();

                XEnumeration enumeration =
xEnumeratedFields.createEnumeration();
                while (enumeration.hasMoreElements()) {
                          Object field =  enumeration.nextElement();

                        XPropertySet props2 =
(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, field);
                        XPropertySetInfo info = props2.getPropertySetInfo();
                        Property[] pp = info.getProperties();
                        for (Property p : pp) {
                            System.out.println(p.Name + "=" +
props2.getPropertyValue(p.Name));
                        }
                }

        } catch (com.sun.star.uno.Exception e) {
            e.printStackTrace();
        }
    }

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