You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/07/16 10:03:55 UTC

DO NOT REPLY [Bug 47540] New: Custom properties and Extended properties are not saved

https://issues.apache.org/bugzilla/show_bug.cgi?id=47540

           Summary: Custom properties and Extended properties are not
                    saved
           Product: POI
           Version: 3.5-dev
          Platform: PC
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: roberto.manicardi@gmail.com


Custom properties and Extended properties are not saved when I create a new
XSSFWorkbook.

Below you can find one unit test for Extended properties and one for Custom
properties




    public void testWorkbookExtendedProperties() throws Exception {
        XSSFWorkbook workbook = new XSSFWorkbook();
        POIXMLProperties props = workbook.getProperties();
        assertNotNull(props);

        org.apache.poi.POIXMLProperties.ExtendedProperties properties =
props.getExtendedProperties();
       
org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
ctProps = properties.getUnderlyingProperties();


        String appVersion = "3.5 beta";
        String application = "POI";

        ctProps.setApplication(application);
        ctProps.setAppVersion(appVersion);

        ctProps=null;
        properties=null;
        props = null;

        XSSFWorkbook newWorkbook =
XSSFTestDataSamples.writeOutAndReadBack(workbook);

        assertTrue(workbook!=newWorkbook);


        POIXMLProperties newProps = newWorkbook.getProperties();
        assertNotNull(newProps);
        org.apache.poi.POIXMLProperties.ExtendedProperties newProperties =
newProps.getExtendedProperties();
       
org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTProperties
newCtProps = newProperties.getUnderlyingProperties();

        assertEquals(application,newCtProps.getApplication());
        assertEquals(appVersion,newCtProps.getAppVersion());




    }


    public void testWorkbookCustomProperties() throws Exception {
        XSSFWorkbook workbook = new XSSFWorkbook();
        POIXMLProperties props = workbook.getProperties();
        assertNotNull(props);

        org.apache.poi.POIXMLProperties.CustomProperties properties =
props.getCustomProperties();
       
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
ctProps = properties.getUnderlyingProperties();

       
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
property = ctProps.addNewProperty();


        String fmtid =
"{A1A1A1A1A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1A1A1A1A1}";
        int pId = 1;
        String name = "testProperty";
        String stringValue = "testValue";


        property.setFmtid(fmtid);
        property.setPid(pId);
        property.setName(name);
        property.setBstr(stringValue);


        property =null;
        ctProps=null;
        properties=null;
        props = null;

        XSSFWorkbook newWorkbook =
XSSFTestDataSamples.writeOutAndReadBack(workbook);

        assertTrue(workbook!=newWorkbook);


        POIXMLProperties newProps = newWorkbook.getProperties();
        assertNotNull(newProps);
        org.apache.poi.POIXMLProperties.CustomProperties newProperties =
newProps.getCustomProperties();
       
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties
newCtProps = newProperties.getUnderlyingProperties();

        assertEquals(1,newCtProps.getPropertyArray().length);


       
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty
newpProperty = newCtProps.getPropertyArray()[0];

        assertEquals(fmtid, newpProperty.getFmtid() );
        assertEquals(pId,newpProperty.getPid());
        assertEquals(name,newpProperty.getName());
        assertEquals(stringValue,newpProperty.getBstr());


    }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47540] Custom properties and Extended properties are not saved

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47540





--- Comment #1 from awm@mbcli.com  2009-07-17 08:44:19 PST ---
I also would like to add in that you can't currently save the XWPFDocument
properties. 

      XWPFDocument doc = new
XWPFDocument(POIXMLDocument.openPackage("c:\\test.docx"));

      CustomProperties props = doc.getProperties().getCustomProperties();

      CTProperty[] ctp = props.getUnderlyingProperties().getPropertyArray();
      for (CTProperty foo : ctp) {
          System.out.println(foo.toString());
      } 

But there is no, doc.setProperties(...) 
Tested with 3.5-beta7

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47540] Custom properties and Extended properties are not saved

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47540


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #2 from Yegor Kozlov <ye...@dinom.ru>  2009-07-19 11:30:28 PST ---
Fixed in r795587, junit added.

I also added an example on setting extended / custom OOXML properties:
http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java

Regards,
Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47540] Custom properties and Extended properties are not saved

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47540


awm@mbcli.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |awm@mbcli.com




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org