You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2008/11/03 18:54:01 UTC

svn commit: r710114 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml scratchpad/src/org/apache/poi/hslf/model/Picture.java scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java

Author: yegor
Date: Mon Nov  3 09:54:01 2008
New Revision: 710114

URL: http://svn.apache.org/viewvc?rev=710114&view=rev
Log:
fixed #46122: Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER was not found

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=710114&r1=710113&r2=710114&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Mon Nov  3 09:54:01 2008
@@ -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>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=710114&r1=710113&r2=710114&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Nov  3 09:54:01 2008
@@ -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>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java?rev=710114&r1=710113&r2=710114&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java Mon Nov  3 09:54:01 2008
@@ -196,10 +196,14 @@
         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 @@
         ShapePainter.paint(this, graphics);
 
         PictureData data = getPictureData();
-        data.draw(graphics, this);
+        if(data != null) data.draw(graphics, this);
 
         graphics.setTransform(at);
     }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java?rev=710114&r1=710113&r2=710114&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java Mon Nov  3 09:54:01 2008
@@ -20,9 +20,12 @@
 
 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 @@
 
     }
 
+    /**
+     * 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);
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org