Bug 43222

Summary: [PATCH] Support for getting OLE objects from HSSFWorkbook
Product: POI Reporter: Trejkaz (pen name) <trejkaz>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: enhancement Keywords: PatchAvailable
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Patch to add embedded object support to HSSF
Test file for OLE2 embedding in an XLS file.
Patch version 2

Description Trejkaz (pen name) 2007-08-27 21:08:52 UTC
Added support for the sub-record which stores the embedded object IDs.  Added
usermodel API for getting access to the embedded object's data.
Comment 1 Trejkaz (pen name) 2007-08-27 21:09:23 UTC
Created attachment 20716 [details]
Patch to add embedded object support to HSSF
Comment 2 Trejkaz (pen name) 2007-08-27 21:17:41 UTC
Created attachment 20717 [details]
Test file for OLE2 embedding in an XLS file.

Attaching test file.

Unit test code: (there is a tiny amount of our framework in it to locate the
file, should be easily removed.

    /**
     * Tests that embedded objects are accessible.
     *
     * @throws Exception if an error occurs.
     */
    public void testEmbeddedObjects() throws Exception
    {
	File file = getDataFile("office/ole2-embedding.xls");
	HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
	List objects = workbook.getAllEmbeddedObjects();
	assertEquals("Wrong number of objects", 2, objects.size());
	assertEquals("Wrong name for first object", "MBD06CAB431",
		     ((HSSFObjectData)
objects.get(0)).getDirectory().getName());
	assertEquals("Wrong name for second object", "MBD06CAC85A",
		     ((HSSFObjectData)
objects.get(1)).getDirectory().getName());
    }
Comment 3 Trejkaz (pen name) 2007-08-29 18:09:55 UTC
Turns out this breaks something else, working on version 2.
Comment 4 Trejkaz (pen name) 2007-08-29 18:34:38 UTC
Created attachment 20734 [details]
Patch version 2

Here's the fixed version... it doesn't break the sheets, and is simpler than
the original anyway.
Comment 5 Yegor Kozlov 2007-09-08 09:40:37 UTC
Patch applied. Thanks for it.

I will not close this bug for the same reason as Bug 43222 - it lacks unit tests.
Please provide at least a unit test for EmbeddedObjectRefSubRecord. 

Also, dropping a line in the HSSF quick guide won't harm.   

Regards,
Yegor
Comment 6 Yegor Kozlov 2008-01-24 23:11:21 UTC
Unit tests were added. The bug can be closed.

Yegor