<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta4" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46122 - fixed Picture.draw to skip rendering if picture data was not found</action>
<action dev="POI-DEVELOPERS" type="fix">15716 - memory usage optimisation - converted Ptg arrays into Formula objects</action>
<action dev="POI-DEVELOPERS" type="add">46065 - added implementation for VALUE function</action>
<action dev="POI-DEVELOPERS" type="add">45966 - added implementation for FIND function</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta4" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46122 - fixed Picture.draw to skip rendering if picture data was not found</action>
<action dev="POI-DEVELOPERS" type="fix">15716 - memory usage optimisation - converted Ptg arrays into Formula objects</action>
<action dev="POI-DEVELOPERS" type="add">46065 - added implementation for VALUE function</action>
<action dev="POI-DEVELOPERS" type="add">45966 - added implementation for FIND function</action>
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
-
+ if(bstore == null) {
+ logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
+ return null;
+ }
List lst = bstore.getChildRecords();
int idx = getPictureIndex();
if (idx == 0){
+ logger.log(POILogger.DEBUG, "picture index was not found, returning ");
return null;
} else {
return (EscherBSERecord)lst.get(idx-1);
ShapePainter.paint(this, graphics);
PictureData data = getPictureData();
- data.draw(graphics, this);
+ if(data != null) data.draw(graphics, this);
graphics.setTransform(at);
}
\r
import java.io.FileOutputStream;\r
import java.io.File;\r
+import java.io.IOException;\r
import java.awt.*;\r
+import java.awt.image.BufferedImage;\r
\r
import org.apache.poi.hslf.usermodel.SlideShow;\r
+import org.apache.poi.hslf.usermodel.PictureData;\r
import org.apache.poi.hslf.HSLFSlideShow;\r
import org.apache.poi.ddf.EscherBSERecord;\r
\r
\r
}\r
\r
+ /**\r
+ * Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER\r
+ * was not found. The correct behaviour is to return null.\r
+ */\r
+ public void test46122() throws IOException {\r
+ SlideShow ppt = new SlideShow();\r
+ Slide slide = ppt.createSlide();\r
+\r
+ Picture pict = new Picture(-1); //index to non-existing picture data\r
+ pict.setSheet(slide);\r
+ PictureData data = pict.getPictureData();\r
+ assertNull(data);\r
+\r
+ BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);\r
+ Graphics2D graphics = img.createGraphics();\r
+ pict.draw(graphics);\r
+\r
+ assertTrue("no errors rendering Picture with null data", true);\r
+ }\r
+\r
}\r