diff options
author | PJ Fanning <fanningpj@apache.org> | 2018-09-26 21:42:21 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2018-09-26 21:42:21 +0000 |
commit | 43c57c26c26d85a0e083d40b92e98a0f5efb34a2 (patch) | |
tree | e966151ee8e5823b4be72095e82e9ce345c7d9ed /src/ooxml/java | |
parent | 9973fecad03c8155833f076c8d4139d6a2925e23 (diff) | |
download | poi-43c57c26c26d85a0e083d40b92e98a0f5efb34a2.tar.gz poi-43c57c26c26d85a0e083d40b92e98a0f5efb34a2.zip |
[bug-62736] Relations on XSLFPictureShape are removed unconditionally. Thanks to Mate Borcsok
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1842055 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java index 2dbc39bff4..cee875a831 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java @@ -692,10 +692,23 @@ implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> { /** * Helper method for sheet and group shapes * - * @param pictureShape the picture shapes whose relation is to be removed + * @param pictureShape the picture shapes whose relation is to be removed, + * only if there are no more relations on its sheet to that picture */ void removePictureRelation(XSLFPictureShape pictureShape) { - removeRelation(pictureShape.getBlipId()); + int numberOfRelations = 0; + String targetBlipId = pictureShape.getBlipId(); + for (XSLFShape shape : pictureShape.getSheet().getShapes()) { + if (shape instanceof XSLFPictureShape) { + XSLFPictureShape currentPictureShape = ((XSLFPictureShape) shape); + if (currentPictureShape.getBlipId().equals(targetBlipId)) { + numberOfRelations++; + } + } + } + if (numberOfRelations <= 1) { + removeRelation(pictureShape.getBlipId()); + } } |