diff --git a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java index 043d39099..7aab65765 100644 --- a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java @@ -66,7 +66,7 @@ public class XSLFFileHandler extends SlideShowHandler { @Override @Test public void test() throws Exception { - File file = new File("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx"); + File file = new File("test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx"); try (InputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); } diff --git a/src/java/org/apache/poi/sl/draw/DrawShape.java b/src/java/org/apache/poi/sl/draw/DrawShape.java index 242b9d6a6..9977e667e 100644 --- a/src/java/org/apache/poi/sl/draw/DrawShape.java +++ b/src/java/org/apache/poi/sl/draw/DrawShape.java @@ -66,7 +66,15 @@ public class DrawShape implements Drawable { if (tx == null) { tx = new AffineTransform(); } - final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D(); + + // we saw one document failing here, probably the format is slightly broken, but + // maybe better to try to handle it more gracefully + java.awt.Shape transformedShape = tx.createTransformedShape(ps.getAnchor()); + if(transformedShape == null) { + return; + } + + final Rectangle2D anchor = transformedShape.getBounds2D(); char cmds[] = isHSLF ? new char[]{ 'h','v','r' } : new char[]{ 'r','h','v' }; for (char ch : cmds) { @@ -184,7 +192,7 @@ public class DrawShape implements Drawable { } AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM); - if(tx != null && !tx.isIdentity()) { + if(tx != null && !tx.isIdentity() && tx.createTransformedShape(anchor) != null) { anchor = tx.createTransformedShape(anchor).getBounds2D(); } return anchor; diff --git a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java index c5abefa4c..7ed1d35da 100644 --- a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java +++ b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java @@ -405,6 +405,9 @@ public class DrawSimpleShape extends DrawShape { } Rectangle2D anchor = getAnchor(graphics, sh); + if(anchor == null) { + return lst; + } for (Path p : geom) { double w = p.getW(), h = p.getH(), scaleX = Units.toPoints(1), scaleY = scaleX; diff --git a/src/java/org/apache/poi/sl/draw/DrawTextShape.java b/src/java/org/apache/poi/sl/draw/DrawTextShape.java index ed1465381..413ab218c 100644 --- a/src/java/org/apache/poi/sl/draw/DrawTextShape.java +++ b/src/java/org/apache/poi/sl/draw/DrawTextShape.java @@ -45,6 +45,10 @@ public class DrawTextShape extends DrawSimpleShape { TextShape s = getShape(); Rectangle2D anchor = DrawShape.getAnchor(graphics, s); + if(anchor == null) { + return; + } + Insets2D insets = s.getInsets(); double x = anchor.getX() + insets.left; double y = anchor.getY(); diff --git a/test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx b/test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx new file mode 100755 index 000000000..544ee321e Binary files /dev/null and b/test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx differ