mirror of https://github.com/apache/poi.git
Start to do more useful/sensible things with Slide IDs
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@388941 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1e0791f890
commit
8fb8942da5
|
@ -19,11 +19,7 @@
|
||||||
|
|
||||||
package org.apache.poi.hslf.model;
|
package org.apache.poi.hslf.model;
|
||||||
|
|
||||||
import java.util.*;
|
import org.apache.poi.hslf.record.PPDrawing;
|
||||||
|
|
||||||
import org.apache.poi.hslf.record.*;
|
|
||||||
import org.apache.poi.hslf.record.SlideListWithText.*;
|
|
||||||
import org.apache.poi.util.LittleEndian;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a slide's notes in a PowerPoint Document. It
|
* This class represents a slide's notes in a PowerPoint Document. It
|
||||||
|
@ -35,8 +31,8 @@ import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
public class Notes extends Sheet
|
public class Notes extends Sheet
|
||||||
{
|
{
|
||||||
|
|
||||||
private int _sheetNo;
|
private int _sheetNo;
|
||||||
|
private int _slideNo;
|
||||||
private org.apache.poi.hslf.record.Notes _notes;
|
private org.apache.poi.hslf.record.Notes _notes;
|
||||||
private TextRun[] _runs;
|
private TextRun[] _runs;
|
||||||
|
|
||||||
|
@ -48,9 +44,12 @@ public class Notes extends Sheet
|
||||||
*/
|
*/
|
||||||
public Notes (org.apache.poi.hslf.record.Notes notes) {
|
public Notes (org.apache.poi.hslf.record.Notes notes) {
|
||||||
_notes = notes;
|
_notes = notes;
|
||||||
|
|
||||||
|
// Grab our internal sheet ID
|
||||||
|
_sheetNo = notes.getSheetId();
|
||||||
|
|
||||||
// Grab the sheet number, via the NotesAtom
|
// Grab the number of the slide we're for, via the NotesAtom
|
||||||
_sheetNo = _notes.getNotesAtom().getSlideID();
|
_slideNo = _notes.getNotesAtom().getSlideID();
|
||||||
|
|
||||||
// Now, build up TextRuns from pairs of TextHeaderAtom and
|
// Now, build up TextRuns from pairs of TextHeaderAtom and
|
||||||
// one of TextBytesAtom or TextCharsAtom, found inside
|
// one of TextBytesAtom or TextCharsAtom, found inside
|
||||||
|
@ -67,8 +66,13 @@ public class Notes extends Sheet
|
||||||
public TextRun[] getTextRuns() { return _runs; }
|
public TextRun[] getTextRuns() { return _runs; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sheet number
|
* Returns the (internal, RefId based) sheet number (RefId)
|
||||||
*/
|
*/
|
||||||
public int getSheetNumber() { return _sheetNo; }
|
public int getSheetNumber() { return _sheetNo; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the (internal, identifer based) number of the slide we're attached to
|
||||||
|
*/
|
||||||
|
public int getSlideInternalNumber() { return _slideNo; }
|
||||||
|
|
||||||
protected PPDrawing getPPDrawing() { return _notes.getPPDrawing(); }}
|
protected PPDrawing getPPDrawing() { return _notes.getPPDrawing(); }}
|
||||||
|
|
|
@ -44,7 +44,8 @@ public abstract class Sheet
|
||||||
public abstract TextRun[] getTextRuns();
|
public abstract TextRun[] getTextRuns();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sheet number
|
* Returns the (internal, RefID based) sheet number, as used
|
||||||
|
* to reference this sheet from other records.
|
||||||
*/
|
*/
|
||||||
public abstract int getSheetNumber();
|
public abstract int getSheetNumber();
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
|
|
||||||
package org.apache.poi.hslf.model;
|
package org.apache.poi.hslf.model;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.apache.poi.hslf.record.*;
|
import org.apache.poi.hslf.record.PPDrawing;
|
||||||
import org.apache.poi.hslf.record.SlideListWithText.*;
|
import org.apache.poi.hslf.record.SlideAtom;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a slide in a PowerPoint Document. It allows
|
* This class represents a slide in a PowerPoint Document. It allows
|
||||||
|
@ -37,6 +37,7 @@ public class Slide extends Sheet
|
||||||
{
|
{
|
||||||
|
|
||||||
private int _sheetNo;
|
private int _sheetNo;
|
||||||
|
private int _slideNo;
|
||||||
private org.apache.poi.hslf.record.Slide _slide;
|
private org.apache.poi.hslf.record.Slide _slide;
|
||||||
private SlideAtomsSet _atomSet;
|
private SlideAtomsSet _atomSet;
|
||||||
private TextRun[] _runs;
|
private TextRun[] _runs;
|
||||||
|
@ -52,14 +53,12 @@ public class Slide extends Sheet
|
||||||
* @param notes the Notes sheet attached to us
|
* @param notes the Notes sheet attached to us
|
||||||
* @param atomSet the SlideAtomsSet to get the text from
|
* @param atomSet the SlideAtomsSet to get the text from
|
||||||
*/
|
*/
|
||||||
public Slide(org.apache.poi.hslf.record.Slide slide, Notes notes, SlideAtomsSet atomSet) {
|
public Slide(org.apache.poi.hslf.record.Slide slide, Notes notes, SlideAtomsSet atomSet, int slideNumber) {
|
||||||
_slide = slide;
|
_slide = slide;
|
||||||
_notes = notes;
|
_notes = notes;
|
||||||
_atomSet = atomSet;
|
_atomSet = atomSet;
|
||||||
|
_sheetNo = slide.getSheetId();
|
||||||
// Grab the sheet number
|
_slideNo = slideNumber;
|
||||||
//_sheetNo = _slide.getSlideAtom().getSheetNumber();
|
|
||||||
_sheetNo = -1;
|
|
||||||
|
|
||||||
// Grab the TextRuns from the PPDrawing
|
// Grab the TextRuns from the PPDrawing
|
||||||
_otherRuns = findTextRuns(_slide.getPPDrawing());
|
_otherRuns = findTextRuns(_slide.getPPDrawing());
|
||||||
|
@ -89,9 +88,13 @@ public class Slide extends Sheet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Slide instance
|
* Create a new Slide instance
|
||||||
|
* @param sheetNumber The internal number of the sheet, as used by PersistPtrHolder
|
||||||
|
* @param slideNumber The user facing number of the sheet
|
||||||
*/
|
*/
|
||||||
public Slide(){
|
public Slide(int sheetNumber, int slideNumber){
|
||||||
_slide = new org.apache.poi.hslf.record.Slide();
|
_slide = new org.apache.poi.hslf.record.Slide();
|
||||||
|
_sheetNo = sheetNumber;
|
||||||
|
_slideNo = slideNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,10 +125,16 @@ public class Slide extends Sheet
|
||||||
public TextRun[] getTextRuns() { return _runs; }
|
public TextRun[] getTextRuns() { return _runs; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sheet number
|
* Returns the (internal, RefId based) sheet number
|
||||||
|
* @see getSlideNumber()
|
||||||
*/
|
*/
|
||||||
public int getSheetNumber() { return _sheetNo; }
|
public int getSheetNumber() { return _sheetNo; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the (public facing) page number of this slide
|
||||||
|
*/
|
||||||
|
public int getSlideNumber() { return _slideNo; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the underlying slide record
|
* Returns the underlying slide record
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class PersistPtrHolder extends PositionDependentRecordAtom
|
||||||
private byte[] _header;
|
private byte[] _header;
|
||||||
private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
|
private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
|
||||||
private long _type;
|
private long _type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the lookup for slides to their position on disk.
|
* Holds the lookup for slides to their position on disk.
|
||||||
* You always need to check the most recent PersistPtrHolder
|
* You always need to check the most recent PersistPtrHolder
|
||||||
|
|
|
@ -29,6 +29,20 @@ import java.util.Hashtable;
|
||||||
|
|
||||||
public abstract class PositionDependentRecordContainer extends RecordContainer implements PositionDependentRecord
|
public abstract class PositionDependentRecordContainer extends RecordContainer implements PositionDependentRecord
|
||||||
{
|
{
|
||||||
|
private int sheetId; // Found from PersistPtrHolder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch our sheet ID, as found from a PersistPtrHolder.
|
||||||
|
* Should match the RefId of our matching SlidePersistAtom
|
||||||
|
*/
|
||||||
|
public int getSheetId() { return sheetId; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set our sheet ID, as found from a PersistPtrHolder
|
||||||
|
*/
|
||||||
|
public void setSheetId(int id) { sheetId = id; }
|
||||||
|
|
||||||
|
|
||||||
/** Our location on the disk, as of the last write out */
|
/** Our location on the disk, as of the last write out */
|
||||||
protected int myLastOnDiskOffset;
|
protected int myLastOnDiskOffset;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class Slide extends PositionDependentRecordContainer
|
||||||
* We are of type 1006
|
* We are of type 1006
|
||||||
*/
|
*/
|
||||||
public long getRecordType() { return _type; }
|
public long getRecordType() { return _type; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the contents of the record back, so it can be written
|
* Write the contents of the record back, so it can be written
|
||||||
* to disk
|
* to disk
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.poi.hslf.record.Document;
|
||||||
import org.apache.poi.hslf.record.DocumentAtom;
|
import org.apache.poi.hslf.record.DocumentAtom;
|
||||||
import org.apache.poi.hslf.record.FontCollection;
|
import org.apache.poi.hslf.record.FontCollection;
|
||||||
import org.apache.poi.hslf.record.ParentAwareRecord;
|
import org.apache.poi.hslf.record.ParentAwareRecord;
|
||||||
|
import org.apache.poi.hslf.record.PositionDependentRecordContainer;
|
||||||
import org.apache.poi.hslf.record.Record;
|
import org.apache.poi.hslf.record.Record;
|
||||||
import org.apache.poi.hslf.record.RecordContainer;
|
import org.apache.poi.hslf.record.RecordContainer;
|
||||||
import org.apache.poi.hslf.record.RecordTypes;
|
import org.apache.poi.hslf.record.RecordTypes;
|
||||||
|
@ -210,6 +211,14 @@ public class SlideShow
|
||||||
(Integer)slideIDtoRecordLookup.get(thisID);
|
(Integer)slideIDtoRecordLookup.get(thisID);
|
||||||
int storeAt = storeAtI.intValue();
|
int storeAt = storeAtI.intValue();
|
||||||
|
|
||||||
|
// Tell it its Sheet ID, if it cares
|
||||||
|
// TODO: Check that this is the right ID to feed in
|
||||||
|
if(pdr instanceof PositionDependentRecordContainer) {
|
||||||
|
PositionDependentRecordContainer pdrc =
|
||||||
|
(PositionDependentRecordContainer)_records[i];
|
||||||
|
pdrc.setSheetId(thisID.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, save the record
|
// Finally, save the record
|
||||||
_mostRecentCoreRecords[storeAt] = _records[i];
|
_mostRecentCoreRecords[storeAt] = _records[i];
|
||||||
}
|
}
|
||||||
|
@ -356,6 +365,7 @@ public class SlideShow
|
||||||
org.apache.poi.hslf.record.Slide slideRecord = (org.apache.poi.hslf.record.Slide)slidesV.get(i);
|
org.apache.poi.hslf.record.Slide slideRecord = (org.apache.poi.hslf.record.Slide)slidesV.get(i);
|
||||||
|
|
||||||
// Decide if we've got a SlideAtomSet to use
|
// Decide if we've got a SlideAtomSet to use
|
||||||
|
// TODO: Use the internal IDs to match instead
|
||||||
SlideAtomsSet atomSet = null;
|
SlideAtomsSet atomSet = null;
|
||||||
if(i < slideAtomSets.length) {
|
if(i < slideAtomSets.length) {
|
||||||
atomSet = slideAtomSets[i];
|
atomSet = slideAtomSets[i];
|
||||||
|
@ -368,14 +378,14 @@ public class SlideShow
|
||||||
int notesID = sa.getNotesID();
|
int notesID = sa.getNotesID();
|
||||||
if(notesID != 0) {
|
if(notesID != 0) {
|
||||||
for(int k=0; k<_notes.length; k++) {
|
for(int k=0; k<_notes.length; k++) {
|
||||||
if(_notes[k].getSheetNumber() == notesID) {
|
if(_notes[k].getSlideInternalNumber() == notesID) {
|
||||||
thisNotes = _notes[k];
|
thisNotes = _notes[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Slide model layer
|
// Create the Slide model layer
|
||||||
_slides[i] = new Slide(slideRecord,thisNotes,atomSet);
|
_slides[i] = new Slide(slideRecord,thisNotes,atomSet, (i+1));
|
||||||
|
|
||||||
// Now supply ourselves to all the rich text runs
|
// Now supply ourselves to all the rich text runs
|
||||||
// of this slide's TextRuns
|
// of this slide's TextRuns
|
||||||
|
@ -492,7 +502,6 @@ public class SlideShow
|
||||||
if(prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
|
if(prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
|
||||||
prev = spa;
|
prev = spa;
|
||||||
}
|
}
|
||||||
System.err.println("Prev is " + prev.getRefID());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +521,8 @@ public class SlideShow
|
||||||
|
|
||||||
|
|
||||||
// Create a new Slide
|
// Create a new Slide
|
||||||
Slide slide = new Slide();
|
Slide slide = new Slide(sp.getRefID(), _slides.length+1);
|
||||||
|
// Add in to the list of Slides
|
||||||
Slide[] s = new Slide[_slides.length+1];
|
Slide[] s = new Slide[_slides.length+1];
|
||||||
System.arraycopy(_slides, 0, s, 0, _slides.length);
|
System.arraycopy(_slides, 0, s, 0, _slides.length);
|
||||||
s[_slides.length] = slide;
|
s[_slides.length] = slide;
|
||||||
|
@ -520,7 +530,8 @@ public class SlideShow
|
||||||
System.out.println("Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier());
|
System.out.println("Added slide " + _slides.length + " with ref " + sp.getRefID() + " and identifier " + sp.getSlideIdentifier());
|
||||||
|
|
||||||
// Add the core records for this new Slide to the record tree
|
// Add the core records for this new Slide to the record tree
|
||||||
org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
|
org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
|
||||||
|
slideRecord.setSheetId(sp.getRefID());
|
||||||
int slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
|
int slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
|
||||||
_records = _hslfSlideShow.getRecords();
|
_records = _hslfSlideShow.getRecords();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue