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/08 00:35:41 UTC
svn commit: r1664935 [2/4] - in /poi/branches/common_sl/src:
examples/src/org/apache/poi/hslf/examples/
ooxml/java/org/apache/poi/xslf/model/
ooxml/java/org/apache/poi/xslf/usermodel/
scratchpad/src/org/apache/poi/hslf/blip/ scratchpad/src/org/apache/p...
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Sat Mar 7 23:35:40 2015
@@ -19,17 +19,18 @@
package org.apache.poi.xslf.usermodel;
-import java.awt.*;
-import java.awt.Shape;
-import java.awt.geom.*;
-import java.util.ArrayList;
-import java.util.List;
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.draw.geom.*;
import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;
+import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Beta;
@@ -37,7 +38,7 @@ import org.apache.poi.util.Units;
import org.apache.poi.xslf.model.PropertyFetcher;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
-import org.openxmlformats.schemas.presentationml.x2006.main.*;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
/**
* Represents a single (non-group) shape in a .pptx slide show
@@ -54,75 +55,104 @@ public abstract class XSLFSimpleShape ex
/**
*
- * @return the sheet this shape belongs to
- */
- public XSLFSheet getSheet() {
- return _sheet;
- }
-
- /**
- *
* @param type
*/
public void setShapeType(ShapeType type){
- CTShape shape = (CTShape) getXmlObject();
STShapeType.Enum geom = STShapeType.Enum.forInt(type.ooxmlId);
- shape.getSpPr().getPrstGeom().setPrst(geom);
+ getSpPr().getPrstGeom().setPrst(geom);
}
public ShapeType getShapeType(){
- CTShape shape = (CTShape) getXmlObject();
- STShapeType.Enum geom = shape.getSpPr().getPrstGeom().getPrst();
+ STShapeType.Enum geom = getSpPr().getPrstGeom().getPrst();
return ShapeType.forId(geom.intValue(), true);
}
+
+ protected CTTransform2D getSafeXfrm() {
+ CTTransform2D xfrm = getXfrm();
+ return (xfrm == null ? getSpPr().addNewXfrm() : xfrm);
+ }
+
+ protected CTTransform2D getXfrm() {
+ PropertyFetcher<CTTransform2D> fetcher = new PropertyFetcher<CTTransform2D>() {
+ public boolean fetch(XSLFShape shape) {
+ CTShapeProperties pr = getSpPr();
+ if (pr.isSetXfrm()) {
+ setValue(pr.getXfrm());
+ return true;
+ }
+ return false;
+ }
+ };
+ fetchShapeProperty(fetcher);
+ return fetcher.getValue();
+ }
@Override
- public String getShapeName() {
- return getNvPr().getName();
+ public Rectangle2D getAnchor() {
+
+ CTTransform2D xfrm = getXfrm();
+
+ CTPoint2D off = xfrm.getOff();
+ long x = off.getX();
+ long y = off.getY();
+ CTPositiveSize2D ext = xfrm.getExt();
+ long cx = ext.getCx();
+ long cy = ext.getCy();
+ return new Rectangle2D.Double(
+ Units.toPoints(x), Units.toPoints(y),
+ Units.toPoints(cx), Units.toPoints(cy));
}
@Override
- public int getShapeId() {
- return (int) getNvPr().getId();
+ public void setAnchor(Rectangle2D anchor) {
+ CTTransform2D xfrm = getSafeXfrm();
+ CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
+ long x = Units.toEMU(anchor.getX());
+ long y = Units.toEMU(anchor.getY());
+ off.setX(x);
+ off.setY(y);
+ CTPositiveSize2D ext = xfrm.isSetExt() ? xfrm.getExt() : xfrm
+ .addNewExt();
+ long cx = Units.toEMU(anchor.getWidth());
+ long cy = Units.toEMU(anchor.getHeight());
+ ext.setCx(cx);
+ ext.setCy(cy);
}
-
+
@Override
public void setRotation(double theta) {
- CTShapeProperties spPr = getSpPr();
- CTTransform2D xfrm = spPr.isSetXfrm() ? spPr.getXfrm() : spPr.addNewXfrm();
- xfrm.setRot((int) (theta * 60000));
+ getSafeXfrm().setRot((int) (theta * 60000));
}
@Override
public double getRotation() {
CTTransform2D xfrm = getXfrm();
- return (double) xfrm.getRot() / 60000;
+ return (xfrm == null || !xfrm.isSetRot()) ? 0 : (xfrm.getRot() / 60000.d);
}
@Override
public void setFlipHorizontal(boolean flip) {
- CTShapeProperties spPr = getSpPr();
- CTTransform2D xfrm = spPr.isSetXfrm() ? spPr.getXfrm() : spPr.addNewXfrm();
- xfrm.setFlipH(flip);
+ getSafeXfrm().setFlipH(flip);
}
@Override
public void setFlipVertical(boolean flip) {
- CTShapeProperties spPr = getSpPr();
- CTTransform2D xfrm = spPr.isSetXfrm() ? spPr.getXfrm() : spPr.addNewXfrm();
- xfrm.setFlipV(flip);
+ getSafeXfrm().setFlipV(flip);
}
@Override
public boolean getFlipHorizontal() {
- return getXfrm().getFlipH();
+ CTTransform2D xfrm = getXfrm();
+ return (xfrm == null || !xfrm.isSetFlipH()) ? false : getXfrm().getFlipH();
}
@Override
public boolean getFlipVertical() {
- return getXfrm().getFlipV();
+ CTTransform2D xfrm = getXfrm();
+ return (xfrm == null || !xfrm.isSetFlipV()) ? false : getXfrm().getFlipV();
}
+
/**
* Get default line properties defined in the theme (if any).
* Used internally to resolve shape properties.
@@ -135,7 +165,7 @@ public abstract class XSLFSimpleShape ex
if (style != null) {
// 1-based index of a line style within the style matrix
int idx = (int) style.getLnRef().getIdx();
- CTStyleMatrix styleMatrix = _sheet.getTheme().getXmlObject().getThemeElements().getFmtScheme();
+ CTStyleMatrix styleMatrix = getSheet().getTheme().getXmlObject().getThemeElements().getFmtScheme();
ln = styleMatrix.getLnStyleLst().getLnArray(idx - 1);
}
return ln;
@@ -175,14 +205,57 @@ public abstract class XSLFSimpleShape ex
* if outline is turned off
*/
public Color getLineColor() {
- RenderableShape rShape = new RenderableShape(this);
- Paint paint = rShape.getLinePaint(null);
- if (paint instanceof Color) {
- return (Color) paint;
+ PaintStyle ps = getLinePaint();
+ if (ps == null || ps == TRANSPARENT_PAINT) return null;
+ if (ps instanceof SolidPaint) {
+ Color col = ((SolidPaint)ps).getSolidColor().getColor();
+ return (col == DrawPaint.NO_PAINT) ? null : col;
}
return null;
}
+ protected PaintStyle getLinePaint() {
+ PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {
+ public boolean fetch(XSLFShape shape) {
+ CTLineProperties spPr = shape.getSpPr().getLn();
+ if (spPr != null) {
+ if (spPr.isSetNoFill()) {
+ setValue(TRANSPARENT_PAINT); // use it as 'nofill' value
+ return true;
+ }
+ PaintStyle paint = getPaint(spPr, null);
+ if (paint != null) {
+ setValue(paint);
+ return true;
+ }
+ }
+ return false;
+
+ }
+ };
+ fetchShapeProperty(fetcher);
+
+ PaintStyle paint = fetcher.getValue();
+ if (paint != null) return paint;
+
+ // line color was not found, check if it is defined in the theme
+ CTShapeStyle style = getSpStyle();
+ if (style == null) return TRANSPARENT_PAINT;
+
+ // get a reference to a line style within the style matrix.
+ CTStyleMatrixReference lnRef = style.getLnRef();
+ int idx = (int)lnRef.getIdx();
+ CTSchemeColor phClr = lnRef.getSchemeClr();
+ if(idx > 0){
+ XSLFTheme theme = getSheet().getTheme();
+ XmlObject lnProps = theme.getXmlObject().
+ getThemeElements().getFmtScheme().getLnStyleLst().selectPath("*")[idx - 1];
+ paint = getPaint(lnProps, phClr);
+ }
+
+ return paint == null ? TRANSPARENT_PAINT : paint;
+ }
+
/**
*
* @param width line width in points. <code>0</code> means no line
@@ -377,10 +450,11 @@ public abstract class XSLFSimpleShape ex
* is not solid (pattern or gradient)
*/
public Color getFillColor() {
- RenderableShape rShape = new RenderableShape(this);
- Paint paint = rShape.getFillPaint(null);
- if (paint instanceof Color) {
- return (Color) paint;
+ PaintStyle ps = getFillPaint();
+ if (ps == null || ps == TRANSPARENT_PAINT) return null;
+ if (ps instanceof SolidPaint) {
+ Color col = ((SolidPaint)ps).getSolidColor().getColor();
+ return (col == DrawPaint.NO_PAINT) ? null : col;
}
return null;
}
@@ -410,7 +484,7 @@ public abstract class XSLFSimpleShape ex
// 1-based index of a shadow style within the style matrix
int idx = (int) style.getEffectRef().getIdx();
if(idx != 0) {
- CTStyleMatrix styleMatrix = _sheet.getTheme().getXmlObject().getThemeElements().getFmtScheme();
+ CTStyleMatrix styleMatrix = getSheet().getTheme().getXmlObject().getThemeElements().getFmtScheme();
CTEffectStyleItem ef = styleMatrix.getEffectStyleLst().getEffectStyleArray(idx - 1);
obj = ef.getEffectLst().getOuterShdw();
}
@@ -493,7 +567,7 @@ public abstract class XSLFSimpleShape ex
/**
* Specifies the line end decoration, such as a triangle or arrowhead.
*/
- public void setLineHeadDecoration(LineDecoration style) {
+ public void setLineHeadDecoration(DecorationShape style) {
CTLineProperties ln = getSpPr().getLn();
CTLineEndProperties lnEnd = ln.isSetHeadEnd() ? ln.getHeadEnd() : ln.addNewHeadEnd();
if (style == null) {
@@ -503,18 +577,18 @@ public abstract class XSLFSimpleShape ex
}
}
- public LineDecoration getLineHeadDecoration() {
+ public DecorationShape getLineHeadDecoration() {
CTLineProperties ln = getSpPr().getLn();
- if (ln == null || !ln.isSetHeadEnd()) return LineDecoration.NONE;
+ if (ln == null || !ln.isSetHeadEnd()) return DecorationShape.NONE;
STLineEndType.Enum end = ln.getHeadEnd().getType();
- return end == null ? LineDecoration.NONE : LineDecoration.values()[end.intValue() - 1];
+ return end == null ? DecorationShape.NONE : DecorationShape.values()[end.intValue() - 1];
}
/**
* specifies decorations which can be added to the head of a line.
*/
- public void setLineHeadWidth(LineEndWidth style) {
+ public void setLineHeadWidth(DecorationSize style) {
CTLineProperties ln = getSpPr().getLn();
CTLineEndProperties lnEnd = ln.isSetHeadEnd() ? ln.getHeadEnd() : ln.addNewHeadEnd();
if (style == null) {
@@ -524,18 +598,18 @@ public abstract class XSLFSimpleShape ex
}
}
- public LineEndWidth getLineHeadWidth() {
+ public DecorationSize getLineHeadWidth() {
CTLineProperties ln = getSpPr().getLn();
- if (ln == null || !ln.isSetHeadEnd()) return LineEndWidth.MEDIUM;
+ if (ln == null || !ln.isSetHeadEnd()) return DecorationSize.MEDIUM;
STLineEndWidth.Enum w = ln.getHeadEnd().getW();
- return w == null ? LineEndWidth.MEDIUM : LineEndWidth.values()[w.intValue() - 1];
+ return w == null ? DecorationSize.MEDIUM : DecorationSize.values()[w.intValue() - 1];
}
/**
* Specifies the line end width in relation to the line width.
*/
- public void setLineHeadLength(LineEndLength style) {
+ public void setLineHeadLength(DecorationSize style) {
CTLineProperties ln = getSpPr().getLn();
CTLineEndProperties lnEnd = ln.isSetHeadEnd() ? ln.getHeadEnd() : ln.addNewHeadEnd();
@@ -546,18 +620,18 @@ public abstract class XSLFSimpleShape ex
}
}
- public LineEndLength getLineHeadLength() {
+ public DecorationSize getLineHeadLength() {
CTLineProperties ln = getSpPr().getLn();
- if (ln == null || !ln.isSetHeadEnd()) return LineEndLength.MEDIUM;
+ if (ln == null || !ln.isSetHeadEnd()) return DecorationSize.MEDIUM;
STLineEndLength.Enum len = ln.getHeadEnd().getLen();
- return len == null ? LineEndLength.MEDIUM : LineEndLength.values()[len.intValue() - 1];
+ return len == null ? DecorationSize.MEDIUM : DecorationSize.values()[len.intValue() - 1];
}
/**
* Specifies the line end decoration, such as a triangle or arrowhead.
*/
- public void setLineTailDecoration(LineDecoration style) {
+ public void setLineTailDecoration(DecorationShape style) {
CTLineProperties ln = getSpPr().getLn();
CTLineEndProperties lnEnd = ln.isSetTailEnd() ? ln.getTailEnd() : ln.addNewTailEnd();
if (style == null) {
@@ -567,18 +641,18 @@ public abstract class XSLFSimpleShape ex
}
}
- public LineDecoration getLineTailDecoration() {
+ public DecorationShape getLineTailDecoration() {
CTLineProperties ln = getSpPr().getLn();
- if (ln == null || !ln.isSetTailEnd()) return LineDecoration.NONE;
+ if (ln == null || !ln.isSetTailEnd()) return DecorationShape.NONE;
STLineEndType.Enum end = ln.getTailEnd().getType();
- return end == null ? LineDecoration.NONE : LineDecoration.values()[end.intValue() - 1];
+ return end == null ? DecorationShape.NONE : DecorationShape.values()[end.intValue() - 1];
}
/**
* specifies decorations which can be added to the tail of a line.
*/
- public void setLineTailWidth(LineEndWidth style) {
+ public void setLineTailWidth(DecorationSize style) {
CTLineProperties ln = getSpPr().getLn();
CTLineEndProperties lnEnd = ln.isSetTailEnd() ? ln.getTailEnd() : ln.addNewTailEnd();
if (style == null) {
@@ -588,18 +662,18 @@ public abstract class XSLFSimpleShape ex
}
}
- public LineEndWidth getLineTailWidth() {
+ public DecorationSize getLineTailWidth() {
CTLineProperties ln = getSpPr().getLn();
- if (ln == null || !ln.isSetTailEnd()) return LineEndWidth.MEDIUM;
+ if (ln == null || !ln.isSetTailEnd()) return DecorationSize.MEDIUM;
STLineEndWidth.Enum w = ln.getTailEnd().getW();
- return w == null ? LineEndWidth.MEDIUM : LineEndWidth.values()[w.intValue() - 1];
+ return w == null ? DecorationSize.MEDIUM : DecorationSize.values()[w.intValue() - 1];
}
/**
* Specifies the line end width in relation to the line width.
*/
- public void setLineTailLength(LineEndLength style) {
+ public void setLineTailLength(DecorationSize style) {
CTLineProperties ln = getSpPr().getLn();
CTLineEndProperties lnEnd = ln.isSetTailEnd() ? ln.getTailEnd() : ln.addNewTailEnd();
@@ -610,142 +684,12 @@ public abstract class XSLFSimpleShape ex
}
}
- public LineEndLength getLineTailLength() {
+ public DecorationSize getLineTailLength() {
CTLineProperties ln = getSpPr().getLn();
- if (ln == null || !ln.isSetTailEnd()) return LineEndLength.MEDIUM;
+ if (ln == null || !ln.isSetTailEnd()) return DecorationSize.MEDIUM;
STLineEndLength.Enum len = ln.getTailEnd().getLen();
- return len == null ? LineEndLength.MEDIUM : LineEndLength.values()[len.intValue() - 1];
- }
-
- Outline getTailDecoration(Graphics2D graphics) {
- LineEndLength tailLength = getLineTailLength();
- LineEndWidth tailWidth = getLineTailWidth();
-
- double lineWidth = Math.max(2.5, getLineWidth());
-
- Rectangle2D anchor = new RenderableShape(this).getAnchor(graphics);
- double x2 = anchor.getX() + anchor.getWidth(),
- y2 = anchor.getY() + anchor.getHeight();
-
- double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());
-
- AffineTransform at = new AffineTransform();
- Shape shape = null;
- Path p = null;
- Rectangle2D bounds;
- double scaleY = Math.pow(2, tailWidth.ordinal());
- double scaleX = Math.pow(2, tailLength.ordinal());
- switch (getLineTailDecoration()) {
- case OVAL:
- p = new Path();
- shape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
- bounds = shape.getBounds2D();
- at.translate(x2 - bounds.getWidth() / 2, y2 - bounds.getHeight() / 2);
- at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
- break;
- case ARROW:
- p = new Path();
- GeneralPath arrow = new GeneralPath();
- arrow.moveTo((float) (-lineWidth * 3), (float) (-lineWidth * 2));
- arrow.lineTo(0, 0);
- arrow.lineTo((float) (-lineWidth * 3), (float) (lineWidth * 2));
- shape = arrow;
- at.translate(x2, y2);
- at.rotate(alpha);
- break;
- case TRIANGLE:
- p = new Path();
- scaleY = tailWidth.ordinal() + 1;
- scaleX = tailLength.ordinal() + 1;
- GeneralPath triangle = new GeneralPath();
- triangle.moveTo((float) (-lineWidth * scaleX), (float) (-lineWidth * scaleY / 2));
- triangle.lineTo(0, 0);
- triangle.lineTo((float) (-lineWidth * scaleX), (float) (lineWidth * scaleY / 2));
- triangle.closePath();
- shape = triangle;
- at.translate(x2, y2);
- at.rotate(alpha);
- break;
- default:
- break;
- }
-
- if (shape != null) {
- shape = at.createTransformedShape(shape);
- }
- return shape == null ? null : new Outline(shape, p);
- }
-
- Outline getHeadDecoration(Graphics2D graphics) {
- LineEndLength headLength = getLineHeadLength();
- LineEndWidth headWidth = getLineHeadWidth();
-
- double lineWidth = Math.max(2.5, getLineWidth());
-
- Rectangle2D anchor = new RenderableShape(this).getAnchor(graphics);
- double x1 = anchor.getX(),
- y1 = anchor.getY();
-
- double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());
-
- AffineTransform at = new AffineTransform();
- Shape shape = null;
- Path p = null;
- Rectangle2D bounds;
- double scaleY = 1;
- double scaleX = 1;
- switch (getLineHeadDecoration()) {
- case OVAL:
- p = new Path();
- shape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
- bounds = shape.getBounds2D();
- at.translate(x1 - bounds.getWidth() / 2, y1 - bounds.getHeight() / 2);
- at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
- break;
- case STEALTH:
- case ARROW:
- p = new Path(false, true);
- GeneralPath arrow = new GeneralPath();
- arrow.moveTo((float) (lineWidth * 3 * scaleX), (float) (-lineWidth * scaleY * 2));
- arrow.lineTo(0, 0);
- arrow.lineTo((float) (lineWidth * 3 * scaleX), (float) (lineWidth * scaleY * 2));
- shape = arrow;
- at.translate(x1, y1);
- at.rotate(alpha);
- break;
- case TRIANGLE:
- p = new Path();
- scaleY = headWidth.ordinal() + 1;
- scaleX = headLength.ordinal() + 1;
- GeneralPath triangle = new GeneralPath();
- triangle.moveTo((float) (lineWidth * scaleX), (float) (-lineWidth * scaleY / 2));
- triangle.lineTo(0, 0);
- triangle.lineTo((float) (lineWidth * scaleX), (float) (lineWidth * scaleY / 2));
- triangle.closePath();
- shape = triangle;
- at.translate(x1, y1);
- at.rotate(alpha);
- break;
- default:
- break;
- }
-
- if (shape != null) {
- shape = at.createTransformedShape(shape);
- }
- return shape == null ? null : new Outline(shape, p);
- }
-
- private List<Outline> getDecorationOutlines(Graphics2D graphics){
- List<Outline> lst = new ArrayList<Outline>();
-
- Outline head = getHeadDecoration(graphics);
- if(head != null) lst.add(head);
-
- Outline tail = getTailDecoration(graphics);
- if(tail != null) lst.add(tail);
- return lst;
+ return len == null ? DecorationSize.MEDIUM : DecorationSize.values()[len.intValue() - 1];
}
public boolean isPlaceholder() {
@@ -753,25 +697,79 @@ public abstract class XSLFSimpleShape ex
return ph != null;
}
- public Hyperlink getHyperlink() {
- // TODO Auto-generated method stub
+ @SuppressWarnings("deprecation")
+ public Guide getAdjustValue(String name) {
+ CTPresetGeometry2D prst = getSpPr().getPrstGeom();
+ if (prst.isSetAvLst()) {
+ for (CTGeomGuide g : prst.getAvLst().getGdArray()) {
+ if (g.getName().equals(name)) {
+ return new Guide(g.getName(), g.getFmla());
+ }
+ }
+ }
+
return null;
}
- public void setHyperlink(Hyperlink hyperlink) {
- // TODO Auto-generated method stub
-
+ public LineDecoration getLineDecoration() {
+ return new LineDecoration() {
+ public DecorationShape getHeadShape() {
+ return getLineHeadDecoration();
+ }
+
+ public DecorationSize getHeadWidth() {
+ return getLineHeadWidth();
+ }
+
+ public DecorationSize getHeadLength() {
+ return getLineHeadLength();
+ }
+
+ public DecorationShape getTailShape() {
+ return getLineTailDecoration();
+ }
+
+ public DecorationSize getTailWidth() {
+ return getLineTailWidth();
+ }
+
+ public DecorationSize getTailLength() {
+ return getLineTailLength();
+ }
+ };
}
- public Guide getAdjustValue(String name) {
- // TODO Auto-generated method stub
- return null;
+ /**
+ * fetch shape fill as a java.awt.Paint
+ *
+ * @return either Color or GradientPaint or TexturePaint or null
+ */
+ public FillStyle getFillStyle() {
+ return new FillStyle() {
+ public PaintStyle getPaint() {
+ return XSLFSimpleShape.this.getFillPaint();
+ }
+ };
}
- public org.apache.poi.sl.usermodel.LineDecoration getLineDecoration() {
- // TODO Auto-generated method stub
- return null;
+ public StrokeStyle getStrokeStyle() {
+ return new StrokeStyle() {
+ public PaintStyle getPaint() {
+ return XSLFSimpleShape.this.getLinePaint();
+ }
+
+ public LineCap getLineCap() {
+ return XSLFSimpleShape.this.getLineCap();
+ }
+
+ public LineDash getLineDash() {
+ return XSLFSimpleShape.this.getLineDash();
+ }
+
+ public double getLineWidth() {
+ return XSLFSimpleShape.this.getLineWidth();
+ }
+
+ };
}
-
-
}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Sat Mar 7 23:35:40 2015
@@ -16,7 +16,6 @@
==================================================================== */
package org.apache.poi.xslf.usermodel;
-import java.awt.Graphics2D;
import java.io.IOException;
import org.apache.poi.POIXMLDocumentPart;
@@ -26,21 +25,11 @@ import org.apache.poi.sl.usermodel.Notes
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
-import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
+import org.openxmlformats.schemas.presentationml.x2006.main.*;
@Beta
-public final class XSLFSlide extends XSLFSheet implements Slide {
+public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape> {
private final CTSlide _slide;
private XSLFSlideLayout _layout;
private XSLFComments _comments;
@@ -220,17 +209,6 @@ public final class XSLFSlide extends XSL
setFollowMasterGraphics(follow);
}
-
- @Override
- public void draw(Graphics2D graphics){
-
- XSLFBackground bg = getBackground();
- if(bg != null) bg.draw(graphics);
-
- super.draw(graphics);
- }
-
-
@Override
public XSLFSlide importContent(XSLFSheet src){
super.importContent(src);
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java Sat Mar 7 23:35:40 2015
@@ -31,7 +31,7 @@ import org.openxmlformats.schemas.presen
import java.io.IOException;
@Beta
-public class XSLFSlideLayout extends XSLFSheet implements MasterSheet {
+public class XSLFSlideLayout extends XSLFSheet implements MasterSheet<XSLFShape> {
private CTSlideLayout _layout;
private XSLFSlideMaster _master;
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java Sat Mar 7 23:35:40 2015
@@ -54,7 +54,7 @@ import java.util.Map;
* @author Yegor Kozlov
*/
@Beta
- public class XSLFSlideMaster extends XSLFSheet implements MasterSheet {
+ public class XSLFSlideMaster extends XSLFSheet implements MasterSheet<XSLFShape> {
private CTSlideMaster _slide;
private Map<String, XSLFSlideLayout> _layouts;
private XSLFTheme _theme;
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java Sat Mar 7 23:35:40 2015
@@ -23,42 +23,22 @@ import java.awt.Color;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.Units;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
-import org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
-import org.openxmlformats.schemas.drawingml.x2006.main.STPenAlignment;
-import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
/**
* Represents a cell of a table in a .pptx presentation
- *
- * @author Yegor Kozlov
*/
public class XSLFTableCell extends XSLFTextShape {
static double defaultBorderWidth = 1.0;
+ private CTTableCellProperties _tcPr = null;
/*package*/ XSLFTableCell(CTTableCell cell, XSLFSheet sheet){
super(cell, sheet);
}
@Override
- public CTTableCell getXmlObject(){
- return (CTTableCell)super.getXmlObject();
- }
-
- @Override
protected CTTextBody getTextBody(boolean create){
- CTTableCell cell = getXmlObject();
+ CTTableCell cell = (CTTableCell)getXmlObject();
CTTextBody txBody = cell.getTxBody();
if (txBody == null && create) {
txBody = cell.addNewTxBody();
@@ -78,135 +58,72 @@ public class XSLFTableCell extends XSLFT
return cell;
}
+ protected CTTableCellProperties getCellProperties(boolean create) {
+ if (_tcPr == null) {
+ CTTableCell cell = (CTTableCell)getXmlObject();
+ _tcPr = cell.getTcPr();
+ if (_tcPr == null && create) {
+ _tcPr = cell.addNewTcPr();
+ }
+ }
+ return _tcPr;
+ }
+
@Override
public void setLeftInset(double margin){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- if(pr == null) pr = getXmlObject().addNewTcPr();
-
+ CTTableCellProperties pr = getCellProperties(true);
pr.setMarL(Units.toEMU(margin));
}
@Override
public void setRightInset(double margin){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- if(pr == null) pr = getXmlObject().addNewTcPr();
-
+ CTTableCellProperties pr = getCellProperties(true);
pr.setMarR(Units.toEMU(margin));
}
@Override
public void setTopInset(double margin){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- if(pr == null) pr = getXmlObject().addNewTcPr();
-
+ CTTableCellProperties pr = getCellProperties(true);
pr.setMarT(Units.toEMU(margin));
}
@Override
public void setBottomInset(double margin){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- if(pr == null) pr = getXmlObject().addNewTcPr();
-
+ CTTableCellProperties pr = getCellProperties(true);
pr.setMarB(Units.toEMU(margin));
}
- public void setBorderLeft(double width){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.isSetLnL() ? pr.getLnL() : pr.addNewLnL();
- ln.setW(Units.toEMU(width));
- }
-
- public double getBorderLeft(){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.getLnL();
- return ln == null || !ln.isSetW() ? defaultBorderWidth : Units.toPoints(ln.getW());
- }
-
- public void setBorderLeftColor(Color color){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- CTLineProperties ln = pr.isSetLnL() ? pr.getLnL() : pr.addNewLnL();
- setLineColor(ln, color);
- }
-
- public Color getBorderLeftColor(){
- return getLineColor(getXmlObject().getTcPr().getLnL());
- }
-
- public void setBorderRight(double width){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.isSetLnR() ? pr.getLnR() : pr.addNewLnR();
- ln.setW(Units.toEMU(width));
- }
-
- public double getBorderRight(){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.getLnR();
- return ln == null || !ln.isSetW() ? defaultBorderWidth : Units.toPoints(ln.getW());
- }
-
- public void setBorderRightColor(Color color){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- CTLineProperties ln = pr.isSetLnR() ? pr.getLnR() : pr.addNewLnR();
- setLineColor(ln, color);
- }
-
- public Color getBorderRightColor(){
- return getLineColor(getXmlObject().getTcPr().getLnR());
- }
-
- public void setBorderTop(double width){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.isSetLnT() ? pr.getLnT() : pr.addNewLnT();
- ln.setW(Units.toEMU(width));
- }
-
- public double getBorderTop(){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.getLnT();
- return ln == null || !ln.isSetW() ? defaultBorderWidth : Units.toPoints(ln.getW());
- }
-
- public void setBorderTopColor(Color color){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- CTLineProperties ln = pr.isSetLnT() ? pr.getLnT() : pr.addNewLnT();
- setLineColor(ln, color);
- }
-
- public Color getBorderTopColor(){
- return getLineColor(getXmlObject().getTcPr().getLnT());
+ private CTLineProperties getCTLine(char bltr, boolean create) {
+ CTTableCellProperties pr = getCellProperties(create);
+ if (pr == null) return null;
+
+ switch (bltr) {
+ case 'b':
+ return (pr.isSetLnB()) ? pr.getLnB() : (create ? pr.addNewLnB() : null);
+ case 'l':
+ return (pr.isSetLnL()) ? pr.getLnL() : (create ? pr.addNewLnL() : null);
+ case 't':
+ return (pr.isSetLnT()) ? pr.getLnT() : (create ? pr.addNewLnT() : null);
+ case 'r':
+ return (pr.isSetLnR()) ? pr.getLnR() : (create ? pr.addNewLnR() : null);
+ default:
+ return null;
+ }
}
-
- public void setBorderBottom(double width){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.isSetLnB() ? pr.getLnB() : pr.addNewLnB();
+
+ private void setBorderWidth(char bltr, double width) {
+ CTLineProperties ln = getCTLine(bltr, true);
ln.setW(Units.toEMU(width));
}
- public double getBorderBottom(){
- CTTableCellProperties pr = getXmlObject().getTcPr();
-
- CTLineProperties ln = pr.getLnB();
- return ln == null || !ln.isSetW() ? defaultBorderWidth : Units.toPoints(ln.getW());
+ private double getBorderWidth(char bltr) {
+ CTLineProperties ln = getCTLine(bltr, false);
+ return (ln == null) ? defaultBorderWidth : Units.toPoints(ln.getW());
}
- public void setBorderBottomColor(Color color){
- CTTableCellProperties pr = getXmlObject().getTcPr();
- CTLineProperties ln = pr.isSetLnB() ? pr.getLnB() : pr.addNewLnB();
- setLineColor(ln, color);
- }
+ private void setBorderColor(char bltr, Color color) {
+ CTLineProperties ln = getCTLine(bltr, true);
- public Color getBorderBottomColor(){
- return getLineColor(getXmlObject().getTcPr().getLnB());
- }
-
- private void setLineColor(CTLineProperties ln, Color color){
if(color == null){
ln.addNewNoFill();
if(ln.isSetSolidFill()) ln.unsetSolidFill();
@@ -233,19 +150,85 @@ public class XSLFTableCell extends XSLFT
rgb.setVal(new byte[]{(byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue()});
ln.addNewSolidFill().setSrgbClr(rgb);
}
- }
-
- private Color getLineColor(CTLineProperties ln){
- if(ln == null || ln.isSetNoFill() || !ln.isSetSolidFill()) return null;
+ }
+
+ private Color getBorderColor(char bltr) {
+ CTLineProperties ln = getCTLine(bltr,false);
+ if (ln == null || ln.isSetNoFill() || !ln.isSetSolidFill()) return null;
CTSolidColorFillProperties fill = ln.getSolidFill();
- if(!fill.isSetSrgbClr()) {
+ if (!fill.isSetSrgbClr()) {
// TODO for now return null for all colors except explicit RGB
return null;
}
byte[] val = fill.getSrgbClr().getVal();
return new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
+ }
+
+ public void setBorderLeft(double width) {
+ setBorderWidth('l', width);
}
+
+ public double getBorderLeft() {
+ return getBorderWidth('l');
+ }
+
+ public void setBorderLeftColor(Color color) {
+ setBorderColor('l', color);
+ }
+
+ public Color getBorderLeftColor() {
+ return getBorderColor('l');
+ }
+
+ public void setBorderRight(double width) {
+ setBorderWidth('r', width);
+ }
+
+ public double getBorderRight() {
+ return getBorderWidth('r');
+ }
+
+ public void setBorderRightColor(Color color) {
+ setBorderColor('r', color);
+ }
+
+ public Color getBorderRightColor() {
+ return getBorderColor('r');
+ }
+
+ public void setBorderTop(double width) {
+ setBorderWidth('t', width);
+ }
+
+ public double getBorderTop() {
+ return getBorderWidth('t');
+ }
+
+ public void setBorderTopColor(Color color) {
+ setBorderColor('t', color);
+ }
+
+ public Color getBorderTopColor() {
+ return getBorderColor('t');
+ }
+
+ public void setBorderBottom(double width) {
+ setBorderWidth('b', width);
+ }
+
+ public double getBorderBottom() {
+ return getBorderWidth('b');
+ }
+
+ public void setBorderBottomColor(Color color) {
+ setBorderColor('b', color);
+ }
+
+ public Color getBorderBottomColor(){
+ return getBorderColor('b');
+ }
+
/**
* Specifies a solid color fill. The shape is filled entirely with the specified color.
*
@@ -254,7 +237,7 @@ public class XSLFTableCell extends XSLFT
*/
@Override
public void setFillColor(Color color) {
- CTTableCellProperties spPr = getXmlObject().getTcPr();
+ CTTableCellProperties spPr = getCellProperties(true);
if (color == null) {
if(spPr.isSetSolidFill()) spPr.unsetSolidFill();
}
@@ -274,11 +257,11 @@ public class XSLFTableCell extends XSLFT
*/
@Override
public Color getFillColor(){
- CTTableCellProperties spPr = getXmlObject().getTcPr();
- if(!spPr.isSetSolidFill() ) return null;
+ CTTableCellProperties spPr = getCellProperties(false);
+ if (spPr == null || !spPr.isSetSolidFill()) return null;
CTSolidColorFillProperties fill = spPr.getSolidFill();
- if(!fill.isSetSrgbClr()) {
+ if (!fill.isSetSrgbClr()) {
// TODO for now return null for all colors except explicit RGB
return null;
}
@@ -287,38 +270,36 @@ public class XSLFTableCell extends XSLFT
}
void setGridSpan(int gridSpan_) {
- getXmlObject().setGridSpan(gridSpan_);
+ ((CTTableCell)getXmlObject()).setGridSpan(gridSpan_);
}
void setRowSpan(int rowSpan_) {
- getXmlObject().setRowSpan(rowSpan_);
+ ((CTTableCell)getXmlObject()).setRowSpan(rowSpan_);
}
void setHMerge(boolean merge_) {
- getXmlObject().setHMerge(merge_);
+ ((CTTableCell)getXmlObject()).setHMerge(merge_);
}
void setVMerge(boolean merge_) {
- getXmlObject().setVMerge(merge_);
+ ((CTTableCell)getXmlObject()).setVMerge(merge_);
}
@Override
public void setVerticalAlignment(VerticalAlignment anchor){
- CTTableCellProperties cellProps = getXmlObject().getTcPr();
- if(cellProps != null) {
- if(anchor == null) {
- if(cellProps.isSetAnchor()) {
- cellProps.unsetAnchor();
- }
- } else {
- cellProps.setAnchor(STTextAnchoringType.Enum.forInt(anchor.ordinal() + 1));
+ CTTableCellProperties cellProps = getCellProperties(true);
+ if(anchor == null) {
+ if(cellProps.isSetAnchor()) {
+ cellProps.unsetAnchor();
}
- }
+ } else {
+ cellProps.setAnchor(STTextAnchoringType.Enum.forInt(anchor.ordinal() + 1));
+ }
}
@Override
public VerticalAlignment getVerticalAlignment(){
- CTTableCellProperties cellProps = getXmlObject().getTcPr();
+ CTTableCellProperties cellProps = getCellProperties(false);
VerticalAlignment align = VerticalAlignment.TOP;
if(cellProps != null && cellProps.isSetAnchor()) {
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Sat Mar 7 23:35:40 2015
@@ -17,8 +17,6 @@
package org.apache.poi.xslf.usermodel;
import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
import java.util.*;
import org.apache.poi.sl.usermodel.TextParagraph;
@@ -37,7 +35,7 @@ import org.openxmlformats.schemas.presen
* @since POI-3.8
*/
@Beta
-public class XSLFTextParagraph implements TextParagraph {
+public class XSLFTextParagraph implements TextParagraph<XSLFTextRun> {
private final CTTextParagraph _p;
private final List<XSLFTextRun> _runs;
private final XSLFTextShape _shape;
@@ -697,44 +695,6 @@ public class XSLFTextParagraph implement
return "[" + getClass() + "]" + getText();
}
- /**
- * Returns wrapping width to break lines in this paragraph
- *
- * @param firstLine whether the first line is breaking
- *
- * @return wrapping width in points
- */
- double getWrappingWidth(boolean firstLine, Graphics2D graphics){
- // internal margins for the text box
- double leftInset = _shape.getLeftInset();
- double rightInset = _shape.getRightInset();
-
- RenderableShape rShape = new RenderableShape(_shape);
- Rectangle2D anchor = rShape.getAnchor(graphics);
-
- double leftMargin = getLeftMargin();
- double indent = getIndent();
-
- double width;
- if(!_shape.getWordWrap()) {
- // if wordWrap == false then we return the advance to the right border of the sheet
- width = _shape.getSheet().getSlideShow().getPageSize().getWidth() - anchor.getX();
- } else {
- width = anchor.getWidth() - leftInset - rightInset - leftMargin;
- if(firstLine) {
- if(isBullet()){
- if(indent > 0) width -= indent;
- } else {
- if(indent > 0) width -= indent; // first line indentation
- else if (indent < 0) { // hanging indentation: the first line start at the left margin
- width += leftMargin;
- }
- }
- }
- }
-
- return width;
- }
CTTextParagraphProperties getDefaultMasterStyle(){
CTPlaceholder ph = _shape.getCTPlaceholder();
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java Sat Mar 7 23:35:40 2015
@@ -19,17 +19,13 @@
package org.apache.poi.xslf.usermodel;
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
import java.util.*;
import org.apache.poi.POIXMLException;
import org.apache.poi.sl.draw.DrawFactory;
-import org.apache.poi.sl.draw.geom.Guide;
+import org.apache.poi.sl.draw.DrawTextShape;
import org.apache.poi.sl.usermodel.*;
-import org.apache.poi.sl.usermodel.LineDecoration;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.model.PropertyFetcher;
@@ -40,18 +36,11 @@ import org.openxmlformats.schemas.presen
/**
* Represents a shape that can hold text.
- *
- * @author Yegor Kozlov
*/
@Beta
-public abstract class XSLFTextShape extends XSLFSimpleShape implements TextShape {
+public abstract class XSLFTextShape extends XSLFSimpleShape implements TextShape<XSLFTextParagraph> {
private final List<XSLFTextParagraph> _paragraphs;
- /**
- * whether the text was broken into lines.
- */
- private boolean _isTextBroken;
-
@SuppressWarnings("deprecation")
/*package*/ XSLFTextShape(XmlObject shape, XSLFSheet sheet) {
super(shape, sheet);
@@ -66,7 +55,7 @@ public abstract class XSLFTextShape exte
}
public Iterator<XSLFTextParagraph> iterator(){
- return _paragraphs.iterator();
+ return getTextParagraphs().iterator();
}
/**
@@ -408,22 +397,15 @@ public abstract class XSLFTextShape exte
return textBody == null ? null : textBody.getBodyPr();
}
-
protected abstract CTTextBody getTextBody(boolean create);
public Placeholder getTextType(){
- CTPlaceholder ph;
- XmlObject[] obj = getXmlObject().selectPath(
- "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:nvPr/p:ph");
- if(obj.length == 1){
- ph = (CTPlaceholder)obj[0];
- int val = ph.getType().intValue();
- return Placeholder.values()[val - 1];
- }
- else {
- return null;
- }
+ CTPlaceholder ph = getCTPlaceholder();
+ if (ph == null) return null;
+
+ int val = ph.getType().intValue();
+ return Placeholder.values()[val - 1];
}
@@ -437,10 +419,11 @@ public abstract class XSLFTextShape exte
* @param placeholder
*/
public void setPlaceholder(Placeholder placeholder){
- CTShape sh = (CTShape)getXmlObject();
- CTApplicationNonVisualDrawingProps nv = sh.getNvSpPr().getNvPr();
+ String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:nvPr";
+ CTApplicationNonVisualDrawingProps nv = selectProperty(CTApplicationNonVisualDrawingProps.class, xquery);
+ if (nv == null) return;
if(placeholder == null) {
- if(nv.isSetPh()) nv.unsetPh();
+ if (nv.isSetPh()) nv.unsetPh();
} else {
nv.addNewPh().setType(STPlaceholderType.Enum.forInt(placeholder.ordinal() + 1));
}
@@ -450,14 +433,9 @@ public abstract class XSLFTextShape exte
* Compute the cumulative height occupied by the text
*/
public double getTextHeight(){
- // dry-run in a 1x1 image and return the vertical advance
- BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
- Graphics2D graphics = img.createGraphics();
- DrawFactory fact = DrawFactory.getInstance(graphics);
- fact.getDrawable(this);
-
- breakText(graphics);
- return drawParagraphs(graphics, 0, 0);
+ DrawFactory drawFact = DrawFactory.getInstance(null);
+ DrawTextShape<XSLFTextShape> dts = drawFact.getDrawable(this);
+ return dts.getTextHeight();
}
/**
@@ -521,19 +499,4 @@ public abstract class XSLFTextShape exte
}
}
-
- public LineDecoration getLineDecoration() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public FillStyle getFillStyle() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Guide getAdjustValue(String name) {
- // TODO Auto-generated method stub
- return null;
- }
}
\ No newline at end of file
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java Sat Mar 7 23:35:40 2015
@@ -18,7 +18,7 @@
package org.apache.poi.hslf.blip;
import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.model.Shape;
+import org.apache.poi.hslf.model.HSLFShape;
import org.apache.poi.hslf.exceptions.HSLFException;
import java.io.ByteArrayOutputStream;
@@ -67,7 +67,7 @@ public final class EMF extends Metafile
header.wmfsize = data.length;
//we don't have a EMF reader in java, have to set default image size 200x200
header.bounds = new java.awt.Rectangle(0, 0, 200, 200);
- header.size = new java.awt.Dimension(header.bounds.width*Shape.EMU_PER_POINT, header.bounds.height*Shape.EMU_PER_POINT);
+ header.size = new java.awt.Dimension(header.bounds.width*HSLFShape.EMU_PER_POINT, header.bounds.height*HSLFShape.EMU_PER_POINT);
header.zipsize = compressed.length;
byte[] checksum = getChecksum(data);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java Sat Mar 7 23:35:40 2015
@@ -24,7 +24,7 @@ import java.util.zip.InflaterInputStream
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.model.Shape;
+import org.apache.poi.hslf.model.HSLFShape;
/**
* Represents Macintosh PICT picture data.
@@ -86,8 +86,8 @@ public final class PICT extends Metafile
header.wmfsize = data.length - 512;
//we don't have a PICT reader in java, have to set default image size 200x200
header.bounds = new java.awt.Rectangle(0, 0, 200, 200);
- header.size = new java.awt.Dimension(header.bounds.width*Shape.EMU_PER_POINT,
- header.bounds.height*Shape.EMU_PER_POINT);
+ header.size = new java.awt.Dimension(header.bounds.width*HSLFShape.EMU_PER_POINT,
+ header.bounds.height*HSLFShape.EMU_PER_POINT);
header.zipsize = compressed.length;
byte[] checksum = getChecksum(data);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java Sat Mar 7 23:35:40 2015
@@ -20,7 +20,7 @@ package org.apache.poi.hslf.blip;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.model.Shape;
+import org.apache.poi.hslf.model.HSLFShape;
import org.apache.poi.hslf.exceptions.HSLFException;
import java.io.*;
@@ -78,7 +78,7 @@ public final class WMF extends Metafile
header.wmfsize = data.length - aldus.getSize();
header.bounds = new java.awt.Rectangle((short)aldus.left, (short)aldus.top, (short)aldus.right-(short)aldus.left, (short)aldus.bottom-(short)aldus.top);
//coefficient to translate from WMF dpi to 96pdi
- int coeff = 96*Shape.EMU_PER_POINT/aldus.inch;
+ int coeff = 96*HSLFShape.EMU_PER_POINT/aldus.inch;
header.size = new java.awt.Dimension(header.bounds.width*coeff, header.bounds.height*coeff);
header.zipsize = compressed.length;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java Sat Mar 7 23:35:40 2015
@@ -192,7 +192,7 @@ public final class PowerPointExtractor e
for (int i = 0; i < _slides.length; i++) {
Slide slide = _slides[i];
- Shape[] shapes = slide.getShapes();
+ HSLFShape[] shapes = slide.getShapes();
for (int j = 0; j < shapes.length; j++) {
if (shapes[j] instanceof OLEShape) {
list.add((OLEShape) shapes[j]);
@@ -221,7 +221,7 @@ public final class PowerPointExtractor e
if (getSlideText) {
if (getMasterText) {
for (SlideMaster master : _show.getSlidesMasters()) {
- for(Shape sh : master.getShapes()){
+ for(HSLFShape sh : master.getShapes()){
if(sh instanceof TextShape){
if(MasterSheet.isPlaceholder(sh)) {
// don't bother about boiler
@@ -255,7 +255,7 @@ public final class PowerPointExtractor e
textRunsToText(ret, slide.getTextRuns());
// Table text
- for (Shape shape : slide.getShapes()){
+ for (HSLFShape shape : slide.getShapes()){
if (shape instanceof Table){
extractTableText(ret, (Table)shape);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java Sat Mar 7 23:35:40 2015
@@ -65,7 +65,7 @@ public final class ActiveXShape extends
* this picture in the <code>Slide</code>
* @param parent the parent shape of this picture
*/
- protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
+ protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
super(escherRecord, parent);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java Sat Mar 7 23:35:40 2015
@@ -35,13 +35,13 @@ import java.awt.geom.Rectangle2D;
*/
public class AutoShape extends TextShape {
- protected AutoShape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
+ protected AutoShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
super(escherRecord, parent);
}
- public AutoShape(ShapeType type, ShapeContainer<Shape> parent){
+ public AutoShape(ShapeType type, ShapeContainer<HSLFShape> parent){
super(null, parent);
- _escherContainer = createSpContainer(type, parent instanceof ShapeGroup);
+ _escherContainer = createSpContainer(type, parent instanceof HSLFGroupShape);
}
public AutoShape(ShapeType type){
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java Sat Mar 7 23:35:40 2015
@@ -70,14 +70,14 @@ public final class AutoShapes {
shapes = new ShapeOutline[255];
shapes[ShapeType.RECT.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
Rectangle2D path = new Rectangle2D.Float(0, 0, 21600, 21600);
return path;
}
};
shapes[ShapeType.ROUND_RECT.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
RoundRectangle2D path = new RoundRectangle2D.Float(0, 0, 21600, 21600, adjval, adjval);
return path;
@@ -85,14 +85,14 @@ public final class AutoShapes {
};
shapes[ShapeType.ELLIPSE.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
Ellipse2D path = new Ellipse2D.Float(0, 0, 21600, 21600);
return path;
}
};
shapes[ShapeType.DIAMOND.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
GeneralPath path = new GeneralPath();
path.moveTo(10800, 0);
path.lineTo(21600, 10800);
@@ -105,7 +105,7 @@ public final class AutoShapes {
//m@0,l,21600r21600
shapes[ShapeType.TRIANGLE.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 10800);
GeneralPath path = new GeneralPath();
path.moveTo(adjval, 0);
@@ -117,7 +117,7 @@ public final class AutoShapes {
};
shapes[ShapeType.RT_TRIANGLE.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
GeneralPath path = new GeneralPath();
path.moveTo(0, 0);
path.lineTo(21600, 21600);
@@ -128,7 +128,7 @@ public final class AutoShapes {
};
shapes[ShapeType.PARALLELOGRAM.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
GeneralPath path = new GeneralPath();
@@ -142,7 +142,7 @@ public final class AutoShapes {
};
shapes[ShapeType.TRAPEZOID.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
GeneralPath path = new GeneralPath();
@@ -156,7 +156,7 @@ public final class AutoShapes {
};
shapes[ShapeType.HEXAGON.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
GeneralPath path = new GeneralPath();
@@ -172,7 +172,7 @@ public final class AutoShapes {
};
shapes[ShapeType.OCTAGON.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 6326);
GeneralPath path = new GeneralPath();
@@ -190,7 +190,7 @@ public final class AutoShapes {
};
shapes[ShapeType.PLUS.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
GeneralPath path = new GeneralPath();
@@ -212,7 +212,7 @@ public final class AutoShapes {
};
shapes[ShapeType.PENTAGON.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
GeneralPath path = new GeneralPath();
path.moveTo(10800, 0);
@@ -226,7 +226,7 @@ public final class AutoShapes {
};
shapes[ShapeType.DOWN_ARROW.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m0@0 l@1@0 @1,0 @2,0 @2@0,21600@0,10800,21600xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);
int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
@@ -244,7 +244,7 @@ public final class AutoShapes {
};
shapes[ShapeType.UP_ARROW.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m0@0 l@1@0 @1,21600@2,21600@2@0,21600@0,10800,xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
@@ -262,7 +262,7 @@ public final class AutoShapes {
};
shapes[ShapeType.RIGHT_ARROW.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m@0, l@0@1 ,0@1,0@2@0@2@0,21600,21600,10800xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 16200);
int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
@@ -280,7 +280,7 @@ public final class AutoShapes {
};
shapes[ShapeType.LEFT_ARROW.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m@0, l@0@1,21600@1,21600@2@0@2@0,21600,,10800xe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 5400);
@@ -298,7 +298,7 @@ public final class AutoShapes {
};
shapes[ShapeType.CAN.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m10800,qx0@1l0@2qy10800,21600,21600@2l21600@1qy10800,xem0@1qy10800@0,21600@1nfe
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 5400);
@@ -322,7 +322,7 @@ public final class AutoShapes {
};
shapes[ShapeType.LEFT_BRACE.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m21600,qx10800@0l10800@2qy0@11,10800@3l10800@1qy21600,21600e
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);
int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 10800);
@@ -350,7 +350,7 @@ public final class AutoShapes {
};
shapes[ShapeType.RIGHT_BRACE.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
//m,qx10800@0 l10800@2qy21600@11,10800@3l10800@1qy,21600e
int adjval = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUSTVALUE, 1800);
int adjval2 = shape.getEscherProperty(EscherProperties.GEOMETRY__ADJUST2VALUE, 10800);
@@ -378,7 +378,7 @@ public final class AutoShapes {
};
shapes[ShapeType.STRAIGHT_CONNECTOR_1.nativeId] = new ShapeOutline(){
- public java.awt.Shape getOutline(Shape shape){
+ public java.awt.Shape getOutline(HSLFShape shape){
return new Line2D.Float(0, 0, 21600, 21600);
}
};
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Background.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Background.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Background.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Background.java Sat Mar 7 23:35:40 2015
@@ -38,9 +38,9 @@ import org.apache.poi.util.POILogger;
*
* @author Yegor Kozlov
*/
-public final class Background extends Shape {
+public final class Background extends HSLFShape {
- protected Background(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent) {
+ protected Background(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent) {
super(escherRecord, parent);
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java Sat Mar 7 23:35:40 2015
@@ -98,7 +98,7 @@ public final class Fill {
/**
* The shape this background applies to
*/
- protected Shape shape;
+ protected HSLFShape shape;
/**
* Construct a <code>Fill</code> object for a shape.
@@ -106,7 +106,7 @@ public final class Fill {
*
* @param shape the shape this background applies to
*/
- public Fill(Shape shape){
+ public Fill(HSLFShape shape){
this.shape = shape;
}
@@ -118,7 +118,7 @@ public final class Fill {
*/
public int getFillType(){
EscherOptRecord opt = shape.getEscherOptRecord();
- EscherSimpleProperty prop = Shape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
+ EscherSimpleProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
return prop == null ? FILL_SOLID : prop.getPropertyValue();
}
@@ -126,7 +126,7 @@ public final class Fill {
*/
protected void afterInsert(Sheet sh){
EscherOptRecord opt = shape.getEscherOptRecord();
- EscherSimpleProperty p = Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
+ EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if(p != null) {
int idx = p.getPropertyValue();
EscherBSERecord bse = getEscherBSERecord(idx);
@@ -143,7 +143,7 @@ public final class Fill {
SlideShow ppt = sheet.getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
- EscherContainerRecord bstore = Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
+ EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if(bstore == null) {
logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
@@ -160,7 +160,7 @@ public final class Fill {
*/
public void setFillType(int type){
EscherOptRecord opt = shape.getEscherOptRecord();
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);
+ HSLFShape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type);
}
/**
@@ -168,7 +168,7 @@ public final class Fill {
*/
public Color getForegroundColor(){
EscherOptRecord opt = shape.getEscherOptRecord();
- EscherSimpleProperty p = Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
+ EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
if(p != null && (p.getPropertyValue() & 0x10) == 0) return null;
@@ -182,12 +182,12 @@ public final class Fill {
public void setForegroundColor(Color color){
EscherOptRecord opt = shape.getEscherOptRecord();
if (color == null) {
- Shape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150000);
+ HSLFShape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150000);
}
else {
int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
- Shape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150011);
+ HSLFShape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb);
+ HSLFShape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150011);
}
}
@@ -196,7 +196,7 @@ public final class Fill {
*/
public Color getBackgroundColor(){
EscherOptRecord opt = shape.getEscherOptRecord();
- EscherSimpleProperty p = Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
+ EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
if(p != null && (p.getPropertyValue() & 0x10) == 0) return null;
@@ -209,11 +209,11 @@ public final class Fill {
public void setBackgroundColor(Color color){
EscherOptRecord opt = shape.getEscherOptRecord();
if (color == null) {
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);
+ HSLFShape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1);
}
else {
int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();
- Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);
+ HSLFShape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);
}
}
@@ -222,7 +222,7 @@ public final class Fill {
*/
public PictureData getPictureData(){
EscherOptRecord opt = shape.getEscherOptRecord();
- EscherSimpleProperty p = Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
+ EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if (p == null) return null;
SlideShow ppt = shape.getSheet().getSlideShow();
@@ -230,7 +230,7 @@ public final class Fill {
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
- EscherContainerRecord bstore = Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
+ EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
java.util.List<EscherRecord> lst = bstore.getChildRecords();
int idx = p.getPropertyValue();
@@ -255,7 +255,7 @@ public final class Fill {
*/
public void setPictureData(int idx){
EscherOptRecord opt = shape.getEscherOptRecord();
- Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);
+ HSLFShape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx);
if( idx != 0 ) {
if( shape.getSheet() != null ) {
EscherBSERecord bse = getEscherBSERecord(idx);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java Sat Mar 7 23:35:40 2015
@@ -62,7 +62,7 @@ public final class Freeform extends Auto
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
- protected Freeform(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
+ protected Freeform(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
super(escherRecord, parent);
}
@@ -73,9 +73,9 @@ public final class Freeform extends Auto
* @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 Freeform(ShapeContainer<Shape> parent){
+ public Freeform(ShapeContainer<HSLFShape> parent){
super((EscherContainerRecord)null, parent);
- _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof ShapeGroup);
+ _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
}
/**
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java (from r1662967, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java&r1=1662967&r2=1664935&rev=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java Sat Mar 7 23:35:40 2015
@@ -40,13 +40,13 @@ import org.apache.poi.util.POILogger;
*
* @author Yegor Kozlov
*/
-public class ShapeGroup extends Shape implements ShapeContainer<Shape> {
+public class HSLFGroupShape extends HSLFShape implements ShapeContainer<HSLFShape> {
/**
* Create a new ShapeGroup. This constructor is used when a new shape is created.
*
*/
- public ShapeGroup(){
+ public HSLFGroupShape(){
this(null, null);
_escherContainer = createSpContainer(false);
}
@@ -57,16 +57,16 @@ public class ShapeGroup extends Shape im
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of the shape
*/
- protected ShapeGroup(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
+ protected HSLFGroupShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
super(escherRecord, parent);
}
/**
* @return the shapes contained in this group container
*/
- public Shape[] getShapes() {
- List<Shape> shapeList = getShapeList();
- Shape[] shapes = shapeList.toArray(new Shape[shapeList.size()]);
+ public HSLFShape[] getShapes() {
+ List<HSLFShape> shapeList = getShapeList();
+ HSLFShape[] shapes = shapeList.toArray(new HSLFShape[shapeList.size()]);
return shapes;
}
@@ -174,7 +174,7 @@ public class ShapeGroup extends Shape im
*
* @param shape - the Shape to add
*/
- public void addShape(Shape shape){
+ public void addShape(HSLFShape shape){
_escherContainer.addChildRecord(shape.getSpContainer());
Sheet sheet = getSheet();
@@ -196,7 +196,7 @@ public class ShapeGroup extends Shape im
anchor.translate(dx, dy);
setAnchor(anchor);
- Shape[] shape = getShapes();
+ HSLFShape[] shape = getShapes();
for (int i = 0; i < shape.length; i++) {
java.awt.Rectangle chanchor = shape[i].getAnchor();
chanchor.translate(dx, dy);
@@ -257,7 +257,7 @@ public class ShapeGroup extends Shape im
AffineTransform at = graphics.getTransform();
- Shape[] sh = getShapes();
+ HSLFShape[] sh = getShapes();
for (int i = 0; i < sh.length; i++) {
sh[i].draw(graphics);
}
@@ -271,11 +271,11 @@ public class ShapeGroup extends Shape im
return groupInfoContainer.getChildById((short)recordId);
}
- public Iterator<Shape> iterator() {
+ public Iterator<HSLFShape> iterator() {
return getShapeList().iterator();
}
- public boolean removeShape(Shape shape) {
+ public boolean removeShape(HSLFShape shape) {
// TODO: implement!
throw new UnsupportedOperationException();
}
@@ -283,7 +283,7 @@ public class ShapeGroup extends Shape im
/**
* @return the shapes contained in this group container
*/
- protected List<Shape> getShapeList() {
+ protected List<HSLFShape> getShapeList() {
// Out escher container record should contain several
// SpContainers, the first of which is the group shape itself
Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
@@ -292,13 +292,13 @@ public class ShapeGroup extends Shape im
if (iter.hasNext()) {
iter.next();
}
- List<Shape> shapeList = new ArrayList<Shape>();
+ List<HSLFShape> shapeList = new ArrayList<HSLFShape>();
while (iter.hasNext()) {
EscherRecord r = iter.next();
if(r instanceof EscherContainerRecord) {
// Create the Shape for it
EscherContainerRecord container = (EscherContainerRecord)r;
- Shape shape = ShapeFactory.createShape(container, this);
+ HSLFShape shape = ShapeFactory.createShape(container, this);
shape.setSheet(getSheet());
shapeList.add( shape );
} else {
Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java (from r1662967, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java&r1=1662967&r2=1664935&rev=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java Sat Mar 7 23:35:40 2015
@@ -45,7 +45,7 @@ import java.awt.geom.Rectangle2D;
*
* @author Yegor Kozlov
*/
-public abstract class Shape implements org.apache.poi.sl.usermodel.Shape<Shape> {
+public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSLFShape> {
// For logging
protected POILogger logger = POILogFactory.getLogger(this.getClass());
@@ -85,7 +85,7 @@ public abstract class Shape implements o
* Parent of this shape.
* <code>null</code> for the topmost shapes.
*/
- protected ShapeContainer<Shape> _parent;
+ protected ShapeContainer<HSLFShape> _parent;
/**
* The <code>Sheet</code> this shape belongs to
@@ -103,7 +103,7 @@ public abstract class Shape implements o
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
* @param parent the parent of this Shape
*/
- protected Shape(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
+ protected HSLFShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
_escherContainer = escherRecord;
_parent = parent;
}
@@ -116,7 +116,7 @@ public abstract class Shape implements o
/**
* @return the parent of this shape
*/
- public ShapeContainer<Shape> getParent(){
+ public ShapeContainer<HSLFShape> getParent(){
return _parent;
}
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=1664935&r1=1664934&r2=1664935&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 Sat Mar 7 23:35:40 2015
@@ -176,7 +176,7 @@ public final class Hyperlink {
* @param shape <code>Shape</code> to lookup hyperlink in
* @return found hyperlink or <code>null</code>
*/
- protected static Hyperlink find(Shape shape){
+ protected static Hyperlink find(HSLFShape shape){
List<Hyperlink> lst = new ArrayList<Hyperlink>();
SlideShow ppt = shape.getSheet().getSlideShow();
//document-level container which stores info about all links in a presentation
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=1664935&r1=1664934&r2=1664935&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 Sat Mar 7 23:35:40 2015
@@ -97,13 +97,13 @@ public final class Line extends SimpleSh
public static final int LINE_TRIPLE = 4;
- protected Line(EscherContainerRecord escherRecord, ShapeContainer<Shape> parent){
+ protected Line(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
super(escherRecord, parent);
}
- public Line(ShapeContainer<Shape> parent){
+ public Line(ShapeContainer<HSLFShape> parent){
super(null, parent);
- _escherContainer = createSpContainer(parent instanceof ShapeGroup);
+ _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
}
public Line(){
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java?rev=1664935&r1=1664934&r2=1664935&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.java Sat Mar 7 23:35:40 2015
@@ -46,7 +46,7 @@ public abstract class MasterSheet extend
*
* @return true if the shape is a placeholder
*/
- public static boolean isPlaceholder(Shape shape){
+ public static boolean isPlaceholder(HSLFShape shape){
if(!(shape instanceof TextShape)) return false;
TextShape tx = (TextShape)shape;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org