Bug 55758 - Problems embedding non-office OLE object into PPT SlideShow
Summary: Problems embedding non-office OLE object into PPT SlideShow
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.10-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on: 55579
  Show dependency tree
Reported: 2013-11-07 15:40 UTC by Peter Adelmann
Modified: 2013-11-25 22:36 UTC (History)
0 users

PPT Slideshow with single molfile embedded (101.00 KB, application/vnd.ms-powerpoint)
2013-11-07 15:40 UTC, Peter Adelmann
OLE-implementation for Accelrys Draw .mol-file embedding (13.47 KB, application/octet-stream)
2013-11-25 22:32 UTC, Andreas Beeker

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Adelmann 2013-11-07 15:40:05 UTC
Created attachment 31026 [details]
PPT Slideshow with single molfile embedded

I have attached the code used for this prototype and both files although one is an empty ppt file which is pointless.  The file of interest is a mol file which is readable from accelerys draw version 4.1 (You may be able to d/l and install a trial of this software).  The object created from accelerys is called a mol file which is a representation of a molecule.  If you copy the mol file and paste it into a ppt slideshow it creates a ole object in the ppt file.  I have also attached(no I haven't only one attachement allowed) some java code which is based on PoiOleXlsInPpt a proof of concept out on the internet at 
The code uses an ppt/mol file and creates a new ppt and then attempts to create the ole object using poi's internals to embed the mol file and saves the new ppt file.  Based on our work with the code, the ppt file gets created, but then when trying to open the saved file with ppt. the application complains that the ppt file is corrupt and tries to repair but can't manange to repair the file and can't open the file.  So the ppt slideshow gets created but then can't be opened by ppt which suggests some is incorrect in the creation of the new file. Of course this use case works without a problem when the code which embeds the ole object is commented out.  So there's something in the embedding code which is not creating the object properly. Thanks.  I was going to try and attach the code but it doesn't look like multiple attachments are allowed so you got the ppt slideshow with a molfile embedded in it. I can provide our code if it makes things easier but I'm just trying to create a new ppt ss with the molfile embedded in it much like a copy and paste would do in windoze.  My real work is to get the molefile and embed into ppt but I can do that if we can just fix the issue with embedding the molefile into ppt. I can provide any additional info if needed.  Andreas Beeker was helping me on the user group and this bug is reported based on his suggestion.
Comment 1 Andreas Beeker 2013-11-25 22:32:45 UTC
Created attachment 31076 [details]
OLE-implementation for Accelrys Draw .mol-file embedding

The attachment contains a c# project to process a .mol file and generated
the neccessary ole object to be embedded by the also included java class.

An Accelrys Draw (AD) ole objects contains two streams.
1. "Contents": the bigger one, which is a concatenation of the following formats:
   - a mol-file
   - a skc-file
   - a mol-file, an ASCII-file, same as the 1st file, but with a line
     length (byte) as first char of the line
   - a emf-file
   - a wmf-file
   each file is prefixed with little endian integer, which specifies the file length
2. "\1Ole10Native": a "malformed" Ole10Native object, which is a subset of the
   Contents stream

as it works out, it's enough to embed the Contents stream

In the trial version, AD provides a few .net libraries and
JNI-Bridge consisting out of jar and two dlls. Although it's
possible to produce a few files of the mentioned above with
the bridge, it lacks emf/wmf support. There's a function
to copy data to and from the clipboard, which has the format 
of the contents stream, but it's not working.

After a bit of decompiling of the .net and .jar files,
I've started a small workaround c# project and it became visible
that the clipboard function always throws a "coinitialize hasn't
been called" error, no matter if I called coinitialize manually
or tweaked around the appartment model of the calling code.
The other functions work as designed.

So finally the solution is that c# helper, which generates the
contents stream and an emf preview image, and the embedding code
based on #55579.

It took a bit until the ensemble worked on Peters environment,
so in the rare case, that anybody else uses this code ;) ...
you might need to change the .net dll references and/or copy
various AD dlls to the local working dir.

As for the POI part this is only a very specific test, I'll
(try to) close this bug as "won't fix"