You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/03/20 00:44:25 UTC
svn commit: r1667902 [4/8] - in /poi/branches/common_sl/src:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hssf/usermodel/examples/
examples/src/org/apache/poi/xslf/usermodel/
examples/src/org/apache/poi/xssf/usermodel/examples...
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java (from r1664935, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java&r1=1664935&r2=1667902&rev=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java Thu Mar 19 23:44:23 2015
@@ -47,7 +47,7 @@ import org.apache.poi.hslf.record.TextBy
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
/**
* 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
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
- protected TextShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+ protected HSLFTextShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
super(escherRecord, parent);
}
@@ -122,7 +122,7 @@ public abstract class TextShape extends
* @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<HSLFShape> parent){
+ public HSLFTextShape(ShapeContainer<HSLFShape> parent){
super(null, parent);
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
}
@@ -131,15 +131,15 @@ public abstract class TextShape extends
* 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
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
* AutoShape: align=center, valign=middle
*
*/
- protected void setDefaultTextProperties(TextRun _txtrun){
+ protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
}
@@ -180,7 +180,7 @@ public abstract class TextShape extends
* @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
* @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
*
* @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
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
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
* @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
* @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
/**
* @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
}
}
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
}
}
- 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
}
}
}
+
// 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
* @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
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java Thu Mar 19 23:44:23 2015
@@ -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
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java Thu Mar 19 23:44:23 2015
@@ -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 <code>TextRun</code> to lookup hyperlinks in
* @return found hyperlinks or <code>null</code> if not found
*/
- protected static Hyperlink[] find(TextRun run){
+ protected static Hyperlink[] find(HSLFTextParagraph run){
List<Hyperlink> lst = new ArrayList<Hyperlink>();
- 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<Hyperlink> lst = new ArrayList<Hyperlink>();
- 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) {
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Line.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Line.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Line.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Line.java Thu Mar 19 23:44:23 2015
@@ -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<HSLFShape> parent){
super(escherRecord, parent);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java Thu Mar 19 23:44:23 2015
@@ -24,7 +24,7 @@ import org.apache.poi.ddf.EscherContaine
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.Shape
*
* @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 Pi
/**
* 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 Pi
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;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java Thu Mar 19 23:44:23 2015
@@ -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 Pict
*
* @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 Pict
*/
public ExEmbed getExEmbed(){
if(_exEmbed == null){
- SlideShow ppt = getSheet().getSlideShow();
+ HSLFSlideShow ppt = getSheet().getSlideShow();
ExObjList lst = ppt.getDocumentRecord().getExObjList();
if(lst == null){
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java Thu Mar 19 23:44:23 2015
@@ -28,7 +28,7 @@ import java.awt.image.renderable.Rendera
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
*/
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
* @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
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
*/
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
}
}
- 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
}
}
- protected void applyPaint(SimpleShape shape) {
+ protected void applyPaint(HSLFSimpleShape shape) {
if (_paint instanceof Color) {
shape.getFill().setForegroundColor((Color)_paint);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java Thu Mar 19 23:44:23 2015
@@ -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<HSLFShape> parent){
super(escherRecord, parent);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java Thu Mar 19 23:44:23 2015
@@ -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.
*
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java Thu Mar 19 23:44:23 2015
@@ -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;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java Thu Mar 19 23:44:23 2015
@@ -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();
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java Thu Mar 19 23:44:23 2015
@@ -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.Sli
*
* @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 M
/**
* Returns an array of all the TextRuns found
*/
- public TextRun[] getTextRuns() {
+ public HSLFTextParagraph[] getTextRuns() {
return _runs;
}
/**
* Returns <code>null</code> since SlideMasters doen't have master sheet.
*/
- public MasterSheet getMasterSheet() {
+ public HSLFMasterSheet getMasterSheet() {
return null;
}
@@ -112,7 +112,7 @@ public final class SlideMaster extends M
* 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 M
}
}
- 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;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java Thu Mar 19 23:44:23 2015
@@ -115,7 +115,7 @@ public final class Table extends HSLFGro
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 HSLFGro
List<List<HSLFShape>> lst = new ArrayList<List<HSLFShape>>();
List<HSLFShape> 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 HSLFGro
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 HSLFGro
*
* @param sheet owner of this shape
*/
- public void setSheet(Sheet sheet){
+ public void setSheet(HSLFSheet sheet){
super.setSheet(sheet);
if(cells == null) initTable();
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java Thu Mar 19 23:44:23 2015
@@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.Shape
*
* @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;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java Thu Mar 19 23:44:23 2015
@@ -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;
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java Thu Mar 19 23:44:23 2015
@@ -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 M
/**
* 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 M
* 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();
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java (from r1662967, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java&r1=1662967&r2=1667902&rev=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java Thu Mar 19 23:44:23 2015
@@ -26,7 +26,7 @@ import org.apache.poi.hslf.record.ExOleO
*
* @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;
}
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java (from r1662967, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java&r1=1662967&r2=1667902&rev=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java Thu Mar 19 23:44:23 2015
@@ -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 <code>Picture<code> class.
* @return concrete instance of <code>PictureData</code>
*/
- 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());
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (from r1664935, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java&r1=1664935&r2=1667902&rev=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Thu Mar 19 23:44:23 2015
@@ -37,19 +37,9 @@ import org.apache.poi.ddf.EscherContaine
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.SlideP
import org.apache.poi.hslf.record.UserEditAtom;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.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<Record> records = new ArrayList<Record>();
ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
- ArrayList<Slide> sl = new ArrayList<Slide>();
+ ArrayList<HSLFSlide> sl = new ArrayList<HSLFSlide>();
- ArrayList<Notes> nt = new ArrayList<Notes>();
- for (Notes notes : getNotes())
+ ArrayList<HSLFNotes> nt = new ArrayList<HSLFNotes>();
+ 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 <code>Slide</code>
*/
- 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
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java (from r1662967, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java&r1=1662967&r2=1667902&rev=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java Thu Mar 19 23:44:23 2015
@@ -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<SoundData> lst = new ArrayList<SoundData>();
+ public static HSLFSoundData[] find(Document document){
+ ArrayList<HSLFSoundData> lst = new ArrayList<HSLFSoundData>();
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()]);
}
}
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java (from r1664935, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java&r1=1664935&r2=1667902&rev=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java Thu Mar 19 23:44:23 2015
@@ -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);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java Thu Mar 19 23:44:23 2015
@@ -3,7 +3,7 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawAutoShape<T extends AutoShape<? extends TextParagraph>> extends DrawTextShape<T> {
+public class DrawAutoShape<T extends AutoShape<? extends TextParagraph<? extends TextRun>>> extends DrawTextShape<T> {
public DrawAutoShape(T shape) {
super(shape);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java Thu Mar 19 23:44:23 2015
@@ -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 <T extends Slide<? extends Shape>> DrawSlide<T> getDrawable(T sheet) {
+ public <T extends Slide<? extends Shape, ? extends SlideShow>> DrawSlide<T> getDrawable(T sheet) {
return new DrawSlide<T>(sheet);
}
- public <T extends Sheet<? extends Shape>> DrawSheet<T> getDrawable(T sheet) {
+ public <T extends Sheet<? extends Shape, ? extends SlideShow>> DrawSheet<T> getDrawable(T sheet) {
return new DrawSheet<T>(sheet);
}
- public <T extends MasterSheet<? extends Shape>> DrawMasterSheet<T> getDrawable(T sheet) {
+ public <T extends MasterSheet<? extends Shape, ? extends SlideShow>> DrawMasterSheet<T> getDrawable(T sheet) {
return new DrawMasterSheet<T>(sheet);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java Thu Mar 19 23:44:23 2015
@@ -3,7 +3,7 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawMasterSheet<T extends MasterSheet<? extends Shape>> extends DrawSheet<T> {
+public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends SlideShow>> extends DrawSheet<T> {
public DrawMasterSheet(T sheet) {
super(sheet);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java Thu Mar 19 23:44:23 2015
@@ -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);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java Thu Mar 19 23:44:23 2015
@@ -7,17 +7,12 @@ import java.awt.geom.Rectangle2D;
import org.apache.poi.sl.usermodel.*;
-public class DrawShapeGroup<T extends ShapeGroup<? extends Shape>> implements Drawable {
+public class DrawShapeGroup<T extends ShapeGroup<? extends Shape>> extends DrawShape<T> 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<T extends Sh
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
}
-
- public void drawContent(Graphics2D context) {
- }
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java Thu Mar 19 23:44:23 2015
@@ -6,7 +6,7 @@ import java.awt.geom.AffineTransform;
import org.apache.poi.sl.usermodel.*;
-public class DrawSheet<T extends Sheet<? extends Shape>> implements Drawable {
+public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> implements Drawable {
protected final T sheet;
@@ -14,14 +14,9 @@ public class DrawSheet<T extends Sheet<?
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<T extends Sheet<?
}
}
+ public void applyTransform(Graphics2D context) {
+ }
+
public void drawContent(Graphics2D context) {
- // TODO Auto-generated method stub
-
}
/**
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java Thu Mar 19 23:44:23 2015
@@ -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<T extends S
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<dashPatI.length; i++) {
- dashPatF[i] = dashPatI[i]*lineWidth;
+ dashPatF[i] = dashPatI[i]*Math.max(1, lineWidth);
}
+ LineCap lineCapE = strokeStyle.getLineCap();
+ if (lineCapE == null) lineCapE = LineCap.FLAT;
int lineCap;
- switch (strokeStyle.getLineCap()) {
+ switch (lineCapE) {
case ROUND:
lineCap = BasicStroke.CAP_ROUND;
break;
@@ -246,7 +253,7 @@ public class DrawSimpleShape<T extends S
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(
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java Thu Mar 19 23:44:23 2015
@@ -5,7 +5,7 @@ import java.awt.Graphics2D;
import org.apache.poi.sl.usermodel.*;
-public class DrawSlide<T extends Slide<? extends Shape>> extends DrawSheet<T> {
+public class DrawSlide<T extends Slide<? extends Shape, ? extends SlideShow>> extends DrawSheet<T> {
public DrawSlide(T slide) {
super(slide);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java Thu Mar 19 23:44:23 2015
@@ -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
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
}
public void applyTransform(Graphics2D graphics) {
- // TODO Auto-generated method stub
-
}
public void drawContent(Graphics2D graphics) {
- // TODO Auto-generated method stub
-
}
public TextLayout getLayout() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org