diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index f4ae431ee..cd23b88fe 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 54188 - Avoid NPE in PPT2PNG 52628 - Replace System.err info messages with a POILogger 54137 - improved performance of DataFormatter with Fractions 54099 - Ensure that CTHMerge and CTTcBorders go to poi-ooxml-schemas jar diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java b/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java index 97c818e51..10c468ced 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java @@ -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(); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java index 73e31e575..6ff487038 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java @@ -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()); + } }