poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43376] - Macro code lost after edit a ppt file
Date Mon, 17 Sep 2007 18:54:21 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43376>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43376





------- Additional Comments From yegor@dinom.ru  2007-09-17 11:54 -------
How interesting!

I was sure it's a lost POIFS entry. In Word and Excel macros do live
in POIFS! It turns out PPT is a different case (:.
 
Here is what I've found:
In PPT macros are stored in ExOleObjStg root-level records. I changed the macro
code, saved the ppt and compared it with the original. 
The only difference was in ExOleObjStg. Thanks to Trejkaz, now we have accessors
to this data.

Here is a test code to dump ExOleObjStg in filesystem:

        FileInputStream fis = new FileInputStream("temp.ppt");
        HSLFSlideShow hss = new HSLFSlideShow(fis);

        ObjectData[] obj = hss.getEmbeddedObjects();
        for (int i = 0; i < obj.length; i++) {
            FileOutputStream out = new FileOutputStream("objdata-" + (i+1) +
".dat");
            InputStream is = obj[i].getData();
            byte[] chunk = new byte[16184];
            int count;
            while ((count = is.read(chunk)) >=0 ) {
              out.write(chunk,0,count);
            }
            out.close();
        }

Look at it in a text editor and see that "it is about macros" :).
It looks like this data has a reference (offset) to the owning slide. If I don't
change anything, just re-save the ppt then the macros are there.
If I add a shape the macros are lost. So the task is to find this place
and update the link.

I don't know how to parse this abracadabra. Any ideas?
 AFAIK, VBA macros are stored as "p-code + s-code" where p-code is compiled VBA
code and s-code is the source. That is ExOleObjStg contains both compiled and
source VBA code. 

Useful links are 
http://www.virushelpmunic.de/konferenz/1999/makroviren/ (In German)
http://www.uinc.ru/articles/46/ (In Russian)

They are about Word and Excel and I hope these ideas are applicable to PPT.


Regards,
Yegor

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

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


Mime
View raw message