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