package org.apache.poi.hslf.model;
-import java.util.*;
-
-import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.record.SlideListWithText.*;
-import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hslf.record.PPDrawing;
/**
* This class represents a slide's notes in a PowerPoint Document. It
public class Notes extends Sheet
{
-
private int _sheetNo;
+ private int _slideNo;
private org.apache.poi.hslf.record.Notes _notes;
private TextRun[] _runs;
*/
public Notes (org.apache.poi.hslf.record.Notes notes) {
_notes = notes;
+
+ // Grab our internal sheet ID
+ _sheetNo = notes.getSheetId();
- // Grab the sheet number, via the NotesAtom
- _sheetNo = _notes.getNotesAtom().getSlideID();
+ // Grab the number of the slide we're for, via the NotesAtom
+ _slideNo = _notes.getNotesAtom().getSlideID();
// Now, build up TextRuns from pairs of TextHeaderAtom and
// one of TextBytesAtom or TextCharsAtom, found inside
public TextRun[] getTextRuns() { return _runs; }
/**
- * Returns the sheet number
+ * Returns the (internal, RefId based) sheet number (RefId)
*/
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(); }}
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();
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.SlideListWithText.*;
-import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hslf.record.PPDrawing;
+import org.apache.poi.hslf.record.SlideAtom;
+import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
/**
* This class represents a slide in a PowerPoint Document. It allows
{
private int _sheetNo;
+ private int _slideNo;
private org.apache.poi.hslf.record.Slide _slide;
private SlideAtomsSet _atomSet;
private TextRun[] _runs;
* @param notes the Notes sheet attached to us
* @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;
_notes = notes;
_atomSet = atomSet;
-
- // Grab the sheet number
- //_sheetNo = _slide.getSlideAtom().getSheetNumber();
- _sheetNo = -1;
+ _sheetNo = slide.getSheetId();
+ _slideNo = slideNumber;
// Grab the TextRuns from the PPDrawing
_otherRuns = findTextRuns(_slide.getPPDrawing());
/**
* 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(){
- _slide = new org.apache.poi.hslf.record.Slide();
+ public Slide(int sheetNumber, int slideNumber){
+ _slide = new org.apache.poi.hslf.record.Slide();
+ _sheetNo = sheetNumber;
+ _slideNo = slideNumber;
}
/**
public TextRun[] getTextRuns() { return _runs; }
/**
- * Returns the sheet number
+ * Returns the (internal, RefId based) sheet number
+ * @see getSlideNumber()
*/
public int getSheetNumber() { return _sheetNo; }
-
+
+ /**
+ * Returns the (public facing) page number of this slide
+ */
+ public int getSlideNumber() { return _slideNo; }
+
/**
* Returns the underlying slide record
*/
private byte[] _header;
private byte[] _ptrData; // Will need to update this once we allow updates to _slideLocations
private long _type;
-
+
/**
* Holds the lookup for slides to their position on disk.
* You always need to check the most recent PersistPtrHolder
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 */
protected int myLastOnDiskOffset;
* We are of type 1006
*/
public long getRecordType() { return _type; }
-
+
/**
* Write the contents of the record back, so it can be written
* to disk
import org.apache.poi.hslf.record.DocumentAtom;
import org.apache.poi.hslf.record.FontCollection;
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.RecordContainer;
import org.apache.poi.hslf.record.RecordTypes;
(Integer)slideIDtoRecordLookup.get(thisID);
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
_mostRecentCoreRecords[storeAt] = _records[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
+ // TODO: Use the internal IDs to match instead
SlideAtomsSet atomSet = null;
if(i < slideAtomSets.length) {
atomSet = slideAtomSets[i];
int notesID = sa.getNotesID();
if(notesID != 0) {
for(int k=0; k<_notes.length; k++) {
- if(_notes[k].getSheetNumber() == notesID) {
+ if(_notes[k].getSlideInternalNumber() == notesID) {
thisNotes = _notes[k];
}
}
}
// 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
// of this slide's TextRuns
if(prev.getSlideIdentifier() < spa.getSlideIdentifier()) {
prev = spa;
}
- System.err.println("Prev is " + prev.getRefID());
}
}
// 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];
System.arraycopy(_slides, 0, s, 0, _slides.length);
s[_slides.length] = slide;
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
- 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);
_records = _hslfSlideShow.getRecords();