From 4e0a09ce384da8fdfd55c5153100bbdf8410de81 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 14 Jul 2006 09:18:44 +0000 Subject: [PATCH] Yegor's update from bug #39991 - better identification of what underlying picture data a picture object relates to git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@421843 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hslf/model/Picture.java | 3 ++- .../poi/hslf/usermodel/PictureData.java | 25 +++++++++++++++++++ .../apache/poi/hslf/usermodel/SlideShow.java | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) 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 28e8e3f729..34f560c111 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 f040be4859..7eacac5938 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 178c63095e..090ebb0566 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); -- 2.39.5