summaryrefslogtreecommitdiffstats
path: root/src/ooxml/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2018-09-26 21:42:21 +0000
committerPJ Fanning <fanningpj@apache.org>2018-09-26 21:42:21 +0000
commit43c57c26c26d85a0e083d40b92e98a0f5efb34a2 (patch)
treee966151ee8e5823b4be72095e82e9ce345c7d9ed /src/ooxml/java
parent9973fecad03c8155833f076c8d4139d6a2925e23 (diff)
downloadpoi-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.java17
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());
+ }
}