]> source.dussan.org Git - poi.git/commitdiff
Add a disabled unit test for bug #56812, based on code and file from Geoff Wright
authorNick Burch <nick@apache.org>
Mon, 4 Aug 2014 21:34:51 +0000 (21:34 +0000)
committerNick Burch <nick@apache.org>
Mon, 4 Aug 2014 21:34:51 +0000 (21:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1615803 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
test-data/slideshow/56812.pptx [new file with mode: 0644]

index 872f82f83f3178b17baa1e3bf6cac3fd22d40445..8663b897fc4bbdc8cb83bfe4fb13f32b73e021e5 100644 (file)
 \r
 package org.apache.poi.xslf.usermodel;\r
 \r
+import java.awt.Graphics2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.awt.image.BufferedImage;\r
+import java.io.ByteArrayInputStream;\r
+\r
+import javax.imageio.ImageIO;\r
+import javax.xml.namespace.QName;\r
+\r
 import org.apache.poi.POIXMLException;\r
 import org.apache.poi.openxml4j.opc.PackagePart;\r
 import org.apache.poi.openxml4j.opc.PackageRelationship;\r
 import org.apache.poi.util.Beta;\r
 import org.apache.xmlbeans.XmlCursor;\r
 import org.apache.xmlbeans.XmlObject;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;\r
 \r
-import javax.imageio.ImageIO;\r
-import javax.xml.namespace.QName;\r
-import java.awt.Graphics2D;\r
-import java.awt.geom.Rectangle2D;\r
-import java.awt.image.BufferedImage;\r
-import java.io.ByteArrayInputStream;\r
-\r
 /**\r
  * Represents a picture shape\r
- *\r
- * @author Yegor Kozlov\r
  */\r
 @Beta\r
 public class XSLFPictureShape extends XSLFSimpleShape {\r
index 8c1600fff8a49a34a30159bed86ce62d87c88c8d..fc422e778dfa6b2b121532da9ed2e03debc2250d 100644 (file)
@@ -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 (file)
index 0000000..2fa070a
Binary files /dev/null and b/test-data/slideshow/56812.pptx differ