mirror of https://github.com/apache/poi.git
fixed #46122: Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER was not found
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@710114 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bf3699bb17
commit
d99149477c
|
@ -37,6 +37,7 @@
|
|||
|
||||
<!-- 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>
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<!-- 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>
|
||||
|
|
|
@ -196,10 +196,14 @@ public class Picture extends SimpleShape {
|
|||
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);
|
||||
|
@ -263,7 +267,7 @@ public class Picture extends SimpleShape {
|
|||
ShapePainter.paint(this, graphics);
|
||||
|
||||
PictureData data = getPictureData();
|
||||
data.draw(graphics, this);
|
||||
if(data != null) data.draw(graphics, this);
|
||||
|
||||
graphics.setTransform(at);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,12 @@ import junit.framework.*;
|
|||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.ddf.EscherBSERecord;
|
||||
|
||||
|
@ -70,4 +73,24 @@ public class TestPicture extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER
|
||||
* was not found. The correct behaviour is to return null.
|
||||
*/
|
||||
public void test46122() throws IOException {
|
||||
SlideShow ppt = new SlideShow();
|
||||
Slide slide = ppt.createSlide();
|
||||
|
||||
Picture pict = new Picture(-1); //index to non-existing picture data
|
||||
pict.setSheet(slide);
|
||||
PictureData data = pict.getPictureData();
|
||||
assertNull(data);
|
||||
|
||||
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
pict.draw(graphics);
|
||||
|
||||
assertTrue("no errors rendering Picture with null data", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue