]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 54188 - Avoid NPE in PPT2PNG
authorYegor Kozlov <yegor@apache.org>
Sun, 25 Nov 2012 11:53:50 +0000 (11:53 +0000)
committerYegor Kozlov <yegor@apache.org>
Sun, 25 Nov 2012 11:53:50 +0000 (11:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1413339 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java

index f4ae431eee7fe3ad4026d5953c7ac726aefc56e4..cd23b88fed9d9729a7068ee7a84f31eda5e11861 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.9-beta1" date="2012-??-??">
+          <action dev="poi-developers" type="fix">54188 - Avoid NPE in PPT2PNG</action>
           <action dev="poi-developers" type="fix">52628 - Replace System.err info messages with a POILogger</action>
           <action dev="poi-developers" type="fix">54137 - improved performance of DataFormatter with Fractions</action>
           <action dev="poi-developers" type="fix">54099 - Ensure that CTHMerge and CTTcBorders go to poi-ooxml-schemas jar</action>
index 97c818e519987fc0ba81de769e2484d31e68f269..10c468ced7455c78009be05fd60b89479c5a21d0 100644 (file)
@@ -244,6 +244,11 @@ public final class Freeform extends AutoShape {
 
     public java.awt.Shape getOutline(){
         GeneralPath path =  getPath();
+        if(path == null) {
+            // return empty path if either GEOMETRY__VERTICES or GEOMETRY__SEGMENTINFO is missing, see Bugzilla 54188
+            return new GeneralPath();
+        }
+
         Rectangle2D anchor = getAnchor2D();
         Rectangle2D bounds = path.getBounds2D();
         AffineTransform at = new AffineTransform();
index 73e31e5755a1bc78a025d3133a38aa3048b1c372..6ff487038669f4845c73e14b2fdd6915864b3508 100644 (file)
@@ -71,4 +71,16 @@ public final class TestFreeform extends TestCase {
         java.awt.Shape path2 = p.getOutline();
         assertTrue(new Area(path1).equals(new Area(path2)));
    }
+
+    /**
+     * Avoid NPE in  Freeform.getOutline() if either GEOMETRY__VERTICES or
+     * GEOMETRY__SEGMENTINFO is missing, see Bugzilla 54188
+     */
+    public void test54188() {
+
+        Freeform p = new Freeform();
+        GeneralPath path = (GeneralPath)p.getOutline();
+        GeneralPath emptyPath = new GeneralPath();
+        assertEquals(emptyPath.getBounds2D(), path.getBounds2D());
+    }
 }