Return-Path: X-Original-To: apmail-poi-commits-archive@minotaur.apache.org Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F22F17B0F for ; Mon, 27 Apr 2015 20:13:50 +0000 (UTC) Received: (qmail 90406 invoked by uid 500); 27 Apr 2015 20:13:50 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 90318 invoked by uid 500); 27 Apr 2015 20:13:49 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 90209 invoked by uid 99); 27 Apr 2015 20:13:49 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2015 20:13:49 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id AC9E5AC15B0 for ; Mon, 27 Apr 2015 20:13:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1676365 [3/9] - in /poi/branches/common_sl/src: examples/src/org/apache/poi/hslf/examples/ examples/src/org/apache/poi/hssf/usermodel/examples/ examples/src/org/apache/poi/xslf/usermodel/tutorial/ examples/src/org/apache/poi/xssf/usermodel... Date: Mon, 27 Apr 2015 20:13:46 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150427201349.AC9E5AC15B0@hades.apache.org> Modified: poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java (original) +++ poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java Mon Apr 27 20:13:43 2015 @@ -16,9 +16,10 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import java.awt.Color; +import static org.junit.Assert.*; -import junit.framework.TestCase; +import java.awt.Color; +import java.util.List; import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; import org.apache.poi.sl.usermodel.VerticalAlignment; @@ -30,28 +31,28 @@ import org.openxmlformats.schemas.presen /** * @author Yegor Kozlov */ -public class TestXSLFTextShape extends TestCase { +public class TestXSLFTextShape { public void testLayouts(){ XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("layouts.pptx"); - XSLFSlide[] slide = ppt.getSlides(); + List slide = ppt.getSlides(); - verifySlide1(slide[0]); - verifySlide2(slide[1]); - verifySlide3(slide[2]); - verifySlide4(slide[3]); - verifySlide7(slide[6]); - verifySlide8(slide[7]); - verifySlide10(slide[9]); + verifySlide1(slide.get(0)); + verifySlide2(slide.get(1)); + verifySlide3(slide.get(2)); + verifySlide4(slide.get(3)); + verifySlide7(slide.get(6)); + verifySlide8(slide.get(7)); + verifySlide10(slide.get(9)); } void verifySlide1(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); assertEquals("Title Slide",layout.getName()); - XSLFTextShape shape1 = (XSLFTextShape)shapes[0]; + XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0); CTPlaceholder ph1 = shape1.getCTPlaceholder(); assertEquals(STPlaceholderType.CTR_TITLE, ph1.getType()); // anchor is not defined in the shape @@ -68,20 +69,20 @@ public class TestXSLFTextShape extends T !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor() ); - 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(7.2, shape1.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape1.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape1.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape1.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment()); // now check text properties assertEquals("Centered Title", shape1.getText()); XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(44.0, r1.getFontSize()); + assertEquals(44.0, r1.getFontSize(), 0); assertEquals(Color.black, r1.getFontColor()); - XSLFTextShape shape2 = (XSLFTextShape)shapes[1]; + XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1); CTPlaceholder ph2 = shape2.getCTPlaceholder(); assertEquals(STPlaceholderType.SUB_TITLE, ph2.getType()); // anchor is not defined in the shape @@ -98,26 +99,26 @@ public class TestXSLFTextShape extends T !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor() ); - 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(7.2, shape2.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape2.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape2.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape2.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment()); assertEquals("subtitle", shape2.getText()); XSLFTextRun r2 = shape2.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals("Calibri", r2.getFontFamily()); - assertEquals(32.0, r2.getFontSize()); + assertEquals(32.0, r2.getFontSize(), 0); // TODO fix calculation of tint //assertEquals(new Color(137, 137, 137), r2.getFontColor()); } void verifySlide2(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); assertEquals("Title and Content",layout.getName()); - XSLFTextShape shape1 = (XSLFTextShape)shapes[0]; + XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0); CTPlaceholder ph1 = shape1.getCTPlaceholder(); assertEquals(STPlaceholderType.TITLE, ph1.getType()); // anchor is not defined in the shape @@ -137,20 +138,20 @@ public class TestXSLFTextShape extends T !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor() ); - 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(7.2, shape1.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape1.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape1.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape1.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment()); // now check text properties assertEquals("Title", shape1.getText()); XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(44.0, r1.getFontSize()); + assertEquals(44.0, r1.getFontSize(), 0); assertEquals(Color.black, r1.getFontColor()); - XSLFTextShape shape2 = (XSLFTextShape)shapes[1]; + XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1); CTPlaceholder ph2 = shape2.getCTPlaceholder(); assertFalse(ph2.isSetType()); // assertTrue(ph2.isSetIdx()); @@ -172,54 +173,54 @@ public class TestXSLFTextShape extends T !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor() ); - 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(7.2, shape2.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape2.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape2.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape2.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment()); XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(0, pr1.getParentParagraph().getLevel()); - assertEquals("Content", pr1.getText()); + assertEquals("Content", pr1.getRawText()); assertEquals("Calibri", pr1.getFontFamily()); - assertEquals(32.0, pr1.getFontSize()); - assertEquals(27.0, pr1.getParentParagraph().getLeftMargin()); + assertEquals(32.0, pr1.getFontSize(), 0); + assertEquals(27.0, pr1.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2022", pr1.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr1.getParentParagraph().getBulletFont()); XSLFTextRun pr2 = shape2.getTextParagraphs().get(1).getTextRuns().get(0); assertEquals(1, pr2.getParentParagraph().getLevel()); - assertEquals("Level 2", pr2.getText()); + assertEquals("Level 2", pr2.getRawText()); assertEquals("Calibri", pr2.getFontFamily()); - assertEquals(28.0, pr2.getFontSize()); - assertEquals(58.5, pr2.getParentParagraph().getLeftMargin()); + assertEquals(28.0, pr2.getFontSize(), 0); + assertEquals(58.5, pr2.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2013", pr2.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr2.getParentParagraph().getBulletFont()); XSLFTextRun pr3 = shape2.getTextParagraphs().get(2).getTextRuns().get(0); assertEquals(2, pr3.getParentParagraph().getLevel()); - assertEquals("Level 3", pr3.getText()); + assertEquals("Level 3", pr3.getRawText()); assertEquals("Calibri", pr3.getFontFamily()); - assertEquals(24.0, pr3.getFontSize()); - assertEquals(90.0, pr3.getParentParagraph().getLeftMargin()); + assertEquals(24.0, pr3.getFontSize(), 0); + assertEquals(90.0, pr3.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2022", pr3.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr3.getParentParagraph().getBulletFont()); XSLFTextRun pr4 = shape2.getTextParagraphs().get(3).getTextRuns().get(0); assertEquals(3, pr4.getParentParagraph().getLevel()); - assertEquals("Level 4", pr4.getText()); + assertEquals("Level 4", pr4.getRawText()); assertEquals("Calibri", pr4.getFontFamily()); - assertEquals(20.0, pr4.getFontSize()); - assertEquals(126.0, pr4.getParentParagraph().getLeftMargin()); + assertEquals(20.0, pr4.getFontSize(), 0); + assertEquals(126.0, pr4.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2013", pr4.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr4.getParentParagraph().getBulletFont()); XSLFTextRun pr5 = shape2.getTextParagraphs().get(4).getTextRuns().get(0); assertEquals(4, pr5.getParentParagraph().getLevel()); - assertEquals("Level 5", pr5.getText()); + assertEquals("Level 5", pr5.getRawText()); assertEquals("Calibri", pr5.getFontFamily()); - assertEquals(20.0, pr5.getFontSize()); - assertEquals(162.0, pr5.getParentParagraph().getLeftMargin()); + assertEquals(20.0, pr5.getFontSize(), 0); + assertEquals(162.0, pr5.getParentParagraph().getLeftMargin(), 0); assertEquals("\u00bb", pr5.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr5.getParentParagraph().getBulletFont()); @@ -227,10 +228,10 @@ public class TestXSLFTextShape extends T void verifySlide3(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); assertEquals("Section Header",layout.getName()); - XSLFTextShape shape1 = (XSLFTextShape)shapes[0]; + XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0); CTPlaceholder ph1 = shape1.getCTPlaceholder(); assertEquals(STPlaceholderType.TITLE, ph1.getType()); // anchor is not defined in the shape @@ -247,10 +248,10 @@ public class TestXSLFTextShape extends T !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor() ); - 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(7.2, shape1.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape1.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape1.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape1.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.TOP, shape1.getVerticalAlignment()); // now check text properties @@ -258,13 +259,13 @@ public class TestXSLFTextShape extends T XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(TextAlign.LEFT, r1.getParentParagraph().getTextAlign()); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(40.0, r1.getFontSize()); + assertEquals(40.0, r1.getFontSize(), 0); assertEquals(Color.black, r1.getFontColor()); assertTrue(r1.isBold()); assertFalse(r1.isItalic()); - assertFalse(r1.isUnderline()); + assertFalse(r1.isUnderlined()); - XSLFTextShape shape2 = (XSLFTextShape)shapes[1]; + XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1); CTPlaceholder ph2 = shape2.getCTPlaceholder(); assertEquals(STPlaceholderType.BODY, ph2.getType()); // anchor is not defined in the shape @@ -281,27 +282,27 @@ public class TestXSLFTextShape extends T !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor() ); - 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(7.2, shape2.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape2.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape2.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape2.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.BOTTOM, shape2.getVerticalAlignment()); assertEquals("Section Header", shape2.getText()); XSLFTextRun r2 = shape2.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(TextAlign.LEFT, r2.getParentParagraph().getTextAlign()); assertEquals("Calibri", r2.getFontFamily()); - assertEquals(20.0, r2.getFontSize()); + assertEquals(20.0, r2.getFontSize(), 0); // TODO fix calculation of tint //assertEquals(new Color(137, 137, 137), r2.getFontColor()); } void verifySlide4(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); assertEquals("Two Content",layout.getName()); - XSLFTextShape shape1 = (XSLFTextShape)shapes[0]; + XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0); CTPlaceholder ph1 = shape1.getCTPlaceholder(); assertEquals(STPlaceholderType.TITLE, ph1.getType()); // anchor is not defined in the shape @@ -321,10 +322,10 @@ public class TestXSLFTextShape extends T !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor() ); - 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(7.2, shape1.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape1.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape1.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape1.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment()); // now check text properties @@ -332,10 +333,10 @@ public class TestXSLFTextShape extends T XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(TextAlign.CENTER, r1.getParentParagraph().getTextAlign()); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(44.0, r1.getFontSize()); + assertEquals(44.0, r1.getFontSize(), 0); assertEquals(Color.black, r1.getFontColor()); - XSLFTextShape shape2 = (XSLFTextShape)shapes[1]; + XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1); CTPlaceholder ph2 = shape2.getCTPlaceholder(); assertFalse(ph2.isSetType()); assertTrue(ph2.isSetIdx()); @@ -354,18 +355,18 @@ public class TestXSLFTextShape extends T !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor() ); - 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(7.2, shape2.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape2.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape2.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape2.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment()); XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(0, pr1.getParentParagraph().getLevel()); - assertEquals("Left", pr1.getText()); + assertEquals("Left", pr1.getRawText()); assertEquals("Calibri", pr1.getFontFamily()); - assertEquals(28.0, pr1.getFontSize()); - assertEquals(27.0, pr1.getParentParagraph().getLeftMargin()); + assertEquals(28.0, pr1.getFontSize(), 0); + assertEquals(27.0, pr1.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2022", pr1.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr1.getParentParagraph().getBulletFont()); @@ -373,8 +374,8 @@ public class TestXSLFTextShape extends T assertEquals(1, pr2.getParentParagraph().getLevel()); assertEquals("Level 2", pr2.getParentParagraph().getText()); assertEquals("Calibri", pr2.getFontFamily()); - assertEquals(24.0, pr2.getFontSize()); - assertEquals(58.5, pr2.getParentParagraph().getLeftMargin()); + assertEquals(24.0, pr2.getFontSize(), 0); + assertEquals(58.5, pr2.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2013", pr2.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr2.getParentParagraph().getBulletFont()); @@ -382,8 +383,8 @@ public class TestXSLFTextShape extends T assertEquals(2, pr3.getParentParagraph().getLevel()); assertEquals("Level 3", pr3.getParentParagraph().getText()); assertEquals("Calibri", pr3.getFontFamily()); - assertEquals(20.0, pr3.getFontSize()); - assertEquals(90.0, pr3.getParentParagraph().getLeftMargin()); + assertEquals(20.0, pr3.getFontSize(), 0); + assertEquals(90.0, pr3.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2022", pr3.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr3.getParentParagraph().getBulletFont()); @@ -391,31 +392,32 @@ public class TestXSLFTextShape extends T assertEquals(3, pr4.getParentParagraph().getLevel()); assertEquals("Level 4", pr4.getParentParagraph().getText()); assertEquals("Calibri", pr4.getFontFamily()); - assertEquals(18.0, pr4.getFontSize()); - assertEquals(126.0, pr4.getParentParagraph().getLeftMargin()); + assertEquals(18.0, pr4.getFontSize(), 0); + assertEquals(126.0, pr4.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2013", pr4.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr4.getParentParagraph().getBulletFont()); - XSLFTextShape shape3 = (XSLFTextShape)shapes[2]; + XSLFTextShape shape3 = (XSLFTextShape)shapes.get(2); XSLFTextRun pr5 = shape3.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(0, pr5.getParentParagraph().getLevel()); - assertEquals("Right", pr5.getText()); + assertEquals("Right", pr5.getRawText()); assertEquals("Calibri", pr5.getFontFamily()); assertEquals(Color.black, pr5.getFontColor()); } + @SuppressWarnings("unused") void verifySlide5(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); // TODO } void verifySlide7(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); assertEquals("Blank",layout.getName()); - XSLFTextShape shape1 = (XSLFTextShape)shapes[0]; + XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0); CTPlaceholder ph1 = shape1.getCTPlaceholder(); assertEquals(STPlaceholderType.TITLE, ph1.getType()); // anchor is not defined in the shape @@ -428,10 +430,10 @@ public class TestXSLFTextShape extends T !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor() ); - 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(7.2, shape1.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape1.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape1.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape1.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.MIDDLE, shape1.getVerticalAlignment()); // now check text properties @@ -439,11 +441,11 @@ public class TestXSLFTextShape extends T XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(TextAlign.CENTER, r1.getParentParagraph().getTextAlign()); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(44.0, r1.getFontSize()); + assertEquals(44.0, r1.getFontSize(), 0); assertEquals(Color.black, r1.getFontColor()); assertFalse(r1.isBold()); - XSLFTextShape shape2 = (XSLFTextShape)shapes[1]; + XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1); CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr(); // none of the following properties are set in the shapes and fetched from the master shape @@ -452,19 +454,19 @@ public class TestXSLFTextShape extends T !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor() ); - 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(7.2, shape2.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape2.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape2.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape2.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment()); XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(0, pr1.getParentParagraph().getLevel()); - assertEquals("Default Text", pr1.getText()); + assertEquals("Default Text", pr1.getRawText()); assertEquals("Calibri", pr1.getFontFamily()); - assertEquals(18.0, pr1.getFontSize()); + assertEquals(18.0, pr1.getFontSize(), 0); - XSLFTextShape shape3 = (XSLFTextShape)shapes[2]; + XSLFTextShape shape3 = (XSLFTextShape)shapes.get(2); assertEquals("Default", shape3.getTextParagraphs().get(0).getText()); assertEquals("Text with levels", shape3.getTextParagraphs().get(1).getText()); assertEquals("Level 1", shape3.getTextParagraphs().get(2).getText()); @@ -474,16 +476,16 @@ public class TestXSLFTextShape extends T for(int p = 0; p < 5; p++) { XSLFTextParagraph pr = shape3.getTextParagraphs().get(p); assertEquals("Calibri", pr.getTextRuns().get(0).getFontFamily()); - assertEquals(18.0, pr.getTextRuns().get(0).getFontSize()); + assertEquals(18.0, pr.getTextRuns().get(0).getFontSize(), 0); } } void verifySlide8(XSLFSlide slide){ XSLFSlideLayout layout = slide.getSlideLayout(); - XSLFShape[] shapes = slide.getShapes(); + List shapes = slide.getShapes(); assertEquals("Content with Caption",layout.getName()); - XSLFTextShape shape1 = (XSLFTextShape)shapes[0]; + XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0); CTPlaceholder ph1 = shape1.getCTPlaceholder(); assertEquals(STPlaceholderType.TITLE, ph1.getType()); // anchor is not defined in the shape @@ -501,10 +503,10 @@ public class TestXSLFTextShape extends T !bodyPr1.isSetBIns() && !bodyPr1.isSetTIns() && !bodyPr1.isSetAnchor() ); - 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(7.2, shape1.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape1.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape1.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape1.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.BOTTOM, shape1.getVerticalAlignment()); // now check text properties @@ -512,11 +514,11 @@ public class TestXSLFTextShape extends T XSLFTextRun r1 = shape1.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(TextAlign.LEFT, r1.getParentParagraph().getTextAlign()); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(20.0, r1.getFontSize()); + assertEquals(20.0, r1.getFontSize(), 0); assertEquals(Color.black, r1.getFontColor()); assertTrue(r1.isBold()); - XSLFTextShape shape2 = (XSLFTextShape)shapes[1]; + XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1); CTPlaceholder ph2 = shape2.getCTPlaceholder(); assertFalse(ph2.isSetType()); assertTrue(ph2.isSetIdx()); @@ -535,18 +537,18 @@ public class TestXSLFTextShape extends T !bodyPr2.isSetBIns() && !bodyPr2.isSetTIns() && !bodyPr2.isSetAnchor() ); - 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(7.2, shape2.getLeftInset(), 0); // 0.1" + assertEquals(7.2, shape2.getRightInset(), 0); // 0.1" + assertEquals(3.6, shape2.getTopInset(), 0); // 0.05" + assertEquals(3.6, shape2.getBottomInset(), 0); // 0.05" assertEquals(VerticalAlignment.TOP, shape2.getVerticalAlignment()); XSLFTextRun pr1 = shape2.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(0, pr1.getParentParagraph().getLevel()); - assertEquals("Level 1", pr1.getText()); + assertEquals("Level 1", pr1.getRawText()); assertEquals("Calibri", pr1.getFontFamily()); - assertEquals(32.0, pr1.getFontSize()); - assertEquals(27.0, pr1.getParentParagraph().getLeftMargin()); + assertEquals(32.0, pr1.getFontSize(), 0); + assertEquals(27.0, pr1.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2022", pr1.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr1.getParentParagraph().getBulletFont()); @@ -554,8 +556,8 @@ public class TestXSLFTextShape extends T assertEquals(1, pr2.getParentParagraph().getLevel()); assertEquals("Level 2", pr2.getParentParagraph().getText()); assertEquals("Calibri", pr2.getFontFamily()); - assertEquals(28.0, pr2.getFontSize()); - assertEquals(58.5, pr2.getParentParagraph().getLeftMargin()); + assertEquals(28.0, pr2.getFontSize(), 0); + assertEquals(58.5, pr2.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2013", pr2.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr2.getParentParagraph().getBulletFont()); @@ -563,8 +565,8 @@ public class TestXSLFTextShape extends T assertEquals(2, pr3.getParentParagraph().getLevel()); assertEquals("Level 3", pr3.getParentParagraph().getText()); assertEquals("Calibri", pr3.getFontFamily()); - assertEquals(24.0, pr3.getFontSize()); - assertEquals(90.0, pr3.getParentParagraph().getLeftMargin()); + assertEquals(24.0, pr3.getFontSize(), 0); + assertEquals(90.0, pr3.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2022", pr3.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr3.getParentParagraph().getBulletFont()); @@ -572,20 +574,20 @@ public class TestXSLFTextShape extends T assertEquals(3, pr4.getParentParagraph().getLevel()); assertEquals("Level 4", pr4.getParentParagraph().getText()); assertEquals("Calibri", pr4.getFontFamily()); - assertEquals(20.0, pr4.getFontSize()); - assertEquals(126.0, pr4.getParentParagraph().getLeftMargin()); + assertEquals(20.0, pr4.getFontSize(), 0); + assertEquals(126.0, pr4.getParentParagraph().getLeftMargin(), 0); assertEquals("\u2013", pr4.getParentParagraph().getBulletCharacter()); assertEquals("Arial", pr4.getParentParagraph().getBulletFont()); - XSLFTextShape shape3 = (XSLFTextShape)shapes[2]; + XSLFTextShape shape3 = (XSLFTextShape)shapes.get(2); assertEquals(VerticalAlignment.TOP, shape3.getVerticalAlignment()); assertEquals("Content with caption", shape3.getText()); pr1 = shape3.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(0, pr1.getParentParagraph().getLevel()); - assertEquals("Content with caption", pr1.getText()); + assertEquals("Content with caption", pr1.getRawText()); assertEquals("Calibri", pr1.getFontFamily()); - assertEquals(14.0, pr1.getFontSize()); + assertEquals(14.0, pr1.getFontSize(), 0); } @@ -599,7 +601,7 @@ public class TestXSLFTextShape extends T XSLFTextRun r1 = footer.getTextParagraphs().get(0).getTextRuns().get(0); assertEquals(TextAlign.CENTER, r1.getParentParagraph().getTextAlign()); assertEquals("Calibri", r1.getFontFamily()); - assertEquals(12.0, r1.getFontSize()); + assertEquals(12.0, r1.getFontSize(), 0); // TODO calculation of tint is incorrect assertEquals(new Color(64,64,64), r1.getFontColor()); @@ -614,14 +616,14 @@ public class TestXSLFTextShape extends T public void testTitleStyles(){ XMLSlideShow ppt = new XMLSlideShow(); - XSLFSlideMaster master = ppt.getSlideMasters()[0]; + XSLFSlideMaster master = ppt.getSlideMasters().get(0); XSLFTheme theme = master.getTheme(); XSLFSlideLayout layout = master.getLayout(SlideLayout.TITLE); XSLFSlide slide = ppt.createSlide(layout) ; assertSame(layout, slide.getSlideLayout()); assertSame(master, slide.getSlideMaster()); - XSLFTextShape titleShape = (XSLFTextShape)slide.getPlaceholder(0); + XSLFTextShape titleShape = slide.getPlaceholder(0); titleShape.setText("Apache POI"); XSLFTextParagraph paragraph = titleShape.getTextParagraphs().get(0); XSLFTextRun textRun = paragraph.getTextRuns().get(0); @@ -631,12 +633,12 @@ public class TestXSLFTextShape extends T CTTextParagraphProperties lv1PPr = master.getXmlObject().getTxStyles().getTitleStyle().getLvl1PPr(); CTTextCharacterProperties lv1CPr = lv1PPr.getDefRPr(); assertEquals(4400, lv1CPr.getSz()); - assertEquals(44.0, textRun.getFontSize()); + assertEquals(44.0, textRun.getFontSize(), 0); assertEquals("+mj-lt", lv1CPr.getLatin().getTypeface()); assertEquals("Calibri", theme.getMajorFont()); assertEquals("Calibri", textRun.getFontFamily()); lv1CPr.setSz(3200); - assertEquals(32.0, textRun.getFontSize()); + assertEquals(32.0, textRun.getFontSize(), 0); lv1CPr.getLatin().setTypeface("Arial"); assertEquals("Arial", textRun.getFontFamily()); assertEquals(STTextAlignType.CTR, lv1PPr.getAlgn()); @@ -650,7 +652,7 @@ public class TestXSLFTextShape extends T CTTextParagraphProperties lv2PPr = tx2.getTextBody(true).getLstStyle().addNewLvl1PPr(); CTTextCharacterProperties lv2CPr = lv2PPr.addNewDefRPr(); lv2CPr.setSz(3300); - assertEquals(33.0, textRun.getFontSize()); + assertEquals(33.0, textRun.getFontSize(), 0); lv2CPr.addNewLatin().setTypeface("Times"); assertEquals("Times", textRun.getFontFamily()); lv2PPr.setAlgn(STTextAlignType.R); @@ -663,7 +665,7 @@ public class TestXSLFTextShape extends T CTTextParagraphProperties lv3PPr = tx3.getTextBody(true).getLstStyle().addNewLvl1PPr(); CTTextCharacterProperties lv3CPr = lv3PPr.addNewDefRPr(); lv3CPr.setSz(3400); - assertEquals(34.0, textRun.getFontSize()); + assertEquals(34.0, textRun.getFontSize(), 0); lv3CPr.addNewLatin().setTypeface("Courier New"); assertEquals("Courier New", textRun.getFontFamily()); lv3PPr.setAlgn(STTextAlignType.CTR); @@ -674,7 +676,7 @@ public class TestXSLFTextShape extends T CTTextParagraphProperties lv4PPr = titleShape.getTextBody(true).getLstStyle().addNewLvl1PPr(); CTTextCharacterProperties lv4CPr = lv4PPr.addNewDefRPr(); lv4CPr.setSz(3500); - assertEquals(35.0, textRun.getFontSize()); + assertEquals(35.0, textRun.getFontSize(), 0); lv4CPr.addNewLatin().setTypeface("Arial"); assertEquals("Arial", textRun.getFontFamily()); lv4PPr.setAlgn(STTextAlignType.L); @@ -684,7 +686,7 @@ public class TestXSLFTextShape extends T CTTextParagraphProperties lv5PPr = paragraph.getXmlObject().addNewPPr(); CTTextCharacterProperties lv5CPr = textRun.getXmlObject().getRPr(); lv5CPr.setSz(3600); - assertEquals(36.0, textRun.getFontSize()); + assertEquals(36.0, textRun.getFontSize(), 0); lv5CPr.addNewLatin().setTypeface("Calibri"); assertEquals("Calibri", textRun.getFontFamily()); lv5PPr.setAlgn(STTextAlignType.CTR); @@ -694,14 +696,14 @@ public class TestXSLFTextShape extends T public void testBodyStyles(){ XMLSlideShow ppt = new XMLSlideShow(); - XSLFSlideMaster master = ppt.getSlideMasters()[0]; + XSLFSlideMaster master = ppt.getSlideMasters().get(0); XSLFTheme theme = master.getTheme(); XSLFSlideLayout layout = master.getLayout(SlideLayout.TITLE_AND_CONTENT); XSLFSlide slide = ppt.createSlide(layout) ; assertSame(layout, slide.getSlideLayout()); assertSame(master, slide.getSlideMaster()); - XSLFTextShape tx1 = (XSLFTextShape)slide.getPlaceholder(1); + XSLFTextShape tx1 = slide.getPlaceholder(1); tx1.clearText(); XSLFTextParagraph p1 = tx1.addNewTextParagraph(); @@ -731,12 +733,12 @@ public class TestXSLFTextShape extends T CTTextCharacterProperties lv3CPr = lv3PPr.getDefRPr(); // lv1 assertEquals(3200, lv1CPr.getSz()); - assertEquals(32.0, r1.getFontSize()); + assertEquals(32.0, r1.getFontSize(), 0); assertEquals("+mn-lt", lv1CPr.getLatin().getTypeface()); assertEquals("Calibri", theme.getMinorFont()); assertEquals("Calibri", r1.getFontFamily()); lv1CPr.setSz(3300); - assertEquals(33.0, r1.getFontSize()); + assertEquals(33.0, r1.getFontSize(), 0); lv1CPr.getLatin().setTypeface("Arial"); assertEquals("Arial", r1.getFontFamily()); assertEquals(STTextAlignType.L, lv1PPr.getAlgn()); @@ -745,9 +747,9 @@ public class TestXSLFTextShape extends T assertEquals(TextAlign.RIGHT, p1.getTextAlign()); //lv2 assertEquals(2800, lv2CPr.getSz()); - assertEquals(28.0, r2.getFontSize()); + assertEquals(28.0, r2.getFontSize(), 0); lv2CPr.setSz(3300); - assertEquals(33.0, r2.getFontSize()); + assertEquals(33.0, r2.getFontSize(), 0); lv2CPr.getLatin().setTypeface("Times"); assertEquals("Times", r2.getFontFamily()); assertEquals(STTextAlignType.L, lv2PPr.getAlgn()); @@ -756,9 +758,9 @@ public class TestXSLFTextShape extends T assertEquals(TextAlign.RIGHT, p2.getTextAlign()); //lv3 assertEquals(2400, lv3CPr.getSz()); - assertEquals(24.0, r3.getFontSize()); + assertEquals(24.0, r3.getFontSize(), 0); lv3CPr.setSz(2500); - assertEquals(25.0, r3.getFontSize()); + assertEquals(25.0, r3.getFontSize(), 0); lv3CPr.getLatin().setTypeface("Courier New"); assertEquals("Courier New", r3.getFontFamily()); assertEquals(STTextAlignType.L, lv3PPr.getAlgn()); @@ -780,21 +782,21 @@ public class TestXSLFTextShape extends T lv3CPr = lv3PPr.addNewDefRPr(); lv1CPr.setSz(3300); - assertEquals(33.0, r1.getFontSize()); + assertEquals(33.0, r1.getFontSize(), 0); lv1CPr.addNewLatin().setTypeface("Times"); assertEquals("Times", r1.getFontFamily()); lv1PPr.setAlgn(STTextAlignType.L); assertEquals(TextAlign.LEFT, p1.getTextAlign()); lv2CPr.setSz(3300); - assertEquals(33.0, r2.getFontSize()); + assertEquals(33.0, r2.getFontSize(), 0); lv2CPr.addNewLatin().setTypeface("Times"); assertEquals("Times", r2.getFontFamily()); lv2PPr.setAlgn(STTextAlignType.L); assertEquals(TextAlign.LEFT, p2.getTextAlign()); lv3CPr.setSz(3300); - assertEquals(33.0, r3.getFontSize()); + assertEquals(33.0, r3.getFontSize(), 0); lv3CPr.addNewLatin().setTypeface("Times"); assertEquals("Times", r3.getFontFamily()); lv3PPr.setAlgn(STTextAlignType.L); @@ -812,21 +814,21 @@ public class TestXSLFTextShape extends T lv3CPr = lv3PPr.addNewDefRPr(); lv1CPr.setSz(3400); - assertEquals(34.0, r1.getFontSize()); + assertEquals(34.0, r1.getFontSize(), 0); lv1CPr.addNewLatin().setTypeface("Courier New"); assertEquals("Courier New", r1.getFontFamily()); lv1PPr.setAlgn(STTextAlignType.CTR); assertEquals(TextAlign.CENTER, p1.getTextAlign()); lv2CPr.setSz(3400); - assertEquals(34.0, r2.getFontSize()); + assertEquals(34.0, r2.getFontSize(), 0); lv2CPr.addNewLatin().setTypeface("Courier New"); assertEquals("Courier New", r2.getFontFamily()); lv2PPr.setAlgn(STTextAlignType.CTR); assertEquals(TextAlign.CENTER, p2.getTextAlign()); lv3CPr.setSz(3400); - assertEquals(34.0, r3.getFontSize()); + assertEquals(34.0, r3.getFontSize(), 0); lv3CPr.addNewLatin().setTypeface("Courier New"); assertEquals("Courier New", r3.getFontFamily()); lv3PPr.setAlgn(STTextAlignType.CTR); @@ -842,21 +844,21 @@ public class TestXSLFTextShape extends T lv3CPr = lv3PPr.addNewDefRPr(); lv1CPr.setSz(3500); - assertEquals(35.0, r1.getFontSize()); + assertEquals(35.0, r1.getFontSize(), 0); lv1CPr.addNewLatin().setTypeface("Arial"); assertEquals("Arial", r1.getFontFamily()); lv1PPr.setAlgn(STTextAlignType.L); assertEquals(TextAlign.LEFT, p1.getTextAlign()); lv2CPr.setSz(3500); - assertEquals(35.0, r2.getFontSize()); + assertEquals(35.0, r2.getFontSize(), 0); lv2CPr.addNewLatin().setTypeface("Arial"); assertEquals("Arial", r2.getFontFamily()); lv2PPr.setAlgn(STTextAlignType.L); assertEquals(TextAlign.LEFT, p2.getTextAlign()); lv3CPr.setSz(3500); - assertEquals(35.0, r3.getFontSize()); + assertEquals(35.0, r3.getFontSize(), 0); lv3CPr.addNewLatin().setTypeface("Arial"); assertEquals("Arial", r3.getFontFamily()); lv3PPr.setAlgn(STTextAlignType.L); @@ -871,21 +873,21 @@ public class TestXSLFTextShape extends T lv3CPr = r3.getXmlObject().getRPr(); lv1CPr.setSz(3600); - assertEquals(36.0, r1.getFontSize()); + assertEquals(36.0, r1.getFontSize(), 0); lv1CPr.addNewLatin().setTypeface("Calibri"); assertEquals("Calibri", r1.getFontFamily()); lv1PPr.setAlgn(STTextAlignType.CTR); assertEquals(TextAlign.CENTER, p1.getTextAlign()); lv2CPr.setSz(3600); - assertEquals(36.0, r2.getFontSize()); + assertEquals(36.0, r2.getFontSize(), 0); lv2CPr.addNewLatin().setTypeface("Calibri"); assertEquals("Calibri", r2.getFontFamily()); lv2PPr.setAlgn(STTextAlignType.CTR); assertEquals(TextAlign.CENTER, p2.getTextAlign()); lv3CPr.setSz(3600); - assertEquals(36.0, r3.getFontSize()); + assertEquals(36.0, r3.getFontSize(), 0); lv3CPr.addNewLatin().setTypeface("Calibri"); assertEquals("Calibri", r3.getFontFamily()); lv3PPr.setAlgn(STTextAlignType.CTR); Modified: poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java (original) +++ poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java Mon Apr 27 20:13:43 2015 @@ -16,32 +16,39 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import junit.framework.TestCase; -import org.apache.poi.xslf.XSLFTestDataSamples; +import static org.junit.Assert.*; import java.awt.Color; -import java.awt.TexturePaint; +import java.util.List; + +import org.apache.poi.sl.usermodel.*; +import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint; +import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; +import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint; +import org.apache.poi.xslf.XSLFTestDataSamples; +import org.junit.Test; /** * test reading properties from a multi-theme and multi-master document * * @author Yegor Kozlov */ -public class TestXSLFTheme extends TestCase { +public class TestXSLFTheme { + @Test public void testRead(){ XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("themes.pptx"); - XSLFSlide[] slides = ppt.getSlides(); + List 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]); + slide1(slides.get(0)); + slide2(slides.get(1)); + slide3(slides.get(2)); + slide4(slides.get(3)); + slide5(slides.get(4)); + slide6(slides.get(5)); + slide7(slides.get(6)); + slide8(slides.get(7)); + slide9(slides.get(8)); + slide10(slides.get(9)); } private XSLFShape getShape(XSLFSheet sheet, String name){ @@ -58,11 +65,10 @@ public class TestXSLFTheme extends TestC assertEquals("Office Theme", theme.getName()); 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 + assertTrue(sh1.getFillStyle().getPaint() instanceof SolidPaint) ; // solid fill } @@ -73,20 +79,19 @@ public class TestXSLFTheme extends TestC } void slide3(XSLFSlide slide){ - assertNull(slide.getBackground().getFillColor()); - assertTrue(slide.getBackground().getPaint(null).getClass().getName().indexOf("Gradient") > 0); + PaintStyle fs = slide.getBackground().getFillStyle().getPaint(); + assertTrue(fs instanceof GradientPaint); } void slide4(XSLFSlide slide){ - assertNull(slide.getBackground().getFillColor()); - assertTrue(slide.getBackground().getPaint(null).getClass().getName().indexOf("Gradient") > 0); + PaintStyle fs = slide.getBackground().getFillStyle().getPaint(); + assertTrue(fs instanceof GradientPaint); 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 + assertTrue(sh1.getFillStyle().getPaint() instanceof SolidPaint) ; // solid fill XSLFTextShape sh2 = (XSLFTextShape)getShape(slide, "Title 3"); XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0); @@ -97,14 +102,15 @@ public class TestXSLFTheme extends TestC } void slide5(XSLFSlide slide){ - assertTrue(slide.getBackground().getPaint(null) instanceof TexturePaint); + PaintStyle fs = slide.getBackground().getFillStyle().getPaint(); + assertTrue(fs 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()); + assertEquals(36.0, run2.getFontSize(), 0); assertTrue(slide.getSlideLayout().getFollowMasterGraphics()); } @@ -133,15 +139,18 @@ public class TestXSLFTheme extends TestC } void slide8(XSLFSlide slide){ - assertTrue(slide.getBackground().getPaint(null) instanceof TexturePaint); + PaintStyle fs = slide.getBackground().getFillStyle().getPaint(); + assertTrue(fs instanceof TexturePaint); } void slide9(XSLFSlide slide){ - assertTrue(slide.getBackground().getPaint(null) instanceof TexturePaint); + PaintStyle fs = slide.getBackground().getFillStyle().getPaint(); + assertTrue(fs instanceof TexturePaint); } void slide10(XSLFSlide slide){ - assertTrue(slide.getBackground().getPaint(null).getClass().getName().indexOf("Gradient") > 0); + PaintStyle fs = slide.getBackground().getFillStyle().getPaint(); + assertTrue(fs instanceof GradientPaint); XSLFTextShape sh1 = (XSLFTextShape)getShape(slide, "Title 3"); XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0); Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java Mon Apr 27 20:13:43 2015 @@ -18,12 +18,13 @@ package org.apache.poi.hslf.blip; import org.apache.poi.hslf.usermodel.HSLFPictureData; -import org.apache.poi.hslf.model.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogFactory; + /* ==================================================================== Licensed to the Apache Software Foundation (ASF) under one or more Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java Mon Apr 27 20:13:43 2015 @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; import org.apache.poi.util.LittleEndian; import java.io.IOException; @@ -35,7 +35,7 @@ public final class DIB extends Bitmap { /** * @return type of this picture - * @see org.apache.poi.hslf.model.HSLFPictureShape#DIB + * @see org.apache.poi.hslf.usermodel.HSLFPictureShape#DIB */ public int getType(){ return HSLFPictureShape.DIB; 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=1676365&r1=1676364&r2=1676365&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 Mon Apr 27 20:13:43 2015 @@ -17,8 +17,8 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.HSLFPictureShape; -import org.apache.poi.hslf.model.HSLFShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFShape; import org.apache.poi.hslf.exceptions.HSLFException; import java.io.ByteArrayOutputStream; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java Mon Apr 27 20:13:43 2015 @@ -17,8 +17,8 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; import java.awt.*; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java Mon Apr 27 20:13:43 2015 @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; /** * Represents a JPEG picture data in a PPT file @@ -28,7 +28,7 @@ public final class JPEG extends Bitmap { /** * @return type of this picture - * @see org.apache.poi.hslf.model.HSLFPictureShape#JPEG + * @see org.apache.poi.hslf.usermodel.HSLFPictureShape#JPEG */ public int getType(){ return HSLFPictureShape.JPEG; 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=1676365&r1=1676364&r2=1676365&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 Mon Apr 27 20:13:43 2015 @@ -23,8 +23,8 @@ import java.io.IOException; import java.util.zip.InflaterInputStream; import org.apache.poi.hslf.exceptions.HSLFException; -import org.apache.poi.hslf.model.HSLFPictureShape; -import org.apache.poi.hslf.model.HSLFShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFShape; /** * Represents Macintosh PICT picture data. @@ -102,7 +102,7 @@ public final class PICT extends Metafile } /** - * @see org.apache.poi.hslf.model.HSLFPictureShape#PICT + * @see org.apache.poi.hslf.usermodel.HSLFPictureShape#PICT */ public int getType(){ return HSLFPictureShape.PICT; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java Mon Apr 27 20:13:43 2015 @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; import org.apache.poi.util.PngUtils; /** @@ -46,7 +46,7 @@ public final class PNG extends Bitmap { /** * @return type of this picture - * @see org.apache.poi.hslf.model.HSLFPictureShape#PNG + * @see org.apache.poi.hslf.usermodel.HSLFPictureShape#PNG */ public int getType(){ return HSLFPictureShape.PNG; 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=1676365&r1=1676364&r2=1676365&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 Mon Apr 27 20:13:43 2015 @@ -19,8 +19,8 @@ package org.apache.poi.hslf.blip; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.POILogger; -import org.apache.poi.hslf.model.HSLFPictureShape; -import org.apache.poi.hslf.model.HSLFShape; +import org.apache.poi.hslf.usermodel.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFShape; import org.apache.poi.hslf.exceptions.HSLFException; import java.io.*; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java Mon Apr 27 20:13:43 2015 @@ -18,8 +18,8 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; /** Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java Mon Apr 27 20:13:43 2015 @@ -17,11 +17,11 @@ package org.apache.poi.hslf.dev; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordTypes; import org.apache.poi.hslf.record.SlideListWithText; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; /** * Uses record level code to Documents. Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java Mon Apr 27 20:13:43 2015 @@ -18,8 +18,8 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; /** * Uses record level code to locate SlideListWithText entries. Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java Mon Apr 27 20:13:43 2015 @@ -18,8 +18,8 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; /** Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java Mon Apr 27 20:13:43 2015 @@ -20,7 +20,6 @@ package org.apache.poi.hslf.dev; import java.io.ByteArrayOutputStream; import java.util.Map; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.Notes; import org.apache.poi.hslf.record.NotesAtom; @@ -32,6 +31,7 @@ import org.apache.poi.hslf.record.SlideA import org.apache.poi.hslf.record.SlideListWithText; import org.apache.poi.hslf.record.SlidePersistAtom; import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; import org.apache.poi.util.LittleEndian; /** Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java Mon Apr 27 20:13:43 2015 @@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Iterator; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Record; import org.apache.poi.util.HexDump; import org.apache.poi.ddf.DefaultEscherRecordFactory; @@ -32,6 +31,7 @@ import org.apache.poi.hslf.record.Escher import org.apache.poi.hslf.record.TextCharsAtom; import org.apache.poi.hslf.record.TextBytesAtom; import org.apache.poi.hslf.record.StyleTextPropAtom; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; /** * This class provides a way to view the contents of a powerpoint file. Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java Mon Apr 27 20:13:43 2015 @@ -17,14 +17,11 @@ package org.apache.poi.hslf.dev; -import org.apache.poi.hslf.*; -import org.apache.poi.hslf.model.HSLFSlideShowImpl; -import org.apache.poi.hslf.model.textproperties.BitMaskTextProp; -import org.apache.poi.hslf.model.textproperties.TextProp; -import org.apache.poi.hslf.model.textproperties.TextPropCollection; -import org.apache.poi.hslf.record.*; +import java.util.List; -import java.util.LinkedList; +import org.apache.poi.hslf.model.textproperties.*; +import org.apache.poi.hslf.record.*; +import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl; /** * Uses record level code to locate StyleTextPropAtom entries. @@ -73,19 +70,19 @@ public final class TextStyleListing { public static void showStyleTextPropAtom(StyleTextPropAtom stpa) { System.out.println("\nFound a StyleTextPropAtom"); - LinkedList paragraphStyles = stpa.getParagraphStyles(); + List paragraphStyles = stpa.getParagraphStyles(); System.out.println("Contains " + paragraphStyles.size() + " paragraph styles:"); for(int i=0; i charStyles = stpa.getCharacterStyles(); System.out.println("Contains " + charStyles.size() + " character styles:"); for(int i=0; i textProps = tpc.getTextPropList(); System.out.println(" Contains " + textProps.size() + " TextProps"); for(int i=0; i _slides; private boolean _slidesByDefault = true; private boolean _notesByDefault = false; @@ -74,6 +68,7 @@ public final class PowerPointExtractor e PowerPointExtractor ppe = new PowerPointExtractor(file); System.out.println(ppe.getText(true, notes, comments, master)); + ppe.close(); } /** @@ -188,13 +183,10 @@ public final class PowerPointExtractor e public List getOLEShapes() { List list = new ArrayList(); - for (int i = 0; i < _slides.length; i++) { - HSLFSlide slide = _slides[i]; - - HSLFShape[] shapes = slide.getShapes(); - for (int j = 0; j < shapes.length; j++) { - if (shapes[j] instanceof OLEShape) { - list.add((OLEShape) shapes[j]); + for (HSLFSlide slide : _slides) { + for (HSLFShape shape : slide.getShapes()) { + if (shape instanceof OLEShape) { + list.add((OLEShape) shape); } } } @@ -219,7 +211,7 @@ public final class PowerPointExtractor e if (getSlideText) { if (getMasterText) { - for (SlideMaster master : _show.getSlidesMasters()) { + for (HSLFSlideMaster master : _show.getSlideMasters()) { for(HSLFShape sh : master.getShapes()){ if(sh instanceof HSLFTextShape){ if(HSLFMasterSheet.isPlaceholder(sh)) { @@ -241,8 +233,8 @@ public final class PowerPointExtractor e } } - for (int i = 0; i < _slides.length; i++) { - HSLFSlide slide = _slides[i]; + for (int i = 0; i < _slides.size(); i++) { + HSLFSlide slide = _slides.get(i); // Slide header, if set HeadersFooters hf = slide.getHeadersFooters(); @@ -251,7 +243,7 @@ public final class PowerPointExtractor e } // Slide text - textRunsToText(ret, slide.getTextRuns()); + textRunsToText(ret, slide.getTextParagraphs()); // Table text for (HSLFShape shape : slide.getShapes()){ @@ -284,8 +276,8 @@ public final class PowerPointExtractor e HashSet seenNotes = new HashSet(); HeadersFooters hf = _show.getNotesHeadersFooters(); - for (int i = 0; i < _slides.length; i++) { - HSLFNotes notes = _slides[i].getNotesSheet(); + for (int i = 0; i < _slides.size(); i++) { + HSLFNotes notes = _slides.get(i).getNotes(); if (notes == null) { continue; } @@ -301,7 +293,7 @@ public final class PowerPointExtractor e } // Notes text - textRunsToText(ret, notes.getTextRuns()); + textRunsToText(ret, notes.getTextParagraphs()); // Repeat the notes footer, if set if (hf != null && hf.isFooterVisible() && hf.getFooterText() != null) { @@ -330,17 +322,17 @@ public final class PowerPointExtractor e ret.append('\n'); } } - private void textRunsToText(StringBuffer ret, HSLFTextParagraph[] runs) { - if (runs==null) { + private void textRunsToText(StringBuffer ret, List> paragraphs) { + if (paragraphs==null) { return; } - for (int j = 0; j < runs.length; j++) { - HSLFTextParagraph run = runs[j]; - if (run != null) { - String text = run.getText(); - ret.append(text); - if (!text.endsWith("\n")) { + for (List lp : paragraphs) { + for (HSLFTextParagraph p : lp) { + for (HSLFTextRun r : p.getTextRuns()) { + ret.append(r.getRawText()); + } + if (ret.length() > 0 && ret.charAt(ret.length()-1) != '\n') { ret.append("\n"); } } Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java Mon Apr 27 20:13:43 2015 @@ -17,20 +17,13 @@ package org.apache.poi.hslf.extractor; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.ArrayList; import java.util.List; -import org.apache.poi.hslf.model.HSLFTextParagraph; -import org.apache.poi.hslf.record.CString; -import org.apache.poi.hslf.record.Record; -import org.apache.poi.hslf.record.RecordTypes; -import org.apache.poi.hslf.record.StyleTextPropAtom; -import org.apache.poi.hslf.record.TextBytesAtom; -import org.apache.poi.hslf.record.TextCharsAtom; -import org.apache.poi.hslf.record.TextHeaderAtom; +import org.apache.poi.hslf.record.*; +import org.apache.poi.hslf.usermodel.HSLFTextParagraph; +import org.apache.poi.hslf.usermodel.HSLFTextShape; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LittleEndian; @@ -174,18 +167,19 @@ public final class QuickButCruddyTextExt } // Otherwise, check the type to see if it's text - long type = LittleEndian.getUShort(pptContents,startPos+2); - HSLFTextParagraph trun = null; + int type = LittleEndian.getUShort(pptContents,startPos+2); // TextBytesAtom if(type == RecordTypes.TextBytesAtom.typeID) { TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8); - trun = new HSLFTextParagraph((TextHeaderAtom)null,tba,(StyleTextPropAtom)null); + String text = HSLFTextParagraph.toExternalString(tba.getText(), -1); + textV.add(text); } // TextCharsAtom if(type == RecordTypes.TextCharsAtom.typeID) { TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8); - trun = new HSLFTextParagraph((TextHeaderAtom)null,tca,(StyleTextPropAtom)null); + String text = HSLFTextParagraph.toExternalString(tca.getText(), -1); + textV.add(text); } // CString (doesn't go via a TextRun) @@ -201,10 +195,6 @@ public final class QuickButCruddyTextExt } } - // If we found text via a TextRun, save it in the vector - if(trun != null) { - textV.add(trun.getText()); - } // Wind on by the atom length, and check we're not at the end int newPos = (startPos + 8 + len); 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=1676365&r1=1676364&r2=1676365&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 Mon Apr 27 20:13:43 2015 @@ -34,6 +34,7 @@ import org.apache.poi.hslf.record.ExObjL import org.apache.poi.hslf.record.OEShapeAtom; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordTypes; +import org.apache.poi.hslf.usermodel.*; import org.apache.poi.sl.usermodel.ShapeContainer; import org.apache.poi.sl.usermodel.ShapeType; import org.apache.poi.util.LittleEndian; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java Mon Apr 27 20:13:43 2015 @@ -18,7 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.hslf.record.*; -import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.*; /** * Header / Footer settings. @@ -240,7 +240,7 @@ public final class HeadersFooters { private boolean isVisible(int flag, int placeholderId){ boolean visible; if(_ppt2007){ - HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0]; + HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlideMasters().get(0); HSLFTextShape placeholder = master.getPlaceholder(placeholderId); visible = placeholder != null && placeholder.getText() != null; } else { @@ -252,7 +252,7 @@ public final class HeadersFooters { private String getPlaceholderText(int placeholderId, CString cs){ String text = null; if(_ppt2007){ - HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0]; + HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlideMasters().get(0); HSLFTextShape placeholder = master.getPlaceholder(placeholderId); if(placeholder != null) text = placeholder.getText(); 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=1676365&r1=1676364&r2=1676365&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 Mon Apr 27 20:13:43 2015 @@ -18,6 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; +import org.apache.poi.hslf.usermodel.*; import org.apache.poi.sl.usermodel.ShapeContainer; import org.apache.poi.sl.usermodel.ShapeType; @@ -30,7 +31,7 @@ import java.awt.geom.Line2D; * @author Yegor Kozlov */ public final class Line extends HSLFSimpleShape { - protected Line(EscherContainerRecord escherRecord, ShapeContainer parent){ + public Line(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java Mon Apr 27 20:13:43 2015 @@ -24,7 +24,7 @@ import org.apache.poi.ddf.EscherContaine import org.apache.poi.ddf.EscherProperties; import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.record.*; -import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.*; import org.apache.poi.sl.usermodel.ShapeContainer; /** @@ -67,7 +67,7 @@ public final class MovieShape extends HS * this picture in the Slide * @param parent the parent shape of this picture */ - protected MovieShape(EscherContainerRecord escherRecord, ShapeContainer parent){ + public MovieShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java Mon Apr 27 20:13:43 2015 @@ -18,8 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; -import org.apache.poi.hslf.usermodel.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.HSLFObjectData; +import org.apache.poi.hslf.usermodel.*; import org.apache.poi.hslf.record.ExObjList; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.ExEmbed; @@ -63,7 +62,7 @@ public final class OLEShape extends HSLF * this picture in the Slide * @param parent the parent shape of this picture */ - protected OLEShape(EscherContainerRecord escherRecord, ShapeContainer parent){ + public OLEShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java Mon Apr 27 20:13:43 2015 @@ -19,19 +19,20 @@ package org.apache.poi.hslf.model; import java.awt.*; -import java.awt.Shape; -import java.awt.font.FontRenderContext; -import java.awt.font.GlyphVector; -import java.awt.font.TextLayout; +import java.awt.font.*; +import java.awt.geom.*; import java.awt.image.*; import java.awt.image.renderable.RenderableImage; -import java.awt.geom.*; import java.text.AttributedCharacterIterator; import java.util.Map; -import org.apache.poi.hslf.usermodel.HSLFTextRun; + import org.apache.poi.hslf.exceptions.HSLFException; -import org.apache.poi.util.POILogger; +import org.apache.poi.hslf.usermodel.*; +import org.apache.poi.sl.usermodel.StrokeStyle; +import org.apache.poi.sl.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; /** * Translates Graphics2D calls into PowerPoint. @@ -251,10 +252,10 @@ public final class PPGraphics2D extends */ public void drawString(String s, float x, float y) { HSLFTextBox txt = new HSLFTextBox(_group); - txt.getTextParagraph().supplySheet(_group.getSheet()); + txt.getTextParagraphs().get(0).supplySheet(_group.getSheet()); txt.setText(s); - HSLFTextRun rt = txt.getTextParagraph().getRichTextRuns()[0]; + HSLFTextRun rt = txt.getTextParagraphs().get(0).getTextRuns().get(0); rt.setFontSize(_font.getSize()); rt.setFontName(_font.getFamily()); @@ -262,13 +263,13 @@ public final class PPGraphics2D extends if (_font.isBold()) rt.setBold(true); if (_font.isItalic()) rt.setItalic(true); - txt.setMarginBottom(0); - txt.setMarginTop(0); - txt.setMarginLeft(0); - txt.setMarginRight(0); + txt.setBottomInset(0); + txt.setTopInset(0); + txt.setLeftInset(0); + txt.setRightInset(0); txt.setWordWrap(HSLFTextBox.WrapNone); - txt.setHorizontalAlignment(HSLFTextBox.AlignLeft); - txt.setVerticalAlignment(HSLFTextBox.AnchorMiddle); + txt.setHorizontalCentered(false); + txt.setVerticalAlignment(VerticalAlignment.MIDDLE); TextLayout layout = new TextLayout(s, _font, getFontRenderContext()); @@ -1794,7 +1795,7 @@ public final class PPGraphics2D extends float[] dash = bs.getDashArray(); if (dash != null) { //TODO: implement more dashing styles - shape.setLineDashing(Line.PEN_DASH); + shape.setLineDashing(StrokeStyle.LineDash.DASH); } } } Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java Mon Apr 27 20:13:43 2015 @@ -19,6 +19,8 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; import org.apache.poi.hslf.record.OEPlaceholderAtom; +import org.apache.poi.hslf.usermodel.HSLFShape; +import org.apache.poi.hslf.usermodel.HSLFTextBox; import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.sl.usermodel.ShapeContainer; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java Mon Apr 27 20:13:43 2015 @@ -18,6 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; +import org.apache.poi.hslf.usermodel.*; import org.apache.poi.sl.usermodel.ShapeContainer; import org.apache.poi.sl.usermodel.ShapeType; import org.apache.poi.util.LittleEndian; Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java?rev=1676365&r1=1676364&r2=1676365&view=diff ============================================================================== --- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java (original) +++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/Table.java Mon Apr 27 20:13:43 2015 @@ -18,6 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; +import org.apache.poi.hslf.usermodel.*; import org.apache.poi.sl.usermodel.ShapeContainer; import org.apache.poi.util.LittleEndian; @@ -319,9 +320,9 @@ public final class Table extends HSLFGro private Line cloneBorder(Line line){ Line border = createBorder(); border.setLineWidth(line.getLineWidth()); - border.setLineStyle(line.getStrokeStyle()); border.setLineDashing(line.getLineDashing()); border.setLineColor(line.getLineColor()); + border.setLineCompound(line.getLineCompound()); return border; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org