You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ni...@apache.org on 2005/06/26 21:03:48 UTC

cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/model Slide.java

nick        2005/06/26 12:03:48

  Modified:    src/scratchpad/src/org/apache/poi/hslf/model Slide.java
  Log:
  The usermodel code is now responsible for filtering out duplicate SlideAtomSets, so update to no longer check for them
  Add the ability to get at the Slide record that this is based on
  
  Revision  Changes    Path
  1.2       +39 -31    jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
  
  Index: Slide.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Slide.java	28 May 2005 05:36:00 -0000	1.1
  +++ Slide.java	26 Jun 2005 19:03:48 -0000	1.2
  @@ -38,20 +38,21 @@
   
     private int _sheetNo;
     private org.apache.poi.hslf.record.Slide _slide;
  -  private SlideAtomsSet[] _atomSet;
  +  private SlideAtomsSet _atomSet;
     private TextRun[] _runs;
     private TextRun[] _otherRuns; // Any from the PPDrawing, shouldn't really be any though
  -  private Notes _notes;
  +  private Notes _notes; // usermodel needs to set this
   
     /**
  -   * Constructs a Slide from the Slide record, and the SlideAtomsSets
  -   *  for ones not embeded in the PPDrawing.
  +   * Constructs a Slide from the Slide record, and the SlideAtomsSet
  +   *  containing the text.
      * Initialises TextRuns, to provide easier access to the text
      *
      * @param slide the Slide record we're based on
  +   * @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) {
   	_slide = slide;
   	_notes = notes;
   	_atomSet = atomSet;
  @@ -63,38 +64,40 @@
   	// Grab the TextRuns from the PPDrawing
   	_otherRuns = findTextRuns(_slide.getPPDrawing());
   
  -
  -	// Ensure we've only got only copy of each SlideAtomSet
  -	// When in doubt, prefere the later one
  -	Hashtable seenSets = new Hashtable();
  -	Vector useSets = new Vector();
  -	for(int i=0; i<_atomSet.length; i++) {
  -		SlideAtomsSet set = _atomSet[i];
  -		int id = set.getSlidePersistAtom().getRefID();
  -		Integer idI = new Integer(id);
  -		if(seenSets.containsKey(idI)) {
  -			// Replace old one
  -			Integer replacePos = (Integer)seenSets.get(idI);
  -			useSets.set(replacePos.intValue(),set);
  -		} else {
  -			// Use for now
  -			useSets.add(set);
  -			seenSets.put(idI,new Integer(useSets.size()-1));
  -		}
  -	}
  -
   	// For the text coming in from the SlideAtomsSet:
   	// Build up TextRuns from pairs of TextHeaderAtom and
   	//  one of TextBytesAtom or TextCharsAtom
  -	Vector runSets = new Vector();
  -	for(int i=0; i<useSets.size(); i++) {
  -		SlideAtomsSet set = (SlideAtomsSet)useSets.get(i);
  -		findTextRuns(set.getSlideRecords(),runSets);
  +	Vector textRuns = new Vector();
  +	if(_atomSet != null) {
  +		findTextRuns(_atomSet.getSlideRecords(),textRuns);
  +	} else {
  +		// No text on the slide, must just be pictures
   	}
  +
   	// Build an array, more useful than a vector
  -	_runs = new TextRun[runSets.size()];
  +	_runs = new TextRun[textRuns.size()];
   	for(int i=0; i<_runs.length; i++) {
  -		_runs[i] = (TextRun)runSets.get(i);
  +		_runs[i] = (TextRun)textRuns.get(i);
  +	}
  +  }
  +
  +
  +  /**
  +   * Sets the Notes that are associated with this. Updates the
  +   *  references in the records to point to the new ID
  +   */
  +  public void setNotes(Notes notes) {
  +	_notes = notes;
  +
  +	// Update the Slide Atom's ID of where to point to
  +	SlideAtom sa = _slide.getSlideAtom();
  +
  +	if(notes == null) {
  +		// Set to 0
  +		sa.setNotesID(0);
  +	} else {
  +		// Set to the value from the notes' sheet id
  +		sa.setNotesID(notes.getSheetNumber());
   	}
     }
   
  @@ -112,6 +115,11 @@
     public int getSheetNumber() { return _sheetNo; }
   
     /**
  +   * Returns the underlying slide record
  +   */
  +  public org.apache.poi.hslf.record.Slide getSlideRecord() { return _slide; }
  +
  +  /**
      * Returns the Notes Sheet for this slide, or null if there isn't one
      */
     public Notes getNotesSheet() { return _notes; }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/