aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-03-19 23:44:23 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-03-19 23:44:23 +0000
commit9a85a2e76bc5317617119f8644c7c6303a0e97dd (patch)
tree58cc24d738e3ccb9059d3d13d9da1967080c1230 /src/ooxml
parent7afac11f67ef21f520dc7b2e797e36f432624222 (diff)
downloadpoi-9a85a2e76bc5317617119f8644c7c6303a0e97dd.tar.gz
poi-9a85a2e76bc5317617119f8644c7c6303a0e97dd.zip
Snapshot commit - still lots of errors, xslf rendering works, started work on hslf
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/common_sl@1667902 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java16
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java23
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java18
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java37
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java39
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java63
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java2
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java4
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java81
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java12
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java168
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java11
17 files changed, 276 insertions, 227 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
index 57e96f8ee5..9a58a5128a 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
@@ -19,25 +19,19 @@
package org.apache.poi.xslf.usermodel;
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
-import org.apache.poi.openxml4j.opc.PackagePart;
-import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.openxml4j.opc.TargetMode;
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.openxml4j.opc.*;
+import org.apache.poi.sl.usermodel.PlaceableShape;
+import org.apache.poi.sl.usermodel.ShapeGroup;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
+import org.openxmlformats.schemas.presentationml.x2006.main.*;
/**
* Represents a group shape that consists of many shapes grouped together.
@@ -45,7 +39,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
* @author Yegor Kozlov
*/
@Beta
-public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, PlaceableShape {
+public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, ShapeGroup<XSLFShape> {
private final List<XSLFShape> _shapes;
private final CTGroupShapeProperties _grpSpPr;
private XSLFDrawing _drawing;
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
index 62f9cc4ad6..a953e2013e 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
@@ -17,20 +17,19 @@
package org.apache.poi.xslf.usermodel;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.sl.usermodel.Notes;
-import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlException;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
-import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
+import org.openxmlformats.schemas.presentationml.x2006.main.*;
@Beta
-public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape> {
+public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape,XMLSlideShow> {
private CTNotesSlide _notes;
/**
@@ -91,19 +90,15 @@ public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape> {
return null;
}
- public TextRun getTextRun() {
+ @Override
+ public List<XSLFTextParagraph> getTextParagraphs() {
+ List<XSLFTextParagraph> tp = new ArrayList<XSLFTextParagraph>();
for (XSLFShape sh : super.getShapes()) {
if (sh instanceof XSLFTextShape) {
XSLFTextShape txt = (XSLFTextShape)sh;
- for (XSLFTextParagraph p : txt.getTextParagraphs()) {
- for (XSLFTextRun r : p.getTextRuns()) {
- return r;
- }
- }
+ tp.addAll(txt.getTextParagraphs());
}
}
- return null;
+ return tp;
}
-
-
}
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
index c5de537677..aeea5cc521 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
@@ -47,7 +47,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
* @author Yegor Kozlov
*/
@Beta
- public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape> {
+ public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape,XMLSlideShow> {
private CTNotesMaster _slide;
private XSLFTheme _theme;
@@ -94,7 +94,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
}
@Override
- public MasterSheet getMasterSheet() {
+ public MasterSheet<XSLFShape,XMLSlideShow> getMasterSheet() {
return null;
}
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
index d0f75e0535..b815e00d42 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
@@ -19,7 +19,6 @@
package org.apache.poi.xslf.usermodel;
-import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
@@ -32,27 +31,18 @@ import javax.xml.namespace.QName;
import org.apache.poi.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.sl.usermodel.PictureShape;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTRelativeRect;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
+import org.openxmlformats.schemas.presentationml.x2006.main.*;
/**
* Represents a picture shape
*/
@Beta
-public class XSLFPictureShape extends XSLFSimpleShape {
+public class XSLFPictureShape extends XSLFSimpleShape implements PictureShape {
private XSLFPictureData _data;
/*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) {
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java
index 9004a6be5f..0b0e4f0aad 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java
@@ -88,7 +88,7 @@ public class XSLFShadow extends XSLFShape implements Shadow {
*/
public Color getFillColor() {
SolidPaint ps = getFillStyle();
- if (ps == TRANSPARENT_PAINT) return null;
+ if (ps == PaintStyle.TRANSPARENT_PAINT) return null;
Color col = DrawPaint.applyColorTransform(ps.getSolidColor());
return col;
}
@@ -97,7 +97,7 @@ public class XSLFShadow extends XSLFShape implements Shadow {
public SolidPaint getFillStyle() {
XSLFTheme theme = getSheet().getTheme();
CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
- if(ct == null) return TRANSPARENT_PAINT;
+ if(ct == null) return PaintStyle.TRANSPARENT_PAINT;
CTSchemeColor phClr = ct.getSchemeClr();
final XSLFColor xc = new XSLFColor(ct, theme, phClr);
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
index 5634838302..0f2ba25834 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
@@ -19,7 +19,6 @@
package org.apache.poi.xslf.usermodel;
-import java.awt.Color;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
@@ -28,7 +27,6 @@ import java.util.Comparator;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
@@ -56,19 +54,6 @@ public abstract class XSLFShape implements Shape {
private CTNonVisualDrawingProps _nvPr;
private CTPlaceholder _ph;
- protected static final SolidPaint TRANSPARENT_PAINT = new SolidPaint() {
- public ColorStyle getSolidColor() {
- return new ColorStyle(){
- public Color getColor() { return DrawPaint.NO_PAINT; }
- 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; }
- };
- }
- };
-
protected XSLFShape(XmlObject shape, XSLFSheet sheet) {
_shape = shape;
_sheet = sheet;
@@ -146,7 +131,7 @@ public abstract class XSLFShape implements Shape {
try {
pr = shape.getSpPr();
if (((CTShapeProperties)pr).isSetNoFill()) {
- setValue(TRANSPARENT_PAINT);
+ setValue(PaintStyle.TRANSPARENT_PAINT);
return true;
}
} catch (IllegalStateException e) {}
@@ -158,7 +143,7 @@ public abstract class XSLFShape implements Shape {
pr = shape.getGrpSpPr();
}
if (pr == null) {
- setValue(TRANSPARENT_PAINT);
+ setValue(PaintStyle.TRANSPARENT_PAINT);
return true;
}
@@ -190,7 +175,7 @@ public abstract class XSLFShape implements Shape {
fillRef = getBgRef();
}
if (fillRef == null) {
- return TRANSPARENT_PAINT;
+ return PaintStyle.TRANSPARENT_PAINT;
}
// The idx attribute refers to the index of a fill style or
@@ -213,21 +198,21 @@ public abstract class XSLFShape implements Shape {
paint = selectPaint(fillProps, phClr, sheet.getPackagePart());
}
- return paint == null ? TRANSPARENT_PAINT : paint;
+ return paint == null ? PaintStyle.TRANSPARENT_PAINT : paint;
}
protected CTBackgroundProperties getBgPr() {
- String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:bgPr";
+ String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgPr";
return selectProperty(CTBackgroundProperties.class, xquery);
}
protected CTStyleMatrixReference getBgRef() {
- String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:bgRef";
+ String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgRef";
return selectProperty(CTStyleMatrixReference.class, xquery);
}
protected CTGroupShapeProperties getGrpSpPr() {
- String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:grpSpPr";
+ String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:grpSpPr";
return selectProperty(CTGroupShapeProperties.class, xquery);
}
@@ -241,7 +226,7 @@ public abstract class XSLFShape implements Shape {
protected CTShapeProperties getSpPr() {
if (_spPr == null) {
- String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:spPr";
+ String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:spPr";
_spPr = selectProperty(CTShapeProperties.class, xquery);
}
if (_spPr == null) {
@@ -252,7 +237,7 @@ public abstract class XSLFShape implements Shape {
protected CTShapeStyle getSpStyle() {
if (_spStyle == null) {
- String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:style";
+ String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:style";
_spStyle = selectProperty(CTShapeStyle.class, xquery);
}
return _spStyle;
@@ -348,7 +333,7 @@ public abstract class XSLFShape implements Shape {
paint = selectPaint(obj, phClr, pp);
if(paint != null) break;
}
- return paint == null ? TRANSPARENT_PAINT : paint;
+ return paint == null ? PaintStyle.TRANSPARENT_PAINT : paint;
}
/**
@@ -373,7 +358,7 @@ public abstract class XSLFShape implements Shape {
*/
protected PaintStyle selectPaint(XmlObject obj, final CTSchemeColor phClr, final PackagePart parentPart) {
if (obj instanceof CTNoFillProperties) {
- return TRANSPARENT_PAINT;
+ return PaintStyle.TRANSPARENT_PAINT;
} else if (obj instanceof CTSolidColorFillProperties) {
return selectPaint((CTSolidColorFillProperties)obj, phClr, parentPart);
} else if (obj instanceof CTBlipFillProperties) {
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
index 163d8a65aa..38dea1b462 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
@@ -37,7 +37,7 @@ import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelations
import org.openxmlformats.schemas.presentationml.x2006.main.*;
@Beta
-public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet<XSLFShape> {
+public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet<XSLFShape, XMLSlideShow> {
private XSLFCommonSlideData _commonSlideData;
private XSLFDrawing _drawing;
private List<XSLFShape> _shapes;
@@ -516,25 +516,26 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
* Import a package part into this sheet.
*/
PackagePart importPart(PackageRelationship srcRel, PackagePart srcPafrt) {
-
- OPCPackage pkg = getPackagePart().getPackage();
- if(!pkg.containPart(srcPafrt.getPartName())){
- PackageRelationship rel = getPackagePart().addRelationship(
- srcPafrt.getPartName(), TargetMode.INTERNAL, srcRel.getRelationshipType());
-
- PackagePart part = pkg.createPart(srcPafrt.getPartName(), srcPafrt.getContentType());
- OutputStream out = part.getOutputStream();
- try {
- InputStream is = srcPafrt.getInputStream();
- IOUtils.copy(is, out);
- out.close();
- } catch (IOException e){
- throw new POIXMLException(e);
- }
- return part;
- } else {
+ PackagePart destPP = getPackagePart();
+ PackagePartName srcPPName = srcPafrt.getPartName();
+
+ OPCPackage pkg = destPP.getPackage();
+ if(pkg.containPart(srcPPName)){
// already exists
- return pkg.getPart(srcPafrt.getPartName());
+ return pkg.getPart(srcPPName);
+ }
+
+ destPP.addRelationship(srcPPName, TargetMode.INTERNAL, srcRel.getRelationshipType());
+
+ PackagePart part = pkg.createPart(srcPPName, srcPafrt.getContentType());
+ OutputStream out = part.getOutputStream();
+ try {
+ InputStream is = srcPafrt.getInputStream();
+ IOUtils.copy(is, out);
+ out.close();
+ } catch (IOException e){
+ throw new POIXMLException(e);
}
+ return part;
}
} \ No newline at end of file
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
index ffe0fc823d..fb97180605 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
@@ -19,19 +19,21 @@
package org.apache.poi.xslf.usermodel;
+import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT;
+
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.LineCompound;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
@@ -208,8 +210,7 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
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 ((SolidPaint)ps).getSolidColor().getColor();
}
return null;
}
@@ -273,7 +274,6 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
}
/**
- *
* @return line width in points. <code>0</code> means no line.
*/
public double getLineWidth() {
@@ -311,6 +311,54 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
}
/**
+ * @return the line compound
+ */
+ public LineCompound getLineCompound() {
+ PropertyFetcher<Integer> fetcher = new PropertyFetcher<Integer>() {
+ public boolean fetch(XSLFShape shape) {
+ CTShapeProperties spPr = shape.getSpPr();
+ CTLineProperties ln = spPr.getLn();
+ if (ln != null) {
+ STCompoundLine.Enum stCmpd = ln.getCmpd();
+ if (stCmpd != null) {
+ setValue(stCmpd.intValue());
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ fetchShapeProperty(fetcher);
+
+ Integer cmpd = fetcher.getValue();
+ if (cmpd == null) {
+ CTLineProperties defaultLn = getDefaultLineProperties();
+ if (defaultLn != null) {
+ STCompoundLine.Enum stCmpd = defaultLn.getCmpd();
+ if (stCmpd != null) {
+ cmpd = stCmpd.intValue();
+ }
+ }
+ }
+
+ if (cmpd == null) return null;
+
+ switch (cmpd) {
+ default:
+ case STCompoundLine.INT_SNG:
+ return LineCompound.SINGLE;
+ case STCompoundLine.INT_DBL:
+ return LineCompound.DOUBLE;
+ case STCompoundLine.INT_THICK_THIN:
+ return LineCompound.THICK_THIN;
+ case STCompoundLine.INT_THIN_THICK:
+ return LineCompound.THIN_THICK;
+ case STCompoundLine.INT_TRI:
+ return LineCompound.TRIPLE;
+ }
+ }
+
+ /**
*
* @param dash a preset line dashing scheme to stroke thr shape outline
*/
@@ -453,8 +501,7 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
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 ((SolidPaint)ps).getSolidColor().getColor();
}
return null;
}
@@ -769,6 +816,10 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
public double getLineWidth() {
return XSLFSimpleShape.this.getLineWidth();
}
+
+ public LineCompound getLineCompound() {
+ return XSLFSimpleShape.this.getLineCompound();
+ }
};
}
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
index 795daa30b5..ee62ee9d79 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
@@ -29,7 +29,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.*;
@Beta
-public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape> {
+public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape, XMLSlideShow> {
private final CTSlide _slide;
private XSLFSlideLayout _layout;
private XSLFComments _comments;
@@ -245,7 +245,7 @@ public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape> {
throw new UnsupportedOperationException();
}
- public void setNotes(Notes<XSLFShape> notes) {
+ public void setNotes(Notes<XSLFShape,XMLSlideShow> notes) {
// TODO Auto-generated method stub
}
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
index bd6c38ca46..65487bd45b 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
@@ -31,7 +31,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument;
import java.io.IOException;
@Beta
-public class XSLFSlideLayout extends XSLFSheet implements MasterSheet<XSLFShape> {
+public class XSLFSlideLayout extends XSLFSheet implements MasterSheet<XSLFShape, XMLSlideShow> {
private CTSlideLayout _layout;
private XSLFSlideMaster _master;
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
index 0b64306fd1..830a531a24 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
@@ -54,7 +54,7 @@ import java.util.Map;
* @author Yegor Kozlov
*/
@Beta
- public class XSLFSlideMaster extends XSLFSheet implements MasterSheet<XSLFShape> {
+ public class XSLFSlideMaster extends XSLFSheet implements MasterSheet<XSLFShape, XMLSlideShow> {
private CTSlideMaster _slide;
private Map<String, XSLFSlideLayout> _layouts;
private XSLFTheme _theme;
@@ -83,7 +83,7 @@ import java.util.Map;
}
@Override
- public MasterSheet getMasterSheet() {
+ public MasterSheet<XSLFShape, XMLSlideShow> getMasterSheet() {
return null;
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
index e3dad561b6..5b7109059f 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
@@ -18,9 +18,10 @@ package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
-import org.apache.poi.sl.usermodel.ShapeType;
-import org.apache.poi.sl.usermodel.TextAlign;
-import org.apache.poi.sl.usermodel.VerticalAlignment;
+import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
+import org.apache.poi.sl.usermodel.TextShape.TextAutofit;
+import org.apache.poi.sl.usermodel.TextShape.TextDirection;
import org.apache.poi.util.Units;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java
index ae7de8d5c0..0dc9c4d6f7 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java
@@ -16,14 +16,17 @@
==================================================================== */
package org.apache.poi.xslf.usermodel;
+import java.awt.Color;
+import java.awt.Rectangle;
+
import junit.framework.TestCase;
-import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;
+import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
+import org.apache.poi.sl.usermodel.*;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
-import java.awt.*;
-
/**
* @author Yegor Kozlov
*/
@@ -40,70 +43,70 @@ public class TestXSLFConnectorShape extends TestCase {
assertFalse(shape.getSpPr().getLn().isSetTailEnd());
// line decorations
- assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration());
- assertEquals(LineDecoration.NONE, shape.getLineTailDecoration());
+ assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration());
+ assertEquals(DecorationShape.NONE, shape.getLineTailDecoration());
shape.setLineHeadDecoration(null);
shape.setLineTailDecoration(null);
- assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration());
- assertEquals(LineDecoration.NONE, shape.getLineTailDecoration());
+ assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration());
+ assertEquals(DecorationShape.NONE, shape.getLineTailDecoration());
assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetType());
assertFalse(shape.getSpPr().getLn().getTailEnd().isSetType());
- shape.setLineHeadDecoration(LineDecoration.ARROW);
- shape.setLineTailDecoration(LineDecoration.DIAMOND);
- assertEquals(LineDecoration.ARROW, shape.getLineHeadDecoration());
- assertEquals(LineDecoration.DIAMOND, shape.getLineTailDecoration());
+ shape.setLineHeadDecoration(DecorationShape.ARROW);
+ shape.setLineTailDecoration(DecorationShape.DIAMOND);
+ assertEquals(DecorationShape.ARROW, shape.getLineHeadDecoration());
+ assertEquals(DecorationShape.DIAMOND, shape.getLineTailDecoration());
assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getHeadEnd().getType());
assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getTailEnd().getType());
- shape.setLineHeadDecoration(LineDecoration.DIAMOND);
- shape.setLineTailDecoration(LineDecoration.ARROW);
- assertEquals(LineDecoration.DIAMOND, shape.getLineHeadDecoration());
- assertEquals(LineDecoration.ARROW, shape.getLineTailDecoration());
+ shape.setLineHeadDecoration(DecorationShape.DIAMOND);
+ shape.setLineTailDecoration(DecorationShape.ARROW);
+ assertEquals(DecorationShape.DIAMOND, shape.getLineHeadDecoration());
+ assertEquals(DecorationShape.ARROW, shape.getLineTailDecoration());
assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getHeadEnd().getType());
assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getTailEnd().getType());
// line end width
- assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
- assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());
shape.setLineHeadWidth(null);
shape.setLineHeadWidth(null);
- assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
- assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());
assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetW());
assertFalse(shape.getSpPr().getLn().getTailEnd().isSetW());
- shape.setLineHeadWidth(LineEndWidth.LARGE);
- shape.setLineTailWidth(LineEndWidth.MEDIUM);
- assertEquals(LineEndWidth.LARGE, shape.getLineHeadWidth());
- assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
+ shape.setLineHeadWidth(DecorationSize.LARGE);
+ shape.setLineTailWidth(DecorationSize.MEDIUM);
+ assertEquals(DecorationSize.LARGE, shape.getLineHeadWidth());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());
assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getHeadEnd().getW());
assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getTailEnd().getW());
- shape.setLineHeadWidth(LineEndWidth.MEDIUM);
- shape.setLineTailWidth(LineEndWidth.LARGE);
- assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
- assertEquals(LineEndWidth.LARGE, shape.getLineTailWidth());
+ shape.setLineHeadWidth(DecorationSize.MEDIUM);
+ shape.setLineTailWidth(DecorationSize.LARGE);
+ assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());
+ assertEquals(DecorationSize.LARGE, shape.getLineTailWidth());
assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getHeadEnd().getW());
assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getTailEnd().getW());
// line end length
- assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
- assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());
shape.setLineHeadLength(null);
shape.setLineTailLength(null);
- assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
- assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());
assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetLen());
assertFalse(shape.getSpPr().getLn().getTailEnd().isSetLen());
- shape.setLineHeadLength(LineEndLength.LARGE);
- shape.setLineTailLength(LineEndLength.MEDIUM);
- assertEquals(LineEndLength.LARGE, shape.getLineHeadLength());
- assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
+ shape.setLineHeadLength(DecorationSize.LARGE);
+ shape.setLineTailLength(DecorationSize.MEDIUM);
+ assertEquals(DecorationSize.LARGE, shape.getLineHeadLength());
+ assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());
assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getHeadEnd().getLen());
assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getTailEnd().getLen());
- shape.setLineHeadLength(LineEndLength.MEDIUM);
- shape.setLineTailLength(LineEndLength.LARGE);
- assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
- assertEquals(LineEndLength.LARGE, shape.getLineTailLength());
+ shape.setLineHeadLength(DecorationSize.MEDIUM);
+ shape.setLineTailLength(DecorationSize.LARGE);
+ assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());
+ assertEquals(DecorationSize.LARGE, shape.getLineTailLength());
assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getHeadEnd().getLen());
assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getTailEnd().getLen());
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
index 2153ceb26f..b3a5fc211e 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
@@ -20,17 +20,11 @@ import java.awt.Color;
import junit.framework.TestCase;
-import org.apache.poi.sl.usermodel.LineCap;
-import org.apache.poi.sl.usermodel.LineDash;
+import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
+import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Units;
import org.apache.poi.xslf.XSLFTestDataSamples;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
-import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
/**
* @author Yegor Kozlov
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
index 505703bcaa..80a52fd2cc 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
@@ -20,6 +20,7 @@ import junit.framework.TestCase;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.xslf.XSLFTestDataSamples;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
import java.awt.Color;
@@ -99,10 +100,11 @@ public class TestXSLFTable extends TestCase {
XSLFTableCell cell0 = row0.addCell();
assertNotNull(cell0.getXmlObject());
// by default table cell has no borders
- assertTrue(cell0.getXmlObject().getTcPr().getLnB().isSetNoFill());
- assertTrue(cell0.getXmlObject().getTcPr().getLnT().isSetNoFill());
- assertTrue(cell0.getXmlObject().getTcPr().getLnL().isSetNoFill());
- assertTrue(cell0.getXmlObject().getTcPr().getLnR().isSetNoFill());
+ CTTableCell tc = (CTTableCell)cell0.getXmlObject();
+ assertTrue(tc.getTcPr().getLnB().isSetNoFill());
+ assertTrue(tc.getTcPr().getLnT().isSetNoFill());
+ assertTrue(tc.getTcPr().getLnL().isSetNoFill());
+ assertTrue(tc.getTcPr().getLnR().isSetNoFill());
assertSame(cell0, row0.getCells().get(0));
assertEquals(1, tbl.getNumberOfColumns());
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
index 45bc30286e..fb906ed3a1 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
@@ -16,25 +16,46 @@
==================================================================== */
package org.apache.poi.xslf.usermodel;
-import junit.framework.TestCase;
-
-import org.apache.poi.sl.draw.TextFragment;
-import org.apache.poi.sl.usermodel.TextAlign;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
-import org.apache.poi.xslf.XSLFTestDataSamples;
+import static org.junit.Assert.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.List;
+import org.apache.poi.sl.draw.DrawTextFragment;
+import org.apache.poi.sl.draw.DrawTextParagraph;
+import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.xslf.XSLFTestDataSamples;
+import org.junit.Test;
+
/**
* @author Yegor Kozlov
*/
-public class TestXSLFTextParagraph extends TestCase {
+public class TestXSLFTextParagraph {
private static POILogger _logger = POILogFactory.getLogger(XSLFTextParagraph.class);
+ static class DrawTextParagraphProxy extends DrawTextParagraph<XSLFTextRun> {
+ DrawTextParagraphProxy(XSLFTextParagraph p) {
+ super(p);
+ }
+
+ public void breakText(Graphics2D graphics) {
+ super.breakText(graphics);
+ }
+
+ public double getWrappingWidth(boolean firstLine, Graphics2D graphics) {
+ return super.getWrappingWidth(firstLine, graphics);
+ }
+
+ public List<DrawTextFragment> getLines() {
+ return lines;
+ }
+ }
+
+ @Test
public void testWrappingWidth() throws Exception {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
@@ -49,45 +70,47 @@ public class TestXSLFTextParagraph extends TestCase {
Rectangle2D anchor = new Rectangle(50, 50, 300, 200);
sh.setAnchor(anchor);
+
+ DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p);
double leftInset = sh.getLeftInset();
double rightInset = sh.getRightInset();
- assertEquals(7.2, leftInset);
- assertEquals(7.2, rightInset);
+ assertEquals(7.2, leftInset, 0);
+ assertEquals(7.2, rightInset, 0);
double leftMargin = p.getLeftMargin();
- assertEquals(0.0, leftMargin);
+ assertEquals(0.0, leftMargin, 0);
double indent = p.getIndent();
- assertEquals(0.0, indent); // default
+ assertEquals(0.0, indent, 0); // default
double expectedWidth;
// Case 1: bullet=false, leftMargin=0, indent=0.
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
- assertEquals(285.6, expectedWidth); // 300 - 7.2 - 7.2 - 0
- assertEquals(expectedWidth, p.getWrappingWidth(true, null));
- assertEquals(expectedWidth, p.getWrappingWidth(false, null));
+ assertEquals(285.6, expectedWidth, 0); // 300 - 7.2 - 7.2 - 0
+ assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0);
+ assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
p.setLeftMargin(36); // 0.5"
leftMargin = p.getLeftMargin();
- assertEquals(36.0, leftMargin);
+ assertEquals(36.0, leftMargin, 0);
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
assertEquals(249.6, expectedWidth, 1E-5); // 300 - 7.2 - 7.2 - 36
- assertEquals(expectedWidth, p.getWrappingWidth(true, null));
- assertEquals(expectedWidth, p.getWrappingWidth(false, null));
+ assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0);
+ assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
// increase insets, the wrapping width should get smaller
sh.setLeftInset(10);
sh.setRightInset(10);
leftInset = sh.getLeftInset();
rightInset = sh.getRightInset();
- assertEquals(10.0, leftInset);
- assertEquals(10.0, rightInset);
+ assertEquals(10.0, leftInset, 0);
+ assertEquals(10.0, rightInset, 0);
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
- assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36
- assertEquals(expectedWidth, p.getWrappingWidth(true, null));
- assertEquals(expectedWidth, p.getWrappingWidth(false, null));
+ assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
+ assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0);
+ assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
// set a positive indent of a 0.5 inch. This means "First Line" indentation:
// |<--- indent -->|Here goes first line of the text
@@ -95,34 +118,35 @@ public class TestXSLFTextParagraph extends TestCase {
p.setIndent(36.0); // 0.5"
indent = p.getIndent();
- assertEquals(36.0, indent);
+ assertEquals(36.0, indent, 0);
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin - indent;
- assertEquals(208.0, expectedWidth); // 300 - 10 - 10 - 36 - 6.4
- assertEquals(expectedWidth, p.getWrappingWidth(true, null)); // first line is indented
+ assertEquals(208.0, expectedWidth, 0); // 300 - 10 - 10 - 36 - 6.4
+ assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is indented
// other lines are not indented
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
- assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36
- assertEquals(expectedWidth, p.getWrappingWidth(false, null));
+ assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
+ assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
// set a negative indent of a 1 inch. This means "Hanging" indentation:
// Here goes first line of the text
// |<--- indent -->|Here go other lines (second and subsequent)
p.setIndent(-72.0); // 1"
indent = p.getIndent();
- assertEquals(-72.0, indent);
+ assertEquals(-72.0, indent, 0);
expectedWidth = anchor.getWidth() - leftInset - rightInset;
- assertEquals(280.0, expectedWidth); // 300 - 10 - 10
- assertEquals(expectedWidth, p.getWrappingWidth(true, null)); // first line is NOT indented
+ assertEquals(280.0, expectedWidth, 0); // 300 - 10 - 10
+ assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is NOT indented
// other lines are indented by leftMargin (the value of indent is not used)
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
- assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36
- assertEquals(expectedWidth, p.getWrappingWidth(false, null));
+ assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
+ assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
}
/**
* test breaking test into lines.
* This test requires that the Arial font is available and will run only on windows
*/
+ @Test
public void testBreakLines(){
String os = System.getProperty("os.name");
if(os == null || !os.contains("Windows")) {
@@ -144,44 +168,52 @@ public class TestXSLFTextParagraph extends TestCase {
"residing within the corresponding paragraph.");
sh.setAnchor(new Rectangle(50, 50, 300, 200));
+ DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p);
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
- List<TextFragment> lines;
- lines = p.breakText(graphics);
+ List<DrawTextFragment> lines;
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(4, lines.size());
// descrease the shape width from 300 pt to 100 pt
sh.setAnchor(new Rectangle(50, 50, 100, 200));
- lines = p.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(12, lines.size());
// descrease the shape width from 300 pt to 100 pt
sh.setAnchor(new Rectangle(50, 50, 600, 200));
- lines = p.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(2, lines.size());
// set left and right margins to 200pt. This leaves 200pt for wrapping text
sh.setLeftInset(200);
sh.setRightInset(200);
- lines = p.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(5, lines.size());
r.setText("Apache POI");
- lines = p.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(1, lines.size());
assertEquals("Apache POI", lines.get(0).getString());
r.setText("Apache\nPOI");
- lines = p.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(2, lines.size());
assertEquals("Apache", lines.get(0).getString());
assertEquals("POI", lines.get(1).getString());
// trailing newlines are ignored
r.setText("Apache\nPOI\n");
- lines = p.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(2, lines.size());
assertEquals("Apache", lines.get(0).getString());
assertEquals("POI", lines.get(1).getString());
@@ -197,7 +229,8 @@ public class TestXSLFTextParagraph extends TestCase {
r3.setFontFamily("serif"); // this should always be available
r3.setFontSize(10);
r3.setText("POI");
- lines = p2.breakText(graphics);
+ dtp.breakText(graphics);
+ lines = dtp.getLines();
assertEquals(2, lines.size());
assertEquals("Apache", lines.get(0).getString());
assertEquals("POI", lines.get(1).getString());
@@ -206,6 +239,7 @@ public class TestXSLFTextParagraph extends TestCase {
}
+ @Test
public void testThemeInheritance(){
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("prProps.pptx");
XSLFShape[] shapes = ppt.getSlides()[0].getShapes();
@@ -220,6 +254,7 @@ public class TestXSLFTextParagraph extends TestCase {
assertEquals(TextAlign.CENTER, sh3.getTextParagraphs().get(0).getTextAlign());
}
+ @Test
public void testParagraphProperties(){
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
@@ -242,25 +277,25 @@ public class TestXSLFTextParagraph extends TestCase {
p.setBulletFontColor(Color.red);
assertEquals(Color.red, p.getBulletFontColor());
- assertEquals(100.0, p.getBulletFontSize());
+ assertEquals(100.0, p.getBulletFontSize(), 0);
p.setBulletFontSize(200.);
- assertEquals(200., p.getBulletFontSize());
+ assertEquals(200., p.getBulletFontSize(), 0);
p.setBulletFontSize(-20.);
- assertEquals(-20.0, p.getBulletFontSize());
+ assertEquals(-20.0, p.getBulletFontSize(), 0);
- assertEquals(72.0, p.getDefaultTabSize());
+ assertEquals(72.0, p.getDefaultTabSize(), 0);
- assertEquals(0.0, p.getIndent());
+ assertEquals(0.0, p.getIndent(), 0);
p.setIndent(72.0);
- assertEquals(72.0, p.getIndent());
+ assertEquals(72.0, p.getIndent(), 0);
p.setIndent(-1.0); // the value of -1.0 resets to the defaults
- assertEquals(0.0, p.getIndent());
+ assertEquals(0.0, p.getIndent(), 0);
- assertEquals(0.0, p.getLeftMargin());
+ assertEquals(0.0, p.getLeftMargin(), 0);
p.setLeftMargin(72.0);
- assertEquals(72.0, p.getLeftMargin());
+ assertEquals(72.0, p.getLeftMargin(), 0);
p.setLeftMargin(-1.0); // the value of -1.0 resets to the defaults
- assertEquals(0.0, p.getLeftMargin());
+ assertEquals(0.0, p.getLeftMargin(), 0);
assertEquals(0, p.getLevel());
p.setLevel(1);
@@ -268,23 +303,23 @@ public class TestXSLFTextParagraph extends TestCase {
p.setLevel(2);
assertEquals(2, p.getLevel());
- assertEquals(100., p.getLineSpacing());
+ assertEquals(100., p.getLineSpacing(), 0);
p.setLineSpacing(200.);
- assertEquals(200.0, p.getLineSpacing());
+ assertEquals(200.0, p.getLineSpacing(), 0);
p.setLineSpacing(-15.);
- assertEquals(-15.0, p.getLineSpacing());
+ assertEquals(-15.0, p.getLineSpacing(), 0);
- assertEquals(0., p.getSpaceAfter());
+ assertEquals(0., p.getSpaceAfter(), 0);
p.setSpaceAfter(200.);
- assertEquals(200.0, p.getSpaceAfter());
+ assertEquals(200.0, p.getSpaceAfter(), 0);
p.setSpaceAfter(-15.);
- assertEquals(-15.0, p.getSpaceAfter());
+ assertEquals(-15.0, p.getSpaceAfter(), 0);
- assertEquals(0., p.getSpaceBefore());
+ assertEquals(0., p.getSpaceBefore(), 0);
p.setSpaceBefore(200.);
- assertEquals(200.0, p.getSpaceBefore());
+ assertEquals(200.0, p.getSpaceBefore(), 0);
p.setSpaceBefore(-15.);
- assertEquals(-15.0, p.getSpaceBefore());
+ assertEquals(-15.0, p.getSpaceBefore(), 0);
assertEquals(TextAlign.LEFT, p.getTextAlign());
p.setTextAlign(TextAlign.RIGHT);
@@ -296,15 +331,16 @@ public class TestXSLFTextParagraph extends TestCase {
p.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_BOTH, 1);
double tabStop = p.getTabStop(0);
- assertEquals(0.0, tabStop);
+ assertEquals(0.0, tabStop, 0);
p.addTabStop(100.);
- assertEquals(100., p.getTabStop(0));
+ assertEquals(100., p.getTabStop(0), 0);
- assertEquals(72.0, p.getDefaultTabSize());
+ assertEquals(72.0, p.getDefaultTabSize(), 0);
}
+ @Test
public void testLineBreak(){
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
@@ -316,12 +352,12 @@ public class TestXSLFTextParagraph extends TestCase {
XSLFTextRun r2 = p.addLineBreak();
assertEquals("\n", r2.getText());
r2.setFontSize(10.0);
- assertEquals(10.0, r2.getFontSize());
+ assertEquals(10.0, r2.getFontSize(), 0);
XSLFTextRun r3 = p.addNewTextRun();
r3.setText("World!");
r3.setFontSize(20.0);
XSLFTextRun r4 = p.addLineBreak();
- assertEquals(20.0, r4.getFontSize());
+ assertEquals(20.0, r4.getFontSize(), 0);
assertEquals("Hello,\nWorld!\n",sh.getText());
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
index f217c58278..f9232a1733 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
@@ -16,20 +16,17 @@
==================================================================== */
package org.apache.poi.xslf.usermodel;
+import java.awt.Color;
+
import junit.framework.TestCase;
-import org.apache.poi.sl.usermodel.TextAlign;
+import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.xslf.XSLFTestDataSamples;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
-import java.awt.Color;
-
/**
* @author Yegor Kozlov
*/