\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
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;
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()) {