Oliver, thanks. But for the field created by API, save to MS doc binary format, field is lost, I think it's a bug? Am right?
2012/8/23 Oliver Brinzing <[email protected]> > > seems, there are 2 different fields: > > API: <text:author-name text:fixed="false">MyName</text:author-name> > > GUI: <text:initial-creator>MyName</text:initial-creator> > > Regards > > Oliver > > Am 23.08.2012 07:58 schrieb dongjun zong: > > 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(); > > } > > } > > > > > -- > > GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 > >
