From 09b3c01f054367cd14237cac8dd2cdfe6eb594a4 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Tue, 29 Nov 2016 22:41:26 +0000 Subject: #60427 - Creating pictures in PowerPoint slides requires scratchpad-jar for adding WMF images more cases git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1771974 13f79535-47bb-0310-9956-ffa450edef68 --- src/ooxml/java/org/apache/poi/util/OOXMLLite.java | 13 +++++++++---- .../org/apache/poi/xslf/usermodel/TestXSLFTextShape.java | 13 +++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ooxml/java/org/apache/poi/util/OOXMLLite.java b/src/ooxml/java/org/apache/poi/util/OOXMLLite.java index c42ba5e038..0b2c5d92a4 100644 --- a/src/ooxml/java/org/apache/poi/util/OOXMLLite.java +++ b/src/ooxml/java/org/apache/poi/util/OOXMLLite.java @@ -227,10 +227,15 @@ public final class OOXMLLite { cls = cls.replace(".class", ""); - Class testclass = Class.forName(cls); - if (TestCase.class.isAssignableFrom(testclass) - || checkForTestAnnotation(testclass)) { - out.add(testclass); + try { + Class testclass = Class.forName(cls); + if (TestCase.class.isAssignableFrom(testclass) + || checkForTestAnnotation(testclass)) { + out.add(testclass); + } + } catch (Throwable e) { + System.out.println("Class " + cls + " is not in classpath"); + return; } } } 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 8ae19f2659..771fd9d915 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr; import java.awt.Color; @@ -38,6 +39,7 @@ import org.apache.poi.sl.usermodel.SlideShowFactory; import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; import org.apache.poi.sl.usermodel.VerticalAlignment; import org.apache.poi.xslf.XSLFTestDataSamples; +import org.junit.BeforeClass; import org.junit.Test; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties; @@ -47,6 +49,16 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder; import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType; public class TestXSLFTextShape { + private static boolean xslfOnly = false; + + @BeforeClass + public static void checkHslf() { + try { + Class.forName("org.apache.poi.hslf.usermodel.HSLFSlideShow"); + } catch (Exception e) { + xslfOnly = true; + } + } @Test public void testLayouts() throws IOException { @@ -919,6 +931,7 @@ public class TestXSLFTextShape { @Test public void metroBlob() throws IOException { + assumeFalse(xslfOnly); File f = POIDataSamples.getSlideShowInstance().getFile("bug52297.ppt"); SlideShow ppt = SlideShowFactory.create(f); HSLFTextShape sh = (HSLFTextShape)ppt.getSlides().get(1).getShapes().get(3); -- cgit v1.2.3