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
This commit is contained in:
Nick Burch 2014-08-04 21:34:51 +00:00
parent 22aec7b4e3
commit 5a28c2bbb7
3 changed files with 44 additions and 10 deletions

View File

@ -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 {

View 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()) {

Binary file not shown.