You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/04/27 22:13:46 UTC
svn commit: r1676365 [5/9] - in /poi/branches/common_sl/src:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hssf/usermodel/examples/
examples/src/org/apache/poi/xslf/usermodel/tutorial/
examples/src/org/apache/poi/xssf/usermodel...
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java (from r1667902, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java&r1=1667902&r2=1676365&rev=1676365&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java Mon Apr 27 20:13:43 2015
@@ -15,29 +15,15 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf.model;
+package org.apache.poi.hslf.usermodel;
-import java.awt.Graphics2D;
-import java.util.LinkedList;
+import java.util.ArrayList;
import java.util.List;
-import org.apache.poi.ddf.EscherContainerRecord;
-import org.apache.poi.ddf.EscherDgRecord;
-import org.apache.poi.ddf.EscherDggRecord;
-import org.apache.poi.ddf.EscherSpRecord;
-import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.hslf.record.Comment2000;
-import org.apache.poi.hslf.record.EscherTextboxWrapper;
-import org.apache.poi.hslf.record.HeadersFootersContainer;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.RecordContainer;
-import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.hslf.record.SSSlideInfoAtom;
-import org.apache.poi.hslf.record.SlideAtom;
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.record.*;
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
-import org.apache.poi.hslf.record.StyleTextProp9Atom;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.Slide;
@@ -50,10 +36,10 @@ import org.apache.poi.sl.usermodel.Slide
* @author Yegor Kozlov
*/
-public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSlideShow> {
+public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSlideShow,HSLFNotes> {
private int _slideNo;
private SlideAtomsSet _atomSet;
- private HSLFTextParagraph[] _runs;
+ private final List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<List<HSLFTextParagraph>>();
private HSLFNotes _notes; // usermodel needs to set this
/**
@@ -72,33 +58,36 @@ public final class HSLFSlide extends HSL
_atomSet = atomSet;
_slideNo = slideNumber;
- // Grab the TextRuns from the PPDrawing
- HSLFTextParagraph[] _otherRuns = findTextRuns(getPPDrawing());
-
// For the text coming in from the SlideAtomsSet:
// Build up TextRuns from pairs of TextHeaderAtom and
// one of TextBytesAtom or TextCharsAtom
- final List<HSLFTextParagraph> textParagraphs = new LinkedList<HSLFTextParagraph>();
- if(_atomSet != null) {
- findTextParagraphs(_atomSet.getSlideRecords(),textParagraphs);
+ if (_atomSet != null && _atomSet.getSlideRecords().length > 0) {
+ List<List<HSLFTextParagraph>> llhtp = HSLFTextParagraph.findTextParagraphs(_atomSet.getSlideRecords());
+ _paragraphs.addAll(llhtp);
+ if (_paragraphs.isEmpty()) {
+ throw new RuntimeException("No text records found for slide");
+ }
} else {
// No text on the slide, must just be pictures
}
- // Build an array, more useful than a vector
- _runs = new HSLFTextParagraph[textParagraphs.size()+_otherRuns.length];
// Grab text from SlideListWithTexts entries
- int i=0;
- for(HSLFTextParagraph tp : textParagraphs) {
- _runs[i++] = tp;
- tp.supplySheet(this);
+ for(List<HSLFTextParagraph> ltp : _paragraphs) {
+ for (HSLFTextParagraph tp : ltp) {
+ tp.supplySheet(this);
+ }
}
- // Grab text from slide's PPDrawing
- for(HSLFTextParagraph tp : _otherRuns) {
- _runs[i++] = tp;
- tp.supplySheet(this);
- tp.setIndex(-1); // runs found in PPDrawing are not linked with SlideListWithTexts
+
+ // Grab the TextRuns from the PPDrawing
+ List<List<HSLFTextParagraph>> llOtherRuns = HSLFTextParagraph.findTextParagraphs(getPPDrawing());
+ for (List<HSLFTextParagraph> otherRuns : llOtherRuns) {
+ // Grab text from slide's PPDrawing
+ for(HSLFTextParagraph tp : otherRuns) {
+ tp.supplySheet(this);
+ tp.setIndex(-1); // runs found in PPDrawing are not linked with SlideListWithTexts
+ }
}
+ _paragraphs.addAll(llOtherRuns);
}
/**
@@ -112,22 +101,31 @@ public final class HSLFSlide extends HSL
getSheetContainer().setSheetId(sheetRefId);
}
+ /**
+ * Returns the Notes Sheet for this slide, or null if there isn't one
+ */
+ @Override
+ public HSLFNotes getNotes() {
+ return _notes;
+ }
+
/**
* Sets the Notes that are associated with this. Updates the
* references in the records to point to the new ID
*/
+ @Override
public void setNotes(HSLFNotes notes) {
_notes = notes;
// Update the Slide Atom's ID of where to point to
SlideAtom sa = getSlideRecord().getSlideAtom();
- if(notes == null) {
+ if(_notes == null) {
// Set to 0
sa.setNotesID(0);
} else {
// Set to the value from the notes' sheet id
- sa.setNotesID(notes._getSheetNumber());
+ sa.setNotesID(_notes._getSheetNumber());
}
}
@@ -183,7 +181,7 @@ public final class HSLFSlide extends HSL
public HSLFTextBox addTitle() {
Placeholder pl = new Placeholder();
pl.setShapeType(ShapeType.RECT);
- pl.getTextParagraph().setRunType(TextHeaderAtom.TITLE_TYPE);
+ pl.setRunType(TextHeaderAtom.TITLE_TYPE);
pl.setText("Click to edit title");
pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));
addShape(pl);
@@ -205,13 +203,14 @@ public final class HSLFSlide extends HSL
* @return title of this slide
*/
public String getTitle(){
- HSLFTextParagraph[] txt = getTextRuns();
- for (int i = 0; i < txt.length; i++) {
- int type = txt[i].getRunType();
- if (type == TextHeaderAtom.CENTER_TITLE_TYPE ||
- type == TextHeaderAtom.TITLE_TYPE ){
- String title = txt[i].getText();
- return title;
+ for (List<HSLFTextParagraph> tp : getTextParagraphs()) {
+ if (tp.isEmpty()) continue;
+ int type = tp.get(0).getRunType();
+ switch (type) {
+ case TextHeaderAtom.CENTER_TITLE_TYPE:
+ case TextHeaderAtom.TITLE_TYPE:
+ String str = HSLFTextParagraph.getRawText(tp);
+ return HSLFTextParagraph.toExternalString(str, type);
}
}
return null;
@@ -222,7 +221,7 @@ public final class HSLFSlide extends HSL
/**
* Returns an array of all the TextRuns found
*/
- public HSLFTextParagraph[] getTextRuns() { return _runs; }
+ public List<List<HSLFTextParagraph>> getTextParagraphs() { return _paragraphs; }
/**
* Returns the (public facing) page number of this slide
@@ -237,11 +236,6 @@ public final class HSLFSlide extends HSL
}
/**
- * Returns the Notes Sheet for this slide, or null if there isn't one
- */
- public HSLFNotes getNotesSheet() { return _notes; }
-
- /**
* @return set of records inside <code>SlideListWithtext</code> container
* which hold text data for this slide (typically for placeholders).
*/
@@ -254,26 +248,14 @@ public final class HSLFSlide extends HSL
* @return the master sheet associated with this slide.
*/
public HSLFMasterSheet getMasterSheet(){
- SlideMaster[] master = getSlideShow().getSlidesMasters();
- SlideAtom sa = getSlideRecord().getSlideAtom();
- int masterId = sa.getMasterID();
- HSLFMasterSheet sheet = null;
- for (int i = 0; i < master.length; i++) {
- if (masterId == master[i]._getSheetNumber()) {
- sheet = master[i];
- break;
- }
+ int masterId = getSlideRecord().getSlideAtom().getMasterID();
+ for (HSLFSlideMaster sm : getSlideShow().getSlideMasters()) {
+ if (masterId == sm._getSheetNumber()) return sm;
}
- if (sheet == null){
- TitleMaster[] titleMaster = getSlideShow().getTitleMasters();
- if(titleMaster != null) for (int i = 0; i < titleMaster.length; i++) {
- if (masterId == titleMaster[i]._getSheetNumber()) {
- sheet = titleMaster[i];
- break;
- }
- }
+ for (HSLFTitleMaster tm : getSlideShow().getTitleMasters()) {
+ if (masterId == tm._getSheetNumber()) return tm;
}
- return sheet;
+ return null;
}
/**
@@ -424,26 +406,6 @@ public final class HSLFSlide extends HSL
return new Comment[0];
}
- public void draw(Graphics2D graphics){
- HSLFMasterSheet master = getMasterSheet();
- HSLFBackground bg = getBackground();
- if(bg != null)bg.draw(graphics);
-
- if(getFollowMasterObjects()){
- HSLFShape[] sh = master.getShapes();
- for (int i = 0; i < sh.length; i++) {
- if(HSLFMasterSheet.isPlaceholder(sh[i])) continue;
-
- sh[i].draw(graphics);
- }
- }
-
- HSLFShape[] sh = getShapes();
- for (int i = 0; i < sh.length; i++) {
- sh[i].draw(graphics);
- }
- }
-
/**
* Header / Footer settings for this slide.
*
@@ -472,15 +434,8 @@ public final class HSLFSlide extends HSL
}
protected void onAddTextShape(HSLFTextShape shape) {
- HSLFTextParagraph run = shape.getTextParagraph();
-
- if(_runs == null) _runs = new HSLFTextParagraph[]{run};
- else {
- HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1];
- System.arraycopy(_runs, 0, tmp, 0, _runs.length);
- tmp[tmp.length-1] = run;
- _runs = tmp;
- }
+ List<HSLFTextParagraph> newParas = shape.getTextParagraphs();
+ _paragraphs.add(newParas);
}
/** This will return an atom per TextBox, so if the page has two text boxes the method should return two atoms. */
@@ -512,4 +467,14 @@ public final class HSLFSlide extends HSL
? false
: slideInfo.getEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT);
}
+
+ public boolean getFollowMasterColourScheme() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setFollowMasterColourScheme(boolean follow) {
+ // TODO Auto-generated method stub
+
+ }
}
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java (from r1667902, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java&r1=1667902&r2=1676365&rev=1676365&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java Mon Apr 27 20:13:43 2015
@@ -15,12 +15,14 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf.model;
+package org.apache.poi.hslf.usermodel;
+
+import java.util.ArrayList;
+import java.util.List;
import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.HSLFSlideShow;
/**
* SlideMaster determines the graphics, layout, and formatting for all the slides in a given presentation.
@@ -29,8 +31,8 @@ import org.apache.poi.hslf.usermodel.HSL
*
* @author Yegor Kozlov
*/
-public final class SlideMaster extends HSLFMasterSheet {
- private HSLFTextParagraph[] _runs;
+public final class HSLFSlideMaster extends HSLFMasterSheet {
+ private final List<List<HSLFTextParagraph>> _runs = new ArrayList<List<HSLFTextParagraph>>();
/**
* all TxMasterStyleAtoms available in this master
@@ -41,17 +43,21 @@ public final class SlideMaster extends H
* Constructs a SlideMaster from the MainMaster record,
*
*/
- public SlideMaster(MainMaster record, int sheetNo) {
+ public HSLFSlideMaster(MainMaster record, int sheetNo) {
super(record, sheetNo);
- _runs = findTextRuns(getPPDrawing());
- for (int i = 0; i < _runs.length; i++) _runs[i].setSheet(this);
+ _runs.addAll(HSLFTextParagraph.findTextParagraphs(getPPDrawing()));
+ for (List<HSLFTextParagraph> p : _runs) {
+ for (HSLFTextParagraph htp : p) {
+ htp.supplySheet(this);
+ }
+ }
}
/**
* Returns an array of all the TextRuns found
*/
- public HSLFTextParagraph[] getTextRuns() {
+ public List<List<HSLFTextParagraph>> getTextParagraphs() {
return _runs;
}
@@ -131,15 +137,8 @@ public final class SlideMaster extends H
}
protected void onAddTextShape(HSLFTextShape shape) {
- HSLFTextParagraph run = shape.getTextParagraph();
-
- if(_runs == null) _runs = new HSLFTextParagraph[]{run};
- else {
- HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1];
- System.arraycopy(_runs, 0, tmp, 0, _runs.length);
- tmp[tmp.length-1] = run;
- _runs = tmp;
- }
+ List<HSLFTextParagraph> runs = shape.getTextParagraphs();
+ _runs.add(runs);
}
public TxMasterStyleAtom[] getTxMasterStyleAtoms(){
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1676365&r1=1676364&r2=1676365&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Mon Apr 27 20:13:43 2015
@@ -25,12 +25,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -69,7 +64,7 @@ import org.apache.poi.hslf.record.SlideP
import org.apache.poi.hslf.record.UserEditAtom;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.sl.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.*;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -97,10 +92,10 @@ public final class HSLFSlideShow impleme
private Document _documentRecord;
// Friendly objects for people to deal with
- private SlideMaster[] _masters;
- private TitleMaster[] _titleMasters;
- private HSLFSlide[] _slides;
- private HSLFNotes[] _notes;
+ private final List<HSLFSlideMaster> _masters = new ArrayList<HSLFSlideMaster>();
+ private final List<HSLFTitleMaster> _titleMasters = new ArrayList<HSLFTitleMaster>();
+ private final List<HSLFSlide> _slides = new ArrayList<HSLFSlide>();
+ private final List<HSLFNotes> _notes = new ArrayList<HSLFNotes>();
private FontCollection _fonts;
// For logging
@@ -310,27 +305,21 @@ public final class HSLFSlideShow impleme
if (masterSLWT != null) {
masterSets = masterSLWT.getSlideAtomsSets();
- ArrayList<SlideMaster> mmr = new ArrayList<SlideMaster>();
- ArrayList<TitleMaster> tmr = new ArrayList<TitleMaster>();
-
for (SlideAtomsSet sas : masterSets) {
Record r = getCoreRecordForSAS(sas);
int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier();
if (r instanceof org.apache.poi.hslf.record.Slide) {
- TitleMaster master = new TitleMaster((org.apache.poi.hslf.record.Slide) r,
+ HSLFTitleMaster master = new HSLFTitleMaster((org.apache.poi.hslf.record.Slide) r,
sheetNo);
master.setSlideShow(this);
- tmr.add(master);
+ _titleMasters.add(master);
} else if (r instanceof org.apache.poi.hslf.record.MainMaster) {
- SlideMaster master = new SlideMaster((org.apache.poi.hslf.record.MainMaster) r,
+ HSLFSlideMaster master = new HSLFSlideMaster((org.apache.poi.hslf.record.MainMaster) r,
sheetNo);
master.setSlideShow(this);
- mmr.add(master);
+ _masters.add(master);
}
}
-
- _masters = mmr.toArray(new SlideMaster[mmr.size()]);
- _titleMasters = tmr.toArray(new TitleMaster[tmr.size()]);
}
// Having sorted out the masters, that leaves the notes and slides
@@ -408,16 +397,14 @@ public final class HSLFSlideShow impleme
// Finally, generate model objects for everything
// Notes first
- _notes = new HSLFNotes[notesRecords.length];
- for (int i = 0; i < _notes.length; i++) {
- if (notesRecords[i] != null) {
- _notes[i] = new HSLFNotes(notesRecords[i]);
- _notes[i].setSlideShow(this);
- }
+ for (org.apache.poi.hslf.record.Notes n : notesRecords) {
+ if (n == null) continue;
+ HSLFNotes hn = new HSLFNotes(n);
+ hn.setSlideShow(this);
+ _notes.add(hn);
}
// Then slides
- _slides = new HSLFSlide[slidesRecords.length];
- for (int i = 0; i < _slides.length; i++) {
+ for (int i = 0; i < slidesRecords.length; i++) {
SlideAtomsSet sas = slidesSets[i];
int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier();
@@ -429,15 +416,16 @@ public final class HSLFSlideShow impleme
if (noteId != 0) {
Integer notesPos = slideIdToNotes.get(noteId);
if (notesPos != null) {
- notes = _notes[notesPos];
+ notes = _notes.get(notesPos);
} else {
logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
}
}
// Now, build our slide
- _slides[i] = new HSLFSlide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
- _slides[i].setSlideShow(this);
+ HSLFSlide hs = new HSLFSlide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
+ hs.setSlideShow(this);
+ _slides.add(hs);
}
}
@@ -472,28 +460,30 @@ public final class HSLFSlideShow impleme
/**
* Returns an array of all the normal Slides found in the slideshow
*/
- public HSLFSlide[] getSlides() {
+ @Override
+ public List<HSLFSlide> getSlides() {
return _slides;
}
/**
* Returns an array of all the normal Notes found in the slideshow
*/
- public HSLFNotes[] getNotes() {
+ public List<HSLFNotes> getNotes() {
return _notes;
}
/**
* Returns an array of all the normal Slide Masters found in the slideshow
*/
- public SlideMaster[] getSlidesMasters() {
+ @Override
+ public List<HSLFSlideMaster> getSlideMasters() {
return _masters;
}
-
+
/**
* Returns an array of all the normal Title Masters found in the slideshow
*/
- public TitleMaster[] getTitleMasters() {
+ public List<HSLFTitleMaster> getTitleMasters() {
return _titleMasters;
}
@@ -573,12 +563,16 @@ public final class HSLFSlideShow impleme
if (oldSlideNumber < 1 || newSlideNumber < 1) {
throw new IllegalArgumentException("Old and new slide numbers must be greater than 0");
}
- if (oldSlideNumber > _slides.length || newSlideNumber > _slides.length) {
+ if (oldSlideNumber > _slides.size() || newSlideNumber > _slides.size()) {
throw new IllegalArgumentException(
"Old and new slide numbers must not exceed the number of slides ("
- + _slides.length + ")");
+ + _slides.size() + ")");
}
+ _slides.get(newSlideNumber).setSlideNumber(oldSlideNumber);
+ _slides.get(oldSlideNumber).setSlideNumber(newSlideNumber);
+ Collections.swap(_slides, oldSlideNumber-1, newSlideNumber-1);
+
// The order of slides is defined by the order of slide atom sets in the
// SlideListWithText container.
SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
@@ -589,13 +583,9 @@ public final class HSLFSlideShow impleme
sas[newSlideNumber - 1] = tmp;
ArrayList<Record> lst = new ArrayList<Record>();
- for (int i = 0; i < sas.length; i++) {
- lst.add(sas[i].getSlidePersistAtom());
- Record[] r = sas[i].getSlideRecords();
- for (int j = 0; j < r.length; j++) {
- lst.add(r[j]);
- }
- _slides[i].setSlideNumber(i + 1);
+ for (SlideAtomsSet s : sas) {
+ lst.add(s.getSlidePersistAtom());
+ lst.addAll(Arrays.asList(s.getSlideRecords()));
}
Record[] r = lst.toArray(new Record[lst.size()]);
slwt.setChildRecord(r);
@@ -613,7 +603,7 @@ public final class HSLFSlideShow impleme
* @return the slide that was removed from the slide show.
*/
public HSLFSlide removeSlide(int index) {
- int lastSlideIdx = _slides.length - 1;
+ int lastSlideIdx = _slides.size() - 1;
if (index < 0 || index > lastSlideIdx) {
throw new IllegalArgumentException("Slide index (" + index + ") is out of range (0.."
+ lastSlideIdx + ")");
@@ -622,26 +612,19 @@ public final class HSLFSlideShow impleme
SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
- HSLFSlide removedSlide = null;
- ArrayList<Record> records = new ArrayList<Record>();
- ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
- ArrayList<HSLFSlide> sl = new ArrayList<HSLFSlide>();
-
- ArrayList<HSLFNotes> nt = new ArrayList<HSLFNotes>();
- for (HSLFNotes notes : getNotes())
- nt.add(notes);
-
- for (int i = 0, num = 0; i < _slides.length; i++) {
- if (i != index) {
- sl.add(_slides[i]);
- sa.add(sas[i]);
- _slides[i].setSlideNumber(num++);
- records.add(sas[i].getSlidePersistAtom());
- records.addAll(Arrays.asList(sas[i].getSlideRecords()));
- } else {
- removedSlide = _slides[i];
- nt.remove(_slides[i].getNotesSheet());
- }
+ List<Record> records = new ArrayList<Record>();
+ List<SlideAtomsSet> sa = Arrays.asList(sas);
+
+ HSLFSlide removedSlide = _slides.remove(index);
+ _notes.remove(removedSlide.getNotes());
+ sa.remove(index);
+
+ int i=0;
+ for (HSLFSlide s : _slides) s.setSlideNumber(i++);
+
+ for (SlideAtomsSet s : sa) {
+ records.add(s.getSlidePersistAtom());
+ records.addAll(Arrays.asList(s.getSlideRecords()));
}
if (sa.size() == 0) {
_documentRecord.removeSlideListWithText(slwt);
@@ -649,34 +632,29 @@ public final class HSLFSlideShow impleme
slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()]));
slwt.setChildRecord(records.toArray(new Record[records.size()]));
}
- _slides = sl.toArray(new HSLFSlide[sl.size()]);
// if the removed slide had notes - remove references to them too
- if (removedSlide != null) {
- int notesId = removedSlide.getSlideRecord().getSlideAtom().getNotesID();
- if (notesId != 0) {
- SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
- records = new ArrayList<Record>();
- ArrayList<SlideAtomsSet> na = new ArrayList<SlideAtomsSet>();
- for (SlideAtomsSet ns : nslwt.getSlideAtomsSets()) {
- if (ns.getSlidePersistAtom().getSlideIdentifier() != notesId) {
- na.add(ns);
- records.add(ns.getSlidePersistAtom());
- if (ns.getSlideRecords() != null)
- records.addAll(Arrays.asList(ns.getSlideRecords()));
- }
- }
- if (na.size() == 0) {
- _documentRecord.removeSlideListWithText(nslwt);
- } else {
- nslwt.setSlideAtomsSets(na.toArray(new SlideAtomsSet[na.size()]));
- nslwt.setChildRecord(records.toArray(new Record[records.size()]));
+ int notesId = (removedSlide != null) ? removedSlide.getSlideRecord().getSlideAtom().getNotesID() : 0;
+ if (notesId != 0) {
+ SlideListWithText nslwt = _documentRecord.getNotesSlideListWithText();
+ records = new ArrayList<Record>();
+ ArrayList<SlideAtomsSet> na = new ArrayList<SlideAtomsSet>();
+ for (SlideAtomsSet ns : nslwt.getSlideAtomsSets()) {
+ if (ns.getSlidePersistAtom().getSlideIdentifier() == notesId) continue;
+ na.add(ns);
+ records.add(ns.getSlidePersistAtom());
+ if (ns.getSlideRecords() != null) {
+ records.addAll(Arrays.asList(ns.getSlideRecords()));
}
-
+ }
+ if (na.isEmpty()) {
+ _documentRecord.removeSlideListWithText(nslwt);
+ } else {
+ nslwt.setSlideAtomsSets(na.toArray(new SlideAtomsSet[na.size()]));
+ nslwt.setChildRecord(records.toArray(new Record[records.size()]));
}
}
- _notes = nt.toArray(new HSLFNotes[nt.size()]);
return removedSlide;
}
@@ -736,16 +714,13 @@ public final class HSLFSlideShow impleme
slist.addSlidePersistAtom(sp);
// Create a new Slide
- HSLFSlide slide = new HSLFSlide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
+ HSLFSlide slide = new HSLFSlide(sp.getSlideIdentifier(), sp.getRefID(), _slides.size() + 1);
slide.setSlideShow(this);
slide.onCreate();
// Add in to the list of Slides
- HSLFSlide[] s = new HSLFSlide[_slides.length + 1];
- System.arraycopy(_slides, 0, s, 0, _slides.length);
- s[_slides.length] = slide;
- _slides = s;
- logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID()
+ _slides.add(slide);
+ logger.log(POILogger.INFO, "Added slide " + _slides.size() + " with ref " + sp.getRefID()
+ " and identifier " + sp.getSlideIdentifier());
// Add the core records for this new Slide to the record tree
@@ -754,7 +729,7 @@ public final class HSLFSlideShow impleme
sp.setRefID(psrId);
slideRecord.setSheetId(psrId);
- slide.setMasterSheet(_masters[0]);
+ slide.setMasterSheet(_masters.get(0));
// All done and added
return slide;
}
@@ -901,7 +876,7 @@ public final class HSLFSlideShow impleme
*/
public HeadersFooters getSlideHeadersFooters() {
// detect if this ppt was saved in Office2007
- String tag = getSlidesMasters()[0].getProgrammableTag();
+ String tag = getSlideMasters().get(0).getProgrammableTag();
boolean ppt2007 = "___PPT12".equals(tag);
HeadersFootersContainer hdd = null;
@@ -927,7 +902,7 @@ public final class HSLFSlideShow impleme
*/
public HeadersFooters getNotesHeadersFooters() {
// detect if this ppt was saved in Office2007
- String tag = getSlidesMasters()[0].getProgrammableTag();
+ String tag = getSlideMasters().get(0).getProgrammableTag();
boolean ppt2007 = "___PPT12".equals(tag);
HeadersFootersContainer hdd = null;
@@ -943,8 +918,8 @@ public final class HSLFSlideShow impleme
hdd = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
newRecord = true;
}
- if (ppt2007 && _notes.length > 0) {
- return new HeadersFooters(hdd, _notes[0], newRecord, ppt2007);
+ if (ppt2007 && !_notes.isEmpty()) {
+ return new HeadersFooters(hdd, _notes.get(0), newRecord, ppt2007);
}
return new HeadersFooters(hdd, this, newRecord, ppt2007);
}
@@ -1010,10 +985,10 @@ public final class HSLFSlideShow impleme
*
* @return 0-based index of the hyperlink
*/
- public int addHyperlink(Hyperlink link) {
+ public int addHyperlink(HSLFHyperlink link) {
ExHyperlink ctrl = new ExHyperlink();
ExHyperlinkAtom obj = ctrl.getExHyperlinkAtom();
- if(link.getType() == Hyperlink.LINK_SLIDENUMBER) {
+ if(link.getType() == HSLFHyperlink.LINK_SLIDENUMBER) {
ctrl.setLinkURL(link.getAddress(), 0x30);
} else {
ctrl.setLinkURL(link.getAddress());
@@ -1160,4 +1135,15 @@ public final class HSLFSlideShow impleme
return psrId;
}
+
+ public MasterSheet<? extends Shape, ? extends SlideShow> createMasterSheet()
+ throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Resources getResources() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java (from r1667902, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java&r1=1667902&r2=1676365&rev=1676365&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java Mon Apr 27 20:13:43 2015
@@ -15,7 +15,7 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf.model;
+package org.apache.poi.hslf.usermodel;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java (from r1667902, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java&r1=1667902&r2=1676365&rev=1676365&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java Mon Apr 27 20:13:43 2015
@@ -15,7 +15,7 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf.model;
+package org.apache.poi.hslf.usermodel;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -45,8 +45,6 @@ import org.apache.poi.hslf.record.Positi
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordTypes;
import org.apache.poi.hslf.record.UserEditAtom;
-import org.apache.poi.hslf.usermodel.HSLFObjectData;
-import org.apache.poi.hslf.usermodel.HSLFPictureData;
import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptor;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.DocumentEntry;
@@ -203,7 +201,7 @@ public final class HSLFSlideShowImpl ext
* Constructs a new, empty, Powerpoint document.
*/
public static final HSLFSlideShowImpl create() {
- InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("data/empty.ppt");
+ InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt");
if (is == null) {
throw new RuntimeException("Missing resource 'empty.ppt'");
}
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java (from r1667902, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java&r1=1667902&r2=1676365&rev=1676365&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java Mon Apr 27 20:13:43 2015
@@ -15,11 +15,10 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf.model;
+package org.apache.poi.hslf.usermodel;
import org.apache.poi.ddf.*;
-import org.apache.poi.sl.usermodel.ShapeContainer;
-import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.sl.usermodel.*;
/**
* Represents a TextFrame shape in PowerPoint.
@@ -79,13 +78,14 @@ public class HSLFTextBox extends HSLFTex
setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80000);
setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
- _txtrun = createTextRun();
+ // init paragraphs
+ getTextParagraphs();
return _escherContainer;
}
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
- setVerticalAlignment(HSLFTextBox.AnchorTop);
+ setVerticalAlignment(VerticalAlignment.TOP);
setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org