aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2011-11-07 09:12:16 +0000
committerYegor Kozlov <yegor@apache.org>2011-11-07 09:12:16 +0000
commitde14b40a970a2626701f59f1ccfa3b6970614519 (patch)
treec69669a55694ec94fa04fb396000a58287cd6af2 /src/ooxml/testcases/org/apache/poi
parentd6093ba1e32730932b950a93f7ebd9aeba20a370 (diff)
downloadpoi-de14b40a970a2626701f59f1ccfa3b6970614519.tar.gz
poi-de14b40a970a2626701f59f1ccfa3b6970614519.zip
more progress with xlsf: support for gradient and texture fills, backgrounds, improved drawing of preset shapes and many more updates ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1198658 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/geom/TestPresetGeometries.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java2
-rwxr-xr-xsrc/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java60
-rwxr-xr-xsrc/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFColor.java16
-rwxr-xr-xsrc/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java13
-rwxr-xr-xsrc/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShow.java4
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java96
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java135
9 files changed, 223 insertions, 111 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java b/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java
index b9f15139d5..df3e2ec29d 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java
@@ -24,7 +24,7 @@ public class TestFormulaParser extends TestCase {
};
CustomGeometry geom = new CustomGeometry(CTCustomGeometry2D.Factory.newInstance());
- Context ctx = new Context(geom, null);
+ Context ctx = new Context(geom, null, null);
for(Formula fmla : ops) {
ctx.evaluate(fmla);
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/geom/TestPresetGeometries.java b/src/ooxml/testcases/org/apache/poi/xslf/geom/TestPresetGeometries.java
index 5c19b4e53e..c71a065bb7 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/geom/TestPresetGeometries.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/geom/TestPresetGeometries.java
@@ -21,11 +21,7 @@ public class TestPresetGeometries extends TestCase {
for(String name : shapes.keySet()) {
CustomGeometry geom = shapes.get(name);
- Context ctx = new Context(geom, new IAdjustableShape() {
- public Rectangle2D getAnchor() {
- return new Rectangle2D.Double(0, 0, 100, 100);
- }
-
+ Context ctx = new Context(geom, new Rectangle2D.Double(0, 0, 100, 100), new IAdjustableShape() {
public Guide getAdjustValue(String name) {
return null;
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
index 1f8826fdad..948b792b8b 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
@@ -34,7 +34,7 @@ import java.awt.image.BufferedImage;
public class TestPPTX2PNG extends TestCase {
public void testRender(){
String[] testFiles = {"layouts.pptx", "sample.pptx", "shapes.pptx",
- "45541_Header.pptx", "backgrounds.pptx"};
+ "themes.pptx", "backgrounds.pptx"};
for(String sampleFile : testFiles){
XMLSlideShow pptx = XSLFTestDataSamples.openSampleDocument(sampleFile);
Dimension pg = pptx.getPageSize();
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 7cab8ea4e3..d29cb30662 100755
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
@@ -34,38 +34,38 @@ public class TestXSLFAutoShape extends TestCase {
shape.addNewTextParagraph().addNewTextRun().setText("POI");
// default margins from slide master
- assertEquals(3.6, shape.getMarginBottom());
- assertEquals(3.6, shape.getMarginTop());
- assertEquals(7.2, shape.getMarginLeft());
- assertEquals(7.2, shape.getMarginRight());
-
- shape.setMarginBottom(1.0);
- assertEquals(1.0, shape.getMarginBottom());
- shape.setMarginTop(2.0);
- assertEquals(2.0, shape.getMarginTop());
- shape.setMarginLeft(3.0);
- assertEquals(3.0, shape.getMarginLeft());
- shape.setMarginRight(4.0);
- assertEquals(4.0, shape.getMarginRight());
-
- shape.setMarginBottom(0.0);
- assertEquals(0.0, shape.getMarginBottom());
- shape.setMarginTop(0.0);
- assertEquals(0.0, shape.getMarginTop());
- shape.setMarginLeft(0.0);
- assertEquals(0.0, shape.getMarginLeft());
- shape.setMarginRight(0.0);
- assertEquals(0.0, shape.getMarginRight());
+ assertEquals(3.6, shape.getBottomInset());
+ assertEquals(3.6, shape.getTopInset());
+ assertEquals(7.2, shape.getLeftInset());
+ assertEquals(7.2, shape.getRightInset());
+
+ shape.setBottomInset(1.0);
+ assertEquals(1.0, shape.getBottomInset());
+ shape.setTopInset(2.0);
+ assertEquals(2.0, shape.getTopInset());
+ shape.setLeftInset(3.0);
+ assertEquals(3.0, shape.getLeftInset());
+ shape.setRightInset(4.0);
+ assertEquals(4.0, shape.getRightInset());
+
+ shape.setBottomInset(0.0);
+ assertEquals(0.0, shape.getBottomInset());
+ shape.setTopInset(0.0);
+ assertEquals(0.0, shape.getTopInset());
+ shape.setLeftInset(0.0);
+ assertEquals(0.0, shape.getLeftInset());
+ shape.setRightInset(0.0);
+ assertEquals(0.0, shape.getRightInset());
// unset to defauls
- shape.setMarginBottom(-1);
- assertEquals(3.6, shape.getMarginBottom());
- shape.setMarginTop(-1);
- assertEquals(3.6, shape.getMarginTop());
- shape.setMarginLeft(-1);
- assertEquals(7.2, shape.getMarginLeft());
- shape.setMarginRight(-1);
- assertEquals(7.2, shape.getMarginRight());
+ shape.setBottomInset(-1);
+ assertEquals(3.6, shape.getBottomInset());
+ shape.setTopInset(-1);
+ assertEquals(3.6, shape.getTopInset());
+ shape.setLeftInset(-1);
+ assertEquals(7.2, shape.getLeftInset());
+ shape.setRightInset(-1);
+ assertEquals(7.2, shape.getRightInset());
// shape
assertTrue(shape.getWordWrap());
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFColor.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFColor.java
index ffb25b37e1..108fca327b 100755
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFColor.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFColor.java
@@ -37,7 +37,7 @@ public class TestXSLFColor extends TestCase {
CTSRgbColor c = xml.addNewSrgbClr();
c.setVal(new byte[]{(byte)0xFF, 0, 0});
- XSLFColor color = new XSLFColor(xml, null);
+ XSLFColor color = new XSLFColor(xml, null, null);
assertEquals(-1, color.getAlpha());
c.addNewAlpha().setVal(50000);
@@ -99,7 +99,7 @@ public class TestXSLFColor extends TestCase {
c.setSat2(100000);
c.setLum2(50000);
- XSLFColor color = new XSLFColor(xml, null);
+ XSLFColor color = new XSLFColor(xml, null, null);
assertEquals(new Color(128, 00, 00), color.getColor());
}
@@ -107,7 +107,7 @@ public class TestXSLFColor extends TestCase {
CTColor xml = CTColor.Factory.newInstance();
xml.addNewSrgbClr().setVal(new byte[]{ (byte)0xFF, (byte)0xFF, 0});
- XSLFColor color = new XSLFColor(xml, null);
+ XSLFColor color = new XSLFColor(xml, null, null);
assertEquals(new Color(0xFF, 0xFF, 0), color.getColor());
}
@@ -118,19 +118,19 @@ public class TestXSLFColor extends TestCase {
CTColor xml = CTColor.Factory.newInstance();
xml.addNewSchemeClr().setVal(STSchemeColorVal.ACCENT_2);
- XSLFColor color = new XSLFColor(xml, theme);
+ XSLFColor color = new XSLFColor(xml, theme, null);
// accent2 is theme1.xml is <a:srgbClr val="C0504D"/>
assertEquals(Color.decode("0xC0504D"), color.getColor());
xml = CTColor.Factory.newInstance();
xml.addNewSchemeClr().setVal(STSchemeColorVal.LT_1);
- color = new XSLFColor(xml, theme);
+ color = new XSLFColor(xml, theme, null);
// <a:sysClr val="window" lastClr="FFFFFF"/>
assertEquals(Color.decode("0xFFFFFF"), color.getColor());
xml = CTColor.Factory.newInstance();
xml.addNewSchemeClr().setVal(STSchemeColorVal.DK_1);
- color = new XSLFColor(xml, theme);
+ color = new XSLFColor(xml, theme, null);
// <a:sysClr val="windowText" lastClr="000000"/>
assertEquals(Color.decode("0x000000"), color.getColor());
}
@@ -138,7 +138,7 @@ public class TestXSLFColor extends TestCase {
public void testPresetColor() {
CTColor xml = CTColor.Factory.newInstance();
xml.addNewPrstClr().setVal(STPresetColorVal.AQUAMARINE);
- XSLFColor color = new XSLFColor(xml, null);
+ XSLFColor color = new XSLFColor(xml, null, null);
assertEquals(new Color(127, 255, 212), color.getColor());
@@ -147,7 +147,7 @@ public class TestXSLFColor extends TestCase {
STPresetColorVal.Enum val = STPresetColorVal.Enum.forString(colorName);
assertNotNull(colorName, val);
xml.addNewPrstClr().setVal(val);
- color = new XSLFColor(xml, null);
+ color = new XSLFColor(xml, null, null);
assertEquals(XSLFColor.presetColors.get(colorName), color.getColor());
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
index 9ffe69fe98..d8cb5783e4 100755
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
@@ -19,9 +19,6 @@ package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.xslf.XSLFTestDataSamples;
-import org.apache.poi.POIXMLDocumentPart;
-
-import java.util.List;
/**
* @author Yegor Kozlov
@@ -99,11 +96,11 @@ public class TestXSLFSlide extends TestCase {
assertEquals(0, ppt.getSlides().length);
XSLFSlide slide = ppt.createSlide();
- assertTrue(slide.getFollowMasterBackground());
- slide.setFollowMasterBackground(false);
- assertFalse(slide.getFollowMasterBackground());
- slide.setFollowMasterBackground(true);
- assertTrue(slide.getFollowMasterBackground());
+ assertTrue(slide.getFollowMasterGraphics());
+ slide.setFollowMasterGraphics(false);
+ assertFalse(slide.getFollowMasterGraphics());
+ slide.setFollowMasterGraphics(true);
+ assertTrue(slide.getFollowMasterGraphics());
}
} \ No newline at end of file
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShow.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShow.java
index c07493a3f9..46e10e45d8 100755
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShow.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlideShow.java
@@ -38,7 +38,7 @@ public class TestXSLFSlideShow extends TestCase {
List<POIXMLDocumentPart> rels = slide1.getRelations();
assertEquals(1, rels.size());
- assertEquals(slide1.getMasterSheet().getLayout("blank"), rels.get(0));
+ assertEquals(slide1.getSlideMaster().getLayout(SlideLayout.BLANK), rels.get(0));
XSLFSlide slide2 = ppt.createSlide();
assertEquals(2, ppt.getSlides().length);
@@ -91,7 +91,7 @@ public class TestXSLFSlideShow extends TestCase {
assertEquals(1, masters.length);
XSLFSlide slide = ppt.createSlide();
- assertSame(masters[0], slide.getMasterSheet());
+ assertSame(masters[0], slide.getSlideMaster());
}
public void testSlideLayout(){
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 7524b25292..6347b63ccf 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
@@ -65,10 +65,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() &&
!bodyPr1.isSetAnchor()
);
- assertEquals(7.2, shape1.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape1.getMarginRight()); // 0.1"
- assertEquals(3.6, shape1.getMarginTop()); // 0.05"
- assertEquals(3.6, shape1.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape1.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape1.getRightInset()); // 0.1"
+ assertEquals(3.6, shape1.getTopInset()); // 0.05"
+ assertEquals(3.6, shape1.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment());
// now check text properties
@@ -95,10 +95,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() &&
!bodyPr2.isSetAnchor()
);
- assertEquals(7.2, shape2.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape2.getMarginRight()); // 0.1"
- assertEquals(3.6, shape2.getMarginTop()); // 0.05"
- assertEquals(3.6, shape2.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape2.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape2.getRightInset()); // 0.1"
+ assertEquals(3.6, shape2.getTopInset()); // 0.05"
+ assertEquals(3.6, shape2.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
assertEquals("subtitle", shape2.getText());
@@ -134,10 +134,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() &&
!bodyPr1.isSetAnchor()
);
- assertEquals(7.2, shape1.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape1.getMarginRight()); // 0.1"
- assertEquals(3.6, shape1.getMarginTop()); // 0.05"
- assertEquals(3.6, shape1.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape1.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape1.getRightInset()); // 0.1"
+ assertEquals(3.6, shape1.getTopInset()); // 0.05"
+ assertEquals(3.6, shape1.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment());
// now check text properties
@@ -169,10 +169,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() &&
!bodyPr2.isSetAnchor()
);
- assertEquals(7.2, shape2.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape2.getMarginRight()); // 0.1"
- assertEquals(3.6, shape2.getMarginTop()); // 0.05"
- assertEquals(3.6, shape2.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape2.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape2.getRightInset()); // 0.1"
+ assertEquals(3.6, shape2.getTopInset()); // 0.05"
+ assertEquals(3.6, shape2.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0);
@@ -244,10 +244,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() &&
!bodyPr1.isSetAnchor()
);
- assertEquals(7.2, shape1.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape1.getMarginRight()); // 0.1"
- assertEquals(3.6, shape1.getMarginTop()); // 0.05"
- assertEquals(3.6, shape1.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape1.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape1.getRightInset()); // 0.1"
+ assertEquals(3.6, shape1.getTopInset()); // 0.05"
+ assertEquals(3.6, shape1.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.TOP, shape1.getVerticalAlignment());
// now check text properties
@@ -278,10 +278,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() &&
!bodyPr2.isSetAnchor()
);
- assertEquals(7.2, shape2.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape2.getMarginRight()); // 0.1"
- assertEquals(3.6, shape2.getMarginTop()); // 0.05"
- assertEquals(3.6, shape2.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape2.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape2.getRightInset()); // 0.1"
+ assertEquals(3.6, shape2.getTopInset()); // 0.05"
+ assertEquals(3.6, shape2.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.BOTTOM, shape2.getVerticalAlignment());
assertEquals("Section Header", shape2.getText());
@@ -318,10 +318,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() &&
!bodyPr1.isSetAnchor()
);
- assertEquals(7.2, shape1.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape1.getMarginRight()); // 0.1"
- assertEquals(3.6, shape1.getMarginTop()); // 0.05"
- assertEquals(3.6, shape1.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape1.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape1.getRightInset()); // 0.1"
+ assertEquals(3.6, shape1.getTopInset()); // 0.05"
+ assertEquals(3.6, shape1.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment());
// now check text properties
@@ -351,10 +351,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() &&
!bodyPr2.isSetAnchor()
);
- assertEquals(7.2, shape2.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape2.getMarginRight()); // 0.1"
- assertEquals(3.6, shape2.getMarginTop()); // 0.05"
- assertEquals(3.6, shape2.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape2.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape2.getRightInset()); // 0.1"
+ assertEquals(3.6, shape2.getTopInset()); // 0.05"
+ assertEquals(3.6, shape2.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0);
@@ -425,10 +425,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() &&
!bodyPr1.isSetAnchor()
);
- assertEquals(7.2, shape1.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape1.getMarginRight()); // 0.1"
- assertEquals(3.6, shape1.getMarginTop()); // 0.05"
- assertEquals(3.6, shape1.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape1.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape1.getRightInset()); // 0.1"
+ assertEquals(3.6, shape1.getTopInset()); // 0.05"
+ assertEquals(3.6, shape1.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment());
// now check text properties
@@ -449,10 +449,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() &&
!bodyPr2.isSetAnchor()
);
- assertEquals(7.2, shape2.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape2.getMarginRight()); // 0.1"
- assertEquals(3.6, shape2.getMarginTop()); // 0.05"
- assertEquals(3.6, shape2.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape2.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape2.getRightInset()); // 0.1"
+ assertEquals(3.6, shape2.getTopInset()); // 0.05"
+ assertEquals(3.6, shape2.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0);
@@ -498,10 +498,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() &&
!bodyPr1.isSetAnchor()
);
- assertEquals(7.2, shape1.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape1.getMarginRight()); // 0.1"
- assertEquals(3.6, shape1.getMarginTop()); // 0.05"
- assertEquals(3.6, shape1.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape1.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape1.getRightInset()); // 0.1"
+ assertEquals(3.6, shape1.getTopInset()); // 0.05"
+ assertEquals(3.6, shape1.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.BOTTOM, shape1.getVerticalAlignment());
// now check text properties
@@ -532,10 +532,10 @@ public class TestXSLFTextShape extends TestCase {
!bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() &&
!bodyPr2.isSetAnchor()
);
- assertEquals(7.2, shape2.getMarginLeft()); // 0.1"
- assertEquals(7.2, shape2.getMarginRight()); // 0.1"
- assertEquals(3.6, shape2.getMarginTop()); // 0.05"
- assertEquals(3.6, shape2.getMarginBottom()); // 0.05"
+ assertEquals(7.2, shape2.getLeftInset()); // 0.1"
+ assertEquals(7.2, shape2.getRightInset()); // 0.1"
+ assertEquals(3.6, shape2.getTopInset()); // 0.05"
+ assertEquals(3.6, shape2.getBottomInset()); // 0.05"
assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment());
XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0);
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
index 81f35d3250..b01c25e1d5 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
@@ -18,22 +18,141 @@ package org.apache.poi.xslf.usermodel;
import junit.framework.TestCase;
+
import org.apache.poi.xslf.XSLFTestDataSamples;
+import java.awt.Color;
+import java.awt.TexturePaint;
+
/**
- * test common properties for sheets (slides, masters, layouts, etc.)
+ * test reading properties from a multi-theme and multi-master document
*
* @author Yegor Kozlov
*/
public class TestXSLFTheme extends TestCase {
public void testRead(){
- XMLSlideShow ppt = new XMLSlideShow();
- XSLFSlide slide = ppt.createSlide();
- XSLFTheme theme = slide.getSlideLayout().getSlideMaster().getTheme();
- assertNotNull(theme);
-
+ XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("themes.pptx");
+ XSLFSlide[] slides = ppt.getSlides();
+
+ slide1(slides[0]);
+ slide2(slides[1]);
+ slide3(slides[2]);
+ slide4(slides[3]);
+ slide5(slides[4]);
+ slide6(slides[5]);
+ slide7(slides[6]);
+ slide8(slides[7]);
+ slide9(slides[8]);
+ slide10(slides[9]);
+ }
+
+ private XSLFShape getShape(XSLFSheet sheet, String name){
+ for(XSLFShape sh : sheet.getShapes()){
+ if(sh.getShapeName().equals(name)) return sh;
+ }
+ throw new IllegalArgumentException("Shape not found: " + name);
+ }
+
+ void slide1(XSLFSlide slide){
+ assertEquals(Color.white, slide.getBackground().getFillColor());
+
+ XSLFTheme theme = slide.getTheme();
assertEquals("Office Theme", theme.getName());
- //XSLFColor accent1 = theme.getColor("accent1");
- //assertNotNull(accent1);
+
+ XSLFTextShape sh1 = (XSLFTextShape)getShape(slide, "Rectangle 3");
+ RenderableShape rsh1 = new RenderableShape(sh1);
+ XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(Color.white, run1.getFontColor());
+ assertEquals(new Color(79, 129, 189), sh1.getFillColor());
+ assertTrue(rsh1.getFillPaint(null) instanceof Color) ; // solid fill
+
+ }
+
+ void slide2(XSLFSlide slide){
+ // Background 2, darker 10%
+ // YK: PPT shows slightly different color: new Color(221, 217, 195)
+ assertEquals(new Color(214, 212, 203), slide.getBackground().getFillColor());
+ }
+
+ void slide3(XSLFSlide slide){
+ assertNull(slide.getBackground().getFillColor());
+ assertTrue(slide.getBackground().getPaint(null).getClass().getName().indexOf("Gradient") > 0);
+ }
+
+ void slide4(XSLFSlide slide){
+ assertNull(slide.getBackground().getFillColor());
+ assertTrue(slide.getBackground().getPaint(null).getClass().getName().indexOf("Gradient") > 0);
+
+ XSLFTextShape sh1 = (XSLFTextShape)getShape(slide, "Rectangle 4");
+ RenderableShape rsh1 = new RenderableShape(sh1);
+ XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(Color.white, run1.getFontColor());
+ assertEquals(new Color(148, 198, 0), sh1.getFillColor());
+ assertTrue(rsh1.getFillPaint(null) instanceof Color) ; // solid fill
+
+ XSLFTextShape sh2 = (XSLFTextShape)getShape(slide, "Title 3");
+ XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(new Color(148, 198, 0), run2.getFontColor());
+ assertNull(sh2.getFillColor()); // no fill
+
+ assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
+ }
+
+ void slide5(XSLFSlide slide){
+ assertTrue(slide.getBackground().getPaint(null) instanceof TexturePaint);
+
+ XSLFTextShape sh2 = (XSLFTextShape)getShape(slide, "Title 1");
+ XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(new Color(148, 198, 0), run2.getFontColor());
+ assertNull(sh2.getFillColor()); // no fill
+ // font size is 40pt and scale factor is 90%
+ assertEquals(36.0, run2.getFontSize());
+
+ assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
+ }
+
+ void slide6(XSLFSlide slide){
+
+ XSLFTextShape sh1 = (XSLFTextShape)getShape(slide, "Subtitle 3");
+ XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(new Color(66, 66, 66), run1.getFontColor());
+ assertNull(sh1.getFillColor()); // no fill
+
+ XSLFTextShape sh2 = (XSLFTextShape)getShape(slide, "Title 2");
+ XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(new Color(148, 198, 0), run2.getFontColor());
+ assertNull(sh2.getFillColor()); // no fill
+
+ assertFalse(slide.getSlideLayout().getFollowMasterGraphics());
+ }
+
+ void slide7(XSLFSlide slide){
+
+ //YK: PPT reports a slightly different color: r=189,g=239,b=87
+ assertEquals(new Color(182, 218, 108), slide.getBackground().getFillColor());
+
+ assertFalse(slide.getFollowMasterGraphics());
+ }
+
+ void slide8(XSLFSlide slide){
+ assertTrue(slide.getBackground().getPaint(null) instanceof TexturePaint);
+ }
+
+ void slide9(XSLFSlide slide){
+ assertTrue(slide.getBackground().getPaint(null) instanceof TexturePaint);
+ }
+
+ void slide10(XSLFSlide slide){
+ assertTrue(slide.getBackground().getPaint(null).getClass().getName().indexOf("Gradient") > 0);
+
+ XSLFTextShape sh1 = (XSLFTextShape)getShape(slide, "Title 3");
+ XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(Color.white, run1.getFontColor());
+ assertNull(sh1.getFillColor()); // no fill
+
+ XSLFTextShape sh2 = (XSLFTextShape)getShape(slide, "Subtitle 4");
+ XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
+ assertEquals(Color.white, run2.getFontColor());
+ assertNull(sh2.getFillColor()); // no fill
}
}