Bug 52912

Summary: the custom properties write to documents visible from Windows Explorer – but do not display in Office.
Product: POI Reporter: llian
Component: HPSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: critical    
Priority: P2    
Version: 3.8-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: sample document and screen shot related to this issue

Description llian 2012-03-15 01:12:20 UTC
Created attachment 28468 [details]
sample document and screen shot related to this issue

When adding custom properties to a Microsoft Office Word 97 - 2003 document, the properties are not displayed within office Word but visible with the Windows Explorer. Custom means the properties displayed on the "Custom" tab in the documents properties.

This used to be working perfectly in poi3.8.beta4. the issue is happening after upgrading to poi3.8.beta5.

Here is the piece of code we are using to adding custom properties,
File doc1 = new File("test.dpc");
		POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(doc1));
		DirectoryEntry dir = poifs.getRoot();
		DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
		DocumentEntry dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

		DocumentInputStream dis = new DocumentInputStream(siEntry);
		PropertySet ps = new PropertySet(dis);
		SummaryInformation si = new SummaryInformation(ps);
		dis = new DocumentInputStream(dsiEntry);
		ps = new PropertySet(dis);
		DocumentSummaryInformation dsi = new    DocumentSummaryInformation(ps);
		CustomProperties customProperties = dsi.getCustomProperties();
		if (customProperties == null)
			customProperties = new CustomProperties();
		customProperties.put("doc_repo_id", "123456789");

		// Save as our custom properties
		dsi.setCustomProperties(customProperties);
		si.write(dir, siEntry.getName());
		dsi.write(dir, dsiEntry.getName());

		File output = new File("C:\\tempoutput.doc");
		OutputStream out = new FileOutputStream(output);
		poifs.writeFilesystem(out);
		out.close();

Attached "Test write custom properties.doc", 
"properties invisible from office.PNG" and "properties visible from Windows Explorer.PNG" to show this issue.

Same issue for excel document too refer to "Test write custom properties2.xls".

It seems the issue applies to all Microsoft Office Word 97 - 2003 document only.
We tested Word format docx which is Office 2007 and Office 2010 and it worked.

Read more: http://www.differencebetween.com/difference-between-doc-and-vs-docx-in-microsoft-word/#ixzz1p8xFycgr


This issue is critical because our office component is heavily using custom properties to integrate with other application.
Comment 1 Yegor Kozlov 2012-03-15 08:25:53 UTC
Can you please try with the latest build from trunk? There have been fixes in HPFS recently. 

Yegor
Comment 2 llian 2012-03-22 18:06:31 UTC
I tried with the latest build from trunk (poi-3.9-beta1) and it worked fine. 

Thanks!

Leon