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
This commit is contained in:
parent
e15bce1dd2
commit
774caa9892
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -671,6 +671,7 @@ public class SlideShow
|
||||
pict.setUID(uid);
|
||||
pict.setData(data);
|
||||
pict.setType(format);
|
||||
pict.setOffset(offset);
|
||||
|
||||
_hslfSlideShow.addPicture(pict);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user