I played a bit around and tried out three ways to serialize the records to binary file:
- SlideShow.getMostRecentCoreRecords[i].writeOut(out);
- HSLFSlideShow.getRecords[i].writeOut(out);
- reading the docstream like its done in PPTXMLDump.java [poifs.createDocumentInputStream("PowerPoint Document").read(docstream)] then serialize docstream;

After loading the docstream and rebuilding the poifs, i want to create a new SlideShow. All three ending in "java.lang.RuntimeException: Creation support for Current User Atom not complete". However i can use the poifs.writeFilesystem to pruduce a (tested only with few ppts) perfect clone. (Not working with getMostRecentCoreRecords..., rebuild cant be opened...)
Thats how i rebuild the ppt:

fs = new POIFSFileSystem();
fsorg = new POIFSFileSystem(path to org ppt);
fin = new FileInputStream(path to records file);
fs.getRoot().createDocument("PowerPoint Document", fin);
ppt = new SlideShow(new HSLFSlideShow(fs.getRoot, fs));

I need to work with (user)models... What else must i serialize to get it working? Is it possible only to save the most recent records to save some disk space and to avoid problems with CurrentUserAtoms and PersistIncrementalBlocks?

I want to save the ppt in a db. But i cant just copy all binary data into the db, i need some more abstract level, and as i didnt get good results with the (user)models i want to use the record level now to dump the ppt and then transform the records to models after i loaded them.

regards
Felix


Felix Kalka schrieb:
I want to serialize the most recent records to some binary file.
Could you give me some information on how i can rebuild the ppt of the binary data records stream. I thought that i only save the most recent records due to disk space and so i dont have to handle with the PersistIncBlock-Stuff. Is this idea right and do i have all necesary data to rebuild exactly the same ppt in the most recent recs?

regards,
felix

Yegor Kozlov schrieb:
For example the PPTXMLDump.java from you, Yegor, does it generate a xml file with all necesary data to rebuild the presentation?

Yes, it generates all necessary data to rebuild the presentation.
Suppose you serialize root records and want to assemble a ppt from them. A typical structure of records is as follows:

 - Document
 - MainMaster
 - Slide1
 - Slide2
 ...
 - Slide N
 - PersistIncrementalBlock
 - UserEditAtom

The tricky part is PersistIncrementalBlock. For each root record it maps the record offset and persistId. In its turn, persistId is referenced in Document.SlideListWithText.SlidePersistAtom. If you assemble a ppt from slides from different slide shows you need to make sure Document.SlideListWithText and PersistIncrementalBlock match.


Yegor

regards,
felix

Yegor Kozlov schrieb:
Generally speaking, your rebuilt ppt will always be lossy. You have to rebuilt the master sheet too but for now masters are read-only - HSLF can read from master sheets but can't modify them.

There are three important pieces of data to preserve:

 (a) Anchor - defines position of a shape in the slide:
    Rectangle2D anchor = shape.getAnchor2D();

 (b) Text properties, the ones returned by RichTextRun getters.

 (c) basic shape properties, aka "Escher" properties.
The code below demonstrates how to copy Escher properties from one shape to another :


        Map<Integer, Integer> shapeProps = new HashMap();
org.apache.poi.hslf.model.Shape srcShape = ....; // source shape EscherOptRecord opt = (EscherOptRecord)srcShape.getEscherChild(srcShape.getSpContainer(), EscherOptRecord.RECORD_ID); for (Iterator it = opt.getEscherProperties().iterator(); it.hasNext(); ) {
            Object p = it.next();
            if(p instanceof EscherSimpleProperty){
                EscherSimpleProperty sp = (EscherSimpleProperty)p;
                int propId = sp.getId();
                int propValue = sp.getPropertyValue();
                shapeProps.put(propId, propValue);
            } else {
                //for simplicity skip complex and array properties
            }
        }

        //rebuilding presentation
        org.apache.poi.hslf.model.Shape tgtShape = ...; //target shape
for (Iterator<Integer> it = shapeProps.keySet().iterator(); it.hasNext(); ) {
            int propId = it.next();
            int propValue = shapeProps.get(propId);
            tgtShape.setEscherProperty((short)propId, propValue);
        }


Regards,
Yegor

Hi all,
i wrote a programm that iterates over all slides of a presentation and saves all the data of its elements (raw text of TextBoxes/AutoShapes, binary data of Pictures, etc) in some other place.
now i want to "rebuild" the presentation with those elements.
So my question is what fields/objects must i save that the rebuilded presentation looks like the original one? For now, im just talking about TextBoxes and AutoShapes, but i dont mind any answer that helps with other Shape-objects too :) When i save all the fields from my RichTextRun and Shape-objects i have getter/setter-Methods for (eg. fontname/size, bold, italic... margin, alignment...) it doesnt look the same. if i write my original created SlideShow-object out to the filesystem, it looks like the original presenation... So i think i just miss to save some fields... Maybe theres a way to marshal/unmarshal the objects needed to format the presentation, so i dont have to handle with alot of fields... Since i dont know alot about mastersheets and i read that POI dont know much either, i dont know what can be handled through it...

greetings,
Felix

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to