parent){
super(escherRecord, parent);
}
@@ -156,7 +156,7 @@ public class Picture extends SimpleShape {
* for other types sets the default size of 200x200 pixels.
*/
public void setDefaultSize(){
- PictureData pict = getPictureData();
+ HSLFPictureData pict = getPictureData();
if (pict instanceof Bitmap){
BufferedImage img = null;
try {
@@ -183,9 +183,9 @@ public class Picture extends SimpleShape {
*
* @return the picture data for this picture.
*/
- public PictureData getPictureData(){
- SlideShow ppt = getSheet().getSlideShow();
- PictureData[] pict = ppt.getPictureData();
+ public HSLFPictureData getPictureData(){
+ HSLFSlideShow ppt = getSheet().getSlideShow();
+ HSLFPictureData[] pict = ppt.getPictureData();
EscherBSERecord bse = getEscherBSERecord();
if (bse == null){
@@ -202,7 +202,7 @@ public class Picture extends SimpleShape {
}
protected EscherBSERecord getEscherBSERecord(){
- SlideShow ppt = getSheet().getSlideShow();
+ HSLFSlideShow ppt = getSheet().getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
@@ -247,7 +247,7 @@ public class Picture extends SimpleShape {
/**
* By default set the orininal image size
*/
- protected void afterInsert(Sheet sh){
+ protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
EscherBSERecord bse = getEscherBSERecord();
@@ -263,7 +263,7 @@ public class Picture extends SimpleShape {
AffineTransform at = graphics.getTransform();
ShapePainter.paint(this, graphics);
- PictureData data = getPictureData();
+ HSLFPictureData data = getPictureData();
if(data != null) data.draw(graphics, this);
graphics.setTransform(at);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java
index c673cae2de..4e2229982e 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java
@@ -17,17 +17,15 @@
package org.apache.poi.hslf.model;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Iterator;
+
import org.apache.poi.ddf.*;
import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.sl.usermodel.ShapeContainer;
-import org.apache.poi.sl.usermodel.ShapeType;
-import org.apache.poi.util.POILogger;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.Units;
-
-import java.util.*;
-import java.awt.*;
-import java.awt.geom.Rectangle2D;
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.util.*;
/**
*
@@ -45,7 +43,7 @@ import java.awt.geom.Rectangle2D;
*
* @author Yegor Kozlov
*/
-public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape {
+public abstract class HSLFShape implements Shape {
// For logging
protected POILogger logger = POILogFactory.getLogger(this.getClass());
@@ -90,12 +88,12 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.ShapeSheet this shape belongs to
*/
- protected Sheet _sheet;
+ protected HSLFSheet _sheet;
/**
* Fill
*/
- protected Fill _fill;
+ protected HSLFFill _fill;
/**
* Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document.
@@ -336,7 +334,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.ShapeSlideShow this shape belongs to
*/
- public Sheet getSheet(){
+ public HSLFSheet getSheet(){
return _sheet;
}
@@ -354,7 +352,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape> 24) & 0xFF;
int b = (val >> 16) & 0xFF;
@@ -446,11 +449,16 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape {
- private static POILogger logger = POILogFactory.getLogger(Sheet.class);
+public abstract class HSLFSheet implements Sheet {
+ private static POILogger logger = POILogFactory.getLogger(HSLFSheet.class);
/**
* The SlideShow
we belong to
*/
- private SlideShow _slideShow;
+ private HSLFSlideShow _slideShow;
/**
* Sheet background
*/
- private Background _background;
+ private HSLFBackground _background;
/**
* Record container that holds sheet data.
@@ -80,7 +58,7 @@ public abstract class Sheet implements ShapeContainer {
private int _sheetNo;
- public Sheet(SheetContainer container, int sheetNo) {
+ public HSLFSheet(SheetContainer container, int sheetNo) {
_container = container;
_sheetNo = sheetNo;
}
@@ -88,7 +66,7 @@ public abstract class Sheet implements ShapeContainer {
/**
* Returns an array of all the TextRuns in the sheet.
*/
- public abstract TextRun[] getTextRuns();
+ public abstract HSLFTextParagraph[] getTextRuns();
/**
* Returns the (internal, RefID based) sheet number, as used
@@ -116,7 +94,7 @@ public abstract class Sheet implements ShapeContainer {
/**
* Fetch the SlideShow we're attached to
*/
- public SlideShow getSlideShow() {
+ public HSLFSlideShow getSlideShow() {
return _slideShow;
}
@@ -131,13 +109,12 @@ public abstract class Sheet implements ShapeContainer {
* Set the SlideShow we're attached to.
* Also passes it on to our child RichTextRuns
*/
- public void setSlideShow(SlideShow ss) {
+ public void setSlideShow(HSLFSlideShow ss) {
_slideShow = ss;
- TextRun[] trs = getTextRuns();
- if (trs != null) {
- for (int i = 0; i < trs.length; i++) {
- trs[i].supplySlideShow(_slideShow);
- }
+ HSLFTextParagraph[] trs = getTextRuns();
+ if (trs == null) return;
+ for (HSLFTextParagraph tp : trs) {
+ tp.supplySheet(this);
}
}
@@ -145,8 +122,8 @@ public abstract class Sheet implements ShapeContainer {
/**
* For a given PPDrawing, grab all the TextRuns
*/
- public static TextRun[] findTextRuns(PPDrawing ppdrawing) {
- final List runsV = new ArrayList();
+ public static HSLFTextParagraph[] findTextRuns(PPDrawing ppdrawing) {
+ final List runsV = new ArrayList();
final EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers();
for (int i = 0; i < wrappers.length; i++) {
int s1 = runsV.size();
@@ -156,11 +133,11 @@ public abstract class Sheet implements ShapeContainer {
findTextRuns(wrappers[i], runsV);
int s2 = runsV.size();
if (s2 != s1){
- TextRun t = runsV.get(runsV.size()-1);
+ HSLFTextParagraph t = runsV.get(runsV.size()-1);
t.setShapeId(wrappers[i].getShapeId());
}
}
- return runsV.toArray(new TextRun[runsV.size()]);
+ return runsV.toArray(new HSLFTextParagraph[runsV.size()]);
}
/**
* Scans through the supplied record array, looking for
@@ -170,7 +147,7 @@ public abstract class Sheet implements ShapeContainer {
* @param records the records to build from
* @param found vector to add any found to
*/
- protected static void findTextRuns(final Record[] records, final List found) {
+ protected static void findTextParagraphs(final Record[] records, final List found) {
findTextRuns(records, found, null);
}
/**
@@ -181,7 +158,7 @@ public abstract class Sheet implements ShapeContainer {
* @param wrapper an EscherTextboxWrapper
* @param found vector to add any found to
*/
- protected static void findTextRuns(final EscherTextboxWrapper wrapper, final List found) {
+ protected static void findTextRuns(final EscherTextboxWrapper wrapper, final List found) {
findTextRuns(wrapper.getChildRecords(), found, wrapper.getStyleTextProp9Atom());
}
/**
@@ -193,12 +170,12 @@ public abstract class Sheet implements ShapeContainer {
* @param found vector to add any found to
* @param styleTextProp9Atom a StyleTextProp9Atom with numbered lists info
*/
- protected static void findTextRuns(final Record[] records, final List found, final StyleTextProp9Atom styleTextProp9Atom) {
+ protected static void findTextRuns(final Record[] records, final List found, final StyleTextProp9Atom styleTextProp9Atom) {
for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) {
if (records[i] instanceof TextHeaderAtom) {
TextHeaderAtom tha = (TextHeaderAtom) records[i];
StyleTextPropAtom stpa = null;
- TextRun trun = null;
+ HSLFTextParagraph trun = null;
Record next = null;
Record subs = null;
@@ -231,10 +208,10 @@ public abstract class Sheet implements ShapeContainer {
// Now, check if the next record is one to record
if (next instanceof TextCharsAtom) {
TextCharsAtom tca = (TextCharsAtom)next;
- trun = new TextRun(tha, tca, stpa);
+ trun = new HSLFTextParagraph(tha, tca, stpa);
} else if (next instanceof TextBytesAtom) {
TextBytesAtom tba = (TextBytesAtom)next;
- trun = new TextRun(tha, tba, stpa);
+ trun = new HSLFTextParagraph(tha, tba, stpa);
} else if (next instanceof StyleTextPropAtom) {
stpa = (StyleTextPropAtom)next;
} else if (next instanceof TextHeaderAtom) {
@@ -372,7 +349,7 @@ public abstract class Sheet implements ShapeContainer {
/**
* Return the master sheet .
*/
- public abstract MasterSheet getMasterSheet();
+ public abstract HSLFMasterSheet getMasterSheet();
/**
* Color scheme for this sheet.
@@ -386,7 +363,7 @@ public abstract class Sheet implements ShapeContainer {
*
* @return the background shape for this sheet.
*/
- public Background getBackground() {
+ public HSLFBackground getBackground() {
if (_background == null) {
PPDrawing ppdrawing = getPPDrawing();
@@ -400,7 +377,7 @@ public abstract class Sheet implements ShapeContainer {
break;
}
}
- _background = new Background(spContainer, null);
+ _background = new HSLFBackground(spContainer, null);
_background.setSheet(this);
}
return _background;
@@ -416,7 +393,7 @@ public abstract class Sheet implements ShapeContainer {
*
* @param shape
*/
- protected void onAddTextShape(TextShape shape) {
+ protected void onAddTextShape(HSLFTextShape shape) {
}
@@ -426,12 +403,12 @@ public abstract class Sheet implements ShapeContainer {
* @param type type of text, See {@link org.apache.poi.hslf.record.TextHeaderAtom}
* @return TextShape
or null
*/
- public TextShape getPlaceholderByTextType(int type){
+ public HSLFTextShape getPlaceholderByTextType(int type){
HSLFShape[] shape = getShapes();
for (int i = 0; i < shape.length; i++) {
- if(shape[i] instanceof TextShape){
- TextShape tx = (TextShape)shape[i];
- TextRun run = tx.getTextRun();
+ if(shape[i] instanceof HSLFTextShape){
+ HSLFTextShape tx = (HSLFTextShape)shape[i];
+ HSLFTextParagraph run = tx.getTextParagraph();
if(run != null && run.getRunType() == type){
return tx;
}
@@ -446,11 +423,11 @@ public abstract class Sheet implements ShapeContainer {
* @param type type of placeholder to search. See {@link org.apache.poi.hslf.record.OEPlaceholderAtom}
* @return TextShape
or null
*/
- public TextShape getPlaceholder(int type){
+ public HSLFTextShape getPlaceholder(int type){
HSLFShape[] shape = getShapes();
for (int i = 0; i < shape.length; i++) {
- if(shape[i] instanceof TextShape){
- TextShape tx = (TextShape)shape[i];
+ if(shape[i] instanceof HSLFTextShape){
+ HSLFTextShape tx = (HSLFTextShape)shape[i];
int placeholderId = 0;
OEPlaceholderAtom oep = tx.getPlaceholderAtom();
if(oep != null) {
@@ -540,4 +517,14 @@ public abstract class Sheet implements ShapeContainer {
return shapeList;
}
+ /**
+ * @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
+ * Sheets that support the notion of master (slide, slideLayout) should override it and
+ * check this setting
+ */
+ public boolean getFollowMasterGraphics() {
+ return false;
+ }
+
+
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSimpleShape.java
similarity index 89%
rename from src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSimpleShape.java
index bfe6a1d95a..71c3c34d77 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSimpleShape.java
@@ -38,8 +38,10 @@ import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.InteractiveInfo;
import org.apache.poi.hslf.record.InteractiveInfoAtom;
import org.apache.poi.hslf.record.Record;
-import org.apache.poi.sl.usermodel.ShapeContainer;
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.StrokeStyle.*;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.Units;
/**
* An abstract simple (non-group) shape.
@@ -47,7 +49,7 @@ import org.apache.poi.util.LittleEndian;
*
* @author Yegor Kozlov
*/
-public abstract class SimpleShape extends HSLFShape {
+public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
public final static double DEFAULT_LINE_WIDTH = 0.75;
@@ -63,7 +65,7 @@ public abstract class SimpleShape extends HSLFShape {
* @param escherRecord EscherSpContainer
container which holds information about this shape
* @param parent the parent of the shape
*/
- protected SimpleShape(EscherContainerRecord escherRecord, ShapeContainer parent){
+ protected HSLFSimpleShape(EscherContainerRecord escherRecord, ShapeContainer parent){
super(escherRecord, parent);
}
@@ -112,7 +114,7 @@ public abstract class SimpleShape extends HSLFShape {
public double getLineWidth(){
EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
- double width = prop == null ? DEFAULT_LINE_WIDTH : (double)prop.getPropertyValue()/EMU_PER_POINT;
+ double width = (prop == null) ? DEFAULT_LINE_WIDTH : Units.toPoints(prop.getPropertyValue());
return width;
}
@@ -122,7 +124,7 @@ public abstract class SimpleShape extends HSLFShape {
*/
public void setLineWidth(double width){
EscherOptRecord opt = getEscherOptRecord();
- setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, (int)(width*EMU_PER_POINT));
+ setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, Units.toEMU(width));
}
/**
@@ -155,36 +157,45 @@ public abstract class SimpleShape extends HSLFShape {
}
/**
- * Gets line dashing. One of the PEN_* constants defined in this class.
+ * Gets line dashing.
*
* @return dashing of the line.
*/
- public int getLineDashing(){
+ public LineDash getLineDashing(){
EscherOptRecord opt = getEscherOptRecord();
-
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING);
- return prop == null ? Line.PEN_SOLID : prop.getPropertyValue();
+ return (prop == null) ? LineDash.SOLID : LineDash.fromNativeId(prop.getPropertyValue());
}
/**
- * Sets line dashing. One of the PEN_* constants defined in this class.
+ * Sets line dashing.
*
* @param pen new style of the line.
*/
- public void setLineDashing(int pen){
+ public void setLineDashing(LineDash pen){
EscherOptRecord opt = getEscherOptRecord();
-
- setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == Line.PEN_SOLID ? -1 : pen);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == LineDash.SOLID ? -1 : pen.nativeId);
}
/**
- * Sets line style. One of the constants defined in this class.
+ * Gets the line compound style
*
- * @param style new style of the line.
+ * @return the compound style of the line.
*/
- public void setLineStyle(int style){
+ public LineCompound getLineCompound() {
EscherOptRecord opt = getEscherOptRecord();
- setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == Line.LINE_SIMPLE ? -1 : style);
+ EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
+ return (prop == null) ? LineCompound.SINGLE : LineCompound.fromNativeId(prop.getPropertyValue());
+ }
+
+ /**
+ * Sets the line compound style
+ *
+ * @param style new compound style of the line.
+ */
+ public void setLineCompound(LineCompound style){
+ EscherOptRecord opt = getEscherOptRecord();
+ setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == LineCompound.SINGLE ? -1 : style.nativeId);
}
/**
@@ -192,10 +203,29 @@ public abstract class SimpleShape extends HSLFShape {
*
* @return style of the line.
*/
- public int getStrokeStyle(){
- EscherOptRecord opt = getEscherOptRecord();
- EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
- return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue();
+ public StrokeStyle getStrokeStyle(){
+ return new StrokeStyle() {
+ public PaintStyle getPaint() {
+ return null;
+ }
+
+ public LineCap getLineCap() {
+ return null;
+ }
+
+ public LineDash getLineDash() {
+ return null;
+ }
+
+ public LineCompound getLineCompound() {
+ return null;
+ }
+
+ public double getLineWidth() {
+ return 0;
+ }
+
+ };
}
/**
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java
similarity index 88%
rename from src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java
index 1db3173e6a..7030ce73e1 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java
@@ -37,7 +37,9 @@ import org.apache.poi.hslf.record.SlideAtom;
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;
/**
* This class represents a slide in a PowerPoint Document. It allows
@@ -48,11 +50,11 @@ import org.apache.poi.sl.usermodel.ShapeType;
* @author Yegor Kozlov
*/
-public final class Slide extends Sheet {
+public final class HSLFSlide extends HSLFSheet implements Slide {
private int _slideNo;
private SlideAtomsSet _atomSet;
- private TextRun[] _runs;
- private Notes _notes; // usermodel needs to set this
+ private HSLFTextParagraph[] _runs;
+ private HSLFNotes _notes; // usermodel needs to set this
/**
* Constructs a Slide from the Slide record, and the SlideAtomsSet
@@ -63,7 +65,7 @@ public final class Slide extends Sheet {
* @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, int slideIdentifier, int slideNumber) {
+ public HSLFSlide(org.apache.poi.hslf.record.Slide slide, HSLFNotes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
super(slide, slideIdentifier);
_notes = notes;
@@ -71,31 +73,31 @@ public final class Slide extends Sheet {
_slideNo = slideNumber;
// Grab the TextRuns from the PPDrawing
- TextRun[] _otherRuns = findTextRuns(getPPDrawing());
+ 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 textRuns = new LinkedList();
+ final List textParagraphs = new LinkedList();
if(_atomSet != null) {
- findTextRuns(_atomSet.getSlideRecords(),textRuns);
+ findTextParagraphs(_atomSet.getSlideRecords(),textParagraphs);
} else {
// No text on the slide, must just be pictures
}
// Build an array, more useful than a vector
- _runs = new TextRun[textRuns.size()+_otherRuns.length];
+ _runs = new HSLFTextParagraph[textParagraphs.size()+_otherRuns.length];
// Grab text from SlideListWithTexts entries
int i=0;
- for(i=0; iTextBox object that represents the slide's title.
*/
- public TextBox addTitle() {
+ public HSLFTextBox addTitle() {
Placeholder pl = new Placeholder();
pl.setShapeType(ShapeType.RECT);
- pl.getTextRun().setRunType(TextHeaderAtom.TITLE_TYPE);
+ pl.getTextParagraph().setRunType(TextHeaderAtom.TITLE_TYPE);
pl.setText("Click to edit title");
pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));
addShape(pl);
@@ -203,7 +205,7 @@ public final class Slide extends Sheet {
* @return title of this slide
*/
public String getTitle(){
- TextRun[] txt = getTextRuns();
+ HSLFTextParagraph[] txt = getTextRuns();
for (int i = 0; i < txt.length; i++) {
int type = txt[i].getRunType();
if (type == TextHeaderAtom.CENTER_TITLE_TYPE ||
@@ -220,7 +222,7 @@ public final class Slide extends Sheet {
/**
* Returns an array of all the TextRuns found
*/
- public TextRun[] getTextRuns() { return _runs; }
+ public HSLFTextParagraph[] getTextRuns() { return _runs; }
/**
* Returns the (public facing) page number of this slide
@@ -237,7 +239,7 @@ public final class Slide extends Sheet {
/**
* Returns the Notes Sheet for this slide, or null if there isn't one
*/
- public Notes getNotesSheet() { return _notes; }
+ public HSLFNotes getNotesSheet() { return _notes; }
/**
* @return set of records inside SlideListWithtext
container
@@ -251,11 +253,11 @@ public final class Slide extends Sheet {
*
* @return the master sheet associated with this slide.
*/
- public MasterSheet getMasterSheet(){
+ public HSLFMasterSheet getMasterSheet(){
SlideMaster[] master = getSlideShow().getSlidesMasters();
SlideAtom sa = getSlideRecord().getSlideAtom();
int masterId = sa.getMasterID();
- MasterSheet sheet = null;
+ HSLFMasterSheet sheet = null;
for (int i = 0; i < master.length; i++) {
if (masterId == master[i]._getSheetNumber()) {
sheet = master[i];
@@ -277,7 +279,7 @@ public final class Slide extends Sheet {
/**
* Change Master of this slide.
*/
- public void setMasterSheet(MasterSheet master){
+ public void setMasterSheet(HSLFMasterSheet master){
SlideAtom sa = getSlideRecord().getSlideAtom();
int sheetNo = master._getSheetNumber();
sa.setMasterID(sheetNo);
@@ -352,7 +354,7 @@ public final class Slide extends Sheet {
/**
* Background for this slide.
*/
- public Background getBackground() {
+ public HSLFBackground getBackground() {
if(getFollowMasterBackground()) {
return getMasterSheet().getBackground();
}
@@ -423,14 +425,14 @@ public final class Slide extends Sheet {
}
public void draw(Graphics2D graphics){
- MasterSheet master = getMasterSheet();
- Background bg = getBackground();
+ 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(MasterSheet.isPlaceholder(sh[i])) continue;
+ if(HSLFMasterSheet.isPlaceholder(sh[i])) continue;
sh[i].draw(graphics);
}
@@ -469,12 +471,12 @@ public final class Slide extends Sheet {
return new HeadersFooters(hdd, this, newRecord, ppt2007);
}
- protected void onAddTextShape(TextShape shape) {
- TextRun run = shape.getTextRun();
+ protected void onAddTextShape(HSLFTextShape shape) {
+ HSLFTextParagraph run = shape.getTextParagraph();
- if(_runs == null) _runs = new TextRun[]{run};
+ if(_runs == null) _runs = new HSLFTextParagraph[]{run};
else {
- TextRun[] tmp = new TextRun[_runs.length + 1];
+ HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1];
System.arraycopy(_runs, 0, tmp, 0, _runs.length);
tmp[tmp.length-1] = run;
_runs = tmp;
diff --git a/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java
similarity index 98%
rename from src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java
index 07a01aa244..803aeacaf3 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java
@@ -15,7 +15,7 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf;
+package org.apache.poi.hslf.model;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
@@ -49,7 +49,7 @@ import org.apache.poi.util.LittleEndian;
* This class provides helper functions for encrypted PowerPoint documents.
*/
@Internal
-public class EncryptedSlideShow {
+public class HSLFSlideShowEncrypted {
DocumentEncryptionAtom dea;
CryptoAPIEncryptor enc = null;
CryptoAPIDecryptor dec = null;
@@ -58,11 +58,11 @@ public class EncryptedSlideShow {
private static final BitField fieldRecInst = new BitField(0xFFF0);
- protected EncryptedSlideShow(DocumentEncryptionAtom dea) {
+ protected HSLFSlideShowEncrypted(DocumentEncryptionAtom dea) {
this.dea = dea;
}
- protected EncryptedSlideShow(byte[] docstream, NavigableMap recordMap) {
+ protected HSLFSlideShowEncrypted(byte[] docstream, NavigableMap recordMap) {
// check for DocumentEncryptionAtom, which would be at the last offset
// need to ignore already set UserEdit and PersistAtoms
UserEditAtom userEditAtomWithEncryption = null;
@@ -362,7 +362,7 @@ public class EncryptedSlideShow {
/**
* remove duplicated UserEditAtoms and merge PersistPtrHolder.
* Before this method is called, make sure that the offsets are correct,
- * i.e. call {@link HSLFSlideShow#updateAndWriteDependantRecords(OutputStream, Map)}
+ * i.e. call {@link HSLFSlideShowImpl#updateAndWriteDependantRecords(OutputStream, Map)}
*/
protected static Record[] normalizeRecords(Record records[]) {
// http://msdn.microsoft.com/en-us/library/office/gg615594(v=office.14).aspx
diff --git a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java
similarity index 93%
rename from src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java
index 55c3f6f876..48e52da65c 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java
@@ -15,7 +15,7 @@
limitations under the License.
==================================================================== */
-package org.apache.poi.hslf;
+package org.apache.poi.hslf.model;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -45,8 +45,8 @@ import org.apache.poi.hslf.record.PositionDependentRecord;
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.ObjectData;
-import org.apache.poi.hslf.usermodel.PictureData;
+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;
@@ -64,7 +64,7 @@ import org.apache.poi.util.POILogger;
*
* @author Nick Burch
*/
-public final class HSLFSlideShow extends POIDocument {
+public final class HSLFSlideShowImpl extends POIDocument {
public static final int UNSET_OFFSET = -1;
// For logging
@@ -80,10 +80,10 @@ public final class HSLFSlideShow extends POIDocument {
private Record[] _records;
// Raw Pictures contained in the pictures stream
- private List _pictures;
+ private List _pictures;
// Embedded objects stored in storage records in the document stream, lazily populated.
- private ObjectData[] _objects;
+ private HSLFObjectData[] _objects;
/**
* Returns the underlying POIFSFileSystem for the document
@@ -108,7 +108,7 @@ public final class HSLFSlideShow extends POIDocument {
* @param fileName The name of the file to read.
* @throws IOException if there is a problem while parsing the document.
*/
- public HSLFSlideShow(String fileName) throws IOException
+ public HSLFSlideShowImpl(String fileName) throws IOException
{
this(new FileInputStream(fileName));
}
@@ -120,7 +120,7 @@ public final class HSLFSlideShow extends POIDocument {
* @param inputStream the source of the data
* @throws IOException if there is a problem while parsing the document.
*/
- public HSLFSlideShow(InputStream inputStream) throws IOException {
+ public HSLFSlideShowImpl(InputStream inputStream) throws IOException {
//do Ole stuff
this(new POIFSFileSystem(inputStream));
}
@@ -132,7 +132,7 @@ public final class HSLFSlideShow extends POIDocument {
* @param filesystem the POIFS FileSystem to read from
* @throws IOException if there is a problem while parsing the document.
*/
- public HSLFSlideShow(POIFSFileSystem filesystem) throws IOException
+ public HSLFSlideShowImpl(POIFSFileSystem filesystem) throws IOException
{
this(filesystem.getRoot());
}
@@ -144,7 +144,7 @@ public final class HSLFSlideShow extends POIDocument {
* @param filesystem the POIFS FileSystem to read from
* @throws IOException if there is a problem while parsing the document.
*/
- public HSLFSlideShow(NPOIFSFileSystem filesystem) throws IOException
+ public HSLFSlideShowImpl(NPOIFSFileSystem filesystem) throws IOException
{
this(filesystem.getRoot());
}
@@ -160,7 +160,7 @@ public final class HSLFSlideShow extends POIDocument {
* @throws IOException if there is a problem while parsing the document.
*/
@Deprecated
- public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
+ public HSLFSlideShowImpl(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
{
this(dir);
}
@@ -173,7 +173,7 @@ public final class HSLFSlideShow extends POIDocument {
* @param dir the POIFS directory to read from
* @throws IOException if there is a problem while parsing the document.
*/
- public HSLFSlideShow(DirectoryNode dir) throws IOException {
+ public HSLFSlideShowImpl(DirectoryNode dir) throws IOException {
super(handleDualStorage(dir));
// First up, grab the "Current User" stream
@@ -202,13 +202,13 @@ public final class HSLFSlideShow extends POIDocument {
/**
* Constructs a new, empty, Powerpoint document.
*/
- public static final HSLFSlideShow create() {
- InputStream is = HSLFSlideShow.class.getResourceAsStream("data/empty.ppt");
+ public static final HSLFSlideShowImpl create() {
+ InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("data/empty.ppt");
if (is == null) {
throw new RuntimeException("Missing resource 'empty.ppt'");
}
try {
- return new HSLFSlideShow(is);
+ return new HSLFSlideShowImpl(is);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -279,7 +279,7 @@ public final class HSLFSlideShow extends POIDocument {
NavigableMap records = new TreeMap(); // offset -> record
Map persistIds = new HashMap(); // offset -> persistId
initRecordOffsets(docstream, usrOffset, records, persistIds);
- EncryptedSlideShow decryptData = new EncryptedSlideShow(docstream, records);
+ HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(docstream, records);
for (Map.Entry entry : records.entrySet()) {
Integer offset = entry.getKey();
@@ -373,12 +373,12 @@ public final class HSLFSlideShow extends POIDocument {
*/
@SuppressWarnings("unused")
private void readPictures() throws IOException {
- _pictures = new ArrayList();
+ _pictures = new ArrayList();
// if the presentation doesn't contain pictures - will use a null set instead
if (!directory.hasEntry("Pictures")) return;
- EncryptedSlideShow decryptData = new EncryptedSlideShow(getDocumentEncryptionAtom());
+ HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
DocumentEntry entry = (DocumentEntry)directory.getEntry("Pictures");
byte[] pictstream = new byte[entry.getSize()];
@@ -423,7 +423,7 @@ public final class HSLFSlideShow extends POIDocument {
} else {
// Build the PictureData object from the data
try {
- PictureData pict = PictureData.create(type - 0xF018);
+ HSLFPictureData pict = HSLFPictureData.create(type - 0xF018);
// Copy the data, ready to pass to PictureData
byte[] imgdata = new byte[imgsize];
@@ -451,7 +451,7 @@ public final class HSLFSlideShow extends POIDocument {
} catch (IOException e) {
throw new CorruptPowerPointFileException(e);
}
- _records = EncryptedSlideShow.normalizeRecords(_records);
+ _records = HSLFSlideShowEncrypted.normalizeRecords(_records);
}
@@ -517,7 +517,7 @@ public final class HSLFSlideShow extends POIDocument {
persistIds.put(oldToNewPositions.get(entry.getValue()), entry.getKey());
}
- EncryptedSlideShow encData = new EncryptedSlideShow(getDocumentEncryptionAtom());
+ HSLFSlideShowEncrypted encData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
for (Record record : _records) {
assert(record instanceof PositionDependentRecord);
@@ -580,7 +580,7 @@ public final class HSLFSlideShow extends POIDocument {
getDocumentSummaryInformation();
// set new encryption settings
- EncryptedSlideShow encryptedSS = new EncryptedSlideShow(getDocumentEncryptionAtom());
+ HSLFSlideShowEncrypted encryptedSS = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
_records = encryptedSS.updateEncryptionRecord(_records);
// Get a new Filesystem to write into
@@ -615,7 +615,7 @@ public final class HSLFSlideShow extends POIDocument {
if (_pictures.size() > 0) {
BufAccessBAOS pict = new BufAccessBAOS();
- for (PictureData p : _pictures) {
+ for (HSLFPictureData p : _pictures) {
int offset = pict.size();
p.write(pict);
encryptedSS.encryptPicture(pict.getBuf(), offset);
@@ -704,7 +704,7 @@ public final class HSLFSlideShow extends POIDocument {
*
* @return offset of this picture in the Pictures stream
*/
- public int addPicture(PictureData img) {
+ public int addPicture(HSLFPictureData img) {
// Process any existing pictures if we haven't yet
if(_pictures == null) {
try {
@@ -717,7 +717,7 @@ public final class HSLFSlideShow extends POIDocument {
// Add the new picture in
int offset = 0;
if(_pictures.size() > 0) {
- PictureData prev = _pictures.get(_pictures.size() - 1);
+ HSLFPictureData prev = _pictures.get(_pictures.size() - 1);
offset = prev.getOffset() + prev.getRawData().length + 8;
}
img.setOffset(offset);
@@ -750,7 +750,7 @@ public final class HSLFSlideShow extends POIDocument {
* @return array with the read pictures or null
if the
* presentation doesn't contain pictures.
*/
- public PictureData[] getPictures() {
+ public HSLFPictureData[] getPictures() {
if(_pictures == null) {
try {
readPictures();
@@ -759,7 +759,7 @@ public final class HSLFSlideShow extends POIDocument {
}
}
- return _pictures.toArray(new PictureData[_pictures.size()]);
+ return _pictures.toArray(new HSLFPictureData[_pictures.size()]);
}
/**
@@ -767,15 +767,15 @@ public final class HSLFSlideShow extends POIDocument {
*
* @return the embedded objects.
*/
- public ObjectData[] getEmbeddedObjects() {
+ public HSLFObjectData[] getEmbeddedObjects() {
if (_objects == null) {
- List objects = new ArrayList();
+ List objects = new ArrayList();
for (Record r : _records) {
if (r instanceof ExOleObjStg) {
- objects.add(new ObjectData((ExOleObjStg)r));
+ objects.add(new HSLFObjectData((ExOleObjStg)r));
}
}
- _objects = objects.toArray(new ObjectData[objects.size()]);
+ _objects = objects.toArray(new HSLFObjectData[objects.size()]);
}
return _objects;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java
similarity index 89%
rename from src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java
index dc5ac94104..25ea585c95 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java
@@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
*
* @author Yegor Kozlov
*/
-public class TextBox extends TextShape {
+public class HSLFTextBox extends HSLFTextShape {
/**
* Create a TextBox object and initialize it from the supplied Record container.
@@ -38,7 +38,7 @@ public class TextBox extends TextShape {
* @param escherRecord EscherSpContainer
container which holds information about this shape
* @param parent the parent of the shape
*/
- protected TextBox(EscherContainerRecord escherRecord, ShapeContainer parent){
+ protected HSLFTextBox(EscherContainerRecord escherRecord, ShapeContainer parent){
super(escherRecord, parent);
}
@@ -49,7 +49,7 @@ public class TextBox extends TextShape {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
- public TextBox(ShapeContainer parent){
+ public HSLFTextBox(ShapeContainer parent){
super(parent);
}
@@ -57,7 +57,7 @@ public class TextBox extends TextShape {
* Create a new TextBox. This constructor is used when a new shape is created.
*
*/
- public TextBox(){
+ public HSLFTextBox(){
this(null);
}
@@ -84,8 +84,8 @@ public class TextBox extends TextShape {
return _escherContainer;
}
- protected void setDefaultTextProperties(TextRun _txtrun){
- setVerticalAlignment(TextBox.AnchorTop);
+ protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
+ setVerticalAlignment(HSLFTextBox.AnchorTop);
setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002);
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextParagraph.java
similarity index 90%
rename from src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextParagraph.java
index 755482f183..b23c997dbe 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextParagraph.java
@@ -1,746 +1,744 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.PPDrawing;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.RecordContainer;
-import org.apache.poi.hslf.record.SlideListWithText;
-import org.apache.poi.hslf.record.StyleTextProp9Atom;
-import org.apache.poi.hslf.record.StyleTextPropAtom;
-import org.apache.poi.hslf.record.TextBytesAtom;
-import org.apache.poi.hslf.record.TextCharsAtom;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.record.TextRulerAtom;
-import org.apache.poi.hslf.record.TextSpecInfoAtom;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.util.StringUtil;
-
-/**
- * This class represents a run of text in a powerpoint document. That
- * run could be text on a sheet, or text in a note.
- * It is only a very basic class for now
- *
- * @author Nick Burch
- */
-
-public final class TextRun
-{
- // Note: These fields are protected to help with unit testing
- // Other classes shouldn't really go playing with them!
- protected TextHeaderAtom _headerAtom;
- protected TextBytesAtom _byteAtom;
- protected TextCharsAtom _charAtom;
- protected StyleTextPropAtom _styleAtom;
- protected TextRulerAtom _ruler;
- protected boolean _isUnicode;
- protected RichTextRun[] _rtRuns;
- private SlideShow slideShow;
- private Sheet _sheet;
- private int shapeId;
- private int slwtIndex = -1; //position in the owning SlideListWithText
- /**
- * all text run records that follow TextHeaderAtom.
- * (there can be misc InteractiveInfo, TxInteractiveInfo and other records)
- */
- protected Record[] _records;
- // private StyleTextPropAtom styleTextPropAtom;
- private StyleTextProp9Atom styleTextProp9Atom;
-
- /**
- * Constructs a Text Run from a Unicode text block
- *
- * @param tha the TextHeaderAtom that defines what's what
- * @param tca the TextCharsAtom containing the text
- * @param sta the StyleTextPropAtom which defines the character stylings
- */
- public TextRun(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta) {
- this(tha,null,tca,sta);
- }
-
- /**
- * Constructs a Text Run from a Ascii text block
- *
- * @param tha the TextHeaderAtom that defines what's what
- * @param tba the TextBytesAtom containing the text
- * @param sta the StyleTextPropAtom which defines the character stylings
- */
- public TextRun(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) {
- this(tha,tba,null,sta);
- }
-
- /**
- * Internal constructor and initializer
- */
- private TextRun(TextHeaderAtom tha, TextBytesAtom tba, TextCharsAtom tca, StyleTextPropAtom sta) {
- _headerAtom = tha;
- _styleAtom = sta;
- if(tba != null) {
- _byteAtom = tba;
- _isUnicode = false;
- } else {
- _charAtom = tca;
- _isUnicode = true;
- }
- String runRawText = getText();
-
- // Figure out the rich text runs
- LinkedList pStyles = new LinkedList();
- LinkedList cStyles = new LinkedList();
- if(_styleAtom != null) {
- // Get the style atom to grok itself
- _styleAtom.setParentTextSize(runRawText.length());
- pStyles = _styleAtom.getParagraphStyles();
- cStyles = _styleAtom.getCharacterStyles();
- }
- buildRichTextRuns(pStyles, cStyles, runRawText);
- }
-
- public void buildRichTextRuns(LinkedList pStyles, LinkedList cStyles, String runRawText){
-
- // Handle case of no current style, with a default
- if(pStyles.size() == 0 || cStyles.size() == 0) {
- _rtRuns = new RichTextRun[1];
- _rtRuns[0] = new RichTextRun(this, 0, runRawText.length());
- } else {
- // Build up Rich Text Runs, one for each
- // character/paragraph style pair
- List rtrs = new ArrayList();
-
- int pos = 0;
-
- int curP = 0;
- int curC = 0;
- int pLenRemain = -1;
- int cLenRemain = -1;
-
- // Build one for each run with the same style
- while(pos <= runRawText.length() && curP < pStyles.size() && curC < cStyles.size()) {
- // Get the Props to use
- TextPropCollection pProps = pStyles.get(curP);
- TextPropCollection cProps = cStyles.get(curC);
-
- int pLen = pProps.getCharactersCovered();
- int cLen = cProps.getCharactersCovered();
-
- // Handle new pass
- boolean freshSet = false;
- if(pLenRemain == -1 && cLenRemain == -1) { freshSet = true; }
- if(pLenRemain == -1) { pLenRemain = pLen; }
- if(cLenRemain == -1) { cLenRemain = cLen; }
-
- // So we know how to build the eventual run
- int runLen = -1;
- boolean pShared = false;
- boolean cShared = false;
-
- // Same size, new styles - neither shared
- if(pLen == cLen && freshSet) {
- runLen = cLen;
- pShared = false;
- cShared = false;
- curP++;
- curC++;
- pLenRemain = -1;
- cLenRemain = -1;
- } else {
- // Some sharing
-
- // See if we are already in a shared block
- if(pLenRemain < pLen) {
- // Existing shared p block
- pShared = true;
-
- // Do we end with the c block, or either side of it?
- if(pLenRemain == cLenRemain) {
- // We end at the same time
- cShared = false;
- runLen = pLenRemain;
- curP++;
- curC++;
- pLenRemain = -1;
- cLenRemain = -1;
- } else if(pLenRemain < cLenRemain) {
- // We end before the c block
- cShared = true;
- runLen = pLenRemain;
- curP++;
- cLenRemain -= pLenRemain;
- pLenRemain = -1;
- } else {
- // We end after the c block
- cShared = false;
- runLen = cLenRemain;
- curC++;
- pLenRemain -= cLenRemain;
- cLenRemain = -1;
- }
- } else if(cLenRemain < cLen) {
- // Existing shared c block
- cShared = true;
-
- // Do we end with the p block, or either side of it?
- if(pLenRemain == cLenRemain) {
- // We end at the same time
- pShared = false;
- runLen = cLenRemain;
- curP++;
- curC++;
- pLenRemain = -1;
- cLenRemain = -1;
- } else if(cLenRemain < pLenRemain) {
- // We end before the p block
- pShared = true;
- runLen = cLenRemain;
- curC++;
- pLenRemain -= cLenRemain;
- cLenRemain = -1;
- } else {
- // We end after the p block
- pShared = false;
- runLen = pLenRemain;
- curP++;
- cLenRemain -= pLenRemain;
- pLenRemain = -1;
- }
- } else {
- // Start of a shared block
- if(pLenRemain < cLenRemain) {
- // Shared c block
- pShared = false;
- cShared = true;
- runLen = pLenRemain;
- curP++;
- cLenRemain -= pLenRemain;
- pLenRemain = -1;
- } else {
- // Shared p block
- pShared = true;
- cShared = false;
- runLen = cLenRemain;
- curC++;
- pLenRemain -= cLenRemain;
- cLenRemain = -1;
- }
- }
- }
-
- // Wind on
- int prevPos = pos;
- pos += runLen;
- // Adjust for end-of-run extra 1 length
- if(pos > runRawText.length()) {
- runLen--;
- }
-
- // Save
- RichTextRun rtr = new RichTextRun(this, prevPos, runLen, pProps, cProps, pShared, cShared);
- rtrs.add(rtr);
- }
-
- // Build the array
- _rtRuns = rtrs.toArray(new RichTextRun[rtrs.size()]);
- }
-
- }
-
- // Update methods follow
-
- /**
- * Adds the supplied text onto the end of the TextRun,
- * creating a new RichTextRun (returned) for it to
- * sit in.
- * In many cases, before calling this, you'll want to add
- * a newline onto the end of your last RichTextRun
- */
- public RichTextRun appendText(String s) {
- // We will need a StyleTextProp atom
- ensureStyleAtomPresent();
-
- // First up, append the text to the
- // underlying text atom
- int oldSize = getRawText().length();
- storeText(
- getRawText() + s
- );
-
- // If either of the previous styles overran
- // the text by one, we need to shuffle that
- // extra character onto the new ones
- int pOverRun = _styleAtom.getParagraphTextLengthCovered() - oldSize;
- int cOverRun = _styleAtom.getCharacterTextLengthCovered() - oldSize;
- if(pOverRun > 0) {
- TextPropCollection tpc = _styleAtom.getParagraphStyles().getLast();
- tpc.updateTextSize(
- tpc.getCharactersCovered() - pOverRun
- );
- }
- if(cOverRun > 0) {
- TextPropCollection tpc = _styleAtom.getCharacterStyles().getLast();
- tpc.updateTextSize(
- tpc.getCharactersCovered() - cOverRun
- );
- }
-
- // Next, add the styles for its paragraph and characters
- TextPropCollection newPTP =
- _styleAtom.addParagraphTextPropCollection(s.length()+pOverRun);
- TextPropCollection newCTP =
- _styleAtom.addCharacterTextPropCollection(s.length()+cOverRun);
-
- // Now, create the new RichTextRun
- RichTextRun nr = new RichTextRun(
- this, oldSize, s.length(),
- newPTP, newCTP, false, false
- );
-
- // Add the new RichTextRun onto our list
- RichTextRun[] newRuns = new RichTextRun[_rtRuns.length+1];
- System.arraycopy(_rtRuns, 0, newRuns, 0, _rtRuns.length);
- newRuns[newRuns.length-1] = nr;
- _rtRuns = newRuns;
-
- // And return the new run to the caller
- return nr;
- }
-
- /**
- * Saves the given string to the records. Doesn't
- * touch the stylings.
- */
- private void storeText(String s) {
- // Store in the appropriate record
- if(_isUnicode) {
- // The atom can safely convert to unicode
- _charAtom.setText(s);
- } else {
- // Will it fit in a 8 bit atom?
- boolean hasMultibyte = StringUtil.hasMultibyte(s);
- if(! hasMultibyte) {
- // Fine to go into 8 bit atom
- byte[] text = new byte[s.length()];
- StringUtil.putCompressedUnicode(s,text,0);
- _byteAtom.setText(text);
- } else {
- // Need to swap a TextBytesAtom for a TextCharsAtom
-
- // Build the new TextCharsAtom
- _charAtom = new TextCharsAtom();
- _charAtom.setText(s);
-
- // Use the TextHeaderAtom to do the swap on the parent
- RecordContainer parent = _headerAtom.getParentRecord();
- Record[] cr = parent.getChildRecords();
- for(int i=0; i pStyles = _styleAtom.getParagraphStyles();
- while(pStyles.size() > 1) { pStyles.removeLast(); }
-
- if (!pStyles.isEmpty()) {
- pStyles.getFirst().updateTextSize( s.length()+1 );
- }
-
- LinkedList cStyles = _styleAtom.getCharacterStyles();
- while(cStyles.size() > 1) { cStyles.removeLast(); }
-
- if (!cStyles.isEmpty()) {
- cStyles.getFirst().updateTextSize( s.length()+1 );
- }
-
- _rtRuns[0].setText(s);
- } else {
- // Recreate rich text run with no styling
- _rtRuns[0] = new RichTextRun(this,0,s.length());
- }
-
- }
-
- /**
- * Changes the text.
- * Converts '\r' into '\n'
- */
- public void setText(String s) {
- String text = normalize(s);
- setRawText(text);
- }
-
- /**
- * Ensure a StyleTextPropAtom is present for this run,
- * by adding if required. Normally for internal TextRun use.
- */
- public void ensureStyleAtomPresent() {
- if(_styleAtom != null) {
- // All there
- return;
- }
-
- // Create a new one at the right size
- _styleAtom = new StyleTextPropAtom(getRawText().length() + 1);
-
- // Use the TextHeader atom to get at the parent
- RecordContainer runAtomsParent = _headerAtom.getParentRecord();
-
- // Add the new StyleTextPropAtom after the TextCharsAtom / TextBytesAtom
- Record addAfter = _byteAtom;
- if(_byteAtom == null) { addAfter = _charAtom; }
- runAtomsParent.addChildAfter(_styleAtom, addAfter);
-
- // Feed this to our sole rich text run
- if(_rtRuns.length != 1) {
- throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs");
- }
- // These are the only styles for now
- _rtRuns[0].supplyTextProps(
- _styleAtom.getParagraphStyles().get(0),
- _styleAtom.getCharacterStyles().get(0),
- false,
- false
- );
- }
-
- // Accesser methods follow
-
- /**
- * Returns the text content of the run, which has been made safe
- * for printing and other use.
- */
- public String getText() {
- String rawText = getRawText();
-
- // PowerPoint seems to store files with \r as the line break
- // The messes things up on everything but a Mac, so translate
- // them to \n
- String text = rawText.replace('\r','\n');
-
- int type = _headerAtom == null ? 0 : _headerAtom.getTextType();
- if(type == TextHeaderAtom.TITLE_TYPE || type == TextHeaderAtom.CENTER_TITLE_TYPE){
- //0xB acts like cariage return in page titles and like blank in the others
- text = text.replace((char) 0x0B, '\n');
- } else {
- text = text.replace((char) 0x0B, ' ');
- }
- return text;
- }
-
- /**
- * Returns the raw text content of the run. This hasn't had any
- * changes applied to it, and so is probably unlikely to print
- * out nicely.
- */
- public String getRawText() {
- if(_isUnicode) {
- return _charAtom.getText();
- }
- return _byteAtom.getText();
- }
-
- /**
- * Fetch the rich text runs (runs of text with the same styling) that
- * are contained within this block of text
- */
- public RichTextRun[] getRichTextRuns() {
- return _rtRuns;
- }
-
- /**
- * Returns the type of the text, from the TextHeaderAtom.
- * Possible values can be seen from TextHeaderAtom
- * @see org.apache.poi.hslf.record.TextHeaderAtom
- */
- public int getRunType() {
- return _headerAtom.getTextType();
- }
-
- /**
- * Changes the type of the text. Values should be taken
- * from TextHeaderAtom. No checking is done to ensure you
- * set this to a valid value!
- * @see org.apache.poi.hslf.record.TextHeaderAtom
- */
- public void setRunType(int type) {
- _headerAtom.setTextType(type);
- }
-
- /**
- * Supply the SlideShow we belong to.
- * Also passes it on to our child RichTextRuns
- */
- public void supplySlideShow(SlideShow ss) {
- slideShow = ss;
- if(_rtRuns != null) {
- for(int i=0; i<_rtRuns.length; i++) {
- _rtRuns[i].supplySlideShow(slideShow);
- }
- }
- }
-
- public void setSheet(Sheet sheet){
- this._sheet = sheet;
- }
-
- public Sheet getSheet(){
- return this._sheet;
- }
-
- /**
- * @return Shape ID
- */
- protected int getShapeId(){
- return shapeId;
- }
-
- /**
- * @param id Shape ID
- */
- protected void setShapeId(int id){
- shapeId = id;
- }
-
- /**
- * @return 0-based index of the text run in the SLWT container
- */
- protected int getIndex(){
- return slwtIndex;
- }
-
- /**
- * @param id 0-based index of the text run in the SLWT container
- */
- protected void setIndex(int id){
- slwtIndex = id;
- }
-
- /**
- * Is this Text Run one from a {@link PPDrawing}, or is it
- * one from the {@link SlideListWithText}?
- */
- public boolean isDrawingBased() {
- return (slwtIndex == -1);
- }
-
- /**
- * Returns the array of all hyperlinks in this text run
- *
- * @return the array of all hyperlinks in this text run
- * or null
if not found.
- */
- public Hyperlink[] getHyperlinks(){
- return Hyperlink.find(this);
- }
-
- /**
- * Fetch RichTextRun at a given position
- *
- * @param pos 0-based index in the text
- * @return RichTextRun or null if not found
- */
- public RichTextRun getRichTextRunAt(int pos){
- for (int i = 0; i < _rtRuns.length; i++) {
- int start = _rtRuns[i].getStartIndex();
- int end = _rtRuns[i].getEndIndex();
- if(pos >= start && pos < end) return _rtRuns[i];
- }
- return null;
- }
-
- public TextRulerAtom getTextRuler(){
- if(_ruler == null){
- if(_records != null) for (int i = 0; i < _records.length; i++) {
- if(_records[i] instanceof TextRulerAtom) {
- _ruler = (TextRulerAtom)_records[i];
- break;
- }
- }
-
- }
- return _ruler;
-
- }
-
- public TextRulerAtom createTextRuler(){
- _ruler = getTextRuler();
- if(_ruler == null){
- _ruler = TextRulerAtom.getParagraphInstance();
- _headerAtom.getParentRecord().appendChildRecord(_ruler);
- }
- return _ruler;
- }
-
- /**
- * Returns a new string with line breaks converted into internal ppt representation
- */
- public String normalize(String s){
- String ns = s.replaceAll("\\r?\\n", "\r");
- return ns;
- }
-
- /**
- * Returns records that make up this text run
- *
- * @return text run records
- */
- public Record[] getRecords(){
- return _records;
- }
- /** Numbered List info */
- public void setStyleTextProp9Atom(final StyleTextProp9Atom styleTextProp9Atom) {
- this.styleTextProp9Atom = styleTextProp9Atom;
- }
- /** Numbered List info */
- public StyleTextProp9Atom getStyleTextProp9Atom() {
- return this.styleTextProp9Atom;
- }
-
- /** Characters covered */
- public StyleTextPropAtom getStyleTextPropAtom() {
- return this._styleAtom;
- }
-
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.poi.hslf.model.textproperties.TextPropCollection;
+import org.apache.poi.hslf.record.PPDrawing;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.RecordContainer;
+import org.apache.poi.hslf.record.SlideListWithText;
+import org.apache.poi.hslf.record.StyleTextProp9Atom;
+import org.apache.poi.hslf.record.StyleTextPropAtom;
+import org.apache.poi.hslf.record.TextBytesAtom;
+import org.apache.poi.hslf.record.TextCharsAtom;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.hslf.record.TextRulerAtom;
+import org.apache.poi.hslf.record.TextSpecInfoAtom;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.sl.usermodel.TextParagraph;
+import org.apache.poi.util.StringUtil;
+
+/**
+ * This class represents a run of text in a powerpoint document. That
+ * run could be text on a sheet, or text in a note.
+ * It is only a very basic class for now
+ *
+ * @author Nick Burch
+ */
+
+public final class HSLFTextParagraph implements TextParagraph
+{
+ // Note: These fields are protected to help with unit testing
+ // Other classes shouldn't really go playing with them!
+ protected TextHeaderAtom _headerAtom;
+ protected TextBytesAtom _byteAtom;
+ protected TextCharsAtom _charAtom;
+ protected StyleTextPropAtom _styleAtom;
+ protected TextRulerAtom _ruler;
+ protected boolean _isUnicode;
+ protected HSLFTextRun[] _rtRuns;
+ protected HSLFTextShape _parentShape;
+ // private SlideShow slideShow;
+ private HSLFSheet _sheet;
+ private int shapeId;
+ private int slwtIndex = -1; //position in the owning SlideListWithText
+ /**
+ * all text run records that follow TextHeaderAtom.
+ * (there can be misc InteractiveInfo, TxInteractiveInfo and other records)
+ */
+ protected Record[] _records;
+ // private StyleTextPropAtom styleTextPropAtom;
+ private StyleTextProp9Atom styleTextProp9Atom;
+
+ /**
+ * Constructs a Text Run from a Unicode text block
+ *
+ * @param tha the TextHeaderAtom that defines what's what
+ * @param tca the TextCharsAtom containing the text
+ * @param sta the StyleTextPropAtom which defines the character stylings
+ */
+ public HSLFTextParagraph(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta) {
+ this(tha,null,tca,sta);
+ }
+
+ /**
+ * Constructs a Text Run from a Ascii text block
+ *
+ * @param tha the TextHeaderAtom that defines what's what
+ * @param tba the TextBytesAtom containing the text
+ * @param sta the StyleTextPropAtom which defines the character stylings
+ */
+ public HSLFTextParagraph(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) {
+ this(tha,tba,null,sta);
+ }
+
+ /**
+ * Internal constructor and initializer
+ */
+ private HSLFTextParagraph(TextHeaderAtom tha, TextBytesAtom tba, TextCharsAtom tca, StyleTextPropAtom sta) {
+ _headerAtom = tha;
+ _styleAtom = sta;
+ if(tba != null) {
+ _byteAtom = tba;
+ _isUnicode = false;
+ } else {
+ _charAtom = tca;
+ _isUnicode = true;
+ }
+ String runRawText = getText();
+
+ // Figure out the rich text runs
+ LinkedList pStyles = new LinkedList();
+ LinkedList cStyles = new LinkedList();
+ if(_styleAtom != null) {
+ // Get the style atom to grok itself
+ _styleAtom.setParentTextSize(runRawText.length());
+ pStyles = _styleAtom.getParagraphStyles();
+ cStyles = _styleAtom.getCharacterStyles();
+ }
+ buildRichTextRuns(pStyles, cStyles, runRawText);
+ }
+
+ public void buildRichTextRuns(LinkedList pStyles, LinkedList cStyles, String runRawText){
+
+ // Handle case of no current style, with a default
+ if(pStyles.size() == 0 || cStyles.size() == 0) {
+ _rtRuns = new HSLFTextRun[1];
+ _rtRuns[0] = new HSLFTextRun(this, 0, runRawText.length());
+ } else {
+ // Build up Rich Text Runs, one for each
+ // character/paragraph style pair
+ List rtrs = new ArrayList();
+
+ int pos = 0;
+
+ int curP = 0;
+ int curC = 0;
+ int pLenRemain = -1;
+ int cLenRemain = -1;
+
+ // Build one for each run with the same style
+ while(pos <= runRawText.length() && curP < pStyles.size() && curC < cStyles.size()) {
+ // Get the Props to use
+ TextPropCollection pProps = pStyles.get(curP);
+ TextPropCollection cProps = cStyles.get(curC);
+
+ int pLen = pProps.getCharactersCovered();
+ int cLen = cProps.getCharactersCovered();
+
+ // Handle new pass
+ boolean freshSet = false;
+ if(pLenRemain == -1 && cLenRemain == -1) { freshSet = true; }
+ if(pLenRemain == -1) { pLenRemain = pLen; }
+ if(cLenRemain == -1) { cLenRemain = cLen; }
+
+ // So we know how to build the eventual run
+ int runLen = -1;
+ boolean pShared = false;
+ boolean cShared = false;
+
+ // Same size, new styles - neither shared
+ if(pLen == cLen && freshSet) {
+ runLen = cLen;
+ pShared = false;
+ cShared = false;
+ curP++;
+ curC++;
+ pLenRemain = -1;
+ cLenRemain = -1;
+ } else {
+ // Some sharing
+
+ // See if we are already in a shared block
+ if(pLenRemain < pLen) {
+ // Existing shared p block
+ pShared = true;
+
+ // Do we end with the c block, or either side of it?
+ if(pLenRemain == cLenRemain) {
+ // We end at the same time
+ cShared = false;
+ runLen = pLenRemain;
+ curP++;
+ curC++;
+ pLenRemain = -1;
+ cLenRemain = -1;
+ } else if(pLenRemain < cLenRemain) {
+ // We end before the c block
+ cShared = true;
+ runLen = pLenRemain;
+ curP++;
+ cLenRemain -= pLenRemain;
+ pLenRemain = -1;
+ } else {
+ // We end after the c block
+ cShared = false;
+ runLen = cLenRemain;
+ curC++;
+ pLenRemain -= cLenRemain;
+ cLenRemain = -1;
+ }
+ } else if(cLenRemain < cLen) {
+ // Existing shared c block
+ cShared = true;
+
+ // Do we end with the p block, or either side of it?
+ if(pLenRemain == cLenRemain) {
+ // We end at the same time
+ pShared = false;
+ runLen = cLenRemain;
+ curP++;
+ curC++;
+ pLenRemain = -1;
+ cLenRemain = -1;
+ } else if(cLenRemain < pLenRemain) {
+ // We end before the p block
+ pShared = true;
+ runLen = cLenRemain;
+ curC++;
+ pLenRemain -= cLenRemain;
+ cLenRemain = -1;
+ } else {
+ // We end after the p block
+ pShared = false;
+ runLen = pLenRemain;
+ curP++;
+ cLenRemain -= pLenRemain;
+ pLenRemain = -1;
+ }
+ } else {
+ // Start of a shared block
+ if(pLenRemain < cLenRemain) {
+ // Shared c block
+ pShared = false;
+ cShared = true;
+ runLen = pLenRemain;
+ curP++;
+ cLenRemain -= pLenRemain;
+ pLenRemain = -1;
+ } else {
+ // Shared p block
+ pShared = true;
+ cShared = false;
+ runLen = cLenRemain;
+ curC++;
+ pLenRemain -= cLenRemain;
+ cLenRemain = -1;
+ }
+ }
+ }
+
+ // Wind on
+ int prevPos = pos;
+ pos += runLen;
+ // Adjust for end-of-run extra 1 length
+ if(pos > runRawText.length()) {
+ runLen--;
+ }
+
+ // Save
+ HSLFTextRun rtr = new HSLFTextRun(this, prevPos, runLen, pProps, cProps, pShared, cShared);
+ rtrs.add(rtr);
+ }
+
+ // Build the array
+ _rtRuns = rtrs.toArray(new HSLFTextRun[rtrs.size()]);
+ }
+
+ }
+
+ // Update methods follow
+
+ /**
+ * Adds the supplied text onto the end of the TextRun,
+ * creating a new RichTextRun (returned) for it to
+ * sit in.
+ * In many cases, before calling this, you'll want to add
+ * a newline onto the end of your last RichTextRun
+ */
+ public HSLFTextRun appendText(String s) {
+ // We will need a StyleTextProp atom
+ ensureStyleAtomPresent();
+
+ // First up, append the text to the
+ // underlying text atom
+ int oldSize = getRawText().length();
+ storeText(
+ getRawText() + s
+ );
+
+ // If either of the previous styles overran
+ // the text by one, we need to shuffle that
+ // extra character onto the new ones
+ int pOverRun = _styleAtom.getParagraphTextLengthCovered() - oldSize;
+ int cOverRun = _styleAtom.getCharacterTextLengthCovered() - oldSize;
+ if(pOverRun > 0) {
+ TextPropCollection tpc = _styleAtom.getParagraphStyles().getLast();
+ tpc.updateTextSize(
+ tpc.getCharactersCovered() - pOverRun
+ );
+ }
+ if(cOverRun > 0) {
+ TextPropCollection tpc = _styleAtom.getCharacterStyles().getLast();
+ tpc.updateTextSize(
+ tpc.getCharactersCovered() - cOverRun
+ );
+ }
+
+ // Next, add the styles for its paragraph and characters
+ TextPropCollection newPTP =
+ _styleAtom.addParagraphTextPropCollection(s.length()+pOverRun);
+ TextPropCollection newCTP =
+ _styleAtom.addCharacterTextPropCollection(s.length()+cOverRun);
+
+ // Now, create the new RichTextRun
+ HSLFTextRun nr = new HSLFTextRun(
+ this, oldSize, s.length(),
+ newPTP, newCTP, false, false
+ );
+
+ // Add the new RichTextRun onto our list
+ HSLFTextRun[] newRuns = new HSLFTextRun[_rtRuns.length+1];
+ System.arraycopy(_rtRuns, 0, newRuns, 0, _rtRuns.length);
+ newRuns[newRuns.length-1] = nr;
+ _rtRuns = newRuns;
+
+ // And return the new run to the caller
+ return nr;
+ }
+
+ /**
+ * Saves the given string to the records. Doesn't
+ * touch the stylings.
+ */
+ private void storeText(String s) {
+ // Store in the appropriate record
+ if(_isUnicode) {
+ // The atom can safely convert to unicode
+ _charAtom.setText(s);
+ } else {
+ // Will it fit in a 8 bit atom?
+ boolean hasMultibyte = StringUtil.hasMultibyte(s);
+ if(! hasMultibyte) {
+ // Fine to go into 8 bit atom
+ byte[] text = new byte[s.length()];
+ StringUtil.putCompressedUnicode(s,text,0);
+ _byteAtom.setText(text);
+ } else {
+ // Need to swap a TextBytesAtom for a TextCharsAtom
+
+ // Build the new TextCharsAtom
+ _charAtom = new TextCharsAtom();
+ _charAtom.setText(s);
+
+ // Use the TextHeaderAtom to do the swap on the parent
+ RecordContainer parent = _headerAtom.getParentRecord();
+ Record[] cr = parent.getChildRecords();
+ for(int i=0; i pStyles = _styleAtom.getParagraphStyles();
+ while(pStyles.size() > 1) { pStyles.removeLast(); }
+
+ if (!pStyles.isEmpty()) {
+ pStyles.getFirst().updateTextSize( s.length()+1 );
+ }
+
+ LinkedList cStyles = _styleAtom.getCharacterStyles();
+ while(cStyles.size() > 1) { cStyles.removeLast(); }
+
+ if (!cStyles.isEmpty()) {
+ cStyles.getFirst().updateTextSize( s.length()+1 );
+ }
+
+ _rtRuns[0].setText(s);
+ } else {
+ // Recreate rich text run with no styling
+ _rtRuns[0] = new HSLFTextRun(this,0,s.length());
+ }
+
+ }
+
+ /**
+ * Changes the text.
+ * Converts '\r' into '\n'
+ */
+ public void setText(String s) {
+ String text = normalize(s);
+ setRawText(text);
+ }
+
+ /**
+ * Ensure a StyleTextPropAtom is present for this run,
+ * by adding if required. Normally for internal TextRun use.
+ */
+ public void ensureStyleAtomPresent() {
+ if(_styleAtom != null) {
+ // All there
+ return;
+ }
+
+ // Create a new one at the right size
+ _styleAtom = new StyleTextPropAtom(getRawText().length() + 1);
+
+ // Use the TextHeader atom to get at the parent
+ RecordContainer runAtomsParent = _headerAtom.getParentRecord();
+
+ // Add the new StyleTextPropAtom after the TextCharsAtom / TextBytesAtom
+ Record addAfter = _byteAtom;
+ if(_byteAtom == null) { addAfter = _charAtom; }
+ runAtomsParent.addChildAfter(_styleAtom, addAfter);
+
+ // Feed this to our sole rich text run
+ if(_rtRuns.length != 1) {
+ throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs");
+ }
+ // These are the only styles for now
+ _rtRuns[0].supplyTextProps(
+ _styleAtom.getParagraphStyles().get(0),
+ _styleAtom.getCharacterStyles().get(0),
+ false,
+ false
+ );
+ }
+
+ // Accesser methods follow
+
+ /**
+ * Returns the text content of the run, which has been made safe
+ * for printing and other use.
+ */
+ public String getText() {
+ String rawText = getRawText();
+
+ // PowerPoint seems to store files with \r as the line break
+ // The messes things up on everything but a Mac, so translate
+ // them to \n
+ String text = rawText.replace('\r','\n');
+
+ int type = _headerAtom == null ? 0 : _headerAtom.getTextType();
+ if(type == TextHeaderAtom.TITLE_TYPE || type == TextHeaderAtom.CENTER_TITLE_TYPE){
+ //0xB acts like cariage return in page titles and like blank in the others
+ text = text.replace((char) 0x0B, '\n');
+ } else {
+ text = text.replace((char) 0x0B, ' ');
+ }
+ return text;
+ }
+
+ /**
+ * Returns the raw text content of the run. This hasn't had any
+ * changes applied to it, and so is probably unlikely to print
+ * out nicely.
+ */
+ public String getRawText() {
+ if(_isUnicode) {
+ return _charAtom.getText();
+ }
+ return _byteAtom.getText();
+ }
+
+ /**
+ * Fetch the rich text runs (runs of text with the same styling) that
+ * are contained within this block of text
+ */
+ public HSLFTextRun[] getRichTextRuns() {
+ return _rtRuns;
+ }
+
+ /**
+ * Returns the type of the text, from the TextHeaderAtom.
+ * Possible values can be seen from TextHeaderAtom
+ * @see org.apache.poi.hslf.record.TextHeaderAtom
+ */
+ public int getRunType() {
+ return _headerAtom.getTextType();
+ }
+
+ /**
+ * Changes the type of the text. Values should be taken
+ * from TextHeaderAtom. No checking is done to ensure you
+ * set this to a valid value!
+ * @see org.apache.poi.hslf.record.TextHeaderAtom
+ */
+ public void setRunType(int type) {
+ _headerAtom.setTextType(type);
+ }
+
+ /**
+ * Supply the Sheet we belong to, which might have an assigned SlideShow
+ * Also passes it on to our child RichTextRuns
+ */
+ public void supplySheet(HSLFSheet sheet){
+ this._sheet = sheet;
+
+ if (_rtRuns == null) return;
+ for(HSLFTextRun rt : _rtRuns) {
+ rt.updateSheet();
+ }
+ }
+
+ public HSLFSheet getSheet(){
+ return this._sheet;
+ }
+
+ /**
+ * @return Shape ID
+ */
+ protected int getShapeId(){
+ return shapeId;
+ }
+
+ /**
+ * @param id Shape ID
+ */
+ protected void setShapeId(int id){
+ shapeId = id;
+ }
+
+ /**
+ * @return 0-based index of the text run in the SLWT container
+ */
+ protected int getIndex(){
+ return slwtIndex;
+ }
+
+ /**
+ * @param id 0-based index of the text run in the SLWT container
+ */
+ protected void setIndex(int id){
+ slwtIndex = id;
+ }
+
+ /**
+ * Is this Text Run one from a {@link PPDrawing}, or is it
+ * one from the {@link SlideListWithText}?
+ */
+ public boolean isDrawingBased() {
+ return (slwtIndex == -1);
+ }
+
+ /**
+ * Returns the array of all hyperlinks in this text run
+ *
+ * @return the array of all hyperlinks in this text run
+ * or null
if not found.
+ */
+ public Hyperlink[] getHyperlinks(){
+ return Hyperlink.find(this);
+ }
+
+ /**
+ * Fetch RichTextRun at a given position
+ *
+ * @param pos 0-based index in the text
+ * @return RichTextRun or null if not found
+ */
+ public HSLFTextRun getRichTextRunAt(int pos){
+ for (int i = 0; i < _rtRuns.length; i++) {
+ int start = _rtRuns[i].getStartIndex();
+ int end = _rtRuns[i].getEndIndex();
+ if(pos >= start && pos < end) return _rtRuns[i];
+ }
+ return null;
+ }
+
+ public TextRulerAtom getTextRuler(){
+ if(_ruler == null){
+ if(_records != null) for (int i = 0; i < _records.length; i++) {
+ if(_records[i] instanceof TextRulerAtom) {
+ _ruler = (TextRulerAtom)_records[i];
+ break;
+ }
+ }
+
+ }
+ return _ruler;
+
+ }
+
+ public TextRulerAtom createTextRuler(){
+ _ruler = getTextRuler();
+ if(_ruler == null){
+ _ruler = TextRulerAtom.getParagraphInstance();
+ _headerAtom.getParentRecord().appendChildRecord(_ruler);
+ }
+ return _ruler;
+ }
+
+ /**
+ * Returns a new string with line breaks converted into internal ppt representation
+ */
+ public String normalize(String s){
+ String ns = s.replaceAll("\\r?\\n", "\r");
+ return ns;
+ }
+
+ /**
+ * Returns records that make up this text run
+ *
+ * @return text run records
+ */
+ public Record[] getRecords(){
+ return _records;
+ }
+ /** Numbered List info */
+ public void setStyleTextProp9Atom(final StyleTextProp9Atom styleTextProp9Atom) {
+ this.styleTextProp9Atom = styleTextProp9Atom;
+ }
+ /** Numbered List info */
+ public StyleTextProp9Atom getStyleTextProp9Atom() {
+ return this.styleTextProp9Atom;
+ }
+
+ /** Characters covered */
+ public StyleTextPropAtom getStyleTextPropAtom() {
+ return this._styleAtom;
+ }
+
+}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java
similarity index 90%
rename from src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java
index 3f47ae6a5b..17e8b81d21 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java
@@ -47,7 +47,7 @@ import org.apache.poi.hslf.record.TextBytesAtom;
import org.apache.poi.hslf.record.TextCharsAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.record.TxInteractiveInfoAtom;
-import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.util.POILogger;
@@ -56,7 +56,7 @@ import org.apache.poi.util.POILogger;
*
* @author Yegor Kozlov
*/
-public abstract class TextShape extends SimpleShape {
+public abstract class HSLFTextShape extends HSLFSimpleShape {
/**
* How to anchor the text
@@ -92,7 +92,7 @@ public abstract class TextShape extends SimpleShape {
/**
* TextRun object which holds actual text and format data
*/
- protected TextRun _txtrun;
+ protected HSLFTextParagraph _txtrun;
/**
* Escher container which holds text attributes such as
@@ -111,7 +111,7 @@ public abstract class TextShape extends SimpleShape {
* @param escherRecord EscherSpContainer
container which holds information about this shape
* @param parent the parent of the shape
*/
- protected TextShape(EscherContainerRecord escherRecord, ShapeContainer parent){
+ protected HSLFTextShape(EscherContainerRecord escherRecord, ShapeContainer parent){
super(escherRecord, parent);
}
@@ -122,7 +122,7 @@ public abstract class TextShape extends SimpleShape {
* @param parent the parent of this Shape. For example, if this text box is a cell
* in a table then the parent is Table.
*/
- public TextShape(ShapeContainer parent){
+ public HSLFTextShape(ShapeContainer parent){
super(null, parent);
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
}
@@ -131,15 +131,15 @@ public abstract class TextShape extends SimpleShape {
* Create a new TextBox. This constructor is used when a new shape is created.
*
*/
- public TextShape(){
+ public HSLFTextShape(){
this(null);
}
- public TextRun createTextRun(){
+ public HSLFTextParagraph createTextRun(){
_txtbox = getEscherTextboxWrapper();
if(_txtbox == null) _txtbox = new EscherTextboxWrapper();
- _txtrun = getTextRun();
+ _txtrun = getTextParagraph();
if(_txtrun == null){
TextHeaderAtom tha = new TextHeaderAtom();
tha.setParentRecord(_txtbox);
@@ -151,7 +151,7 @@ public abstract class TextShape extends SimpleShape {
StyleTextPropAtom sta = new StyleTextPropAtom(0);
_txtbox.appendChildRecord(sta);
- _txtrun = new TextRun(tha,tca,sta);
+ _txtrun = new HSLFTextParagraph(tha,tca,sta);
_txtrun._records = new Record[]{tha, tca, sta};
_txtrun.setText("");
@@ -170,7 +170,7 @@ public abstract class TextShape extends SimpleShape {
* AutoShape: align=center, valign=middle
*
*/
- protected void setDefaultTextProperties(TextRun _txtrun){
+ protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
}
@@ -180,7 +180,7 @@ public abstract class TextShape extends SimpleShape {
* @return the text string for this textbox.
*/
public String getText(){
- TextRun tx = getTextRun();
+ HSLFTextParagraph tx = getTextParagraph();
return tx == null ? null : tx.getText();
}
@@ -190,7 +190,7 @@ public abstract class TextShape extends SimpleShape {
* @param text the text string used by this object.
*/
public void setText(String text){
- TextRun tx = getTextRun();
+ HSLFTextParagraph tx = getTextParagraph();
if(tx == null){
tx = createTextRun();
}
@@ -204,7 +204,7 @@ public abstract class TextShape extends SimpleShape {
*
* @param sh the sheet we are adding to
*/
- protected void afterInsert(Sheet sh){
+ protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
EscherTextboxWrapper _txtbox = getEscherTextboxWrapper();
@@ -241,7 +241,7 @@ public abstract class TextShape extends SimpleShape {
String txt = getText();
if(txt == null || txt.length() == 0) return new Rectangle2D.Float();
- RichTextRun rt = getTextRun().getRichTextRuns()[0];
+ HSLFTextRun rt = getTextParagraph().getRichTextRuns()[0];
int size = rt.getFontSize();
int style = 0;
if (rt.isBold()) style |= Font.BOLD;
@@ -284,26 +284,26 @@ public abstract class TextShape extends SimpleShape {
public int getVerticalAlignment(){
EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
- int valign = TextShape.AnchorTop;
+ int valign = HSLFTextShape.AnchorTop;
if (prop == null){
/**
* If vertical alignment was not found in the shape properties then try to
* fetch the master shape and search for the align property there.
*/
- int type = getTextRun().getRunType();
- MasterSheet master = getSheet().getMasterSheet();
+ int type = getTextParagraph().getRunType();
+ HSLFMasterSheet master = getSheet().getMasterSheet();
if(master != null){
- TextShape masterShape = master.getPlaceholderByTextType(type);
+ HSLFTextShape masterShape = master.getPlaceholderByTextType(type);
if(masterShape != null) valign = masterShape.getVerticalAlignment();
} else {
//not found in the master sheet. Use the hardcoded defaults.
switch (type){
case TextHeaderAtom.TITLE_TYPE:
case TextHeaderAtom.CENTER_TITLE_TYPE:
- valign = TextShape.AnchorMiddle;
+ valign = HSLFTextShape.AnchorMiddle;
break;
default:
- valign = TextShape.AnchorTop;
+ valign = HSLFTextShape.AnchorTop;
break;
}
}
@@ -330,7 +330,7 @@ public abstract class TextShape extends SimpleShape {
* @param align - the type of horizontal alignment
*/
public void setHorizontalAlignment(int align){
- TextRun tx = getTextRun();
+ HSLFTextParagraph tx = getTextParagraph();
if(tx != null) tx.getRichTextRuns()[0].setAlignment(align);
}
@@ -341,7 +341,7 @@ public abstract class TextShape extends SimpleShape {
* @return align - the type of horizontal alignment
*/
public int getHorizontalAlignment(){
- TextRun tx = getTextRun();
+ HSLFTextParagraph tx = getTextParagraph();
return tx == null ? -1 : tx.getRichTextRuns()[0].getAlignment();
}
@@ -487,7 +487,7 @@ public abstract class TextShape extends SimpleShape {
/**
* @return the TextRun object for this text box
*/
- public TextRun getTextRun(){
+ public HSLFTextParagraph getTextParagraph(){
if (null == this._txtrun) initTextRun();
if (null == this._txtrun && null != this._txtbox) {
TextHeaderAtom tha = null;
@@ -507,36 +507,31 @@ public abstract class TextShape extends SimpleShape {
}
}
if (tba != null) {
- this._txtrun = new TextRun(tha, tba, sta);
+ this._txtrun = new HSLFTextParagraph(tha, tba, sta);
} else if (tca != null) {
- this._txtrun = new TextRun(tha, tca, sta);
+ this._txtrun = new HSLFTextParagraph(tha, tca, sta);
}
}
return _txtrun;
}
- public void setSheet(Sheet sheet) {
+ public void setSheet(HSLFSheet sheet) {
_sheet = sheet;
// Initialize _txtrun object.
// (We can't do it in the constructor because the sheet
// is not assigned then, it's only built once we have
// all the records)
- TextRun tx = getTextRun();
+ HSLFTextParagraph tx = getTextParagraph();
if (tx != null) {
// Supply the sheet to our child RichTextRuns
- tx.setSheet(_sheet);
- RichTextRun[] rt = tx.getRichTextRuns();
- for (int i = 0; i < rt.length; i++) {
- rt[i].supplySlideShow(_sheet.getSlideShow());
- }
+ tx.supplySheet(_sheet);
}
-
}
protected void initTextRun(){
EscherTextboxWrapper txtbox = getEscherTextboxWrapper();
- Sheet sheet = getSheet();
+ HSLFSheet sheet = getSheet();
if(sheet == null || txtbox == null) return;
@@ -550,7 +545,7 @@ public abstract class TextShape extends SimpleShape {
}
}
- TextRun[] runs = _sheet.getTextRuns();
+ HSLFTextParagraph[] runs = _sheet.getTextRuns();
if (ota != null) {
int idx = ota.getTextIndex();
for (int i = 0; i < runs.length; i++) {
@@ -572,11 +567,14 @@ public abstract class TextShape extends SimpleShape {
}
}
}
+
// ensure the same references child records of TextRun
- if(_txtrun != null) for (int i = 0; i < child.length; i++) {
- for (Record r : _txtrun.getRecords()) {
- if (child[i].getRecordType() == r.getRecordType()) {
- child[i] = r;
+ if(_txtrun != null) {
+ for (int i = 0; i < child.length; i++) {
+ for (Record r : _txtrun.getRecords()) {
+ if (child[i].getRecordType() == r.getRecordType()) {
+ child[i] = r;
+ }
}
}
}
@@ -605,7 +603,7 @@ public abstract class TextShape extends SimpleShape {
* @param linkId id of the hyperlink, @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink)
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
- * @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink)
+ * @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addHyperlink(Hyperlink)
*/
public void setHyperlink(int linkId, int beginIndex, int endIndex){
//TODO validate beginIndex and endIndex and throw IllegalArgumentException
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java b/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
index 8bb441e4e4..bd3a6da399 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
@@ -18,7 +18,7 @@
package org.apache.poi.hslf.model;
import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
/**
* Header / Footer settings.
@@ -31,19 +31,19 @@ public final class HeadersFooters {
private HeadersFootersContainer _container;
private boolean _newRecord;
- private SlideShow _ppt;
- private Sheet _sheet;
+ private HSLFSlideShow _ppt;
+ private HSLFSheet _sheet;
private boolean _ppt2007;
- public HeadersFooters(HeadersFootersContainer rec, SlideShow ppt, boolean newRecord, boolean isPpt2007){
+ public HeadersFooters(HeadersFootersContainer rec, HSLFSlideShow ppt, boolean newRecord, boolean isPpt2007){
_container = rec;
_newRecord = newRecord;
_ppt = ppt;
_ppt2007 = isPpt2007;
}
- public HeadersFooters(HeadersFootersContainer rec, Sheet sheet, boolean newRecord, boolean isPpt2007){
+ public HeadersFooters(HeadersFootersContainer rec, HSLFSheet sheet, boolean newRecord, boolean isPpt2007){
_container = rec;
_newRecord = newRecord;
_sheet = sheet;
@@ -240,8 +240,8 @@ public final class HeadersFooters {
private boolean isVisible(int flag, int placeholderId){
boolean visible;
if(_ppt2007){
- Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
- TextShape placeholder = master.getPlaceholder(placeholderId);
+ HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
+ HSLFTextShape placeholder = master.getPlaceholder(placeholderId);
visible = placeholder != null && placeholder.getText() != null;
} else {
visible = _container.getHeadersFootersAtom().getFlag(flag);
@@ -252,8 +252,8 @@ public final class HeadersFooters {
private String getPlaceholderText(int placeholderId, CString cs){
String text = null;
if(_ppt2007){
- Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
- TextShape placeholder = master.getPlaceholder(placeholderId);
+ HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
+ HSLFTextShape placeholder = master.getPlaceholder(placeholderId);
if(placeholder != null) text = placeholder.getText();
//default text in master placeholders is not visible
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java b/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
index df207e6716..2e1f1ec586 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
@@ -18,7 +18,7 @@
package org.apache.poi.hslf.model;
import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherClientDataRecord;
@@ -95,7 +95,7 @@ public final class Hyperlink {
return address;
}
- public void setAddress(Slide slide) {
+ public void setAddress(HSLFSlide slide) {
String href = slide._getSheetNumber() + ","+slide.getSlideNumber()+",Slide " + slide.getSlideNumber();
setAddress(href);;
setTitle("Slide " + slide.getSlideNumber());
@@ -151,9 +151,9 @@ public final class Hyperlink {
* @param run TextRun
to lookup hyperlinks in
* @return found hyperlinks or null
if not found
*/
- protected static Hyperlink[] find(TextRun run){
+ protected static Hyperlink[] find(HSLFTextParagraph run){
List lst = new ArrayList();
- SlideShow ppt = run.getSheet().getSlideShow();
+ HSLFSlideShow ppt = run.getSheet().getSlideShow();
//document-level container which stores info about all links in a presentation
ExObjList exobj = ppt.getDocumentRecord().getExObjList();
if (exobj == null) {
@@ -178,7 +178,7 @@ public final class Hyperlink {
*/
protected static Hyperlink find(HSLFShape shape){
List lst = new ArrayList();
- SlideShow ppt = shape.getSheet().getSlideShow();
+ HSLFSlideShow ppt = shape.getSheet().getSlideShow();
//document-level container which stores info about all links in a presentation
ExObjList exobj = ppt.getDocumentRecord().getExObjList();
if (exobj == null) {
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Line.java b/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
index e811aeb6bf..b2e0b35884 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
@@ -29,74 +29,7 @@ import java.awt.geom.Line2D;
*
* @author Yegor Kozlov
*/
-public final class Line extends SimpleShape {
- /**
- * Solid (continuous) pen
- */
- public static final int PEN_SOLID = 1;
- /**
- * PS_DASH system dash style
- */
- public static final int PEN_PS_DASH = 2;
- /**
- * PS_DOT system dash style
- */
- public static final int PEN_DOT = 3;
- /**
- * PS_DASHDOT system dash style
- */
- public static final int PEN_DASHDOT = 4;
- /**
- * PS_DASHDOTDOT system dash style
- */
- public static final int PEN_DASHDOTDOT = 5;
- /**
- * square dot style
- */
- public static final int PEN_DOTGEL = 6;
- /**
- * dash style
- */
- public static final int PEN_DASH = 7;
- /**
- * long dash style
- */
- public static final int PEN_LONGDASHGEL = 8;
- /**
- * dash short dash
- */
- public static final int PEN_DASHDOTGEL = 9;
- /**
- * long dash short dash
- */
- public static final int PEN_LONGDASHDOTGEL = 10;
- /**
- * long dash short dash short dash
- */
- public static final int PEN_LONGDASHDOTDOTGEL = 11;
-
- /**
- * Single line (of width lineWidth)
- */
- public static final int LINE_SIMPLE = 0;
- /**
- * Double lines of equal width
- */
- public static final int LINE_DOUBLE = 1;
- /**
- * Double lines, one thick, one thin
- */
- public static final int LINE_THICKTHIN = 2;
- /**
- * Double lines, reverse order
- */
- public static final int LINE_THINTHICK = 3;
- /**
- * Three lines, thin, thick, thin
- */
- public static final int LINE_TRIPLE = 4;
-
-
+public final class Line extends HSLFSimpleShape {
protected Line(EscherContainerRecord escherRecord, ShapeContainer parent){
super(escherRecord, parent);
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
index 834dc870e4..e366fdbe92 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
@@ -24,7 +24,7 @@ import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.ShapeContainer;
/**
@@ -32,7 +32,7 @@ import org.apache.poi.sl.usermodel.ShapeContainer;
*
* @author Yegor Kozlov
*/
-public final class MovieShape extends Picture {
+public final class MovieShape extends HSLFPictureShape {
public static final int DEFAULT_MOVIE_THUMBNAIL = -1;
public static final int MOVIE_MPEG = 1;
@@ -113,7 +113,7 @@ public final class MovieShape extends Picture {
/**
* Assign a movie to this shape
*
- * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)
+ * @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addMovie(String, int)
* @param idx the index of the movie
*/
public void setMovieIndex(int idx){
@@ -154,7 +154,7 @@ public final class MovieShape extends Picture {
OEShapeAtom oe = getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
int idx = oe.getOptions();
- SlideShow ppt = getSheet().getSlideShow();
+ HSLFSlideShow ppt = getSheet().getSlideShow();
ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID);
if(lst == null) return null;
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
index a1e9c94e08..49ed8c2073 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
@@ -18,8 +18,8 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.ObjectData;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFObjectData;
import org.apache.poi.hslf.record.ExObjList;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.ExEmbed;
@@ -34,7 +34,7 @@ import org.apache.poi.util.POILogger;
*
* @author Yegor Kozlov
*/
-public final class OLEShape extends Picture {
+public final class OLEShape extends HSLFPictureShape {
protected ExEmbed _exEmbed;
/**
@@ -117,13 +117,13 @@ public final class OLEShape extends Picture {
*
* @return the unique identifier for the OLE object
*/
- public ObjectData getObjectData(){
- SlideShow ppt = getSheet().getSlideShow();
- ObjectData[] ole = ppt.getEmbeddedObjects();
+ public HSLFObjectData getObjectData(){
+ HSLFSlideShow ppt = getSheet().getSlideShow();
+ HSLFObjectData[] ole = ppt.getEmbeddedObjects();
//persist reference
ExEmbed exEmbed = getExEmbed();
- ObjectData data = null;
+ HSLFObjectData data = null;
if(exEmbed != null) {
int ref = exEmbed.getExOleObjAtom().getObjStgDataRef();
@@ -156,7 +156,7 @@ public final class OLEShape extends Picture {
*/
public ExEmbed getExEmbed(){
if(_exEmbed == null){
- SlideShow ppt = getSheet().getSlideShow();
+ HSLFSlideShow ppt = getSheet().getSlideShow();
ExObjList lst = ppt.getDocumentRecord().getExObjList();
if(lst == null){
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java b/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
index f775addac3..47500df2f6 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
@@ -28,7 +28,7 @@ import java.awt.image.renderable.RenderableImage;
import java.awt.geom.*;
import java.text.AttributedCharacterIterator;
import java.util.Map;
-import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
@@ -214,7 +214,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public void draw(Shape shape){
GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
- Freeform p = new Freeform(_group);
+ HSLFFreeformShape p = new HSLFFreeformShape(_group);
p.setPath(path);
p.getFill().setForegroundColor(null);
applyStroke(p);
@@ -250,12 +250,11 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip
*/
public void drawString(String s, float x, float y) {
- TextBox txt = new TextBox(_group);
- txt.getTextRun().supplySlideShow(_group.getSheet().getSlideShow());
- txt.getTextRun().setSheet(_group.getSheet());
+ HSLFTextBox txt = new HSLFTextBox(_group);
+ txt.getTextParagraph().supplySheet(_group.getSheet());
txt.setText(s);
- RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
+ HSLFTextRun rt = txt.getTextParagraph().getRichTextRuns()[0];
rt.setFontSize(_font.getSize());
rt.setFontName(_font.getFamily());
@@ -267,9 +266,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
txt.setMarginTop(0);
txt.setMarginLeft(0);
txt.setMarginRight(0);
- txt.setWordWrap(TextBox.WrapNone);
- txt.setHorizontalAlignment(TextBox.AlignLeft);
- txt.setVerticalAlignment(TextBox.AnchorMiddle);
+ txt.setWordWrap(HSLFTextBox.WrapNone);
+ txt.setHorizontalAlignment(HSLFTextBox.AlignLeft);
+ txt.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
TextLayout layout = new TextLayout(s, _font, getFontRenderContext());
@@ -317,7 +316,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public void fill(Shape shape){
GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
- Freeform p = new Freeform(_group);
+ HSLFFreeformShape p = new HSLFFreeformShape(_group);
p.setPath(path);
applyPaint(p);
p.setLineColor(null); //Fills must be "No Line"
@@ -1788,7 +1787,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
}
}
- protected void applyStroke(SimpleShape shape) {
+ protected void applyStroke(HSLFSimpleShape shape) {
if (_stroke instanceof BasicStroke){
BasicStroke bs = (BasicStroke)_stroke;
shape.setLineWidth(bs.getLineWidth());
@@ -1800,7 +1799,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
}
}
- protected void applyPaint(SimpleShape shape) {
+ protected void applyPaint(HSLFSimpleShape shape) {
if (_paint instanceof Color) {
shape.getFill().setForegroundColor((Color)_paint);
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java b/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
index 0e6052e969..470f6a4204 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
@@ -29,7 +29,7 @@ import java.io.ByteArrayOutputStream;
*
* @author Yegor Kozlov
*/
-public final class Placeholder extends TextBox {
+public final class Placeholder extends HSLFTextBox {
protected Placeholder(EscherContainerRecord escherRecord, ShapeContainer parent){
super(escherRecord, parent);
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java b/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java
index 2d67c03fdc..7bfd95a571 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java
@@ -29,7 +29,7 @@ import java.awt.geom.Point2D;
*
* @author Yegor Kozlov
*/
-public final class Polygon extends AutoShape {
+public final class Polygon extends HSLFAutoShape {
/**
* Create a Polygon object and initialize it from the supplied Record container.
*
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
index 01ac53855c..d21cf9dd2b 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
@@ -89,7 +89,7 @@ public final class ShapeFactory {
ShapeType type = ShapeType.forId(spRecord.getShapeType(), false);
switch (type){
case TEXT_BOX:
- shape = new TextBox(spContainer, parent);
+ shape = new HSLFTextBox(spContainer, parent);
break;
case HOST_CONTROL:
case FRAME: {
@@ -110,7 +110,7 @@ public final class ShapeFactory {
shape = new OLEShape(spContainer, parent);
}
- if(shape == null) shape = new Picture(spContainer, parent);
+ if(shape == null) shape = new HSLFPictureShape(spContainer, parent);
break;
}
case LINE:
@@ -120,16 +120,16 @@ public final class ShapeFactory {
EscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
EscherProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
if(prop != null)
- shape = new Freeform(spContainer, parent);
+ shape = new HSLFFreeformShape(spContainer, parent);
else {
logger.log(POILogger.WARN, "Creating AutoShape for a NotPrimitive shape");
- shape = new AutoShape(spContainer, parent);
+ shape = new HSLFAutoShape(spContainer, parent);
}
break;
}
default:
- shape = new AutoShape(spContainer, parent);
+ shape = new HSLFAutoShape(spContainer, parent);
break;
}
return shape;
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
index c9954a8dee..e9686a6120 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
@@ -35,7 +35,7 @@ import org.apache.poi.util.POILogger;
public final class ShapePainter {
protected static final POILogger logger = POILogFactory.getLogger(ShapePainter.class);
- public static void paint(SimpleShape shape, Graphics2D graphics){
+ public static void paint(HSLFSimpleShape shape, Graphics2D graphics){
Rectangle2D anchor = shape.getLogicalAnchor2D();
java.awt.Shape outline = shape.getOutline();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java b/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
index a103d09c77..859ceebb42 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
@@ -20,7 +20,7 @@ package org.apache.poi.hslf.model;
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.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
/**
* SlideMaster determines the graphics, layout, and formatting for all the slides in a given presentation.
@@ -29,8 +29,8 @@ import org.apache.poi.hslf.usermodel.SlideShow;
*
* @author Yegor Kozlov
*/
-public final class SlideMaster extends MasterSheet {
- private TextRun[] _runs;
+public final class SlideMaster extends HSLFMasterSheet {
+ private HSLFTextParagraph[] _runs;
/**
* all TxMasterStyleAtoms available in this master
@@ -51,14 +51,14 @@ public final class SlideMaster extends MasterSheet {
/**
* Returns an array of all the TextRuns found
*/
- public TextRun[] getTextRuns() {
+ public HSLFTextParagraph[] getTextRuns() {
return _runs;
}
/**
* Returns null
since SlideMasters doen't have master sheet.
*/
- public MasterSheet getMasterSheet() {
+ public HSLFMasterSheet getMasterSheet() {
return null;
}
@@ -112,7 +112,7 @@ public final class SlideMaster extends MasterSheet {
* Assign SlideShow for this slide master.
* (Used interanlly)
*/
- public void setSlideShow(SlideShow ss) {
+ public void setSlideShow(HSLFSlideShow ss) {
super.setSlideShow(ss);
//after the slide show is assigned collect all available style records
@@ -130,12 +130,12 @@ public final class SlideMaster extends MasterSheet {
}
}
- protected void onAddTextShape(TextShape shape) {
- TextRun run = shape.getTextRun();
+ protected void onAddTextShape(HSLFTextShape shape) {
+ HSLFTextParagraph run = shape.getTextParagraph();
- if(_runs == null) _runs = new TextRun[]{run};
+ if(_runs == null) _runs = new HSLFTextParagraph[]{run};
else {
- TextRun[] tmp = new TextRun[_runs.length + 1];
+ HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1];
System.arraycopy(_runs, 0, tmp, 0, _runs.length);
tmp[tmp.length-1] = run;
_runs = tmp;
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Table.java b/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
index f94bd7f5b6..99ee13f211 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
@@ -115,7 +115,7 @@ public final class Table extends HSLFGroupShape {
return cells.length;
}
- protected void afterInsert(Sheet sh){
+ protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
@@ -165,7 +165,7 @@ public final class Table extends HSLFGroupShape {
List> lst = new ArrayList>();
List row = null;
for (HSLFShape sh : shapeList) {
- if(sh instanceof TextShape){
+ if(sh instanceof HSLFTextShape){
Rectangle anchor = sh.getAnchor();
if(anchor.y != y0){
y0 = anchor.y;
@@ -180,7 +180,7 @@ public final class Table extends HSLFGroupShape {
for (int i = 0; i < lst.size(); i++) {
row = lst.get(i);
for (int j = 0; j < row.size(); j++) {
- TextShape tx = (TextShape)row.get(j);
+ HSLFTextShape tx = (HSLFTextShape)row.get(j);
cells[i][j] = new TableCell(tx.getSpContainer(), getParent());
cells[i][j].setSheet(tx.getSheet());
}
@@ -192,7 +192,7 @@ public final class Table extends HSLFGroupShape {
*
* @param sheet owner of this shape
*/
- public void setSheet(Sheet sheet){
+ public void setSheet(HSLFSheet sheet){
super.setSheet(sheet);
if(cells == null) initTable();
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java b/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
index 715181cfad..18431a720c 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
@@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
*
* @author Yegor Kozlov
*/
-public final class TableCell extends TextBox {
+public final class TableCell extends HSLFTextBox {
protected static final int DEFAULT_WIDTH = 100;
protected static final int DEFAULT_HEIGHT = 40;
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
index 4b8805c266..038e28a04d 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
@@ -35,7 +35,7 @@ import java.util.List;
import java.util.Map;
import org.apache.poi.hslf.record.TextRulerAtom;
-import org.apache.poi.hslf.usermodel.RichTextRun;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -57,27 +57,27 @@ public final class TextPainter {
*/
protected static final char DEFAULT_BULLET_CHAR = '\u25a0';
- protected TextShape _shape;
+ protected HSLFTextShape _shape;
- public TextPainter(TextShape shape){
+ public TextPainter(HSLFTextShape shape){
_shape = shape;
}
- public AttributedString getAttributedString(TextRun txrun) {
+ public AttributedString getAttributedString(HSLFTextParagraph txrun) {
return getAttributedString(txrun, null);
}
/**
* Convert the underlying set of rich text runs into java.text.AttributedString
*/
- public AttributedString getAttributedString(TextRun txrun, Graphics2D graphics){
+ public AttributedString getAttributedString(HSLFTextParagraph txrun, Graphics2D graphics){
String text = txrun.getText();
//TODO: properly process tabs
text = text.replace('\t', ' ');
text = text.replace((char)160, ' ');
AttributedString at = new AttributedString(text);
- RichTextRun[] rt = txrun.getRichTextRuns();
+ HSLFTextRun[] rt = txrun.getRichTextRuns();
for (int i = 0; i < rt.length; i++) {
int start = rt[i].getStartIndex();
int end = rt[i].getEndIndex();
@@ -157,15 +157,15 @@ public final class TextPainter {
int valign = _shape.getVerticalAlignment();
double y0 = anchor.getY();
switch (valign){
- case TextShape.AnchorTopBaseline:
- case TextShape.AnchorTop:
+ case HSLFTextShape.AnchorTopBaseline:
+ case HSLFTextShape.AnchorTop:
y0 += _shape.getMarginTop();
break;
- case TextShape.AnchorBottom:
+ case HSLFTextShape.AnchorBottom:
y0 += anchor.getHeight() - textHeight - _shape.getMarginBottom();
break;
default:
- case TextShape.AnchorMiddle:
+ case HSLFTextShape.AnchorMiddle:
float delta = (float)anchor.getHeight() - textHeight - _shape.getMarginTop() - _shape.getMarginBottom();
y0 += _shape.getMarginTop() + delta/2;
break;
@@ -205,14 +205,14 @@ public final class TextPainter {
pen.y = y0;
switch (elem[i]._align) {
default:
- case TextShape.AlignLeft:
+ case HSLFTextShape.AlignLeft:
pen.x = anchor.getX() + _shape.getMarginLeft();
break;
- case TextShape.AlignCenter:
+ case HSLFTextShape.AlignCenter:
pen.x = anchor.getX() + _shape.getMarginLeft() +
(anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()) / 2;
break;
- case TextShape.AlignRight:
+ case HSLFTextShape.AlignRight:
pen.x = anchor.getX() + _shape.getMarginLeft() +
(anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight());
break;
@@ -235,7 +235,7 @@ public final class TextPainter {
}
public TextElement[] getTextElements(float textWidth, FontRenderContext frc, Graphics2D graphics){
- TextRun run = _shape.getTextRun();
+ HSLFTextParagraph run = _shape.getTextParagraph();
if (run == null) return null;
String text = run.getText();
@@ -257,7 +257,7 @@ public final class TextPainter {
boolean prStart = text.charAt(startIndex) == '\n';
if(prStart) measurer.setPosition(startIndex++);
- RichTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex);
+ HSLFTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex);
if(rt == null) {
logger.log(POILogger.WARN, "RichTextRun not found at pos" + startIndex + "; text.length: " + text.length());
break;
@@ -283,7 +283,7 @@ public final class TextPainter {
if(bulletOffset > 0 || prStart || startIndex == 0) wrappingWidth -= textOffset;
- if (_shape.getWordWrap() == TextShape.WrapNone) {
+ if (_shape.getWordWrap() == HSLFTextShape.WrapNone) {
wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java b/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java
index 843f123890..8184c030fa 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java
@@ -25,8 +25,8 @@ import org.apache.poi.hslf.record.*;
*
* @author Yegor Kozlov
*/
-public final class TitleMaster extends MasterSheet {
- private TextRun[] _runs;
+public final class TitleMaster extends HSLFMasterSheet {
+ private HSLFTextParagraph[] _runs;
/**
* Constructs a TitleMaster
@@ -42,7 +42,7 @@ public final class TitleMaster extends MasterSheet {
/**
* Returns an array of all the TextRuns found
*/
- public TextRun[] getTextRuns() {
+ public HSLFTextParagraph[] getTextRuns() {
return _runs;
}
@@ -50,14 +50,14 @@ public final class TitleMaster extends MasterSheet {
* Delegate the call to the underlying slide master.
*/
public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
- MasterSheet master = getMasterSheet();
+ HSLFMasterSheet master = getMasterSheet();
return master == null ? null : master.getStyleAttribute(txtype, level, name, isCharacter);
}
/**
* Returns the slide master for this title master.
*/
- public MasterSheet getMasterSheet(){
+ public HSLFMasterSheet getMasterSheet(){
SlideMaster[] master = getSlideShow().getSlidesMasters();
SlideAtom sa = ((org.apache.poi.hslf.record.Slide)getSheetContainer()).getSlideAtom();
int masterId = sa.getMasterID();
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
similarity index 96%
rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java
rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
index bbef87a96c..f02ddbe785 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java
@@ -26,7 +26,7 @@ import org.apache.poi.hslf.record.ExOleObjStg;
*
* @author Daniel Noll
*/
-public class ObjectData {
+public class HSLFObjectData {
/**
* The record that contains the object data.
*/
@@ -37,7 +37,7 @@ public class ObjectData {
*
* @param storage the record that contains the object data.
*/
- public ObjectData(ExOleObjStg storage) {
+ public HSLFObjectData(ExOleObjStg storage) {
this.storage = storage;
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
similarity index 88%
rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java
rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
index 857ad5451e..9d9b0dc594 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
@@ -30,7 +30,7 @@ import org.apache.poi.hslf.blip.JPEG;
import org.apache.poi.hslf.blip.PICT;
import org.apache.poi.hslf.blip.PNG;
import org.apache.poi.hslf.blip.WMF;
-import org.apache.poi.hslf.model.Picture;
+import org.apache.poi.hslf.model.HSLFPictureShape;
import org.apache.poi.poifs.crypt.CryptoFunctions;
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.util.LittleEndian;
@@ -42,7 +42,7 @@ import org.apache.poi.util.POILogger;
*
* @author Yegor Kozlov
*/
-public abstract class PictureData {
+public abstract class HSLFPictureData {
protected POILogger logger = POILogFactory.getLogger(this.getClass());
@@ -68,6 +68,14 @@ public abstract class PictureData {
*/
public abstract int getType();
+
+ /**
+ * Returns content type (mime type) of this picture.
+ *
+ * @return content type of this picture.
+ */
+ public abstract String getContentType();
+
/**
* Returns the binary data of this Picture
* @return picture data
@@ -86,9 +94,9 @@ public abstract class PictureData {
protected static final ImagePainter[] painters = new ImagePainter[8];
static {
- PictureData.setImagePainter(Picture.PNG, new BitmapPainter());
- PictureData.setImagePainter(Picture.JPEG, new BitmapPainter());
- PictureData.setImagePainter(Picture.DIB, new BitmapPainter());
+ HSLFPictureData.setImagePainter(HSLFPictureShape.PNG, new BitmapPainter());
+ HSLFPictureData.setImagePainter(HSLFPictureShape.JPEG, new BitmapPainter());
+ HSLFPictureData.setImagePainter(HSLFPictureShape.DIB, new BitmapPainter());
}
/**
@@ -173,25 +181,25 @@ public abstract class PictureData {
* Must be one of the static constants defined in the Picture class.
* @return concrete instance of PictureData
*/
- public static PictureData create(int type){
- PictureData pict;
+ public static HSLFPictureData create(int type){
+ HSLFPictureData pict;
switch (type){
- case Picture.EMF:
+ case HSLFPictureShape.EMF:
pict = new EMF();
break;
- case Picture.WMF:
+ case HSLFPictureShape.WMF:
pict = new WMF();
break;
- case Picture.PICT:
+ case HSLFPictureShape.PICT:
pict = new PICT();
break;
- case Picture.JPEG:
+ case HSLFPictureShape.JPEG:
pict = new JPEG();
break;
- case Picture.PNG:
+ case HSLFPictureShape.PNG:
pict = new PNG();
break;
- case Picture.DIB:
+ case HSLFPictureShape.DIB:
pict = new DIB();
break;
default:
@@ -227,7 +235,7 @@ public abstract class PictureData {
return getData().length;
}
- public void draw(Graphics2D graphics, Picture parent){
+ public void draw(Graphics2D graphics, HSLFPictureShape parent){
ImagePainter painter = painters[getType()];
if(painter != null) painter.paint(graphics, this, parent);
else logger.log(POILogger.WARN, "Rendering is not supported: " + getClass().getName());
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
similarity index 94%
rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
index d6829b4b4e..1f9f6ca027 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
@@ -37,19 +37,9 @@ import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.hpsf.ClassID;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
import org.apache.poi.hslf.exceptions.HSLFException;
-import org.apache.poi.hslf.model.HeadersFooters;
-import org.apache.poi.hslf.model.Hyperlink;
-import org.apache.poi.hslf.model.MovieShape;
-import org.apache.poi.hslf.model.Notes;
-import org.apache.poi.hslf.model.PPFont;
-import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.model.HSLFShape;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.SlideMaster;
-import org.apache.poi.hslf.model.TitleMaster;
+import org.apache.poi.hslf.model.*;
import org.apache.poi.hslf.record.Document;
import org.apache.poi.hslf.record.DocumentAtom;
import org.apache.poi.hslf.record.ExAviMovie;
@@ -79,6 +69,7 @@ import org.apache.poi.hslf.record.SlidePersistAtom;
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.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -91,9 +82,9 @@ import org.apache.poi.util.POILogger;
* @author Nick Burch
* @author Yegor kozlov
*/
-public final class SlideShow {
+public final class HSLFSlideShow implements SlideShow {
// What we're based on
- private HSLFSlideShow _hslfSlideShow;
+ private HSLFSlideShowImpl _hslfSlideShow;
// Pointers to the most recent versions of the core records
// (Document, Notes, Slide etc)
@@ -108,8 +99,8 @@ public final class SlideShow {
// Friendly objects for people to deal with
private SlideMaster[] _masters;
private TitleMaster[] _titleMasters;
- private Slide[] _slides;
- private Notes[] _notes;
+ private HSLFSlide[] _slides;
+ private HSLFNotes[] _notes;
private FontCollection _fonts;
// For logging
@@ -128,7 +119,7 @@ public final class SlideShow {
*
* @param hslfSlideShow the HSLFSlideShow to base on
*/
- public SlideShow(HSLFSlideShow hslfSlideShow) {
+ public HSLFSlideShow(HSLFSlideShowImpl hslfSlideShow) {
// Get useful things from our base slideshow
_hslfSlideShow = hslfSlideShow;
@@ -149,15 +140,15 @@ public final class SlideShow {
/**
* Constructs a new, empty, Powerpoint document.
*/
- public SlideShow() {
- this(HSLFSlideShow.create());
+ public HSLFSlideShow() {
+ this(HSLFSlideShowImpl.create());
}
/**
* Constructs a Powerpoint document from an input stream.
*/
- public SlideShow(InputStream inputStream) throws IOException {
- this(new HSLFSlideShow(inputStream));
+ public HSLFSlideShow(InputStream inputStream) throws IOException {
+ this(new HSLFSlideShowImpl(inputStream));
}
/**
@@ -417,21 +408,21 @@ public final class SlideShow {
// Finally, generate model objects for everything
// Notes first
- _notes = new Notes[notesRecords.length];
+ _notes = new HSLFNotes[notesRecords.length];
for (int i = 0; i < _notes.length; i++) {
if (notesRecords[i] != null) {
- _notes[i] = new Notes(notesRecords[i]);
+ _notes[i] = new HSLFNotes(notesRecords[i]);
_notes[i].setSlideShow(this);
}
}
// Then slides
- _slides = new Slide[slidesRecords.length];
+ _slides = new HSLFSlide[slidesRecords.length];
for (int i = 0; i < _slides.length; i++) {
SlideAtomsSet sas = slidesSets[i];
int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier();
// Do we have a notes for this?
- Notes notes = null;
+ HSLFNotes notes = null;
// Slide.SlideAtom.notesId references the corresponding notes slide.
// 0 if slide has no notes.
int noteId = slidesRecords[i].getSlideAtom().getNotesID();
@@ -445,7 +436,7 @@ public final class SlideShow {
}
// Now, build our slide
- _slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
+ _slides[i] = new HSLFSlide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
_slides[i].setSlideShow(this);
}
}
@@ -481,14 +472,14 @@ public final class SlideShow {
/**
* Returns an array of all the normal Slides found in the slideshow
*/
- public Slide[] getSlides() {
+ public HSLFSlide[] getSlides() {
return _slides;
}
/**
* Returns an array of all the normal Notes found in the slideshow
*/
- public Notes[] getNotes() {
+ public HSLFNotes[] getNotes() {
return _notes;
}
@@ -509,22 +500,22 @@ public final class SlideShow {
/**
* Returns the data of all the pictures attached to the SlideShow
*/
- public PictureData[] getPictureData() {
+ public HSLFPictureData[] getPictureData() {
return _hslfSlideShow.getPictures();
}
/**
* Returns the data of all the embedded OLE object in the SlideShow
*/
- public ObjectData[] getEmbeddedObjects() {
+ public HSLFObjectData[] getEmbeddedObjects() {
return _hslfSlideShow.getEmbeddedObjects();
}
/**
* Returns the data of all the embedded sounds in the SlideShow
*/
- public SoundData[] getSoundData() {
- return SoundData.find(_documentRecord);
+ public HSLFSoundData[] getSoundData() {
+ return HSLFSoundData.find(_documentRecord);
}
/**
@@ -621,7 +612,7 @@ public final class SlideShow {
* the index of the slide to remove (0-based)
* @return the slide that was removed from the slide show.
*/
- public Slide removeSlide(int index) {
+ public HSLFSlide removeSlide(int index) {
int lastSlideIdx = _slides.length - 1;
if (index < 0 || index > lastSlideIdx) {
throw new IllegalArgumentException("Slide index (" + index + ") is out of range (0.."
@@ -631,13 +622,13 @@ public final class SlideShow {
SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
- Slide removedSlide = null;
+ HSLFSlide removedSlide = null;
ArrayList records = new ArrayList();
ArrayList sa = new ArrayList();
- ArrayList sl = new ArrayList();
+ ArrayList sl = new ArrayList();
- ArrayList nt = new ArrayList();
- for (Notes notes : getNotes())
+ ArrayList nt = new ArrayList();
+ for (HSLFNotes notes : getNotes())
nt.add(notes);
for (int i = 0, num = 0; i < _slides.length; i++) {
@@ -658,7 +649,7 @@ public final class SlideShow {
slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()]));
slwt.setChildRecord(records.toArray(new Record[records.size()]));
}
- _slides = sl.toArray(new Slide[sl.size()]);
+ _slides = sl.toArray(new HSLFSlide[sl.size()]);
// if the removed slide had notes - remove references to them too
@@ -685,7 +676,7 @@ public final class SlideShow {
}
}
- _notes = nt.toArray(new Notes[nt.size()]);
+ _notes = nt.toArray(new HSLFNotes[nt.size()]);
return removedSlide;
}
@@ -701,7 +692,7 @@ public final class SlideShow {
*
* @return the created Slide
*/
- public Slide createSlide() {
+ public HSLFSlide createSlide() {
SlideListWithText slist = null;
// We need to add the records to the SLWT that deals
@@ -745,12 +736,12 @@ public final class SlideShow {
slist.addSlidePersistAtom(sp);
// Create a new Slide
- Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
+ HSLFSlide slide = new HSLFSlide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
slide.setSlideShow(this);
slide.onCreate();
// Add in to the list of Slides
- Slide[] s = new Slide[_slides.length + 1];
+ HSLFSlide[] s = new HSLFSlide[_slides.length + 1];
System.arraycopy(_slides, 0, s, 0, _slides.length);
s[_slides.length] = slide;
_slides = s;
@@ -779,7 +770,7 @@ public final class SlideShow {
* @return the index to this picture (1 based).
*/
public int addPicture(byte[] data, int format) throws IOException {
- byte[] uid = PictureData.getChecksum(data);
+ byte[] uid = HSLFPictureData.getChecksum(data);
EscherContainerRecord bstore;
@@ -801,7 +792,7 @@ public final class SlideShow {
}
}
- PictureData pict = PictureData.create(format);
+ HSLFPictureData pict = HSLFPictureData.create(format);
pict.setData(data);
int offset = _hslfSlideShow.addPicture(pict);
@@ -815,12 +806,12 @@ public final class SlideShow {
bse.setBlipTypeMacOS((byte) format);
bse.setBlipTypeWin32((byte) format);
- if (format == Picture.EMF)
- bse.setBlipTypeMacOS((byte) Picture.PICT);
- else if (format == Picture.WMF)
- bse.setBlipTypeMacOS((byte) Picture.PICT);
- else if (format == Picture.PICT)
- bse.setBlipTypeWin32((byte) Picture.WMF);
+ if (format == HSLFPictureShape.EMF)
+ bse.setBlipTypeMacOS((byte) HSLFPictureShape.PICT);
+ else if (format == HSLFPictureShape.WMF)
+ bse.setBlipTypeMacOS((byte) HSLFPictureShape.PICT);
+ else if (format == HSLFPictureShape.PICT)
+ bse.setBlipTypeWin32((byte) HSLFPictureShape.WMF);
bse.setRef(0);
bse.setOffset(offset);
@@ -1134,7 +1125,7 @@ public final class SlideShow {
}
protected int addPersistentObject(PositionDependentRecord slideRecord) {
- slideRecord.setLastOnDiskOffset(HSLFSlideShow.UNSET_OFFSET);
+ slideRecord.setLastOnDiskOffset(HSLFSlideShowImpl.UNSET_OFFSET);
_hslfSlideShow.appendRootLevelRecord((Record)slideRecord);
// For position dependent records, hold where they were and now are
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java
similarity index 89%
rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java
rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java
index 9fd85e1bdb..7750b25f15 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java
@@ -26,7 +26,7 @@ import java.util.ArrayList;
*
* @author Yegor Kozlov
*/
-public final class SoundData {
+public final class HSLFSoundData {
/**
* The record that contains the object data.
*/
@@ -37,7 +37,7 @@ public final class SoundData {
*
* @param container the record that contains the sound data.
*/
- public SoundData(Sound container) {
+ public HSLFSoundData(Sound container) {
this._container = container;
}
@@ -74,8 +74,8 @@ public final class SoundData {
* @param document the document to find in
* @return the array with the sound data
*/
- public static SoundData[] find(Document document){
- ArrayList lst = new ArrayList();
+ public static HSLFSoundData[] find(Document document){
+ ArrayList lst = new ArrayList();
Record[] ch = document.getChildRecords();
for (int i = 0; i < ch.length; i++) {
if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){
@@ -83,12 +83,12 @@ public final class SoundData {
Record[] sr = col.getChildRecords();
for (int j = 0; j < sr.length; j++) {
if(sr[j] instanceof Sound){
- lst.add(new SoundData((Sound)sr[j]));
+ lst.add(new HSLFSoundData((Sound)sr[j]));
}
}
}
}
- return lst.toArray(new SoundData[lst.size()]);
+ return lst.toArray(new HSLFSoundData[lst.size()]);
}
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
similarity index 90%
rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
index 878f8c12eb..06980e9ff5 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
@@ -19,16 +19,14 @@ package org.apache.poi.hslf.usermodel;
import java.awt.Color;
-import org.apache.poi.hslf.model.MasterSheet;
-import org.apache.poi.hslf.model.HSLFShape;
-import org.apache.poi.hslf.model.Sheet;
-import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.*;
import org.apache.poi.hslf.model.textproperties.BitMaskTextProp;
import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp;
import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.ColorSchemeAtom;
+import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -37,13 +35,13 @@ import org.apache.poi.util.POILogger;
* Represents a run of text, all with the same style
*
*/
-public final class RichTextRun {
+public final class HSLFTextRun implements TextRun {
protected POILogger logger = POILogFactory.getLogger(this.getClass());
/** The TextRun we belong to */
- private TextRun parentRun;
+ private HSLFTextParagraph parentParagraph;
/** The SlideShow we belong to */
- private SlideShow slideShow;
+ // private SlideShow slideShow;
/** Where in the parent TextRun we start from */
private int startPos;
@@ -68,7 +66,7 @@ public final class RichTextRun {
* @param startAt
* @param len
*/
- public RichTextRun(TextRun parent, int startAt, int len) {
+ public HSLFTextRun(HSLFTextParagraph parent, int startAt, int len) {
this(parent, startAt, len, null, null, false, false);
}
/**
@@ -81,10 +79,10 @@ public final class RichTextRun {
* @param pShared The paragraph styles are shared with other runs
* @param cShared The character styles are shared with other runs
*/
- public RichTextRun(TextRun parent, int startAt, int len,
+ public HSLFTextRun(HSLFTextParagraph parent, int startAt, int len,
TextPropCollection pStyle, TextPropCollection cStyle,
boolean pShared, boolean cShared) {
- parentRun = parent;
+ parentParagraph = parent;
startPos = startAt;
length = len;
paragraphStyle = pStyle;
@@ -109,8 +107,7 @@ public final class RichTextRun {
/**
* Supply the SlideShow we belong to
*/
- public void supplySlideShow(SlideShow ss) {
- slideShow = ss;
+ public void updateSheet() {
if (_fontname != null) {
setFontName(_fontname);
_fontname = null;
@@ -146,20 +143,20 @@ public final class RichTextRun {
* Fetch the text, in output suitable form
*/
public String getText() {
- return parentRun.getText().substring(startPos, startPos+length);
+ return parentParagraph.getText().substring(startPos, startPos+length);
}
/**
* Fetch the text, in raw storage form
*/
public String getRawText() {
- return parentRun.getRawText().substring(startPos, startPos+length);
+ return parentParagraph.getRawText().substring(startPos, startPos+length);
}
/**
* Change the text
*/
public void setText(String text) {
- String s = parentRun.normalize(text);
+ String s = parentParagraph.normalize(text);
setRawText(s);
}
@@ -168,7 +165,7 @@ public final class RichTextRun {
*/
public void setRawText(String text) {
length = text.length();
- parentRun.changeTextInRichTextRun(this,text);
+ parentParagraph.changeTextInRichTextRun(this,text);
}
/**
@@ -207,10 +204,10 @@ public final class RichTextRun {
prop = (BitMaskTextProp)props.findByName(propname);
}
if (prop == null){
- Sheet sheet = parentRun.getSheet();
+ HSLFSheet sheet = parentParagraph.getSheet();
if(sheet != null){
- int txtype = parentRun.getRunType();
- MasterSheet master = sheet.getMasterSheet();
+ int txtype = parentParagraph.getRunType();
+ HSLFMasterSheet master = sheet.getMasterSheet();
if (master != null){
prop = (BitMaskTextProp)master.getStyleAttribute(txtype, getIndentLevel(), propname, isCharacter);
}
@@ -243,7 +240,7 @@ public final class RichTextRun {
// Ensure we have the StyleTextProp atom we're going to need
if(props == null) {
- parentRun.ensureStyleAtomPresent();
+ parentParagraph.ensureStyleAtomPresent();
props = isCharacter ? characterStyle : paragraphStyle;
}
@@ -279,9 +276,9 @@ public final class RichTextRun {
}
if (prop == null){
- Sheet sheet = parentRun.getSheet();
- int txtype = parentRun.getRunType();
- MasterSheet master = sheet.getMasterSheet();
+ HSLFSheet sheet = parentParagraph.getSheet();
+ int txtype = parentParagraph.getRunType();
+ HSLFMasterSheet master = sheet.getMasterSheet();
if (master != null)
prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, true);
}
@@ -303,9 +300,9 @@ public final class RichTextRun {
hardAttribute = maskProp != null && maskProp.getValue() == 0;
}
if (prop == null && !hardAttribute){
- Sheet sheet = parentRun.getSheet();
- int txtype = parentRun.getRunType();
- MasterSheet master = sheet.getMasterSheet();
+ HSLFSheet sheet = parentParagraph.getSheet();
+ int txtype = parentParagraph.getRunType();
+ HSLFMasterSheet master = sheet.getMasterSheet();
if (master != null)
prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, false);
}
@@ -321,7 +318,7 @@ public final class RichTextRun {
public void setParaTextPropVal(String propName, int val) {
// Ensure we have the StyleTextProp atom we're going to need
if(paragraphStyle == null) {
- parentRun.ensureStyleAtomPresent();
+ parentParagraph.ensureStyleAtomPresent();
// paragraphStyle will now be defined
}
@@ -337,7 +334,7 @@ public final class RichTextRun {
public void setCharTextPropVal(String propName, int val) {
// Ensure we have the StyleTextProp atom we're going to need
if(characterStyle == null) {
- parentRun.ensureStyleAtomPresent();
+ parentParagraph.ensureStyleAtomPresent();
// characterStyle will now be defined
}
@@ -380,14 +377,14 @@ public final class RichTextRun {
/**
* Is the text underlined?
*/
- public boolean isUnderlined() {
+ public boolean isUnderline() {
return isCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX);
}
/**
* Is the text underlined?
*/
- public void setUnderlined(boolean underlined) {
+ public void setUnderline(boolean underlined) {
setCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX, underlined);
}
@@ -486,21 +483,25 @@ public final class RichTextRun {
* Sets the font name to use
*/
public void setFontName(String fontName) {
- if (slideShow == null) {
+ HSLFSheet sheet = parentParagraph.getSheet();
+ HSLFSlideShowImpl slideShow = (sheet == null) ? null : sheet.getSlideShow();
+ if (sheet == null || slideShow == null) {
//we can't set font since slideshow is not assigned yet
_fontname = fontName;
- } else {
- // Get the index for this font (adding if needed)
- int fontIdx = slideShow.getFontCollection().addFont(fontName);
- setCharTextPropVal("font.index", fontIdx);
+ return;
}
+ // Get the index for this font (adding if needed)
+ int fontIdx = slideShow.getFontCollection().addFont(fontName);
+ setCharTextPropVal("font.index", fontIdx);
}
/**
* Gets the font name
*/
public String getFontName() {
- if (slideShow == null) {
+ HSLFSheet sheet = parentParagraph.getSheet();
+ HSLFSlideShowImpl slideShow = (sheet == null) ? null : sheet.getSlideShow();
+ if (sheet == null || slideShow == null) {
return _fontname;
}
int fontIdx = getCharTextPropVal("font.index");
@@ -517,7 +518,7 @@ public final class RichTextRun {
int cidx = rgb >> 24;
if (rgb % 0x1000000 == 0){
- ColorSchemeAtom ca = parentRun.getSheet().getColorScheme();
+ ColorSchemeAtom ca = parentParagraph.getSheet().getColorScheme();
if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx);
}
Color tmp = new Color(rgb, true);
@@ -673,7 +674,7 @@ public final class RichTextRun {
int cidx = rgb >> 24;
if (rgb % 0x1000000 == 0){
- ColorSchemeAtom ca = parentRun.getSheet().getColorScheme();
+ ColorSchemeAtom ca = parentParagraph.getSheet().getColorScheme();
if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx);
}
Color tmp = new Color(rgb, true);
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java
index f28c2cbfd4..f9fc966575 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java
@@ -3,7 +3,7 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawAutoShape> extends DrawTextShape {
+public class DrawAutoShape>> extends DrawTextShape {
public DrawAutoShape(T shape) {
super(shape);
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java
index 80b95ee5f6..bf82208cdc 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java
@@ -45,7 +45,7 @@ public class DrawFactory {
boolean isHint = false;
if (graphics != null) {
factory = (DrawFactory)graphics.getRenderingHint(DRAW_FACTORY);
- isHint = true;
+ isHint = (factory != null);
}
// secondly try the thread local default
if (factory == null) {
@@ -76,25 +76,25 @@ public class DrawFactory {
} else if (shape instanceof Background) {
return getDrawable((Background)shape);
} else if (shape instanceof Slide) {
- return getDrawable((Slide extends Shape>)shape);
+ return getDrawable((Slide extends Shape, ? extends SlideShow>)shape);
} else if (shape instanceof MasterSheet) {
- return getDrawable((MasterSheet extends Shape>)shape);
+ return getDrawable((MasterSheet extends Shape, ? extends SlideShow>)shape);
} else if (shape instanceof Sheet) {
- return getDrawable((Sheet extends Shape>)shape);
+ return getDrawable((Sheet extends Shape, ? extends SlideShow>)shape);
}
throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass());
}
- public > DrawSlide getDrawable(T sheet) {
+ public > DrawSlide getDrawable(T sheet) {
return new DrawSlide(sheet);
}
- public > DrawSheet getDrawable(T sheet) {
+ public > DrawSheet getDrawable(T sheet) {
return new DrawSheet(sheet);
}
- public > DrawMasterSheet getDrawable(T sheet) {
+ public > DrawMasterSheet getDrawable(T sheet) {
return new DrawMasterSheet(sheet);
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java
index 7a89828ede..452704a757 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java
@@ -3,7 +3,7 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawMasterSheet> extends DrawSheet {
+public class DrawMasterSheet> extends DrawSheet {
public DrawMasterSheet(T sheet) {
super(sheet);
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java
index 77a0da740a..ca2346b207 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java
@@ -17,6 +17,7 @@
package org.apache.poi.sl.draw;
+import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT;
import java.awt.*;
import java.awt.MultipleGradientPaint.ColorSpaceType;
import java.awt.MultipleGradientPaint.CycleMethod;
@@ -35,7 +36,7 @@ import org.apache.poi.util.POILogger;
public class DrawPaint {
- public final static Color NO_PAINT = new Color(0xFF, 0xFF, 0xFF, 0);
+
private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);
protected PlaceableShape shape;
@@ -43,6 +44,21 @@ public class DrawPaint {
public DrawPaint(PlaceableShape shape) {
this.shape = shape;
}
+
+ public static SolidPaint createSolidPaint(final Color color) {
+ return new SolidPaint() {
+ public ColorStyle getSolidColor() {
+ return new ColorStyle(){
+ public Color getColor() { return color; }
+ public int getAlpha() { return -1; }
+ public int getLumOff() { return -1; }
+ public int getLumMod() { return -1; }
+ public int getShade() { return -1; }
+ public int getTint() { return -1; }
+ };
+ }
+ };
+ }
public Paint getPaint(Graphics2D graphics, PaintStyle paint) {
if (paint instanceof SolidPaint) {
@@ -74,7 +90,7 @@ public class DrawPaint {
protected Paint getTexturePaint(TexturePaint fill, Graphics2D graphics) {
InputStream is = fill.getImageData();
- if (is == null) return NO_PAINT;
+ if (is == null) return TRANSPARENT_PAINT.getSolidColor().getColor();
assert(graphics != null);
ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);
@@ -84,7 +100,7 @@ public class DrawPaint {
renderer.loadImage(fill.getImageData(), fill.getContentType());
} catch (IOException e) {
LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e);
- return NO_PAINT;
+ return TRANSPARENT_PAINT.getSolidColor().getColor();
}
int alpha = fill.getAlpha();
@@ -105,7 +121,9 @@ public class DrawPaint {
public static Color applyColorTransform(ColorStyle color){
Color result = color.getColor();
- if (result == null || color.getAlpha() == 100) return NO_PAINT;
+ if (result == null || color.getAlpha() == 100) {
+ return TRANSPARENT_PAINT.getSolidColor().getColor();
+ }
result = applyAlpha(result, color);
result = applyLuminanace(result, color);
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java
index 238bb1a116..ceda9280c4 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java
@@ -7,17 +7,12 @@ import java.awt.geom.Rectangle2D;
import org.apache.poi.sl.usermodel.*;
-public class DrawShapeGroup> implements Drawable {
+public class DrawShapeGroup> extends DrawShape implements Drawable {
- protected final T shape;
-
public DrawShapeGroup(T shape) {
- this.shape = shape;
+ super(shape);
}
- public void applyTransform(Graphics2D context) {
- }
-
public void draw(Graphics2D graphics) {
// the coordinate system of this group of shape
@@ -54,7 +49,4 @@ public class DrawShapeGroup> implements Dr
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
}
-
- public void drawContent(Graphics2D context) {
- }
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java
index d3901b39b3..d0026f31dc 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java
@@ -6,7 +6,7 @@ import java.awt.geom.AffineTransform;
import org.apache.poi.sl.usermodel.*;
-public class DrawSheet> implements Drawable {
+public class DrawSheet> implements Drawable {
protected final T sheet;
@@ -14,14 +14,9 @@ public class DrawSheet> implements Drawable {
this.sheet = sheet;
}
- public void applyTransform(Graphics2D context) {
- // TODO Auto-generated method stub
-
- }
-
public void draw(Graphics2D graphics) {
DrawFactory drawFact = DrawFactory.getInstance(graphics);
- MasterSheet extends Shape> master = sheet.getMasterSheet();
+ MasterSheet extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();
if(sheet.getFollowMasterGraphics() && master != null) {
Drawable drawer = drawFact.getDrawable(master);
@@ -53,9 +48,10 @@ public class DrawSheet> implements Drawable {
}
}
+ public void applyTransform(Graphics2D context) {
+ }
+
public void drawContent(Graphics2D context) {
- // TODO Auto-generated method stub
-
}
/**
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java
index c5e5b4244c..4ff0034eba 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java
@@ -18,7 +18,7 @@ import org.apache.poi.sl.draw.geom.*;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
-import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
+import org.apache.poi.sl.usermodel.StrokeStyle.*;
import org.apache.poi.util.Units;
@@ -223,15 +223,22 @@ public class DrawSimpleShape extends DrawShape {
if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt
LineDash lineDash = strokeStyle.getLineDash();
+ if (lineDash == null) {
+ lineDash = LineDash.SOLID;
+ lineWidth = 0.0f;
+ }
+
int dashPatI[] = lineDash.pattern;
float[] dashPatF = new float[dashPatI.length];
final float dash_phase = 0;
for (int i=0; i extends DrawShape {
int lineJoin = BasicStroke.JOIN_ROUND;
- return new BasicStroke(lineWidth, lineCap, lineJoin, Math.max(1, lineWidth), dashPatF, dash_phase);
+ return new BasicStroke(lineWidth, lineCap, lineJoin, lineWidth, dashPatF, dash_phase);
}
protected void drawShadow(
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java
index 8bc4eaf686..cada314ece 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java
@@ -5,7 +5,7 @@ import java.awt.Graphics2D;
import org.apache.poi.sl.usermodel.*;
-public class DrawSlide> extends DrawSheet {
+public class DrawSlide> extends DrawSheet {
public DrawSlide(T slide) {
super(slide);
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java
index c9bf1f4085..4b2c79e378 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java
@@ -4,8 +4,6 @@ import java.awt.Graphics2D;
import java.awt.font.TextLayout;
import java.text.*;
-import org.apache.poi.xslf.usermodel.XSLFRenderingHint;
-
public class DrawTextFragment implements Drawable {
final TextLayout layout;
final AttributedString str;
@@ -29,8 +27,8 @@ public class DrawTextFragment implements Drawable {
double yBaseline = y + layout.getAscent();
- Integer textMode = (Integer)graphics.getRenderingHint(XSLFRenderingHint.TEXT_RENDERING_MODE);
- if(textMode != null && textMode == XSLFRenderingHint.TEXT_AS_SHAPES){
+ Integer textMode = (Integer)graphics.getRenderingHint(Drawable.TEXT_RENDERING_MODE);
+ if(textMode != null && textMode == Drawable.TEXT_AS_SHAPES){
layout.draw(graphics, (float)x, (float)yBaseline);
} else {
graphics.drawString(str.getIterator(), (float)x, (float)yBaseline );
@@ -38,13 +36,9 @@ public class DrawTextFragment implements Drawable {
}
public void applyTransform(Graphics2D graphics) {
- // TODO Auto-generated method stub
-
}
public void drawContent(Graphics2D graphics) {
- // TODO Auto-generated method stub
-
}
public TextLayout getLayout() {
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java
index cda6a1a88f..f0b4ff42b3 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java
@@ -8,7 +8,7 @@ import java.util.Iterator;
import org.apache.poi.sl.usermodel.*;
-public class DrawTextShape> extends DrawSimpleShape {
+public class DrawTextShape>> extends DrawSimpleShape {
public DrawTextShape(T shape) {
super(shape);
@@ -26,7 +26,7 @@ public class DrawTextShape> extends
// Transform of text in flipped shapes is special.
// At this point the flip and rotation transform is already applied
- // (see XSLFShape#applyTransform ), but we need to restore it to avoid painting "upside down".
+ // (see DrawShape#applyTransform ), but we need to restore it to avoid painting "upside down".
// See Bugzilla 54210.
if(shape.getFlipVertical()){
@@ -84,12 +84,12 @@ public class DrawTextShape> extends
Insets2D shapePadding = shape.getInsets();
double y0 = y;
- Iterator extends TextParagraph> paragraphs = shape.iterator();
+ Iterator extends TextParagraph extends TextRun>> paragraphs = shape.iterator();
boolean isFirstLine = true;
while (paragraphs.hasNext()){
- TextParagraph p = paragraphs.next();
- DrawTextParagraph dp = fact.getDrawable(p);
+ TextParagraph extends TextRun> p = paragraphs.next();
+ DrawTextParagraph extends TextRun> dp = fact.getDrawable(p);
dp.setInsets(shapePadding);
dp.breakText(graphics);
diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java b/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java
index d876d1512a..736dc0d668 100644
--- a/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java
+++ b/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java
@@ -45,7 +45,7 @@ public class PresetGeometries extends LinkedHashMap {
@SuppressWarnings("unused")
public void init(InputStream is) throws XMLStreamException, JAXBException {
- Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") );
+ // Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") );
// StAX:
@@ -58,7 +58,7 @@ public class PresetGeometries extends LinkedHashMap {
long cntElem = 0;
XMLInputFactory staxFactory = XMLInputFactory.newInstance();
- XMLEventReader staxReader = staxFactory.createXMLEventReader(xml);
+ XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
// ignore StartElement:
XMLEvent evDoc = staxFiltRd.nextEvent();
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java
index 21c3a507fd..1bf073dfbb 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java
@@ -17,5 +17,5 @@
package org.apache.poi.sl.usermodel;
-public interface AutoShape extends TextShape {
+public interface AutoShape> extends TextShape {
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java
index 09d61989df..e0843a11a1 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java
@@ -17,6 +17,6 @@
package org.apache.poi.sl.usermodel;
-public interface FreeformShape extends AutoShape {
+public interface FreeformShape> extends AutoShape {
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java
index 8ba80156bd..727217d3fa 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java
@@ -17,6 +17,6 @@
package org.apache.poi.sl.usermodel;
-public interface MasterSheet extends Sheet {
+public interface MasterSheet extends Sheet {
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java
index c16774c298..08f023cd9f 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java
@@ -17,6 +17,8 @@
package org.apache.poi.sl.usermodel;
-public interface Notes extends Sheet {
- public TextRun getTextRun();
+import java.util.List;
+
+public interface Notes extends Sheet {
+ List extends TextParagraph extends TextRun>> getTextParagraphs();
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java
index 9dcd495e40..2551201692 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java
@@ -17,8 +17,11 @@
package org.apache.poi.sl.usermodel;
+import java.awt.Color;
import java.io.InputStream;
+import org.apache.poi.sl.draw.DrawPaint;
+
public interface PaintStyle {
@@ -55,4 +58,6 @@ public interface PaintStyle {
*/
int getAlpha();
}
+
+ SolidPaint TRANSPARENT_PAINT = DrawPaint.createSolidPaint(new Color(0xFF, 0xFF, 0xFF, 0));
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java
index 6ad149b489..4de645d41f 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java
@@ -19,14 +19,11 @@ package org.apache.poi.sl.usermodel;
public interface Shape {
- ShapeContainer getParent();
+ ShapeContainer extends Shape> getParent();
/**
*
* @return the sheet this shape belongs to
*/
- Sheet getSheet();
-
-
-
+ Sheet extends Shape, ? extends SlideShow> getSheet();
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java
index 8de1dbcb06..7bd940c36c 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java
@@ -19,6 +19,6 @@ package org.apache.poi.sl.usermodel;
import java.awt.geom.Rectangle2D;
-public interface ShapeGroup extends ShapeContainer, PlaceableShape {
+public interface ShapeGroup extends Shape, ShapeContainer, PlaceableShape {
Rectangle2D getInteriorAnchor();
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java
index 64b53a3014..6f4ba0ac67 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java
@@ -21,8 +21,8 @@ package org.apache.poi.sl.usermodel;
/**
* Common parent of Slides, Notes and Masters
*/
-public interface Sheet extends ShapeContainer {
- SlideShow getSlideShow();
+public interface Sheet extends ShapeContainer {
+ SS getSlideShow();
/**
* @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
@@ -31,7 +31,7 @@ public interface Sheet extends ShapeContainer {
*/
boolean getFollowMasterGraphics();
- MasterSheet getMasterSheet();
+ MasterSheet getMasterSheet();
Background getBackground();
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java
index 243d9a8174..b2027c182c 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java
@@ -17,9 +17,9 @@
package org.apache.poi.sl.usermodel;
-public interface Slide extends Sheet {
- public Notes getNotes();
- public void setNotes(Notes notes);
+public interface Slide extends Sheet {
+ public Notes getNotes();
+ public void setNotes(Notes notes);
public boolean getFollowMasterBackground();
public void setFollowMasterBackground(boolean follow);
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java
index 4505ca5843..e3007f6c17 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java
@@ -21,11 +21,11 @@ import java.awt.Dimension;
import java.io.IOException;
public interface SlideShow {
- Slide createSlide() throws IOException;
- MasterSheet createMasterSheet() throws IOException;
+ Slide extends Shape, ? extends SlideShow> createSlide() throws IOException;
+ MasterSheet extends Shape, ? extends SlideShow> createMasterSheet() throws IOException;
- Slide[] getSlides();
- MasterSheet[] getMasterSheet();
+ Slide extends Shape, ? extends SlideShow>[] getSlides();
+ MasterSheet extends Shape, ? extends SlideShow>[] getMasterSheet();
Resources getResources();
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java
index c02e1a33f9..a55317740a 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java
@@ -33,27 +33,75 @@ public interface StrokeStyle {
* with actual line width
*/
enum LineDash {
- SOLID(1),
- DOT(1,1),
- DASH(3,4),
- LG_DASH(8,3),
- DASH_DOT(4,3,1,3),
- LG_DASH_DOT(8,3,1,3),
- LG_DASH_DOT_DOT(8,3,1,3,1,3),
- SYS_DASH(2,2),
- SYS_DOT(1,1),
- SYS_DASH_DOT,
- SYS_DASH_DOT_DOT;
+ /** Solid (continuous) pen - native 1 */
+ SOLID(1, 1),
+ /** square dot style - native 6 */
+ DOT(6, 1,1),
+ /** dash style - native 7 */
+ DASH(7, 3,4),
+ /** dash short dash - native 9*/
+ DASH_DOT(9, 4,3,1,3),
+ /** long dash style - native 8 */
+ LG_DASH(8, 8,3),
+ /** long dash short dash - native 10 */
+ LG_DASH_DOT(10, 8,3,1,3),
+ /** long dash short dash short dash - native 11 */
+ LG_DASH_DOT_DOT(11, 8,3,1,3,1,3),
+ /** PS_DASH system dash style - native 2 */
+ SYS_DASH(2, 2,2),
+ /** PS_DOT system dash style - native 3 */
+ SYS_DOT(3, 1,1),
+ /** PS_DASHDOT system dash style - native 4 */
+ SYS_DASH_DOT(4, 2,2,1,1),
+ /** PS_DASHDOTDOT system dash style / native 5 */
+ SYS_DASH_DOT_DOT(5, 2,2,1,1,1,1);
- public int pattern[];
-
- LineDash(int... pattern) {
+ public final int pattern[];
+ public final int nativeId;
+
+ LineDash(int nativeId, int... pattern) {
+ this.nativeId = nativeId;
this.pattern = (pattern == null || pattern.length == 0) ? new int[]{1} : pattern;
}
+
+ public static LineDash fromNativeId(int nativeId) {
+ for (LineDash ld : values()) {
+ if (ld.nativeId == nativeId) return ld;
+ }
+ return null;
+ }
}
-
+
+ enum LineCompound {
+ /** Single line (of width lineWidth) - native 0 / ooxml default */
+ SINGLE(0),
+ /** Double lines of equal width - native 1 / ooxml "dbl" */
+ DOUBLE(1),
+ /** Double lines, one thick, one thin - native 2 / ooxml "thickThin" */
+ THICK_THIN(2),
+ /** Double lines, reverse order - native 3 / ooxml "thinThick" */
+ THIN_THICK(3),
+ /** Three lines, thin, thick, thin - native 4 / ooxml "tri" */
+ TRIPLE(4);
+
+ public final int nativeId;
+
+ LineCompound(int nativeId) {
+ this.nativeId = nativeId;
+ }
+
+ public static LineCompound fromNativeId(int nativeId) {
+ for (LineCompound lc : values()) {
+ if (lc.nativeId == nativeId) return lc;
+ }
+ return null;
+ }
+ }
+
+
PaintStyle getPaint();
LineCap getLineCap();
LineDash getLineDash();
+ LineCompound getLineCompound();
double getLineWidth();
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java
index 9ac61d526a..3fa3bbe20d 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java
@@ -17,5 +17,5 @@
package org.apache.poi.sl.usermodel;
-public interface TextBox extends AutoShape {
+public interface TextBox> extends AutoShape {
}
diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java
index f9b1833610..a6a53fe1bd 100644
--- a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java
+++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java
@@ -19,7 +19,7 @@ package org.apache.poi.sl.usermodel;
-public interface TextShape> extends SimpleShape, Iterable {
+public interface TextShape> extends SimpleShape, Iterable {
/**
* Vertical Text Types
*/
diff --git a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java b/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
index b3f91236ec..134f3e8ac0 100644
--- a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
+++ b/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java
@@ -22,9 +22,10 @@ package org.apache.poi;
import junit.framework.TestCase;
+
import java.io.*;
-import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.poifs.filesystem.*;
@@ -47,7 +48,7 @@ public final class TestPOIDocumentScratchpad extends TestCase {
* a Word Document for our testing
*/
public void setUp() throws Exception {
- doc = new HSLFSlideShow(POIDataSamples.getSlideShowInstance().openResourceAsStream("basic_test_ppt_file.ppt"));
+ doc = new HSLFSlideShowImpl(POIDataSamples.getSlideShowInstance().openResourceAsStream("basic_test_ppt_file.ppt"));
doc2 = HWPFTestDataSamples.openSampleFile("test2.doc");
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java b/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java
index 6740708792..6207a4597d 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java
@@ -24,7 +24,8 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
public class HSLFTestDataSamples {
@@ -45,12 +46,12 @@ public class HSLFTestDataSamples {
* from a ByteArrayInputStream.
* Useful for verifying that the serialisation round trip
*/
- public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
+ public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
original.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- return new HSLFSlideShow(bais);
+ return new HSLFSlideShowImpl(bais);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -61,12 +62,12 @@ public class HSLFTestDataSamples {
* from a ByteArrayInputStream.
* Useful for verifying that the serialisation round trip
*/
- public static SlideShow writeOutAndReadBack(SlideShow original) {
+ public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
original.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- return new SlideShow(bais);
+ return new HSLFSlideShow(bais);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java
index da07810b86..3de6032ae5 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java
@@ -21,6 +21,7 @@ package org.apache.poi.hslf;
import junit.framework.TestCase;
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.POIDataSamples;
/**
@@ -32,28 +33,28 @@ public final class TestEncryptedFile extends TestCase {
private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
public void testLoadNonEncrypted() throws Exception {
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
assertNotNull(hss);
}
public void testLoadEncrypted() throws Exception {
try {
- new HSLFSlideShow(slTests.openResourceAsStream("Password_Protected-hello.ppt"));
+ new HSLFSlideShowImpl(slTests.openResourceAsStream("Password_Protected-hello.ppt"));
fail();
} catch(EncryptedPowerPointFileException e) {
// Good
}
try {
- new HSLFSlideShow(slTests.openResourceAsStream("Password_Protected-np-hello.ppt"));
+ new HSLFSlideShowImpl(slTests.openResourceAsStream("Password_Protected-np-hello.ppt"));
fail();
} catch(EncryptedPowerPointFileException e) {
// Good
}
try {
- new HSLFSlideShow(slTests.openResourceAsStream("Password_Protected-56-hello.ppt"));
+ new HSLFSlideShowImpl(slTests.openResourceAsStream("Password_Protected-56-hello.ppt"));
fail();
} catch(EncryptedPowerPointFileException e) {
// Good
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java
index 1398e747e1..ae64b3614d 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java
@@ -25,7 +25,8 @@ import java.io.FileNotFoundException;
import junit.framework.TestCase;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@@ -37,9 +38,9 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
*/
public final class TestReWrite extends TestCase {
// HSLFSlideShow primed on the test data
- private HSLFSlideShow hssA;
- private HSLFSlideShow hssB;
- private HSLFSlideShow hssC;
+ private HSLFSlideShowImpl hssA;
+ private HSLFSlideShowImpl hssB;
+ private HSLFSlideShowImpl hssC;
// POIFS primed on the test data
private POIFSFileSystem pfsA;
private POIFSFileSystem pfsB;
@@ -50,20 +51,20 @@ public final class TestReWrite extends TestCase {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
pfsA = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- hssA = new HSLFSlideShow(pfsA);
+ hssA = new HSLFSlideShowImpl(pfsA);
pfsB = new POIFSFileSystem(slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt"));
- hssB = new HSLFSlideShow(pfsB);
+ hssB = new HSLFSlideShowImpl(pfsB);
pfsC = new POIFSFileSystem(slTests.openResourceAsStream("WithMacros.ppt"));
- hssC = new HSLFSlideShow(pfsC);
+ hssC = new HSLFSlideShowImpl(pfsC);
}
public void testWritesOutTheSame() throws Exception {
assertWritesOutTheSame(hssA, pfsA);
assertWritesOutTheSame(hssB, pfsB);
}
- public void assertWritesOutTheSame(HSLFSlideShow hss, POIFSFileSystem pfs) throws Exception {
+ public void assertWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws Exception {
// Write out to a byte array
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss.write(baos);
@@ -129,9 +130,9 @@ public final class TestReWrite extends TestCase {
// We need to identify and fix that first
//assertSlideShowWritesOutTheSame(hssB, pfsB);
}
- public void assertSlideShowWritesOutTheSame(HSLFSlideShow hss, POIFSFileSystem pfs) throws Exception {
+ public void assertSlideShowWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws Exception {
// Create a slideshow covering it
- SlideShow ss = new SlideShow(hss);
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
ss.getSlides();
ss.getNotes();
@@ -163,7 +164,7 @@ public final class TestReWrite extends TestCase {
}
public void test48593() throws Exception {
- SlideShow slideShow = new SlideShow();
+ HSLFSlideShow slideShow = new HSLFSlideShow();
slideShow.createSlide();
slideShow = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
slideShow.createSlide();
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java
index ae76116a41..31a80ae306 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java
@@ -19,8 +19,11 @@ package org.apache.poi.hslf;
import junit.framework.TestCase;
+
import java.io.*;
import java.util.*;
+
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.hslf.record.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.POIDataSamples;
@@ -33,14 +36,14 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestReWriteSanity extends TestCase {
// HSLFSlideShow primed on the test data
- private HSLFSlideShow ss;
+ private HSLFSlideShowImpl ss;
// POIFS primed on the test data
private POIFSFileSystem pfs;
public TestReWriteSanity() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShow(pfs);
+ ss = new HSLFSlideShowImpl(pfs);
}
public void testUserEditAtomsRight() throws Exception {
@@ -52,7 +55,7 @@ public final class TestReWriteSanity extends TestCase {
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
// Create a new one from that
- HSLFSlideShow wss = new HSLFSlideShow(bais);
+ HSLFSlideShowImpl wss = new HSLFSlideShowImpl(bais);
// Find the location of the PersistPtrIncrementalBlocks and
// UserEditAtoms
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java
index 5d509b6203..732f609381 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java
@@ -19,6 +19,8 @@ package org.apache.poi.hslf;
import junit.framework.TestCase;
+
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.hslf.record.*;
import org.apache.poi.POIDataSamples;
@@ -30,11 +32,11 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestRecordCounts extends TestCase {
// HSLFSlideShow primed on the test data
- private HSLFSlideShow ss;
+ private HSLFSlideShowImpl ss;
public TestRecordCounts() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- ss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
}
public void testSheetsCount() {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
index 7fc234f8ef..a00d75d03e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
@@ -23,9 +23,9 @@ import java.util.List;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POITestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.hslf.model.OLEShape;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.poifs.filesystem.DirectoryNode;
@@ -140,7 +140,7 @@ public final class TestExtractor extends POITestCase {
POIFSFileSystem fs = new POIFSFileSystem(
POIDataSamples.getSpreadSheetInstance().openResourceAsStream("excel_with_embeded.xls")
);
- HSLFSlideShow ss;
+ HSLFSlideShowImpl ss;
DirectoryNode dirA = (DirectoryNode)
fs.getRoot().getEntry("MBD0000A3B6");
@@ -151,14 +151,14 @@ public final class TestExtractor extends POITestCase {
assertNotNull(dirB.getEntry("PowerPoint Document"));
// Check the first file
- ss = new HSLFSlideShow(dirA);
+ ss = new HSLFSlideShowImpl(dirA);
ppe = new PowerPointExtractor(ss);
assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
ppe.getText(true, false)
);
// And the second
- ss = new HSLFSlideShow(dirB);
+ ss = new HSLFSlideShowImpl(dirB);
ppe = new PowerPointExtractor(ss);
assertEquals("Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n",
ppe.getText(true, false)
@@ -186,7 +186,7 @@ public final class TestExtractor extends POITestCase {
num_doc++;
} else if ("Presentation".equals(name)) {
num_ppt++;
- SlideShow ppt = new SlideShow(data);
+ HSLFSlideShow ppt = new HSLFSlideShow(data);
}
}
assertEquals("Expected 2 embedded Word Documents", 2, num_doc);
@@ -241,8 +241,8 @@ public final class TestExtractor extends POITestCase {
String text;
// With a header on the notes
- HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("45537_Header.ppt"));
- SlideShow ss = new SlideShow(hslf);
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("45537_Header.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(hslf);
assertNotNull(ss.getNotesHeadersFooters());
assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getHeaderText());
@@ -259,8 +259,8 @@ public final class TestExtractor extends POITestCase {
// And with a footer, also on notes
- hslf = new HSLFSlideShow(slTests.openResourceAsStream("45537_Footer.ppt"));
- ss = new SlideShow(hslf);
+ hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("45537_Footer.ppt"));
+ ss = new HSLFSlideShow(hslf);
assertNotNull(ss.getNotesHeadersFooters());
assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getFooterText());
@@ -281,7 +281,7 @@ public final class TestExtractor extends POITestCase {
String masterTitleText = "This is the Master Title";
String masterRandomText = "This text comes from the Master Slide";
String masterFooterText = "Footer from the master slide";
- HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("WithMaster.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithMaster.ppt"));
ppe = new PowerPointExtractor(hslf);
@@ -309,7 +309,7 @@ public final class TestExtractor extends POITestCase {
// Now with another file only containing master text
// Will always show up
String masterText = "Footer from the master slide";
- HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("WithMaster.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithMaster.ppt"));
ppe = new PowerPointExtractor(hslf);
@@ -322,7 +322,7 @@ public final class TestExtractor extends POITestCase {
* Bug #54880 Chinese text not extracted properly
*/
public void testChineseText() throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("54880_chinese.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("54880_chinese.ppt"));
ppe = new PowerPointExtractor(hslf);
String text = ppe.getText();
@@ -360,7 +360,7 @@ public final class TestExtractor extends POITestCase {
// Open via a HWPFDocument
for(DirectoryNode dir : files) {
- HSLFSlideShow slideshow = new HSLFSlideShow(dir);
+ HSLFSlideShowImpl slideshow = new HSLFSlideShowImpl(dir);
PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
assertEquals(expectText, extractor.getText());
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
index 8838561501..0d1cfd9e09 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
@@ -32,9 +32,8 @@ import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherSimpleProperty;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.record.Document;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.ShapeType;
import org.junit.Test;
@@ -52,16 +51,16 @@ public final class TestBackground {
*/
@Test
public void defaults() {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType());
+ assertEquals(HSLFFill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType());
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
assertTrue(slide.getFollowMasterBackground());
- assertEquals(Fill.FILL_SOLID, slide.getBackground().getFill().getFillType());
+ assertEquals(HSLFFill.FILL_SOLID, slide.getBackground().getFill().getFillType());
- HSLFShape shape = new AutoShape(ShapeType.RECT);
- assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
+ HSLFShape shape = new HSLFAutoShape(ShapeType.RECT);
+ assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType());
}
/**
@@ -69,31 +68,31 @@ public final class TestBackground {
*/
@Test
public void readBackground() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("backgrounds.ppt"));
- Fill fill;
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("backgrounds.ppt"));
+ HSLFFill fill;
HSLFShape shape;
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
fill = slide[0].getBackground().getFill();
- assertEquals(Fill.FILL_PICTURE, fill.getFillType());
+ assertEquals(HSLFFill.FILL_PICTURE, fill.getFillType());
shape = slide[0].getShapes()[0];
- assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType());
fill = slide[1].getBackground().getFill();
- assertEquals(Fill.FILL_PATTERN, fill.getFillType());
+ assertEquals(HSLFFill.FILL_PATTERN, fill.getFillType());
shape = slide[1].getShapes()[0];
- assertEquals(Fill.FILL_BACKGROUND, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_BACKGROUND, shape.getFill().getFillType());
fill = slide[2].getBackground().getFill();
- assertEquals(Fill.FILL_TEXTURE, fill.getFillType());
+ assertEquals(HSLFFill.FILL_TEXTURE, fill.getFillType());
shape = slide[2].getShapes()[0];
- assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_PICTURE, shape.getFill().getFillType());
fill = slide[3].getBackground().getFill();
- assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType());
+ assertEquals(HSLFFill.FILL_SHADE_CENTER, fill.getFillType());
shape = slide[3].getShapes()[0];
- assertEquals(Fill.FILL_SHADE, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_SHADE, shape.getFill().getFillType());
}
/**
@@ -101,9 +100,9 @@ public final class TestBackground {
*/
@Test
public void backgroundPicture() throws Exception {
- SlideShow ppt = new SlideShow();
- Slide slide;
- Fill fill;
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide;
+ HSLFFill fill;
HSLFShape shape;
int idx;
@@ -111,45 +110,45 @@ public final class TestBackground {
slide = ppt.createSlide();
slide.setFollowMasterBackground(false);
fill = slide.getBackground().getFill();
- idx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG);
- fill.setFillType(Fill.FILL_PICTURE);
+ idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+ fill.setFillType(HSLFFill.FILL_PICTURE);
fill.setPictureData(idx);
- shape = new AutoShape(ShapeType.RECT);
+ shape = new HSLFAutoShape(ShapeType.RECT);
shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
fill = shape.getFill();
- fill.setFillType(Fill.FILL_SOLID);
+ fill.setFillType(HSLFFill.FILL_SOLID);
slide.addShape(shape);
//slide 2
slide = ppt.createSlide();
slide.setFollowMasterBackground(false);
fill = slide.getBackground().getFill();
- idx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG);
- fill.setFillType(Fill.FILL_PATTERN);
+ idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+ fill.setFillType(HSLFFill.FILL_PATTERN);
fill.setPictureData(idx);
fill.setBackgroundColor(Color.green);
fill.setForegroundColor(Color.red);
- shape = new AutoShape(ShapeType.RECT);
+ shape = new HSLFAutoShape(ShapeType.RECT);
shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
fill = shape.getFill();
- fill.setFillType(Fill.FILL_BACKGROUND);
+ fill.setFillType(HSLFFill.FILL_BACKGROUND);
slide.addShape(shape);
//slide 3
slide = ppt.createSlide();
slide.setFollowMasterBackground(false);
fill = slide.getBackground().getFill();
- idx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG);
- fill.setFillType(Fill.FILL_TEXTURE);
+ idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+ fill.setFillType(HSLFFill.FILL_TEXTURE);
fill.setPictureData(idx);
- shape = new AutoShape(ShapeType.RECT);
+ shape = new HSLFAutoShape(ShapeType.RECT);
shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
fill = shape.getFill();
- fill.setFillType(Fill.FILL_PICTURE);
- idx = ppt.addPicture(_slTests.readFile("clock.jpg"), Picture.JPEG);
+ fill.setFillType(HSLFFill.FILL_PICTURE);
+ idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG);
fill.setPictureData(idx);
slide.addShape(shape);
@@ -157,14 +156,14 @@ public final class TestBackground {
slide = ppt.createSlide();
slide.setFollowMasterBackground(false);
fill = slide.getBackground().getFill();
- fill.setFillType(Fill.FILL_SHADE_CENTER);
+ fill.setFillType(HSLFFill.FILL_SHADE_CENTER);
fill.setBackgroundColor(Color.white);
fill.setForegroundColor(Color.darkGray);
- shape = new AutoShape(ShapeType.RECT);
+ shape = new HSLFAutoShape(ShapeType.RECT);
shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
fill = shape.getFill();
- fill.setFillType(Fill.FILL_SHADE);
+ fill.setFillType(HSLFFill.FILL_SHADE);
fill.setBackgroundColor(Color.red);
fill.setForegroundColor(Color.green);
slide.addShape(shape);
@@ -174,42 +173,42 @@ public final class TestBackground {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
- Slide[] slides = ppt.getSlides();
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
+ HSLFSlide[] slides = ppt.getSlides();
fill = slides[0].getBackground().getFill();
- assertEquals(Fill.FILL_PICTURE, fill.getFillType());
+ assertEquals(HSLFFill.FILL_PICTURE, fill.getFillType());
assertEquals(3, getFillPictureRefCount(slides[0].getBackground(), fill));
shape = slides[0].getShapes()[0];
- assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType());
fill = slides[1].getBackground().getFill();
- assertEquals(Fill.FILL_PATTERN, fill.getFillType());
+ assertEquals(HSLFFill.FILL_PATTERN, fill.getFillType());
shape = slides[1].getShapes()[0];
- assertEquals(Fill.FILL_BACKGROUND, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_BACKGROUND, shape.getFill().getFillType());
fill = slides[2].getBackground().getFill();
- assertEquals(Fill.FILL_TEXTURE, fill.getFillType());
+ assertEquals(HSLFFill.FILL_TEXTURE, fill.getFillType());
assertEquals(3, getFillPictureRefCount(slides[2].getBackground(), fill));
shape = slides[2].getShapes()[0];
- assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_PICTURE, shape.getFill().getFillType());
assertEquals(1, getFillPictureRefCount(shape, fill));
fill = slides[3].getBackground().getFill();
- assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType());
+ assertEquals(HSLFFill.FILL_SHADE_CENTER, fill.getFillType());
shape = slides[3].getShapes()[0];
- assertEquals(Fill.FILL_SHADE, shape.getFill().getFillType());
+ assertEquals(HSLFFill.FILL_SHADE, shape.getFill().getFillType());
}
- private int getFillPictureRefCount(HSLFShape shape, Fill fill) {
+ private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) {
EscherOptRecord opt = shape.getEscherOptRecord();
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if(p != null) {
int idx = p.getPropertyValue();
- Sheet sheet = shape.getSheet();
- SlideShow ppt = sheet.getSlideShow();
+ HSLFSheet sheet = shape.getSheet();
+ HSLFSlideShow ppt = sheet.getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
index 6ff4870386..6d1365efbe 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
@@ -43,7 +43,7 @@ public final class TestFreeform extends TestCase {
path1.lineTo(100, 200);
path1.closePath();
- Freeform p = new Freeform();
+ HSLFFreeformShape p = new HSLFFreeformShape();
p.setPath(path1);
java.awt.Shape path2 = p.getOutline();
@@ -54,7 +54,7 @@ public final class TestFreeform extends TestCase {
GeneralPath path1 = new GeneralPath(new Line2D.Double(100, 100, 200, 100));
- Freeform p = new Freeform();
+ HSLFFreeformShape p = new HSLFFreeformShape();
p.setPath(path1);
java.awt.Shape path2 = p.getOutline();
@@ -65,7 +65,7 @@ public final class TestFreeform extends TestCase {
GeneralPath path1 = new GeneralPath(new Rectangle2D.Double(100, 100, 200, 50));
- Freeform p = new Freeform();
+ HSLFFreeformShape p = new HSLFFreeformShape();
p.setPath(path1);
java.awt.Shape path2 = p.getOutline();
@@ -78,7 +78,7 @@ public final class TestFreeform extends TestCase {
*/
public void test54188() {
- Freeform p = new Freeform();
+ HSLFFreeformShape p = new HSLFFreeformShape();
GeneralPath path = (GeneralPath)p.getOutline();
GeneralPath emptyPath = new GeneralPath();
assertEquals(emptyPath.getBounds2D(), path.getBounds2D());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
index 1e86b8c3af..8239a359d5 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
@@ -18,7 +18,7 @@
package org.apache.poi.hslf.model;
import java.io.*;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
import junit.framework.TestCase;
@@ -33,7 +33,7 @@ public final class TestHeadersFooters extends TestCase
public void testRead() throws Exception
{
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("headers_footers.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("headers_footers.ppt"));
HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
assertTrue(slideHdd.isFooterVisible());
@@ -53,7 +53,7 @@ public final class TestHeadersFooters extends TestCase
assertTrue(notesHdd.isUserDateVisible());
assertNull(notesHdd.getDateTimeText());
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
//the first slide uses presentation-scope headers / footers
HeadersFooters hd1 = slide[0].getHeadersFooters();
assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible());
@@ -77,7 +77,7 @@ public final class TestHeadersFooters extends TestCase
*/
public void testReadNoHeadersFooters() throws Exception
{
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
assertFalse(slideHdd.isFooterVisible());
@@ -97,7 +97,7 @@ public final class TestHeadersFooters extends TestCase
assertFalse(notesHdd.isUserDateVisible());
assertNull(notesHdd.getDateTimeText());
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
for(int i=0 ; i < slide.length; i++){
HeadersFooters hd1 = slide[i].getHeadersFooters();
assertFalse(hd1.isFooterVisible());
@@ -114,7 +114,7 @@ public final class TestHeadersFooters extends TestCase
*/
public void testRead2007() throws Exception
{
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("headers_footers_2007.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("headers_footers_2007.ppt"));
HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
assertTrue(slideHdd.isFooterVisible());
@@ -137,7 +137,7 @@ public final class TestHeadersFooters extends TestCase
//assertEquals("08/12/08", notesHdd.getDateTimeText());
//per-slide headers / footers
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
//the first slide uses presentation-scope headers / footers
HeadersFooters hd1 = slide[0].getHeadersFooters();
assertTrue(hd1.isFooterVisible());
@@ -174,7 +174,7 @@ public final class TestHeadersFooters extends TestCase
public void testCreateSlideFooters() throws Exception
{
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
HeadersFooters hdd = ppt.getSlideHeadersFooters();
hdd.setFootersText("My slide footer");
hdd.setSlideNumberVisible(true);
@@ -183,7 +183,7 @@ public final class TestHeadersFooters extends TestCase
ppt.write(out);
byte[] b = out.toByteArray();
- SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
+ HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(b));
HeadersFooters hdd2 = ppt2.getSlideHeadersFooters();
assertTrue(hdd2.isSlideNumberVisible());
assertTrue(hdd2.isFooterVisible());
@@ -192,7 +192,7 @@ public final class TestHeadersFooters extends TestCase
public void testCreateNotesFooters() throws Exception
{
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
HeadersFooters hdd = ppt.getNotesHeadersFooters();
hdd.setFootersText("My notes footer");
hdd.setHeaderText("My notes header");
@@ -202,7 +202,7 @@ public final class TestHeadersFooters extends TestCase
ppt.write(out);
byte[] b = out.toByteArray();
- SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b));
+ HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(b));
HeadersFooters hdd2 = ppt2.getNotesHeadersFooters();
assertTrue(hdd2.isSlideNumberVisible());
assertTrue(hdd2.isFooterVisible());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java
index 6f9f9eb8b4..83e6ca6582 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java
@@ -19,7 +19,7 @@ package org.apache.poi.hslf.model;
import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -31,10 +31,10 @@ public final class TestHyperlink extends TestCase {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
public void testTextRunHyperlinks() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("WithLinks.ppt"));
- TextRun[] run;
- Slide slide;
+ HSLFTextParagraph[] run;
+ HSLFSlide slide;
slide = ppt.getSlides()[0];
run = slide.getTextRuns();
for (int i = 0; i < run.length; i++) {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
index 9de8cad43e..11a64f6379 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java
@@ -23,7 +23,7 @@ import junit.framework.TestCase;
import org.apache.poi.hslf.blip.BitmapPainter;
import org.apache.poi.hslf.blip.ImagePainter;
-import org.apache.poi.hslf.usermodel.PictureData;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
/**
* Test Picture shape.
@@ -36,19 +36,19 @@ public final class TestImagePainter extends TestCase {
public CustomImagePainter() {
// no fields to initialise
}
- public void paint(Graphics2D graphics, PictureData pict, Picture parent){
+ public void paint(Graphics2D graphics, HSLFPictureData pict, HSLFPictureShape parent){
//do noting
}
}
public void testImagePainter() {
- ImagePainter pntr = PictureData.getImagePainter(Picture.PNG);
- assertTrue(PictureData.getImagePainter(Picture.PNG) instanceof BitmapPainter);
- assertTrue(PictureData.getImagePainter(Picture.JPEG) instanceof BitmapPainter);
- assertTrue(PictureData.getImagePainter(Picture.DIB) instanceof BitmapPainter);
+ ImagePainter pntr = HSLFPictureData.getImagePainter(HSLFPictureShape.PNG);
+ assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.PNG) instanceof BitmapPainter);
+ assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.JPEG) instanceof BitmapPainter);
+ assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.DIB) instanceof BitmapPainter);
- PictureData.setImagePainter(Picture.WMF, new CustomImagePainter());
- assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainter);
+ HSLFPictureData.setImagePainter(HSLFPictureShape.WMF, new CustomImagePainter());
+ assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.WMF) instanceof CustomImagePainter);
}
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java
index 735fa30466..413ff8ebe8 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java
@@ -21,7 +21,7 @@ import java.awt.Color;
import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
/**
* Test Line shape.
@@ -31,9 +31,9 @@ import org.apache.poi.hslf.usermodel.SlideShow;
public final class TestLine extends TestCase {
public void testCreateLines() {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
slide.addTitle().setText("Lines tester");
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java
index 9460642bb4..1b5bbd3298 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java
@@ -23,7 +23,7 @@ import java.io.ByteArrayOutputStream;
import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -36,13 +36,13 @@ public final class TestMovieShape extends TestCase {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
public void testCreate() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
String path = "/test-movie.mpg";
int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);
- int thumbnailIdx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG);
+ int thumbnailIdx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);
shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
@@ -56,7 +56,7 @@ public final class TestMovieShape extends TestCase {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
slide = ppt.getSlides()[0];
shape = (MovieShape)slide.getShapes()[0];
assertEquals(path, shape.getPath());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
index 249c4ee964..410f48226a 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
@@ -28,10 +28,9 @@ import java.io.InputStream;
import junit.framework.TestCase;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.ObjectData;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFObjectData;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.HWPFDocument;
@@ -46,31 +45,31 @@ public final class TestOleEmbedding extends TestCase {
* @throws Exception if an error occurs.
*/
public void testOleEmbedding2003() throws Exception {
- HSLFSlideShow slideShow = new HSLFSlideShow(_slTests.openResourceAsStream("ole2-embedding-2003.ppt"));
+ HSLFSlideShowImpl slideShow = new HSLFSlideShowImpl(_slTests.openResourceAsStream("ole2-embedding-2003.ppt"));
// Placeholder EMFs for clients that don't support the OLE components.
- PictureData[] pictures = slideShow.getPictures();
+ HSLFPictureData[] pictures = slideShow.getPictures();
assertEquals("Should be two pictures", 2, pictures.length);
//assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData());
//assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData());
// Actual embedded objects.
- ObjectData[] objects = slideShow.getEmbeddedObjects();
+ HSLFObjectData[] objects = slideShow.getEmbeddedObjects();
assertEquals("Should be two objects", 2, objects.length);
//assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData());
//assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData());
}
public void testOLEShape() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("ole2-embedding-2003.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("ole2-embedding-2003.ppt"));
- Slide slide = ppt.getSlides()[0];
+ HSLFSlide slide = ppt.getSlides()[0];
HSLFShape[] sh = slide.getShapes();
int cnt = 0;
for (int i = 0; i < sh.length; i++) {
if(sh[i] instanceof OLEShape){
cnt++;
OLEShape ole = (OLEShape)sh[i];
- ObjectData data = ole.getObjectData();
+ HSLFObjectData data = ole.getObjectData();
if("Worksheet".equals(ole.getInstanceName())){
//Voila! we created a workbook from the embedded OLE data
HSSFWorkbook wb = new HSSFWorkbook(data.getData());
@@ -94,11 +93,11 @@ public final class TestOleEmbedding extends TestCase {
}
public void testEmbedding() throws Exception {
- HSLFSlideShow _hslfSlideShow = HSLFSlideShow.create();
- SlideShow ppt = new SlideShow(_hslfSlideShow);
+ HSLFSlideShowImpl _hslfSlideShow = HSLFSlideShowImpl.create();
+ HSLFSlideShow ppt = new HSLFSlideShow(_hslfSlideShow);
File pict = POIDataSamples.getSlideShowInstance().getFile("clock.jpg");
- int pictId = ppt.addPicture(pict, Picture.JPEG);
+ int pictId = ppt.addPicture(pict, HSLFPictureShape.JPEG);
InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("Employee.xls");
POIFSFileSystem poiData1 = new POIFSFileSystem(is);
@@ -106,14 +105,14 @@ public final class TestOleEmbedding extends TestCase {
int oleObjectId1 = ppt.addEmbed(poiData1);
- Slide slide1 = ppt.createSlide();
+ HSLFSlide slide1 = ppt.createSlide();
OLEShape oleShape1 = new OLEShape(pictId);
oleShape1.setObjectID(oleObjectId1);
slide1.addShape(oleShape1);
oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100));
// add second slide with different order in object creation
- Slide slide2 = ppt.createSlide();
+ HSLFSlide slide2 = ppt.createSlide();
OLEShape oleShape2 = new OLEShape(pictId);
is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleWithImages.xls");
@@ -129,7 +128,7 @@ public final class TestOleEmbedding extends TestCase {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ppt.write(bos);
- ppt = new SlideShow(new ByteArrayInputStream(bos.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(bos.toByteArray()));
OLEShape comp = (OLEShape)ppt.getSlides()[0].getShapes()[0];
byte compData[] = IOUtils.toByteArray(comp.getObjectData().getData());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java
index aff848dfc5..fb04ccf5dd 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java
@@ -18,7 +18,7 @@
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
/**
* Test adding fonts to the presenataion resources
@@ -28,7 +28,7 @@ import org.apache.poi.hslf.usermodel.SlideShow;
public final class TestPPFont extends TestCase{
public void testCreate() {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
assertEquals(1, ppt.getNumberOfFonts());
assertEquals("Arial", ppt.getFont(0).getFontName());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
index b58dbadecf..b71ce01035 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
@@ -18,12 +18,11 @@
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.HSLFSlideShow;
+
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
import java.awt.*;
-import java.awt.Rectangle;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
@@ -34,10 +33,10 @@ import java.io.ByteArrayInputStream;
*/
public final class TestPPGraphics2D extends TestCase {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
- private SlideShow ppt;
+ private HSLFSlideShow ppt;
protected void setUp() throws Exception {
- ppt = new SlideShow(_slTests.openResourceAsStream("empty.ppt"));
+ ppt = new HSLFSlideShow(_slTests.openResourceAsStream("empty.ppt"));
}
public void testGraphics() throws Exception {
@@ -45,7 +44,7 @@ public final class TestPPGraphics2D extends TestCase {
assertEquals(0, ppt.getSlides().length);
// Add a slide
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
assertEquals(1, ppt.getSlides().length);
// Add some stuff into it
@@ -73,7 +72,7 @@ public final class TestPPGraphics2D extends TestCase {
out.close();
// And read it back in
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertEquals(1, ppt.getSlides().length);
slide = ppt.getSlides()[0];
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
index fabf63beee..08077f0e00 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
@@ -36,9 +36,8 @@ import javax.imageio.ImageIO;
import org.apache.poi.POIDataSamples;
import org.apache.poi.ddf.EscherBSERecord;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.util.JvmBugs;
import org.junit.Ignore;
import org.junit.Test;
@@ -58,16 +57,16 @@ public final class TestPicture {
*/
@Test
public void multiplePictures() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide s = ppt.createSlide();
- Slide s2 = ppt.createSlide();
- Slide s3 = ppt.createSlide();
+ HSLFSlide s = ppt.createSlide();
+ HSLFSlide s2 = ppt.createSlide();
+ HSLFSlide s3 = ppt.createSlide();
- int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), Picture.JPEG);
- Picture pict = new Picture(idx);
- Picture pict2 = new Picture(idx);
- Picture pict3 = new Picture(idx);
+ int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
+ HSLFPictureShape pict2 = new HSLFPictureShape(idx);
+ HSLFPictureShape pict3 = new HSLFPictureShape(idx);
pict.setAnchor(new Rectangle(10,10,100,100));
s.addShape(pict);
@@ -93,12 +92,12 @@ public final class TestPicture {
*/
@Test
public void bug46122() {
- SlideShow ppt = new SlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
- Picture pict = new Picture(-1); //index to non-existing picture data
+ HSLFPictureShape pict = new HSLFPictureShape(-1); //index to non-existing picture data
pict.setSheet(slide);
- PictureData data = pict.getPictureData();
+ HSLFPictureData data = pict.getPictureData();
assertNull(data);
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
@@ -108,9 +107,9 @@ public final class TestPicture {
@Test
public void macImages() throws Exception {
- HSLFSlideShow hss = new HSLFSlideShow(_slTests.openResourceAsStream("53446.ppt"));
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("53446.ppt"));
- PictureData[] pictures = hss.getPictures();
+ HSLFPictureData[] pictures = hss.getPictures();
assertEquals(15, pictures.length);
int[][] expectedSizes = {
@@ -134,7 +133,7 @@ public final class TestPicture {
for (int i = 0; i < pictures.length; i++) {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(pictures[i].getData()));
- if (pictures[i].getType() != Picture.WMF && pictures[i].getType() != Picture.EMF) {
+ if (pictures[i].getType() != HSLFPictureShape.WMF && pictures[i].getType() != HSLFPictureShape.EMF) {
assertNotNull(image);
int[] dimensions = expectedSizes[i];
@@ -163,12 +162,12 @@ public final class TestPicture {
// System.out.println("########################");
InputStream is = _slTests.openResourceAsStream("54541_cropped_bitmap.ppt");
- SlideShow ss = new SlideShow(is);
+ HSLFSlideShow ss = new HSLFSlideShow(is);
is.close();
Dimension pg = ss.getPageSize();
int i=1;
- for(Slide slide : ss.getSlides()) {
+ for(HSLFSlide slide : ss.getSlides()) {
BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
fixFonts(graphics);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java
index 23b798fd6f..e1703626ca 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java
@@ -18,9 +18,9 @@
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.HSLFSlideShow;
+
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
@@ -36,15 +36,15 @@ public final class TestSetBoldItalic extends TestCase {
* and set some of the style attributes
*/
public void testTextBoxWrite() throws Exception {
- SlideShow ppt = new SlideShow();
- Slide sl = ppt.createSlide();
- RichTextRun rt;
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide sl = ppt.createSlide();
+ HSLFTextRun rt;
String val = "Hello, World!";
// Create a new textbox, and give it lots of properties
- TextBox txtbox = new TextBox();
- rt = txtbox.getTextRun().getRichTextRuns()[0];
+ HSLFTextBox txtbox = new HSLFTextBox();
+ rt = txtbox.getTextParagraph().getRichTextRuns()[0];
txtbox.setText(val);
rt.setFontSize(42);
rt.setBold(true);
@@ -53,7 +53,7 @@ public final class TestSetBoldItalic extends TestCase {
sl.addShape(txtbox);
// Check it before save
- rt = txtbox.getTextRun().getRichTextRuns()[0];
+ rt = txtbox.getTextParagraph().getRichTextRuns()[0];
assertEquals(val, rt.getText());
assertEquals(42, rt.getFontSize());
assertTrue(rt.isBold());
@@ -64,11 +64,11 @@ public final class TestSetBoldItalic extends TestCase {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
sl = ppt.getSlides()[0];
- txtbox = (TextBox)sl.getShapes()[0];
- rt = txtbox.getTextRun().getRichTextRuns()[0];
+ txtbox = (HSLFTextBox)sl.getShapes()[0];
+ rt = txtbox.getTextParagraph().getRichTextRuns()[0];
// Check after save
assertEquals(val, rt.getText());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
index 700b758a1e..9456c211f8 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
@@ -38,9 +38,8 @@ import org.apache.poi.ddf.EscherDggRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherSimpleProperty;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.ShapeType;
import org.junit.Before;
import org.junit.Test;
@@ -53,17 +52,17 @@ import org.junit.Test;
public final class TestShapes {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
- private SlideShow ppt;
- private SlideShow pptB;
+ private HSLFSlideShow ppt;
+ private HSLFSlideShow pptB;
@Before
public void setUp() throws Exception {
InputStream is1 = null, is2 = null;
try {
is1 = _slTests.openResourceAsStream("empty.ppt");
- ppt = new SlideShow(is1);
+ ppt = new HSLFSlideShow(is1);
is2 = _slTests.openResourceAsStream("empty_textbox.ppt");
- pptB = new SlideShow(is2);
+ pptB = new HSLFSlideShow(is2);
} finally {
is1.close();
is2.close();
@@ -72,7 +71,7 @@ public final class TestShapes {
@Test
public void graphics() throws Exception {
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
Line line = new Line();
java.awt.Rectangle lineAnchor = new java.awt.Rectangle(100, 200, 50, 60);
@@ -82,7 +81,7 @@ public final class TestShapes {
line.setLineColor(Color.red);
slide.addShape(line);
- AutoShape ellipse = new AutoShape(ShapeType.ELLIPSE);
+ HSLFAutoShape ellipse = new HSLFAutoShape(ShapeType.ELLIPSE);
java.awt.Rectangle ellipseAnchor = new Rectangle(320, 154, 55, 111);
ellipse.setAnchor(ellipseAnchor);
ellipse.setLineWidth(2);
@@ -97,7 +96,7 @@ public final class TestShapes {
//read ppt from byte array
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertEquals(1, ppt.getSlides().length);
slide = ppt.getSlides()[0];
@@ -107,7 +106,7 @@ public final class TestShapes {
assertTrue(shape[0] instanceof Line); //group shape
assertEquals(lineAnchor, shape[0].getAnchor()); //group shape
- assertTrue(shape[1] instanceof AutoShape); //group shape
+ assertTrue(shape[1] instanceof HSLFAutoShape); //group shape
assertEquals(ellipseAnchor, shape[1].getAnchor()); //group shape
}
@@ -117,17 +116,17 @@ public final class TestShapes {
*/
@Test
public void textBoxRead() throws Exception {
- ppt = new SlideShow(_slTests.openResourceAsStream("with_textbox.ppt"));
- Slide sl = ppt.getSlides()[0];
+ ppt = new HSLFSlideShow(_slTests.openResourceAsStream("with_textbox.ppt"));
+ HSLFSlide sl = ppt.getSlides()[0];
HSLFShape[] sh = sl.getShapes();
for (int i = 0; i < sh.length; i++) {
- assertTrue(sh[i] instanceof TextBox);
- TextBox txtbox = (TextBox)sh[i];
+ assertTrue(sh[i] instanceof HSLFTextBox);
+ HSLFTextBox txtbox = (HSLFTextBox)sh[i];
String text = txtbox.getText();
assertNotNull(text);
- assertEquals(txtbox.getTextRun().getRichTextRuns().length, 1);
- RichTextRun rt = txtbox.getTextRun().getRichTextRuns()[0];
+ assertEquals(txtbox.getTextParagraph().getRichTextRuns().length, 1);
+ HSLFTextRun rt = txtbox.getTextParagraph().getRichTextRuns()[0];
if (text.equals("Hello, World!!!")){
assertEquals(32, rt.getFontSize());
@@ -153,15 +152,15 @@ public final class TestShapes {
*/
@Test
public void textBoxWriteBytes() throws Exception {
- ppt = new SlideShow();
- Slide sl = ppt.createSlide();
- RichTextRun rt;
+ ppt = new HSLFSlideShow();
+ HSLFSlide sl = ppt.createSlide();
+ HSLFTextRun rt;
String val = "Hello, World!";
// Create a new textbox, and give it lots of properties
- TextBox txtbox = new TextBox();
- rt = txtbox.getTextRun().getRichTextRuns()[0];
+ HSLFTextBox txtbox = new HSLFTextBox();
+ rt = txtbox.getTextParagraph().getRichTextRuns()[0];
txtbox.setText(val);
rt.setFontName("Arial");
rt.setFontSize(42);
@@ -172,7 +171,7 @@ public final class TestShapes {
sl.addShape(txtbox);
// Check it before save
- rt = txtbox.getTextRun().getRichTextRuns()[0];
+ rt = txtbox.getTextParagraph().getRichTextRuns()[0];
assertEquals(val, rt.getText());
assertEquals(42, rt.getFontSize());
assertTrue(rt.isBold());
@@ -186,11 +185,11 @@ public final class TestShapes {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
sl = ppt.getSlides()[0];
- txtbox = (TextBox)sl.getShapes()[0];
- rt = txtbox.getTextRun().getRichTextRuns()[0];
+ txtbox = (HSLFTextBox)sl.getShapes()[0];
+ rt = txtbox.getTextParagraph().getRichTextRuns()[0];
// Check after save
assertEquals(val, rt.getText());
@@ -208,8 +207,8 @@ public final class TestShapes {
@Test
public void emptyTextBox() {
assertEquals(2, pptB.getSlides().length);
- Slide s1 = pptB.getSlides()[0];
- Slide s2 = pptB.getSlides()[1];
+ HSLFSlide s1 = pptB.getSlides()[0];
+ HSLFSlide s2 = pptB.getSlides()[1];
// Check we can get the shapes count
assertEquals(2, s1.getShapes().length);
@@ -231,11 +230,11 @@ public final class TestShapes {
}
private void textBoxSet(String filename) throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream(filename));
- Slide[] sl = ppt.getSlides();
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(filename));
+ HSLFSlide[] sl = ppt.getSlides();
for (int k = 0; k < sl.length; k++) {
ArrayList lst1 = new ArrayList();
- TextRun[] txt = sl[k].getTextRuns();
+ HSLFTextParagraph[] txt = sl[k].getTextRuns();
for (int i = 0; i < txt.length; i++) {
lst1.add(txt[i].getText());
}
@@ -243,8 +242,8 @@ public final class TestShapes {
ArrayList lst2 = new ArrayList();
HSLFShape[] sh = sl[k].getShapes();
for (int i = 0; i < sh.length; i++) {
- if (sh[i] instanceof TextShape){
- TextShape tbox = (TextShape)sh[i];
+ if (sh[i] instanceof HSLFTextShape){
+ HSLFTextShape tbox = (HSLFTextShape)sh[i];
lst2.add(tbox.getText());
}
}
@@ -258,9 +257,9 @@ public final class TestShapes {
*/
@Test
public void shapeGroup() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
Dimension pgsize = ppt.getPageSize();
HSLFGroupShape group = new HSLFGroupShape();
@@ -268,8 +267,8 @@ public final class TestShapes {
group.setAnchor(new Rectangle(0, 0, (int)pgsize.getWidth(), (int)pgsize.getHeight()));
slide.addShape(group);
- int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), Picture.JPEG);
- Picture pict = new Picture(idx, group);
+ int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG);
+ HSLFPictureShape pict = new HSLFPictureShape(idx, group);
pict.setAnchor(new Rectangle(0, 0, 200, 200));
group.addShape(pict);
@@ -283,7 +282,7 @@ public final class TestShapes {
out.close();
ByteArrayInputStream is = new ByteArrayInputStream(out.toByteArray());
- ppt = new SlideShow(is);
+ ppt = new HSLFSlideShow(is);
is.close();
slide = ppt.getSlides()[0];
@@ -295,10 +294,10 @@ public final class TestShapes {
group = (HSLFGroupShape)shape[0];
HSLFShape[] grshape = group.getShapes();
assertEquals(2, grshape.length);
- assertTrue(grshape[0] instanceof Picture);
+ assertTrue(grshape[0] instanceof HSLFPictureShape);
assertTrue(grshape[1] instanceof Line);
- pict = (Picture)grshape[0];
+ pict = (HSLFPictureShape)grshape[0];
assertEquals(new Rectangle(0, 0, 200, 200), pict.getAnchor());
line = (Line)grshape[1];
@@ -311,8 +310,8 @@ public final class TestShapes {
@Test
public void removeShapes() throws IOException {
String file = "with_textbox.ppt";
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream(file));
- Slide sl = ppt.getSlides()[0];
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(file));
+ HSLFSlide sl = ppt.getSlides()[0];
HSLFShape[] sh = sl.getShapes();
assertEquals("expected four shaped in " + file, 4, sh.length);
//remove all
@@ -328,30 +327,30 @@ public final class TestShapes {
ppt.write(out);
out.close();
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
sl = ppt.getSlides()[0];
assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
}
@Test
public void lineWidth() {
- SimpleShape sh = new AutoShape(ShapeType.RT_TRIANGLE);
+ HSLFSimpleShape sh = new HSLFAutoShape(ShapeType.RT_TRIANGLE);
EscherOptRecord opt = sh.getEscherOptRecord();
- EscherSimpleProperty prop = SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
+ EscherSimpleProperty prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
assertNull(prop);
- assertEquals(SimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0);
+ assertEquals(HSLFSimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0);
sh.setLineWidth(1.0);
- prop = SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
+ prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
assertNotNull(prop);
assertEquals(1.0, sh.getLineWidth(), 0);
}
@Test
public void shapeId() {
- SlideShow ppt = new SlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
HSLFShape shape = null;
//EscherDgg is a document-level record which keeps track of the drawing groups
@@ -400,25 +399,25 @@ public final class TestShapes {
@Test
public void lineColor() throws IOException {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("51731.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("51731.ppt"));
HSLFShape[] shape = ppt.getSlides()[0].getShapes();
assertEquals(4, shape.length);
- TextShape sh1 = (TextShape)shape[0];
+ HSLFTextShape sh1 = (HSLFTextShape)shape[0];
assertEquals("Hello Apache POI", sh1.getText());
assertNull(sh1.getLineColor());
- TextShape sh2 = (TextShape)shape[1];
+ HSLFTextShape sh2 = (HSLFTextShape)shape[1];
assertEquals("Why are you showing this border?", sh2.getText());
assertNull(sh2.getLineColor());
- TextShape sh3 = (TextShape)shape[2];
+ HSLFTextShape sh3 = (HSLFTextShape)shape[2];
assertEquals("Text in a black border", sh3.getText());
assertEquals(Color.black, sh3.getLineColor());
assertEquals(0.75, sh3.getLineWidth(), 0);
- TextShape sh4 = (TextShape)shape[3];
+ HSLFTextShape sh4 = (HSLFTextShape)shape[3];
assertEquals("Border width is 5 pt", sh4.getText());
assertEquals(Color.black, sh4.getLineColor());
assertEquals(5.0, sh4.getLineWidth(), 0);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
index a22e7eb3f9..60b8ca42e2 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
@@ -23,7 +23,7 @@ import junit.framework.TestCase;
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.PPDrawing;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -42,7 +42,7 @@ public final class TestSheet extends TestCase {
String[] tests = {"SampleShow.ppt", "backgrounds.ppt", "text_shapes.ppt", "pictures.ppt"};
for (String file : tests) {
try {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream(file));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(file));
doSlideShow(ppt);
} catch (EncryptedPowerPointFileException e){
; //skip encrypted ppt
@@ -50,21 +50,21 @@ public final class TestSheet extends TestCase {
}
}
- private void doSlideShow(SlideShow ppt) {
- Slide[] slide = ppt.getSlides();
+ private void doSlideShow(HSLFSlideShow ppt) {
+ HSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
verify(slide[i]);
- Notes notes = slide[i].getNotesSheet();
+ HSLFNotes notes = slide[i].getNotesSheet();
if(notes != null) verify(notes);
- MasterSheet master = slide[i].getMasterSheet();
+ HSLFMasterSheet master = slide[i].getMasterSheet();
assertNotNull(master);
verify(master);
}
}
- private void verify(Sheet sheet){
+ private void verify(HSLFSheet sheet){
assertNotNull(sheet.getSlideShow());
ColorSchemeAtom colorscheme = sheet.getColorScheme();
@@ -73,13 +73,13 @@ public final class TestSheet extends TestCase {
PPDrawing ppdrawing = sheet.getPPDrawing();
assertNotNull(ppdrawing);
- Background background = sheet.getBackground();
+ HSLFBackground background = sheet.getBackground();
assertNotNull(background);
assertTrue(sheet._getSheetNumber() != 0);
assertTrue(sheet._getSheetRefId() != 0);
- TextRun[] txt = sheet.getTextRuns();
+ HSLFTextParagraph[] txt = sheet.getTextRuns();
if (txt == null) {
throw new AssertionFailedError("no text runs");
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java
index 71c95f87b7..2d4fe15131 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java
@@ -20,9 +20,8 @@ package org.apache.poi.hslf.model;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.record.SlideAtom;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -32,16 +31,16 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestSlideChangeNotes extends TestCase {
// SlideShow primed on the test data
- private SlideShow ss;
+ private HSLFSlideShow ss;
public TestSlideChangeNotes() throws Exception {
POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
}
public void testSetToNone() {
- Slide slideOne = ss.getSlides()[0];
+ HSLFSlide slideOne = ss.getSlides()[0];
SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
slideOne.setNotes(null);
@@ -50,8 +49,8 @@ public final class TestSlideChangeNotes extends TestCase {
}
public void testSetToSomething() {
- Slide slideOne = ss.getSlides()[0];
- Notes notesOne = ss.getNotes()[1];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFNotes notesOne = ss.getNotes()[1];
SlideAtom sa = slideOne.getSlideRecord().getSlideAtom();
slideOne.setNotes(notesOne);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
index 45c3c0c2bc..ffb6563da5 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
@@ -22,12 +22,11 @@ import java.io.ByteArrayOutputStream;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
import org.apache.poi.hslf.record.Environment;
import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -43,7 +42,7 @@ public final class TestSlideMaster extends TestCase{
* Check we can read their attributes.
*/
public void testSlideMaster() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
Environment env = ppt.getDocumentRecord().getEnvironment();
@@ -83,7 +82,7 @@ public final class TestSlideMaster extends TestCase{
* Test we can read default text attributes for a title master sheet
*/
public void testTitleMasterTextAttributes() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
TitleMaster[] master = ppt.getTitleMasters();
assertEquals(1, master.length);
@@ -104,14 +103,14 @@ public final class TestSlideMaster extends TestCase{
* Slide 3 has title layout and follows the TitleMaster. Verify that.
*/
public void testTitleMaster() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
- Slide slide = ppt.getSlides()[2];
- MasterSheet masterSheet = slide.getMasterSheet();
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
+ HSLFSlide slide = ppt.getSlides()[2];
+ HSLFMasterSheet masterSheet = slide.getMasterSheet();
assertTrue(masterSheet instanceof TitleMaster);
- TextRun[] txt = slide.getTextRuns();
+ HSLFTextParagraph[] txt = slide.getTextRuns();
for (int i = 0; i < txt.length; i++) {
- RichTextRun rt = txt[i].getRichTextRuns()[0];
+ HSLFTextRun rt = txt[i].getRichTextRuns()[0];
switch(txt[i].getRunType()){
case TextHeaderAtom.CENTER_TITLE_TYPE:
assertEquals("Arial", rt.getFontName());
@@ -133,20 +132,20 @@ public final class TestSlideMaster extends TestCase{
* If a style attribute is not set ensure it is read from the master
*/
public void testMasterAttributes() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
- Slide[] slide = ppt.getSlides();
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
+ HSLFSlide[] slide = ppt.getSlides();
assertEquals(3, slide.length);
- TextRun[] trun;
+ HSLFTextParagraph[] trun;
trun = slide[0].getTextRuns();
for (int i = 0; i < trun.length; i++) {
if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){
- RichTextRun rt = trun[i].getRichTextRuns()[0];
+ HSLFTextRun rt = trun[i].getRichTextRuns()[0];
assertEquals(40, rt.getFontSize());
assertEquals(true, rt.isUnderlined());
assertEquals("Arial", rt.getFontName());
} else if (trun[i].getRunType() == TextHeaderAtom.BODY_TYPE){
- RichTextRun rt;
+ HSLFTextRun rt;
rt = trun[i].getRichTextRuns()[0];
assertEquals(0, rt.getIndentLevel());
assertEquals(32, rt.getFontSize());
@@ -163,12 +162,12 @@ public final class TestSlideMaster extends TestCase{
trun = slide[1].getTextRuns();
for (int i = 0; i < trun.length; i++) {
if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){
- RichTextRun rt = trun[i].getRichTextRuns()[0];
+ HSLFTextRun rt = trun[i].getRichTextRuns()[0];
assertEquals(48, rt.getFontSize());
assertEquals(true, rt.isItalic());
assertEquals("Georgia", rt.getFontName());
} else if (trun[i].getRunType() == TextHeaderAtom.BODY_TYPE){
- RichTextRun rt;
+ HSLFTextRun rt;
rt = trun[i].getRichTextRuns()[0];
assertEquals(0, rt.getIndentLevel());
assertEquals(32, rt.getFontSize());
@@ -182,9 +181,9 @@ public final class TestSlideMaster extends TestCase{
* Check we can dynamically assign a slide master to a slide.
*/
public void testChangeSlideMaster() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
SlideMaster[] master = ppt.getSlidesMasters();
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
int sheetNo;
//each slide uses its own master
@@ -203,7 +202,7 @@ public final class TestSlideMaster extends TestCase{
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
master = ppt.getSlidesMasters();
slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
@@ -216,19 +215,19 @@ public final class TestSlideMaster extends TestCase{
* (typical for the "bullted body" placeholder)
*/
public void testIndentation() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
- Slide slide = ppt.getSlides()[0];
- TextRun[] trun;
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
+ HSLFSlide slide = ppt.getSlides()[0];
+ HSLFTextParagraph[] trun;
trun = slide.getTextRuns();
for (int i = 0; i < trun.length; i++) {
if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){
- RichTextRun rt = trun[i].getRichTextRuns()[0];
+ HSLFTextRun rt = trun[i].getRichTextRuns()[0];
assertEquals(40, rt.getFontSize());
assertEquals(true, rt.isUnderlined());
assertEquals("Arial", rt.getFontName());
} else if (trun[i].getRunType() == TextHeaderAtom.BODY_TYPE){
- RichTextRun[] rt = trun[i].getRichTextRuns();
+ HSLFTextRun[] rt = trun[i].getRichTextRuns();
for (int j = 0; j < rt.length; j++) {
int indent = rt[j].getIndentLevel();
switch (indent){
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java
index 11889f4409..f5e0abef59 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java
@@ -18,8 +18,8 @@
package org.apache.poi.hslf.model;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.SlideShow;
+
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
import java.io.ByteArrayOutputStream;
@@ -39,10 +39,10 @@ public final class TestSlides extends TestCase {
* @throws Exception
*/
public void testAddSlides1() throws Exception {
- SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
+ HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
assertTrue(ppt.getSlides().length == 0);
- Slide s1 = ppt.createSlide();
+ HSLFSlide s1 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 1);
assertEquals(3, s1._getSheetRefId());
assertEquals(256, s1._getSheetNumber());
@@ -53,7 +53,7 @@ public final class TestSlides extends TestCase {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertTrue(ppt.getSlides().length == 1);
}
@@ -62,16 +62,16 @@ public final class TestSlides extends TestCase {
* @throws Exception
*/
public void testAddSlides2() throws Exception {
- SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
+ HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
assertTrue(ppt.getSlides().length == 0);
- Slide s1 = ppt.createSlide();
+ HSLFSlide s1 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 1);
assertEquals(3, s1._getSheetRefId());
assertEquals(256, s1._getSheetNumber());
assertEquals(1, s1.getSlideNumber());
- Slide s2 = ppt.createSlide();
+ HSLFSlide s2 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 2);
assertEquals(4, s2._getSheetRefId());
assertEquals(257, s2._getSheetNumber());
@@ -82,7 +82,7 @@ public final class TestSlides extends TestCase {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertTrue(ppt.getSlides().length == 2);
}
@@ -91,22 +91,22 @@ public final class TestSlides extends TestCase {
* @throws Exception
*/
public void testAddSlides3() throws Exception {
- SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
+ HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
assertTrue(ppt.getSlides().length == 0);
- Slide s1 = ppt.createSlide();
+ HSLFSlide s1 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 1);
assertEquals(3, s1._getSheetRefId());
assertEquals(256, s1._getSheetNumber());
assertEquals(1, s1.getSlideNumber());
- Slide s2 = ppt.createSlide();
+ HSLFSlide s2 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 2);
assertEquals(4, s2._getSheetRefId());
assertEquals(257, s2._getSheetNumber());
assertEquals(2, s2.getSlideNumber());
- Slide s3 = ppt.createSlide();
+ HSLFSlide s3 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 3);
assertEquals(5, s3._getSheetRefId());
assertEquals(258, s3._getSheetNumber());
@@ -118,7 +118,7 @@ public final class TestSlides extends TestCase {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertTrue(ppt.getSlides().length == 3);
// Check IDs are still right
@@ -139,22 +139,22 @@ public final class TestSlides extends TestCase {
*/
public void testAddSlides2to3() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- SlideShow ppt = new SlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
assertTrue(ppt.getSlides().length == 2);
// First slide is 256 / 4
- Slide s1 = ppt.getSlides()[0];
+ HSLFSlide s1 = ppt.getSlides()[0];
assertEquals(256, s1._getSheetNumber());
assertEquals(4, s1._getSheetRefId());
// Last slide is 257 / 6
- Slide s2 = ppt.getSlides()[1];
+ HSLFSlide s2 = ppt.getSlides()[1];
assertEquals(257, s2._getSheetNumber());
assertEquals(6, s2._getSheetRefId());
// Add another slide, goes in at the end
- Slide s3 = ppt.createSlide();
+ HSLFSlide s3 = ppt.createSlide();
assertTrue(ppt.getSlides().length == 3);
assertEquals(258, s3._getSheetNumber());
assertEquals(8, s3._getSheetRefId());
@@ -165,7 +165,7 @@ public final class TestSlides extends TestCase {
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertTrue(ppt.getSlides().length == 3);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
index 480fd8ab65..d3fb354063 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
@@ -23,7 +23,7 @@ import java.io.ByteArrayOutputStream;
import junit.framework.TestCase;
import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
/**
* Test Table
object.
@@ -36,16 +36,16 @@ public final class TestTable extends TestCase {
* Test that ShapeFactory works properly and returns Table
*/
public void testShapeFactory() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
Table tbl = new Table(2, 5);
slide.addShape(tbl);
TableCell cell = tbl.getCell(0, 0);
//table cells have type=TextHeaderAtom.OTHER_TYPE, see bug #46033
- assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextRun().getRunType());
+ assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextParagraph().getRunType());
assertTrue(slide.getShapes()[0] instanceof Table);
Table tbl2 = (Table)slide.getShapes()[0];
@@ -56,7 +56,7 @@ public final class TestTable extends TestCase {
ppt.write(out);
out.close();
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
slide = ppt.getSlides()[0];
assertTrue(slide.getShapes()[0] instanceof Table);
Table tbl3 = (Table)slide.getShapes()[0];
@@ -68,8 +68,8 @@ public final class TestTable extends TestCase {
* Error constructing Table when rownum=1
*/
public void test45889(){
- SlideShow ppt = new SlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
HSLFShape[] shapes;
Table tbl1 = new Table(1, 5);
assertEquals(5, tbl1.getNumberOfColumns());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java
index 1b0119307a..01ce6a0534 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java
@@ -30,8 +30,8 @@ import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.TextBytesAtom;
import org.apache.poi.hslf.record.TextCharsAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -43,24 +43,24 @@ public final class TestTextRun extends TestCase {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
// SlideShow primed on the test data
- private SlideShow ss;
- private SlideShow ssRich;
+ private HSLFSlideShow ss;
+ private HSLFSlideShow ssRich;
protected void setUp() throws IOException {
// Basic (non rich) test file
- ss = new SlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
// Rich test file
- ssRich = new SlideShow(_slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
+ ssRich = new HSLFSlideShow(_slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
}
/**
* Test to ensure that getting the text works correctly
*/
public void testGetText() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
assertEquals(2, textRuns.length);
@@ -74,8 +74,8 @@ public final class TestTextRun extends TestCase {
// Now check on a rich text run
- Slide slideOneR = ssRich.getSlides()[0];
- TextRun[] textRunsR = slideOneR.getTextRuns();
+ HSLFSlide slideOneR = ssRich.getSlides()[0];
+ HSLFTextParagraph[] textRunsR = slideOneR.getTextRuns();
assertEquals(2, textRunsR.length);
assertEquals("This is a title, it\u2019s in black", textRunsR[0].getText());
@@ -88,9 +88,9 @@ public final class TestTextRun extends TestCase {
* Test to ensure changing non rich text bytes->bytes works correctly
*/
public void testSetText() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- TextRun run = textRuns[0];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextParagraph run = textRuns[0];
// Check current text
assertEquals("This is a test title", run.getText());
@@ -110,8 +110,8 @@ public final class TestTextRun extends TestCase {
* chars works correctly
*/
public void testAdvancedSetText() {
- Slide slideOne = ss.getSlides()[0];
- TextRun run = slideOne.getTextRuns()[0];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph run = slideOne.getTextRuns()[0];
TextHeaderAtom tha = run._headerAtom;
TextBytesAtom tba = run._byteAtom;
@@ -171,19 +171,19 @@ public final class TestTextRun extends TestCase {
* set up for it
*/
public void testGetRichTextNonRich() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
assertEquals(2, textRuns.length);
- TextRun trA = textRuns[0];
- TextRun trB = textRuns[1];
+ HSLFTextParagraph trA = textRuns[0];
+ HSLFTextParagraph trB = textRuns[1];
assertEquals(1, trA.getRichTextRuns().length);
assertEquals(1, trB.getRichTextRuns().length);
- RichTextRun rtrA = trA.getRichTextRuns()[0];
- RichTextRun rtrB = trB.getRichTextRuns()[0];
+ HSLFTextRun rtrA = trA.getRichTextRuns()[0];
+ HSLFTextRun rtrB = trB.getRichTextRuns()[0];
assertEquals(trA.getText(), rtrA.getText());
assertEquals(trB.getText(), rtrB.getText());
@@ -198,21 +198,21 @@ public final class TestTextRun extends TestCase {
* Tests to ensure that the rich text runs are built up correctly
*/
public void testGetRichText() {
- Slide slideOne = ssRich.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
+ HSLFSlide slideOne = ssRich.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
assertEquals(2, textRuns.length);
- TextRun trA = textRuns[0];
- TextRun trB = textRuns[1];
+ HSLFTextParagraph trA = textRuns[0];
+ HSLFTextParagraph trB = textRuns[1];
assertEquals(1, trA.getRichTextRuns().length);
assertEquals(3, trB.getRichTextRuns().length);
- RichTextRun rtrA = trA.getRichTextRuns()[0];
- RichTextRun rtrB = trB.getRichTextRuns()[0];
- RichTextRun rtrC = trB.getRichTextRuns()[1];
- RichTextRun rtrD = trB.getRichTextRuns()[2];
+ HSLFTextRun rtrA = trA.getRichTextRuns()[0];
+ HSLFTextRun rtrB = trB.getRichTextRuns()[0];
+ HSLFTextRun rtrC = trB.getRichTextRuns()[1];
+ HSLFTextRun rtrD = trB.getRichTextRuns()[2];
assertEquals(trA.getText(), rtrA.getText());
@@ -244,12 +244,12 @@ public final class TestTextRun extends TestCase {
* ensuring that everything stays with the same default styling
*/
public void testSetTextWhereNotRich() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- TextRun trB = textRuns[1];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextParagraph trB = textRuns[1];
assertEquals(1, trB.getRichTextRuns().length);
- RichTextRun rtrB = trB.getRichTextRuns()[0];
+ HSLFTextRun rtrB = trB.getRichTextRuns()[0];
assertEquals(trB.getText(), rtrB.getText());
assertNull(rtrB._getRawCharacterStyle());
assertNull(rtrB._getRawParagraphStyle());
@@ -268,14 +268,14 @@ public final class TestTextRun extends TestCase {
* sets everything to the same styling
*/
public void testSetTextWhereRich() {
- Slide slideOne = ssRich.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- TextRun trB = textRuns[1];
+ HSLFSlide slideOne = ssRich.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextParagraph trB = textRuns[1];
assertEquals(3, trB.getRichTextRuns().length);
- RichTextRun rtrB = trB.getRichTextRuns()[0];
- RichTextRun rtrC = trB.getRichTextRuns()[1];
- RichTextRun rtrD = trB.getRichTextRuns()[2];
+ HSLFTextRun rtrB = trB.getRichTextRuns()[0];
+ HSLFTextRun rtrC = trB.getRichTextRuns()[1];
+ HSLFTextRun rtrD = trB.getRichTextRuns()[2];
TextPropCollection tpBP = rtrB._getRawParagraphStyle();
TextPropCollection tpBC = rtrB._getRawCharacterStyle();
TextPropCollection tpCP = rtrC._getRawParagraphStyle();
@@ -316,12 +316,12 @@ public final class TestTextRun extends TestCase {
* in a rich text run, that doesn't happen to actually be rich
*/
public void testChangeTextInRichTextRunNonRich() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- TextRun trB = textRuns[1];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextParagraph trB = textRuns[1];
assertEquals(1, trB.getRichTextRuns().length);
- RichTextRun rtrB = trB.getRichTextRuns()[0];
+ HSLFTextRun rtrB = trB.getRichTextRuns()[0];
assertEquals(trB.getText(), rtrB.getText());
assertNull(rtrB._getRawCharacterStyle());
assertNull(rtrB._getRawParagraphStyle());
@@ -341,16 +341,16 @@ public final class TestTextRun extends TestCase {
* correctly
*/
public void testChangeTextInRichTextRun() {
- Slide slideOne = ssRich.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- TextRun trB = textRuns[1];
+ HSLFSlide slideOne = ssRich.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextParagraph trB = textRuns[1];
assertEquals(3, trB.getRichTextRuns().length);
// We start with 3 text runs, each with their own set of styles,
// but all sharing the same paragraph styles
- RichTextRun rtrB = trB.getRichTextRuns()[0];
- RichTextRun rtrC = trB.getRichTextRuns()[1];
- RichTextRun rtrD = trB.getRichTextRuns()[2];
+ HSLFTextRun rtrB = trB.getRichTextRuns()[0];
+ HSLFTextRun rtrC = trB.getRichTextRuns()[1];
+ HSLFTextRun rtrD = trB.getRichTextRuns()[2];
TextPropCollection tpBP = rtrB._getRawParagraphStyle();
TextPropCollection tpBC = rtrB._getRawCharacterStyle();
TextPropCollection tpCP = rtrC._getRawParagraphStyle();
@@ -421,11 +421,11 @@ public final class TestTextRun extends TestCase {
*
*/
public void testBug41015() throws IOException {
- RichTextRun[] rt;
+ HSLFTextRun[] rt;
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("bug-41015.ppt"));
- Slide sl = ppt.getSlides()[0];
- TextRun[] txt = sl.getTextRuns();
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bug-41015.ppt"));
+ HSLFSlide sl = ppt.getSlides()[0];
+ HSLFTextParagraph[] txt = sl.getTextRuns();
assertEquals(2, txt.length);
rt = txt[0].getRichTextRuns();
@@ -448,24 +448,24 @@ public final class TestTextRun extends TestCase {
* Test creation of TextRun objects.
*/
public void testAddTextRun() {
- SlideShow ppt = new SlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
assertNull(slide.getTextRuns());
- TextBox shape1 = new TextBox();
- TextRun run1 = shape1.getTextRun();
+ HSLFTextBox shape1 = new HSLFTextBox();
+ HSLFTextParagraph run1 = shape1.getTextParagraph();
assertSame(run1, shape1.createTextRun());
run1.setText("Text 1");
slide.addShape(shape1);
//The array of Slide's text runs must be updated when new text shapes are added.
- TextRun[] runs = slide.getTextRuns();
+ HSLFTextParagraph[] runs = slide.getTextRuns();
assertNotNull(runs);
assertSame(run1, runs[0]);
- TextBox shape2 = new TextBox();
- TextRun run2 = shape2.getTextRun();
+ HSLFTextBox shape2 = new HSLFTextBox();
+ HSLFTextParagraph run2 = shape2.getTextParagraph();
assertSame(run2, shape2.createTextRun());
run2.setText("Text 2");
slide.addShape(shape2);
@@ -479,14 +479,14 @@ public final class TestTextRun extends TestCase {
//as getShapes()
HSLFShape[] sh = slide.getShapes();
assertEquals(2, sh.length);
- assertTrue(sh[0] instanceof TextBox);
- TextBox box1 = (TextBox)sh[0];
- assertSame(run1, box1.getTextRun());
- TextBox box2 = (TextBox)sh[1];
- assertSame(run2, box2.getTextRun());
+ assertTrue(sh[0] instanceof HSLFTextBox);
+ HSLFTextBox box1 = (HSLFTextBox)sh[0];
+ assertSame(run1, box1.getTextParagraph());
+ HSLFTextBox box2 = (HSLFTextBox)sh[1];
+ assertSame(run2, box2.getTextParagraph());
//test Table - a complex group of shapes containing text objects
- Slide slide2 = ppt.createSlide();
+ HSLFSlide slide2 = ppt.createSlide();
assertNull(slide2.getTextRuns());
Table table = new Table(2, 2);
slide2.addShape(table);
@@ -496,12 +496,12 @@ public final class TestTextRun extends TestCase {
}
public void test48916() throws IOException {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("SampleShow.ppt"));
- for(Slide slide : ppt.getSlides()){
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("SampleShow.ppt"));
+ for(HSLFSlide slide : ppt.getSlides()){
for(HSLFShape sh : slide.getShapes()){
- if(sh instanceof TextShape){
- TextShape tx = (TextShape)sh;
- TextRun run = tx.getTextRun();
+ if(sh instanceof HSLFTextShape){
+ HSLFTextShape tx = (HSLFTextShape)sh;
+ HSLFTextParagraph run = tx.getTextParagraph();
//verify that records cached in TextRun and EscherTextboxWrapper are the same
Record[] runChildren = run.getRecords();
Record[] txboxChildren = tx.getEscherTextboxWrapper().getChildRecords();
@@ -517,13 +517,13 @@ public final class TestTextRun extends TestCase {
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
- for(Slide slide : ppt.getSlides()){
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
+ for(HSLFSlide slide : ppt.getSlides()){
for(HSLFShape sh : slide.getShapes()){
- if(sh instanceof TextShape){
- TextShape tx = (TextShape)sh;
- TextRun run = tx.getTextRun();
- RichTextRun rt = run.getRichTextRuns()[0];
+ if(sh instanceof HSLFTextShape){
+ HSLFTextShape tx = (HSLFTextShape)sh;
+ HSLFTextParagraph run = tx.getTextParagraph();
+ HSLFTextRun rt = run.getRichTextRuns()[0];
assertTrue(rt.isBold());
assertEquals(rt.getFontColor(), Color.RED);
}
@@ -533,9 +533,9 @@ public final class TestTextRun extends TestCase {
}
public void test52244() throws IOException {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("52244.ppt"));
- Slide slide = ppt.getSlides()[0];
- TextRun[] runs = slide.getTextRuns();
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("52244.ppt"));
+ HSLFSlide slide = ppt.getSlides()[0];
+ HSLFTextParagraph[] runs = slide.getTextRuns();
assertEquals("Arial", runs[0].getRichTextRuns()[0].getFontName());
assertEquals(36, runs[0].getRichTextRuns()[0].getFontSize());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java
index db55a2c052..c5a01341ae 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java
@@ -19,11 +19,11 @@ package org.apache.poi.hslf.model;
import junit.framework.TestCase;
+
import java.io.*;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.RichTextRun;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.POIDataSamples;
@@ -36,9 +36,9 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestTextRunReWrite extends TestCase {
// HSLFSlideShow primed on the test data
- private HSLFSlideShow hss;
+ private HSLFSlideShowImpl hss;
// HSLFSlideShow primed on the test data
- private SlideShow ss;
+ private HSLFSlideShow ss;
// POIFS primed on the test data
private POIFSFileSystem pfs;
@@ -49,14 +49,14 @@ public final class TestTextRunReWrite extends TestCase {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
String filename = "Single_Coloured_Page_With_Fonts_and_Alignments.ppt";
pfs = new POIFSFileSystem(slTests.openResourceAsStream(filename));
- hss = new HSLFSlideShow(pfs);
- ss = new SlideShow(hss);
+ hss = new HSLFSlideShowImpl(pfs);
+ ss = new HSLFSlideShow(hss);
}
public void testWritesOutTheSameNonRich() throws Exception {
// Grab the first text run on the first sheet
- TextRun tr1 = ss.getSlides()[0].getTextRuns()[0];
- TextRun tr2 = ss.getSlides()[0].getTextRuns()[1];
+ HSLFTextParagraph tr1 = ss.getSlides()[0].getTextRuns()[0];
+ HSLFTextParagraph tr2 = ss.getSlides()[0].getTextRuns()[1];
// Ensure the text lengths are as we'd expect to start with
assertEquals(1, ss.getSlides().length);
@@ -112,10 +112,10 @@ public final class TestTextRunReWrite extends TestCase {
public void testWritesOutTheSameRich() throws Exception {
// Grab the first text run on the first sheet
- TextRun tr1 = ss.getSlides()[0].getTextRuns()[0];
+ HSLFTextParagraph tr1 = ss.getSlides()[0].getTextRuns()[0];
// Get the first rich text run
- RichTextRun rtr1 = tr1.getRichTextRuns()[0];
+ HSLFTextRun rtr1 = tr1.getRichTextRuns()[0];
// Check that the text sizes are as expected
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
index 542d608d8e..5666b8db0e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
@@ -34,7 +34,7 @@ import java.util.Map;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.ShapeType;
import org.junit.Test;
@@ -48,14 +48,14 @@ public final class TestTextShape {
@Test
public void createAutoShape(){
- TextShape shape = new AutoShape(ShapeType.TRAPEZOID);
- assertNull(shape.getTextRun());
+ HSLFTextShape shape = new HSLFAutoShape(ShapeType.TRAPEZOID);
+ assertNull(shape.getTextParagraph());
assertNull(shape.getText());
assertNull(shape.getEscherTextboxWrapper());
- TextRun run = shape.createTextRun();
+ HSLFTextParagraph run = shape.createTextRun();
assertNotNull(run);
- assertNotNull(shape.getTextRun());
+ assertNotNull(shape.getTextParagraph());
assertNotNull(shape.getEscherTextboxWrapper());
assertEquals("", shape.getText());
assertSame(run, shape.createTextRun());
@@ -64,14 +64,14 @@ public final class TestTextShape {
@Test
public void createTextBox(){
- TextShape shape = new TextBox();
- TextRun run = shape.getTextRun();
+ HSLFTextShape shape = new HSLFTextBox();
+ HSLFTextParagraph run = shape.getTextParagraph();
assertNotNull(run);
assertNotNull(shape.getText());
assertNotNull(shape.getEscherTextboxWrapper());
assertSame(run, shape.createTextRun());
- assertNotNull(shape.getTextRun());
+ assertNotNull(shape.getTextParagraph());
assertNotNull(shape.getEscherTextboxWrapper());
assertEquals("", shape.getText());
@@ -85,15 +85,15 @@ public final class TestTextShape {
*/
@Test
public void read() throws IOException {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text_shapes.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("text_shapes.ppt"));
List lst1 = new ArrayList();
- Slide slide = ppt.getSlides()[0];
+ HSLFSlide slide = ppt.getSlides()[0];
HSLFShape[] shape = slide.getShapes();
for (int i = 0; i < shape.length; i++) {
- assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof TextShape);
- TextShape tx = (TextShape)shape[i];
- TextRun run = tx.getTextRun();
+ assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof HSLFTextShape);
+ HSLFTextShape tx = (HSLFTextShape)shape[i];
+ HSLFTextParagraph run = tx.getTextParagraph();
assertNotNull(run);
int runType = run.getRunType();
@@ -125,7 +125,7 @@ public final class TestTextShape {
}
List lst2 = new ArrayList();
- TextRun[] run = slide.getTextRuns();
+ HSLFTextParagraph[] run = slide.getTextRuns();
for (int i = 0; i < run.length; i++) {
lst2.add(run[i].getText());
}
@@ -135,18 +135,18 @@ public final class TestTextShape {
@Test
public void readWrite() throws IOException {
- SlideShow ppt = new SlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlideShow ppt = new HSLFSlideShow();
+ HSLFSlide slide = ppt.createSlide();
- TextShape shape1 = new TextBox();
- TextRun run1 = shape1.createTextRun();
+ HSLFTextShape shape1 = new HSLFTextBox();
+ HSLFTextParagraph run1 = shape1.createTextRun();
run1.setText("Hello, World!");
slide.addShape(shape1);
shape1.moveTo(100, 100);
- TextShape shape2 = new AutoShape(ShapeType.RIGHT_ARROW);
- TextRun run2 = shape2.createTextRun();
+ HSLFTextShape shape2 = new HSLFAutoShape(ShapeType.RIGHT_ARROW);
+ HSLFTextParagraph run2 = shape2.createTextRun();
run2.setText("Testing TextShape");
slide.addShape(shape2);
shape2.moveTo(300, 300);
@@ -155,37 +155,37 @@ public final class TestTextShape {
ppt.write(out);
out.close();
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
slide = ppt.getSlides()[0];
HSLFShape[] shape = slide.getShapes();
- assertTrue(shape[0] instanceof TextShape);
- shape1 = (TextShape)shape[0];
+ assertTrue(shape[0] instanceof HSLFTextShape);
+ shape1 = (HSLFTextShape)shape[0];
assertEquals(ShapeType.TEXT_BOX, shape1.getShapeType());
- assertEquals("Hello, World!", shape1.getTextRun().getText());
+ assertEquals("Hello, World!", shape1.getTextParagraph().getText());
- assertTrue(shape[1] instanceof TextShape);
- shape1 = (TextShape)shape[1];
+ assertTrue(shape[1] instanceof HSLFTextShape);
+ shape1 = (HSLFTextShape)shape[1];
assertEquals(ShapeType.RIGHT_ARROW, shape1.getShapeType());
- assertEquals("Testing TextShape", shape1.getTextRun().getText());
+ assertEquals("Testing TextShape", shape1.getTextParagraph().getText());
}
@Test
public void margins() throws IOException {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text-margins.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("text-margins.ppt"));
- Slide slide = ppt.getSlides()[0];
+ HSLFSlide slide = ppt.getSlides()[0];
- Map map = new HashMap();
+ Map map = new HashMap();
HSLFShape[] shape = slide.getShapes();
for (int i = 0; i < shape.length; i++) {
- if(shape[i] instanceof TextShape){
- TextShape tx = (TextShape)shape[i];
+ if(shape[i] instanceof HSLFTextShape){
+ HSLFTextShape tx = (HSLFTextShape)shape[i];
map.put(tx.getText(), tx);
}
}
- TextShape tx;
+ HSLFTextShape tx;
tx = map.get("TEST1");
assertEquals(0.1, tx.getMarginLeft()*HSLFShape.EMU_PER_POINT/HSLFShape.EMU_PER_INCH, 0.01);
@@ -214,22 +214,22 @@ public final class TestTextShape {
@Test
public void bug52599() throws IOException {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("52599.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("52599.ppt"));
- Slide slide = ppt.getSlides()[0];
+ HSLFSlide slide = ppt.getSlides()[0];
HSLFShape[] sh = slide.getShapes();
assertEquals(3, sh.length);
- TextShape sh0 = (TextShape)sh[0];
+ HSLFTextShape sh0 = (HSLFTextShape)sh[0];
assertEquals(null, sh0.getText());
- assertEquals(null, sh0.getTextRun());
+ assertEquals(null, sh0.getTextParagraph());
- TextShape sh1 = (TextShape)sh[1];
+ HSLFTextShape sh1 = (HSLFTextShape)sh[1];
assertEquals(null, sh1.getText());
- assertEquals(null, sh1.getTextRun());
+ assertEquals(null, sh1.getTextParagraph());
- TextShape sh2 = (TextShape)sh[2];
+ HSLFTextShape sh2 = (HSLFTextShape)sh[2];
assertEquals("this box should be shown just once", sh2.getText());
- assertEquals(-1, sh2.getTextRun().getIndex());
+ assertEquals(-1, sh2.getTextParagraph().getIndex());
}
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java
index 7db3ca6c8e..7e37b47a43 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java
@@ -19,7 +19,7 @@ package org.apache.poi.hslf.model;
import org.apache.poi.hslf.record.StyleTextPropAtom;
import org.apache.poi.hslf.record.TextCharsAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hssf.usermodel.DummyGraphics2d;
import org.junit.Test;
@@ -27,22 +27,22 @@ import org.junit.Test;
public class TextPainterTest {
@Test
public void testTextPainter() {
- TextShape shape = new Polygon();
+ HSLFTextShape shape = new Polygon();
TextPainter painter = new TextPainter(shape);
- painter.getAttributedString(new TextRun(null, new TextCharsAtom(), null));
+ painter.getAttributedString(new HSLFTextParagraph(null, new TextCharsAtom(), null));
painter.paint(new DummyGraphics2d());
painter.getTextElements((float)1.0, null);
}
@Test
public void testTextPainterWithText() {
- TextShape shape = new Polygon();
+ HSLFTextShape shape = new Polygon();
TextPainter painter = new TextPainter(shape);
TextCharsAtom tca = new TextCharsAtom();
tca.setText("some text to read");
- TextRun txrun = new TextRun(new TextHeaderAtom(), tca, new StyleTextPropAtom(10));
- Slide sheet = new Slide(1, 1, 1);
- sheet.setSlideShow(new SlideShow());
+ HSLFTextParagraph txrun = new HSLFTextParagraph(new TextHeaderAtom(), tca, new StyleTextPropAtom(10));
+ HSLFSlide sheet = new HSLFSlide(1, 1, 1);
+ sheet.setSlideShow(new HSLFSlideShow());
txrun.setSheet(sheet);
painter.getAttributedString(txrun, new DummyGraphics2d());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java
index 05478e3374..60aee0f49d 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java
@@ -24,8 +24,8 @@ import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.junit.Test;
@@ -72,7 +72,7 @@ public final class TestCurrentUserAtom {
new CurrentUserAtom(fs);
assertTrue(true); // not yet failed
- new HSLFSlideShow(fs);
+ new HSLFSlideShowImpl(fs);
}
@Test
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java
index 114a41da8d..d7de61c877 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java
@@ -19,7 +19,7 @@ package org.apache.poi.hslf.record;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.POIDataSamples;
@@ -30,14 +30,14 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestDocument extends TestCase {
// HSLFSlideShow primed on the test data
- private HSLFSlideShow ss;
+ private HSLFSlideShowImpl ss;
// POIFS primed on the test data
private POIFSFileSystem pfs;
public TestDocument() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new HSLFSlideShow(pfs);
+ ss = new HSLFSlideShowImpl(pfs);
}
private Document getDocRecord() {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
index d9e3717842..12c114b344 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
@@ -33,11 +33,11 @@ import org.apache.poi.hpsf.DocumentSummaryInformation;
import org.apache.poi.hpsf.PropertySet;
import org.apache.poi.hpsf.PropertySetFactory;
import org.apache.poi.hpsf.SummaryInformation;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.usermodel.PictureData;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.HSLFSlide;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.poifs.crypt.CryptoFunctions;
import org.apache.poi.poifs.crypt.EncryptionInfo;
@@ -71,8 +71,8 @@ public class TestDocumentEncryption {
for (String pptFile : encPpts) {
try {
NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
- HSLFSlideShow hss = new HSLFSlideShow(fs);
- new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs);
+ new HSLFSlideShow(hss);
fs.close();
} catch (EncryptedPowerPointFileException e) {
fail(pptFile+" can't be decrypted");
@@ -85,9 +85,9 @@ public class TestDocumentEncryption {
String pptFile = "cryptoapi-proc2356.ppt";
Biff8EncryptionKey.setCurrentUserPassword("crypto");
NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
- HSLFSlideShow hss = new HSLFSlideShow(fs);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs);
// need to cache data (i.e. read all data) before changing the key size
- PictureData picsExpected[] = hss.getPictures();
+ HSLFPictureData picsExpected[] = hss.getPictures();
hss.getDocumentSummaryInformation();
EncryptionInfo ei = hss.getDocumentEncryptionAtom().getEncryptionInfo();
((CryptoAPIEncryptionHeader)ei.getHeader()).setKeySize(0x78);
@@ -97,8 +97,8 @@ public class TestDocumentEncryption {
fs.close();
fs = new NPOIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
- hss = new HSLFSlideShow(fs);
- PictureData picsActual[] = hss.getPictures();
+ hss = new HSLFSlideShowImpl(fs);
+ HSLFPictureData picsActual[] = hss.getPictures();
fs.close();
assertEquals(picsExpected.length, picsActual.length);
@@ -112,7 +112,7 @@ public class TestDocumentEncryption {
/* documents with multiple edits need to be normalized for encryption */
String pptFile = "57272_corrupted_usereditatom.ppt";
NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
- HSLFSlideShow hss = new HSLFSlideShow(fs);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs);
hss.normalizeRecords();
// normalized ppt
@@ -128,7 +128,7 @@ public class TestDocumentEncryption {
// decrypted
ByteArrayInputStream bis = new ByteArrayInputStream(encrypted.toByteArray());
fs = new NPOIFSFileSystem(bis);
- hss = new HSLFSlideShow(fs);
+ hss = new HSLFSlideShowImpl(fs);
Biff8EncryptionKey.setCurrentUserPassword(null);
ByteArrayOutputStream actual = new ByteArrayOutputStream();
hss.write(actual);
@@ -143,10 +143,10 @@ public class TestDocumentEncryption {
// http://blogs.msdn.com/b/openspecification/archive/2009/05/08/dominic-salemno.aspx
Biff8EncryptionKey.setCurrentUserPassword("crypto");
NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile("cryptoapi-proc2356.ppt"));
- HSLFSlideShow hss = new HSLFSlideShow(fs);
- SlideShow ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs);
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
- Slide slide = ss.getSlides()[0];
+ HSLFSlide slide = ss.getSlides()[0];
assertEquals("Dominic Salemno", slide.getTextRuns()[0].getText());
String picCmp[][] = {
@@ -160,9 +160,9 @@ public class TestDocumentEncryption {
};
MessageDigest md = CryptoFunctions.getMessageDigest(HashAlgorithm.sha1);
- PictureData pd[] = hss.getPictures();
+ HSLFPictureData pd[] = hss.getPictures();
int i = 0;
- for (PictureData p : pd) {
+ for (HSLFPictureData p : pd) {
byte hash[] = md.digest(p.getData());
assertEquals(Integer.parseInt(picCmp[i][0]), p.getOffset());
assertEquals(picCmp[i][1], Base64.encodeBase64String(hash));
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
index fff9d7286e..f712e20a6d 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java
@@ -25,8 +25,8 @@ import java.util.List;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -99,8 +99,8 @@ public final class TestExHyperlink extends TestCase {
public void testRealFile() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
- SlideShow ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
// Get the document
Document doc = ss.getDocumentRecord();
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java
index d3739ec3b8..836016666e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java
@@ -20,8 +20,8 @@ package org.apache.poi.hslf.record;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.POIDataSamples;
/**
@@ -32,8 +32,8 @@ import org.apache.poi.POIDataSamples;
public class TestExObjList extends TestCase {
public void testRealFile() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt"));
- SlideShow ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt"));
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
// Get the document
Document doc = ss.getDocumentRecord();
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java
index 8481cbc70f..cecf3ee319 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java
@@ -20,7 +20,7 @@ package org.apache.poi.hslf.record;
import junit.framework.TestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.POIDataSamples;
/**
@@ -149,7 +149,7 @@ public final class TestRecordContainer extends TestCase {
// Find a real RecordContainer record
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
Record[] r = hss.getRecords();
for(int i=0; i notesMap = new HashMap();
@@ -143,10 +128,10 @@ public final class TestBugs {
notesMap.put(Integer.valueOf(7), "Although multiply and square root are easier");
notesMap.put(Integer.valueOf(8), "The bus Z is split into Z_H and Z_L");
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
Integer slideNumber = Integer.valueOf(slide[i].getSlideNumber());
- Notes notes = slide[i].getNotesSheet();
+ HSLFNotes notes = slide[i].getNotesSheet();
if (notesMap.containsKey(slideNumber)){
assertNotNull(notes);
String text = notes.getTextRuns()[0].getRawText();
@@ -162,18 +147,18 @@ public final class TestBugs {
*/
@Test
public void bug42485 () throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42485.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42485.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
HSLFShape[] shape = ppt.getSlides()[0].getShapes();
for (int i = 0; i < shape.length; i++) {
if(shape[i] instanceof HSLFGroupShape){
HSLFGroupShape group = (HSLFGroupShape)shape[i];
HSLFShape[] sh = group.getShapes();
for (int j = 0; j < sh.length; j++) {
- if( sh[j] instanceof TextBox){
- TextBox txt = (TextBox)sh[j];
- assertNotNull(txt.getTextRun());
+ if( sh[j] instanceof HSLFTextBox){
+ HSLFTextBox txt = (HSLFTextBox)sh[j];
+ assertNotNull(txt.getTextParagraph());
}
}
}
@@ -185,9 +170,9 @@ public final class TestBugs {
*/
@Test
public void bug42484 () throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42485.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42485.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
HSLFShape[] shape = ppt.getSlides()[0].getShapes();
for (int i = 0; i < shape.length; i++) {
if(shape[i] instanceof HSLFGroupShape){
@@ -207,16 +192,16 @@ public final class TestBugs {
*/
@Test
public void bug41381() throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("alterman_security.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("alterman_security.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
assertTrue("No Exceptions while reading file", true);
assertEquals(1, ppt.getSlidesMasters().length);
assertEquals(1, ppt.getTitleMasters().length);
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
- MasterSheet master = slide[i].getMasterSheet();
+ HSLFMasterSheet master = slide[i].getMasterSheet();
if (i == 0) assertTrue(master instanceof TitleMaster); //the first slide follows TitleMaster
else assertTrue(master instanceof SlideMaster);
}
@@ -227,10 +212,10 @@ public final class TestBugs {
*/
@Test
public void bug42486 () throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42486.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42486.ppt"));
- SlideShow ppt = new SlideShow(hslf);
- Slide[] slide = ppt.getSlides();
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
+ HSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
@SuppressWarnings("unused")
HSLFShape[] shape = slide[i].getShapes();
@@ -244,11 +229,11 @@ public final class TestBugs {
*/
@Test
public void bug42524 () throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42486.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42486.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
//walk down the tree and see if there were no errors while reading
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
HSLFShape[] shape = slide[i].getShapes();
for (int j = 0; j < shape.length; j++) {
@@ -272,17 +257,17 @@ public final class TestBugs {
*/
@Test
public void bug42520 () throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42520.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42520.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
//test case from the bug report
HSLFGroupShape shapeGroup = (HSLFGroupShape)ppt.getSlides()[11].getShapes()[10];
- Picture picture = (Picture)shapeGroup.getShapes()[0];
+ HSLFPictureShape picture = (HSLFPictureShape)shapeGroup.getShapes()[0];
picture.getPictureData();
//walk down the tree and see if there were no errors while reading
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
HSLFShape[] shape = slide[i].getShapes();
for (int j = 0; j < shape.length; j++) {
@@ -291,9 +276,9 @@ public final class TestBugs {
HSLFShape[] comps = group.getShapes();
for (int k = 0; k < comps.length; k++) {
HSLFShape comp = comps[k];
- if (comp instanceof Picture){
+ if (comp instanceof HSLFPictureShape){
@SuppressWarnings("unused")
- PictureData pict = ((Picture)comp).getPictureData();
+ HSLFPictureData pict = ((HSLFPictureShape)comp).getPictureData();
}
}
}
@@ -310,13 +295,13 @@ public final class TestBugs {
*/
@Test
public void bug38256 () throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("38256.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("38256.ppt"));
assertTrue("No Exceptions while reading file", true);
- Slide[] slide = ppt.getSlides();
+ HSLFSlide[] slide = ppt.getSlides();
assertEquals(1, slide.length);
- TextRun[] runs = slide[0].getTextRuns();
+ HSLFTextParagraph[] runs = slide[0].getTextRuns();
assertEquals(4, runs.length);
Set txt = new HashSet();
@@ -338,13 +323,13 @@ public final class TestBugs {
*/
@Test
public void bug43781 () throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("43781.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("43781.ppt"));
assertTrue("No Exceptions while reading file", true);
// Check the first slide
- Slide slide = ppt.getSlides()[0];
- TextRun[] slTr = slide.getTextRuns();
+ HSLFSlide slide = ppt.getSlides()[0];
+ HSLFTextParagraph[] slTr = slide.getTextRuns();
// Has two text runs, one from slide text, one from drawing
assertEquals(2, slTr.length);
@@ -354,11 +339,11 @@ public final class TestBugs {
assertEquals("Second run", slTr[1].getText());
// Check the shape based text runs
- List lst = new ArrayList();
+ List lst = new ArrayList();
HSLFShape[] shape = slide.getShapes();
for (int i = 0; i < shape.length; i++) {
- if( shape[i] instanceof TextShape){
- TextRun textRun = ((TextShape)shape[i]).getTextRun();
+ if( shape[i] instanceof HSLFTextShape){
+ HSLFTextParagraph textRun = ((HSLFTextShape)shape[i]).getTextParagraph();
if(textRun != null) {
lst.add(textRun);
}
@@ -377,17 +362,17 @@ public final class TestBugs {
*/
@Test
public void bug44296 () throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("44296.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("44296.ppt"));
- Slide slide = ppt.getSlides()[0];
+ HSLFSlide slide = ppt.getSlides()[0];
- Background b = slide.getBackground();
- Fill f = b.getFill();
- assertEquals(Fill.FILL_PICTURE, f.getFillType());
+ HSLFBackground b = slide.getBackground();
+ HSLFFill f = b.getFill();
+ assertEquals(HSLFFill.FILL_PICTURE, f.getFillType());
- PictureData pict = f.getPictureData();
+ HSLFPictureData pict = f.getPictureData();
assertNotNull(pict);
- assertEquals(Picture.JPEG, pict.getType());
+ assertEquals(HSLFPictureShape.JPEG, pict.getType());
}
/**
@@ -396,7 +381,7 @@ public final class TestBugs {
@Test
public void bug44770() throws Exception {
try {
- new SlideShow(_slTests.openResourceAsStream("44770.ppt"));
+ new HSLFSlideShow(_slTests.openResourceAsStream("44770.ppt"));
} catch (RuntimeException e) {
if (e.getMessage().equals("Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing")) {
throw new AssertionFailedError("Identified bug 44770");
@@ -410,16 +395,16 @@ public final class TestBugs {
*/
@Test
public void bug41071() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("41071.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("41071.ppt"));
- Slide slide = ppt.getSlides()[0];
+ HSLFSlide slide = ppt.getSlides()[0];
HSLFShape[] sh = slide.getShapes();
assertEquals(1, sh.length);
- assertTrue(sh[0] instanceof TextShape);
- TextShape tx = (TextShape)sh[0];
- assertEquals("Fundera, planera och involvera.", tx.getTextRun().getText());
+ assertTrue(sh[0] instanceof HSLFTextShape);
+ HSLFTextShape tx = (HSLFTextShape)sh[0];
+ assertEquals("Fundera, planera och involvera.", tx.getTextParagraph().getText());
- TextRun[] run = slide.getTextRuns();
+ HSLFTextParagraph[] run = slide.getTextRuns();
assertEquals(1, run.length);
assertEquals("Fundera, planera och involvera.", run[0].getText());
}
@@ -431,10 +416,10 @@ public final class TestBugs {
@Test(expected=OldPowerPointFormatException.class)
public void bug41711() throws Exception {
// New file is fine
- new SlideShow(_slTests.openResourceAsStream("SampleShow.ppt"));
+ new HSLFSlideShow(_slTests.openResourceAsStream("SampleShow.ppt"));
// PowerPoint 95 gives an old format exception
- new SlideShow(_slTests.openResourceAsStream("PPT95.ppt"));
+ new HSLFSlideShow(_slTests.openResourceAsStream("PPT95.ppt"));
}
/**
@@ -442,9 +427,9 @@ public final class TestBugs {
*/
@Test
public void bug49648() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("49648.ppt"));
- for(Slide slide : ppt.getSlides()) {
- for(TextRun run : slide.getTextRuns()) {
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("49648.ppt"));
+ for(HSLFSlide slide : ppt.getSlides()) {
+ for(HSLFTextParagraph run : slide.getTextRuns()) {
String text = run.getRawText();
text.replace("{txtTot}", "With \u0123\u1234\u5678 unicode");
run.setRawText(text);
@@ -458,10 +443,10 @@ public final class TestBugs {
@Test
public void bug41246a() throws Exception {
InputStream fis = _slTests.openResourceAsStream("41246-1.ppt");
- HSLFSlideShow hslf = new HSLFSlideShow(fis);
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(fis);
fis.close();
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
assertTrue("No Exceptions while reading file", true);
ppt = HSLFTestDataSamples.writeOutAndReadBack(ppt);
@@ -471,10 +456,10 @@ public final class TestBugs {
@Test
public void bug41246b() throws Exception {
InputStream fis = _slTests.openResourceAsStream("41246-2.ppt");
- HSLFSlideShow hslf = new HSLFSlideShow(fis);
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(fis);
fis.close();
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
assertTrue("No Exceptions while reading file", true);
ppt = HSLFTestDataSamples.writeOutAndReadBack(ppt);
@@ -487,14 +472,14 @@ public final class TestBugs {
@Test
public void bug45776() throws Exception {
InputStream is = _slTests.openResourceAsStream("45776.ppt");
- SlideShow ppt = new SlideShow(new HSLFSlideShow(is));
+ HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl(is));
is.close();
// get slides
- for (Slide slide : ppt.getSlides()) {
+ for (HSLFSlide slide : ppt.getSlides()) {
for (HSLFShape shape : slide.getShapes()) {
- if (!(shape instanceof TextBox)) continue;
- TextBox tb = (TextBox) shape;
+ if (!(shape instanceof HSLFTextBox)) continue;
+ HSLFTextBox tb = (HSLFTextBox) shape;
// work with TextBox
String str = tb.getText();
@@ -502,7 +487,7 @@ public final class TestBugs {
str = str.replace("$$DATE$$", new Date().toString());
tb.setText(str);
- TextRun tr = tb.getTextRun();
+ HSLFTextParagraph tr = tb.getTextParagraph();
assertEquals(str.length()+1,tr.getStyleTextPropAtom().getParagraphStyles().getFirst().getCharactersCovered());
assertEquals(str.length()+1,tr.getStyleTextPropAtom().getCharacterStyles().getFirst().getCharactersCovered());
}
@@ -513,12 +498,12 @@ public final class TestBugs {
public void bug55732() throws Exception {
File file = _slTests.getFile("bug55732.ppt");
- HSLFSlideShow ss = new HSLFSlideShow(file.getAbsolutePath());
- SlideShow _show = new SlideShow(ss);
- Slide[] _slides = _show.getSlides();
+ HSLFSlideShowImpl ss = new HSLFSlideShowImpl(file.getAbsolutePath());
+ HSLFSlideShow _show = new HSLFSlideShow(ss);
+ HSLFSlide[] _slides = _show.getSlides();
/* Iterate over slides and extract text */
- for( Slide slide : _slides ) {
+ for( HSLFSlide slide : _slides ) {
HeadersFooters hf = slide.getHeadersFooters();
/*boolean visible =*/ hf.isHeaderVisible(); // exception happens here
}
@@ -529,9 +514,9 @@ public final class TestBugs {
public void bug56260() throws Exception {
File file = _slTests.getFile("56260.ppt");
- HSLFSlideShow ss = new HSLFSlideShow(file.getAbsolutePath());
- SlideShow _show = new SlideShow(ss);
- Slide[] _slides = _show.getSlides();
+ HSLFSlideShowImpl ss = new HSLFSlideShowImpl(file.getAbsolutePath());
+ HSLFSlideShow _show = new HSLFSlideShow(ss);
+ HSLFSlide[] _slides = _show.getSlides();
assertEquals(13, _slides.length);
// Check the number of TextHeaderAtoms on Slide 1
@@ -553,7 +538,7 @@ public final class TestBugs {
// Check the number of text runs based on the slide (not textbox)
// Will have skipped the empty one
int str = 0;
- for (TextRun tr : _slides[0].getTextRuns()) {
+ for (HSLFTextParagraph tr : _slides[0].getTextRuns()) {
if (! tr.isDrawingBased()) str++;
}
assertEquals(1, str);
@@ -563,10 +548,10 @@ public final class TestBugs {
public void bug37625() throws IOException {
InputStream inputStream = new FileInputStream(_slTests.getFile("37625.ppt"));
try {
- SlideShow slideShow = new SlideShow(inputStream);
+ HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
assertEquals(29, slideShow.getSlides().length);
- SlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
+ HSLFSlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
assertNotNull(slideBack);
assertEquals(29, slideBack.getSlides().length);
} finally {
@@ -578,10 +563,10 @@ public final class TestBugs {
public void bug57272() throws Exception {
InputStream inputStream = new FileInputStream(_slTests.getFile("57272_corrupted_usereditatom.ppt"));
try {
- SlideShow slideShow = new SlideShow(inputStream);
+ HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
assertEquals(6, slideShow.getSlides().length);
- SlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
+ HSLFSlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
assertNotNull(slideBack);
assertEquals(6, slideBack.getSlides().length);
} finally {
@@ -593,10 +578,10 @@ public final class TestBugs {
public void bug49541() throws Exception {
InputStream inputStream = new FileInputStream(_slTests.getFile("49541_symbol_map.ppt"));
try {
- SlideShow slideShow = new SlideShow(inputStream);
- Slide slide = slideShow.getSlides()[0];
+ HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
+ HSLFSlide slide = slideShow.getSlides()[0];
HSLFGroupShape sg = (HSLFGroupShape)slide.getShapes()[0];
- TextBox tb = (TextBox)sg.getShapes()[0];
+ HSLFTextBox tb = (HSLFTextBox)sg.getShapes()[0];
String text = StringUtil.mapMsCodepointString(tb.getText());
assertEquals("\u226575 years", text);
} finally {
@@ -608,7 +593,7 @@ public final class TestBugs {
public void bug47261() throws Exception {
InputStream inputStream = new FileInputStream(_slTests.getFile("bug47261.ppt"));
try {
- SlideShow slideShow = new SlideShow(inputStream);
+ HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
slideShow.removeSlide(0);
slideShow.createSlide();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -622,7 +607,7 @@ public final class TestBugs {
public void bug56240() throws Exception {
InputStream inputStream = new FileInputStream(_slTests.getFile("bug56240.ppt"));
try {
- SlideShow slideShow = new SlideShow(inputStream);
+ HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
int slideCnt = slideShow.getSlides().length;
assertEquals(105, slideCnt);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -637,8 +622,8 @@ public final class TestBugs {
public void bug46441() throws Exception {
InputStream inputStream = new FileInputStream(_slTests.getFile("bug46441.ppt"));
try {
- SlideShow slideShow = new SlideShow(inputStream);
- AutoShape as = (AutoShape)slideShow.getSlides()[0].getShapes()[0];
+ HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
+ HSLFAutoShape as = (HSLFAutoShape)slideShow.getSlides()[0].getShapes()[0];
EscherOptRecord opt = as.getEscherOptRecord();
EscherArrayProperty ep = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__SHADECOLORS);
double exp[][] = {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java
index eb84e7711a..dbee82742f 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java
@@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.*;
import org.apache.poi.hslf.model.*;
import org.apache.poi.POIDataSamples;
@@ -30,16 +31,16 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestCounts extends TestCase {
// SlideShow primed on the test data
- private SlideShow ss;
+ private HSLFSlideShow ss;
public TestCounts() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
}
public void testSheetsCount() {
- Slide[] slides = ss.getSlides();
+ HSLFSlide[] slides = ss.getSlides();
// Two sheets - master sheet is separate
assertEquals(2, slides.length);
@@ -57,7 +58,7 @@ public final class TestCounts extends TestCase {
}
public void testNotesCount() {
- Notes[] notes = ss.getNotes();
+ HSLFNotes[] notes = ss.getNotes();
// Two sheets -> two notes
// Note: there are also notes on the slide master
//assertEquals(3, notes.length); // When we do slide masters
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java
index a6fa770059..37b7bb6965 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java
@@ -39,7 +39,7 @@ import java.util.Map;
import javax.imageio.ImageIO;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.HSLFSlide;
import org.apache.poi.hslf.model.TextPainter;
import org.apache.poi.util.TempFile;
import org.junit.Ignore;
@@ -82,12 +82,12 @@ public class TestFontRendering {
}
InputStream is = slTests.openResourceAsStream("bug55902-mixedFontChineseCharacters.ppt");
- SlideShow ss = new SlideShow(is);
+ HSLFSlideShow ss = new HSLFSlideShow(is);
is.close();
Dimension pgsize = ss.getPageSize();
- Slide slide = ss.getSlides()[0];
+ HSLFSlide slide = ss.getSlides()[0];
// render it
double zoom = 1;
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
index ce68b7a2d8..088dbb0cee 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
@@ -19,7 +19,9 @@ package org.apache.poi.hslf.usermodel;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.*;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.hslf.record.*;
import org.apache.poi.POIDataSamples;
@@ -30,14 +32,14 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestMostRecentRecords extends TestCase {
// HSLFSlideShow primed on the test data
- private HSLFSlideShow hss;
+ private HSLFSlideShowImpl hss;
// SlideShow primed on the test data
- private SlideShow ss;
+ private HSLFSlideShow ss;
public TestMostRecentRecords() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
}
public void testCount() {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
index 3def468f9e..22b40a22e2 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
@@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.*;
import org.apache.poi.hslf.model.*;
import org.apache.poi.POIDataSamples;
@@ -30,16 +31,16 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestNotesText extends TestCase {
// SlideShow primed on the test data
- private SlideShow ss;
+ private HSLFSlideShow ss;
public TestNotesText() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
}
public void testNotesOne() {
- Notes notes = ss.getNotes()[0];
+ HSLFNotes notes = ss.getNotes()[0];
String[] expectText = new String[] {"These are the notes for page 1"};
assertEquals(expectText.length, notes.getTextRuns().length);
@@ -49,7 +50,7 @@ public final class TestNotesText extends TestCase {
}
public void testNotesTwo() {
- Notes notes = ss.getNotes()[1];
+ HSLFNotes notes = ss.getNotes()[1];
String[] expectText = new String[] {"These are the notes on page two, again lacking formatting"};
assertEquals(expectText.length, notes.getTextRuns().length);
for(int i=0; i 3
assertEquals(s1._getSheetNumber(), _s3._getSheetNumber());
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
index 5475dae9c1..c15bacd1f2 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
@@ -19,7 +19,9 @@ package org.apache.poi.hslf.usermodel;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.*;
+import org.apache.poi.hslf.model.HSLFSlideShowImpl;
import org.apache.poi.hslf.record.ParentAwareRecord;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.RecordContainer;
@@ -34,13 +36,13 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestRecordSetup extends TestCase {
// SlideShow primed on the test data
- private SlideShow ss;
- private HSLFSlideShow hss;
+ private HSLFSlideShow ss;
+ private HSLFSlideShowImpl hss;
public TestRecordSetup() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
}
public void testHandleParentAwareRecords() {
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
index a71b72a28b..267e9ec7a4 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
@@ -23,10 +23,7 @@ import java.io.FileInputStream;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POITestCase;
-import org.apache.poi.hslf.HSLFSlideShow;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.TextBox;
-import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.*;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.SlideListWithText;
@@ -39,40 +36,40 @@ public final class TestRichTextRun extends POITestCase {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
// SlideShow primed on the test data
- private SlideShow ss;
- private SlideShow ssRichA;
- private SlideShow ssRichB;
- private SlideShow ssRichC;
- private SlideShow ssChinese;
- private HSLFSlideShow hss;
- private HSLFSlideShow hssRichA;
- private HSLFSlideShow hssRichB;
- private HSLFSlideShow hssRichC;
- private HSLFSlideShow hssChinese;
+ private HSLFSlideShow ss;
+ private HSLFSlideShow ssRichA;
+ private HSLFSlideShow ssRichB;
+ private HSLFSlideShow ssRichC;
+ private HSLFSlideShow ssChinese;
+ private HSLFSlideShowImpl hss;
+ private HSLFSlideShowImpl hssRichA;
+ private HSLFSlideShowImpl hssRichB;
+ private HSLFSlideShowImpl hssRichC;
+ private HSLFSlideShowImpl hssChinese;
private static String filenameC;
protected void setUp() throws Exception {
// Basic (non rich) test file
- hss = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
// Rich test file A
- hssRichA = new HSLFSlideShow(_slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
- ssRichA = new SlideShow(hssRichA);
+ hssRichA = new HSLFSlideShowImpl(_slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
+ ssRichA = new HSLFSlideShow(hssRichA);
// Rich test file B
- hssRichB = new HSLFSlideShow(_slTests.openResourceAsStream("Single_Coloured_Page_With_Fonts_and_Alignments.ppt"));
- ssRichB = new SlideShow(hssRichB);
+ hssRichB = new HSLFSlideShowImpl(_slTests.openResourceAsStream("Single_Coloured_Page_With_Fonts_and_Alignments.ppt"));
+ ssRichB = new HSLFSlideShow(hssRichB);
// Rich test file C - has paragraph styles that run out before
// the character ones do
filenameC = "ParagraphStylesShorterThanCharStyles.ppt";
- hssRichC = new HSLFSlideShow(_slTests.openResourceAsStream(filenameC));
- ssRichC = new SlideShow(hssRichC);
+ hssRichC = new HSLFSlideShowImpl(_slTests.openResourceAsStream(filenameC));
+ ssRichC = new HSLFSlideShow(hssRichC);
// Rich test file with Chinese + English text in it
- hssChinese = new HSLFSlideShow(_slTests.openResourceAsStream("54880_chinese.ppt"));
- ssChinese = new SlideShow(hssChinese);
+ hssChinese = new HSLFSlideShowImpl(_slTests.openResourceAsStream("54880_chinese.ppt"));
+ ssChinese = new HSLFSlideShow(hssChinese);
}
/**
@@ -80,9 +77,9 @@ public final class TestRichTextRun extends POITestCase {
* on a non rich text run
*/
public void testBoldNonRich() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- RichTextRun rtr = textRuns[0].getRichTextRuns()[0];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextRun rtr = textRuns[0].getRichTextRuns()[0];
assertNull(rtr._getRawCharacterStyle());
assertNull(rtr._getRawParagraphStyle());
@@ -108,9 +105,9 @@ public final class TestRichTextRun extends POITestCase {
* on a rich text run
*/
public void testBoldRich() {
- Slide slideOneR = ssRichA.getSlides()[0];
- TextRun[] textRunsR = slideOneR.getTextRuns();
- RichTextRun[] rtrs = textRunsR[1].getRichTextRuns();
+ HSLFSlide slideOneR = ssRichA.getSlides()[0];
+ HSLFTextParagraph[] textRunsR = slideOneR.getTextRuns();
+ HSLFTextRun[] rtrs = textRunsR[1].getRichTextRuns();
assertEquals(3, rtrs.length);
assertTrue(rtrs[0].isBold());
@@ -136,15 +133,15 @@ public final class TestRichTextRun extends POITestCase {
*/
public void testFontSize() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- RichTextRun rtr = textRuns[0].getRichTextRuns()[0];
+ HSLFSlide slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextRun rtr = textRuns[0].getRichTextRuns()[0];
- Slide slideOneR = ssRichB.getSlides()[0];
- TextRun[] textRunsR = slideOneR.getTextRuns();
- RichTextRun rtrRa = textRunsR[0].getRichTextRuns()[0];
- RichTextRun rtrRb = textRunsR[1].getRichTextRuns()[0];
- RichTextRun rtrRc = textRunsR[1].getRichTextRuns()[3];
+ HSLFSlide slideOneR = ssRichB.getSlides()[0];
+ HSLFTextParagraph[] textRunsR = slideOneR.getTextRuns();
+ HSLFTextRun rtrRa = textRunsR[0].getRichTextRuns()[0];
+ HSLFTextRun rtrRb = textRunsR[1].getRichTextRuns()[0];
+ HSLFTextRun rtrRc = textRunsR[1].getRichTextRuns()[3];
String defaultFont = "Arial";
@@ -195,14 +192,14 @@ public final class TestRichTextRun extends POITestCase {
}
public void testChangeWriteRead() throws Exception {
- HSLFSlideShow[] h = new HSLFSlideShow[] { hss, hssRichA, hssRichB };
- Slide[] s = new Slide[] { ss.getSlides()[0], ssRichA.getSlides()[0], ssRichB.getSlides()[0] };
+ HSLFSlideShowImpl[] h = new HSLFSlideShowImpl[] { hss, hssRichA, hssRichB };
+ HSLFSlide[] s = new HSLFSlide[] { ss.getSlides()[0], ssRichA.getSlides()[0], ssRichB.getSlides()[0] };
for(int i=0; i(text a)(text a)(text b)
// TR:
// (text)
- TextRun[] s7tr = slideSevenC.getTextRuns();
- RichTextRun[] s7rtr0 = s7tr[0].getRichTextRuns();
- RichTextRun[] s7rtr1 = s7tr[1].getRichTextRuns();
- RichTextRun[] s7rtr2 = s7tr[2].getRichTextRuns();
+ HSLFTextParagraph[] s7tr = slideSevenC.getTextRuns();
+ HSLFTextRun[] s7rtr0 = s7tr[0].getRichTextRuns();
+ HSLFTextRun[] s7rtr1 = s7tr[1].getRichTextRuns();
+ HSLFTextRun[] s7rtr2 = s7tr[2].getRichTextRuns();
assertEquals(1, s7rtr0.length);
assertEquals(3, s7rtr1.length);
@@ -334,11 +331,11 @@ public final class TestRichTextRun extends POITestCase {
assertMatchesSLTWC(ssRichC);
assertMatchesFileC(ssRichC);
- Slide slideSevenC = ssRichC.getSlides()[6];
- TextRun[] s7tr = slideSevenC.getTextRuns();
- RichTextRun[] s7rtr0 = s7tr[0].getRichTextRuns();
- RichTextRun[] s7rtr1 = s7tr[1].getRichTextRuns();
- RichTextRun[] s7rtr2 = s7tr[2].getRichTextRuns();
+ HSLFSlide slideSevenC = ssRichC.getSlides()[6];
+ HSLFTextParagraph[] s7tr = slideSevenC.getTextRuns();
+ HSLFTextRun[] s7rtr0 = s7tr[0].getRichTextRuns();
+ HSLFTextRun[] s7rtr1 = s7tr[1].getRichTextRuns();
+ HSLFTextRun[] s7rtr2 = s7tr[2].getRichTextRuns();
String oldText;
@@ -374,9 +371,9 @@ public final class TestRichTextRun extends POITestCase {
* contents.
* @param s
*/
- private void assertMatchesSLTWC(SlideShow s) throws Exception {
+ private void assertMatchesSLTWC(HSLFSlideShow s) throws Exception {
// Grab a new copy of slideshow C
- SlideShow refC = new SlideShow(_slTests.openResourceAsStream(filenameC));
+ HSLFSlideShow refC = new HSLFSlideShow(_slTests.openResourceAsStream(filenameC));
// Write out the 2nd SLWT in the active document
SlideListWithText refSLWT = refC.getDocumentRecord().getSlideListWithTexts()[1];
@@ -411,7 +408,7 @@ public final class TestRichTextRun extends POITestCase {
* Checks that the supplied slideshow still matches the bytes
* of slideshow c
*/
- private static void assertMatchesFileC(SlideShow s) throws Exception {
+ private static void assertMatchesFileC(HSLFSlideShow s) throws Exception {
if (true) { // TODO - test is disabled, pending fix of bug #39800
// System.err.println("Skipping test, as would be marked as failed due to bug #39800"); //
return;
@@ -450,12 +447,12 @@ if(false) {
}
public void testIndentationLevel() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt"));
- Slide[] sl = ppt.getSlides();
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt"));
+ HSLFSlide[] sl = ppt.getSlides();
for (int i = 0; i < sl.length; i++) {
- TextRun[] txt = sl[i].getTextRuns();
+ HSLFTextParagraph[] txt = sl[i].getTextRuns();
for (int j = 0; j < txt.length; j++) {
- RichTextRun[] rt = txt[j].getRichTextRuns();
+ HSLFTextRun[] rt = txt[j].getRichTextRuns();
for (int k = 0; k < rt.length; k++) {
int indent = rt[k].getIndentLevel();
assertTrue(indent >= 0 && indent <= 4 );
@@ -466,12 +463,12 @@ if(false) {
}
public void testReadParagraphStyles() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("bullets.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bullets.ppt"));
assertTrue("No Exceptions while reading file", true);
- RichTextRun rt;
- TextRun[] txt;
- Slide[] slide = ppt.getSlides();
+ HSLFTextRun rt;
+ HSLFTextParagraph[] txt;
+ HSLFSlide[] slide = ppt.getSlides();
assertEquals(2, slide.length);
txt = slide[0].getTextRuns();
@@ -516,12 +513,12 @@ if(false) {
}
public void testSetParagraphStyles() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
- TextBox shape = new TextBox();
- RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
+ HSLFTextBox shape = new HSLFTextBox();
+ HSLFTextRun rt = shape.getTextParagraph().getRichTextRuns()[0];
shape.setText(
"Hello, World!\r" +
"This should be\r" +
@@ -547,10 +544,10 @@ if(false) {
ppt.write(out);
out.close();
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
slide = ppt.getSlides()[0];
- shape = (TextBox)slide.getShapes()[0];
- rt = shape.getTextRun().getRichTextRuns()[0];
+ shape = (HSLFTextBox)slide.getShapes()[0];
+ rt = shape.getTextParagraph().getRichTextRuns()[0];
assertEquals(42, rt.getFontSize());
assertEquals(true, rt.isBullet());
assertEquals(50, rt.getTextOffset());
@@ -559,12 +556,12 @@ if(false) {
}
public void testAddText() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("bullets.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bullets.ppt"));
assertTrue("No Exceptions while reading file", true);
- RichTextRun rt;
- TextRun[] txt;
- Slide[] slides = ppt.getSlides();
+ HSLFTextRun rt;
+ HSLFTextParagraph[] txt;
+ HSLFSlide[] slides = ppt.getSlides();
assertEquals(2, slides.length);
txt = slides[0].getTextRuns();
@@ -605,7 +602,7 @@ if(false) {
ppt.write(out);
out.close();
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
slides = ppt.getSlides();
assertEquals(2, slides.length);
@@ -628,10 +625,10 @@ if(false) {
}
public void testChineseParagraphs() throws Exception {
- RichTextRun[] rts;
- RichTextRun rt;
- TextRun[] txt;
- Slide[] slides = ssChinese.getSlides();
+ HSLFTextRun[] rts;
+ HSLFTextRun rt;
+ HSLFTextParagraph[] txt;
+ HSLFSlide[] slides = ssChinese.getSlides();
// One slide
assertEquals(1, slides.length);
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
index cb27d3ee92..fda2aba0d0 100644
--- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
@@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.*;
import org.apache.poi.hslf.model.*;
import org.apache.poi.POIDataSamples;
@@ -30,16 +31,16 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestSheetText extends TestCase {
// SlideShow primed on the test data
- private SlideShow ss;
+ private HSLFSlideShow ss;
public TestSheetText() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss = new SlideShow(hss);
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss = new HSLFSlideShow(hss);
}
public void testSheetOne() {
- Sheet slideOne = ss.getSlides()[0];
+ HSLFSheet slideOne = ss.getSlides()[0];
String[] expectText = new String[] {"This is a test title","This is a test subtitle\nThis is on page 1"};
assertEquals(expectText.length, slideOne.getTextRuns().length);
@@ -49,7 +50,7 @@ public final class TestSheetText extends TestCase {
}
public void testSheetTwo() {
- Sheet slideTwo = ss.getSlides()[1];
+ HSLFSheet slideTwo = ss.getSlides()[1];
String[] expectText = new String[] {"This is the title on page 2","This is page two\nIt has several blocks of text\nNone of them have formatting"};
assertEquals(expectText.length, slideTwo.getTextRuns().length);
for(int i=0; i