]> source.dussan.org Git - poi.git/commitdiff
Yegor's update from bug #39991 - better identification of what underlying picture...
authorNick Burch <nick@apache.org>
Fri, 14 Jul 2006 09:18:44 +0000 (09:18 +0000)
committerNick Burch <nick@apache.org>
Fri, 14 Jul 2006 09:18:44 +0000 (09:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@421843 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java

index 28e8e3f72918c718778812ee342873a23ac917a6..34f560c1115899548aa40d4be07b9adbe481d980 100644 (file)
@@ -153,10 +153,11 @@ public class Picture extends SimpleShape {
         int idx = getPictureIndex()-1;\r
         EscherBSERecord bse = (EscherBSERecord)lst.get(idx);\r
         for ( int i = 0; i < pict.length; i++ ) {\r
-            if (Arrays.equals(bse.getUid(), pict[i].getUID())){\r
+                       if (pict[i].getOffset() ==  bse.getOffset()){\r
                 return pict[i];\r
             }\r
         }\r
+               System.err.println("Warning - no picture found for our BSE offset " + bse.getOffset());\r
         return null;\r
     }\r
 \r
index f040be4859c71abbe459f38afcc38c9c7817aaf2..7eacac5938b6fddaec846bb231836a0ef71dbfc6 100644 (file)
@@ -49,6 +49,11 @@ public class PictureData {
        */\r
        protected byte[] header;\r
 \r
+       /**\r
+        * The offset to the picture in the stream\r
+        */\r
+       protected int offset;\r
+\r
     public PictureData(){\r
         header = new byte[PictureData.HEADER_SIZE];\r
     }\r
@@ -76,6 +81,7 @@ public class PictureData {
 \r
                // Save the picture data\r
                pictdata = new byte[size];\r
+               this.offset = offset;\r
                System.arraycopy(pictstream, startPos, pictdata, 0, pictdata.length);\r
        }\r
 \r
@@ -163,6 +169,25 @@ public class PictureData {
         return header;\r
     }\r
 \r
+       /**\r
+        * File offset in the 'Pictures' stream\r
+        *\r
+        * @return offset in the 'Pictures' stream\r
+        */\r
+       public int getOffset(){\r
+               return offset;\r
+       }\r
+\r
+       /**\r
+        * Set offset of this picture in the 'Pictures' stream.\r
+        * We need to set it when a new picture is created.\r
+        *\r
+        * @param offset in the 'Pictures' stream\r
+        */\r
+       public void setOffset(int offset){\r
+               this.offset = offset;\r
+       }\r
+\r
     /**\r
      * Compute 16-byte checksum of this picture\r
      */\r
index 178c63095ef11da0a929b3bbf4a7d974c08ebb78..090ebb0566551c0d22242938d5ad1944373b8f33 100644 (file)
@@ -671,6 +671,7 @@ public class SlideShow
         pict.setUID(uid);
         pict.setData(data);
         pict.setType(format);
+               pict.setOffset(offset);
 
         _hslfSlideShow.addPicture(pict);