Re: Working with embedded OLE files/packages

Mathias Bauer <[email protected]> Wed, 05 Jan 2011 11:49:29 +0100
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
Hi David,

On 07.12.2010 12:24, David Roe wrote:
> I have some Excel spreadsheets that contain files embedded as OLE packages
> (Insert->Object-> From file). I want to retrieve the data for those files.
> I've managed to use the API to retrieve the Shape object and get at the OLE
> data but I don't fancy writing my own OLE reading code. Is there an API to
> get at the data inside? I saw css.embed.OLESimpleStorage but I can't seem to
> get anywhere with that. My code so far is (in Python):
>
>          # ... setting up of OOo ...
>
>          sheet = doc.Sheets.getByName('Sheet1')
>          draw_page = sheet.DrawPage
>
>          shape = draw_page.getByIndex(0)
>
>          # CLSID 00000000-0000-0000-0000-000000000000 is a file??
>          print 'CLSID:', shape.CLSID
>
>          obj = shape.EmbeddedObject
>
>          # Create a "storage" object to hold the data from our embedded
> object
>          storage_factory =
> service_manager.createInstance('com.sun.star.embed.StorageFactory')
>          storage = storage_factory.createInstance()
>
>          # Store the data into the "Something" entry of our storage object
>          obj.storeToEntry(storage, 'Something', (), ())
>
>          str_elem = storage.openStreamElement('Something', ElementModes.READ)
>          stream = str_elem.getInputStream()
>
>          sfa =
> service_manager.createInstance('com.sun.star.ucb.SimpleFileAccess')
>          sfa.writeFile(file_url('test.txt'), stream)
>
> Thanks,
> David Roe
>

As you are asking here, this code obviously doesn't work. Can you tell 
us where something goes wrong?

Regards,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS
Please don't reply to "[email protected]".
I use it for the OOo lists and only rarely read other mails sent to it.