summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-08-04 21:34:51 +0000
committerNick Burch <nick@apache.org>2014-08-04 21:34:51 +0000
commit5a28c2bbb7c3cb25bc3f56cdc46bef1583d03eaa (patch)
tree2823056b4388db421d5197cfafefc87f8bd08206
parent22aec7b4e363f61e39cc38bde84648c37003446f (diff)
downloadpoi-5a28c2bbb7c3cb25bc3f56cdc46bef1583d03eaa.tar.gz
poi-5a28c2bbb7c3cb25bc3f56cdc46bef1583d03eaa.zip
Add a disabled unit test for bug #56812, based on code and file from Geoff Wright
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1615803 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java26
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java28
-rw-r--r--test-data/slideshow/56812.pptxbin0 -> 58308 bytes
3 files changed, 44 insertions, 10 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
index 872f82f83f..8663b897fc 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
@@ -19,28 +19,34 @@
package org.apache.poi.xslf.usermodel;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+
+import javax.imageio.ImageIO;
+import javax.xml.namespace.QName;
+
import org.apache.poi.POIXMLException;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.drawingml.x2006.main.*;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
-import javax.imageio.ImageIO;
-import javax.xml.namespace.QName;
-import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-
/**
* Represents a picture shape
- *
- * @author Yegor Kozlov
*/
@Beta
public class XSLFPictureShape extends XSLFSimpleShape {
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
index 8c1600fff8..fc422e778d 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
@@ -25,7 +25,10 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.xslf.usermodel.DrawingParagraph;
import org.apache.poi.xslf.usermodel.DrawingTextBody;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
+import org.apache.poi.xslf.usermodel.XSLFPictureData;
+import org.apache.poi.xslf.usermodel.XSLFPictureShape;
import org.apache.poi.xslf.usermodel.XSLFRelation;
+import org.apache.poi.xslf.usermodel.XSLFShape;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
@@ -136,6 +139,31 @@ public class TestXSLFBugs extends POITestCase {
assertContains("POI can read this", getSlideText(slide));
}
+ /**
+ * When the picture is not embedded but inserted only as a "link to file",
+ * there is no data available and XSLFPictureShape.getPictureData()
+ * gives a NPE, see bug #56812
+ */
+ public void DISABLEDtest56812() throws Exception {
+ XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("56812.pptx");
+
+ int pictures = 0;
+ for (XSLFSlide slide : ppt.getSlides()){
+ for (XSLFShape shape : slide.getShapes()){
+ assertNotNull(shape);
+
+ if (shape instanceof XSLFPictureShape) {
+ XSLFPictureData data = ((XSLFPictureShape) shape).getPictureData();
+ assertNotNull(data);
+ assertNotNull(data.getFileName());
+ pictures++;
+ }
+ }
+ }
+
+ assertEquals(3, pictures);
+ }
+
protected String getSlideText(XSLFSlide slide) {
StringBuffer text = new StringBuffer();
for(DrawingTextBody textBody : slide.getCommonSlideData().getDrawingText()) {
diff --git a/test-data/slideshow/56812.pptx b/test-data/slideshow/56812.pptx
new file mode 100644
index 0000000000..2fa070ad15
--- /dev/null
+++ b/test-data/slideshow/56812.pptx
Binary files differ