hslf: formatting a presentation

View: New views
11 Messages — Rating Filter:   Alert me  

hslf: formatting a presentation

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Yegor Kozlov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ty for your awnser.
Issnt it possible to copy all (mostrecent) records and rebuild the
presentation out of it? or are the style properties saved in some other
place?
Im asking this, cuz i searched a bit in the source-tree and found some
interesting classes that are dumping the data on the record-layer.
For example the PPTXMLDump.java from you, Yegor, does it generate a xml
file with all necesary data to rebuild the presentation?

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: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Yegor Kozlov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: user-unsubscribe@...
>>>> For additional commands, e-mail: user-help@...
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: user-unsubscribe@...
>>>>> For additional commands, e-mail: user-help@...
>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>> For additional commands, e-mail: user-help@...
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 >>I need to work with (user)models... What else must i serialize to get
it working? <<
sorry that was a dumb question... it was easy to find it out myself ^^

 >>Is it possible only to save the most recent records to save some disk
space and to avoid problems with CurrentUserAtoms and
PersistIncrementalBlocks? <<
This is still very important for me. (Now i also dump the CUserAtom, but
if theres a way to skip it, i would appreciate it)

regards
felix


Felix Kalka schrieb:

> 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: user-unsubscribe@...
>>>>>> For additional commands, e-mail: user-help@...
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>>> For additional commands, e-mail: user-help@...
>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>> For additional commands, e-mail: user-help@...
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Nick Burch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 29 Jul 2008, Felix Kalka wrote:
> All three ending in "java.lang.RuntimeException: Creation support for
> Current User Atom not complete".

You might want to take a copy of a CurrentUserAtom, and re-use that every
time. See also http://poi.apache.org/hslf/ppt-file-format.html for why the
CurrentUserAtom is important, and in its own poifs file stream

> Is it possible only to save the most recent records to save some disk
> space and to avoid problems with CurrentUserAtoms and
> PersistIncrementalBlocks?

You'll still need a UserEditAtom and PersistPtrIncrementalBlock. However,
if you go for only the most recent records, you'll only need the one.
Without a CurrentUserAtom, UserEditAtom and PersistPtrIncrementalBlock,
powerpoint (and hslf) have no idea how to find and order the slides

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: hslf: formatting a presentation

by Nick Burch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 29 Jul 2008, Nick Burch wrote:
> On Tue, 29 Jul 2008, Felix Kalka wrote:
>> All three ending in "java.lang.RuntimeException: Creation support for
>> Current User Atom not complete".
>
> You might want to take a copy of a CurrentUserAtom, and re-use that
> every time.

Or do an svn checkout, as I've just added support for creating new
CurrentUserAtoms :)


Also, it's probably worth you reading pages 39-43 of the june 2008 edition
of the ppt file spec from microsoft. The docs on the poi site are probably
easier to get your head around, but the microsoft ones go into the full
detail, and I really wish we'd had them when we started on hslf!

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


HSLF: using master slides from source ppt in another ppt

by Felix Kalka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
is it possible to use the MainMasters from one ppt in another?

regards,
Felix

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: HSLF: using master slides from source ppt in another ppt

by Yegor Kozlov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, in theory it should be possible.

The tricky part is to make sure that all shared resources (Fonts and Pictures) are properly defined in the Document record.
Suppose you assemble a ppt from Document, MainMaster and Slide records, all from different slide shows.

Basically you need to do the following:

  - All sheets in ppt must be defined in a corresponding Document.SlideListWithText.
  - All fonts must be registered in Document.Environment.FontCollection.
  - All picture data must be in the Pictures data stream and the pictures must be described in Document.PPDrawingGroup
  - Construct PersistPtr and UserEditAtom records.
  - Write all records to a binary stream in the correct order


Yegor

> Hi,
> is it possible to use the MainMasters from one ppt in another?
>
> regards,
> Felix
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...

LightInTheBox - Buy quality products at wholesale price!