You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2018/09/18 20:14:59 UTC

[Bug 62736] New: [PATCH] Relations on XSLFPictureShape are removed unconditionally

https://bz.apache.org/bugzilla/show_bug.cgi?id=62736

            Bug ID: 62736
           Summary: [PATCH] Relations on XSLFPictureShape are removed
                    unconditionally
           Product: POI
           Version: 4.0.x-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLF
          Assignee: dev@poi.apache.org
          Reporter: bmateusz@gmail.com
  Target Milestone: ---

It is only safe to remove a relation of a PictureShape if there are no more
relations to that media on its slide.

I created a small example pptx where I copy pasted an image on a slide and
removed only one of them using poi. The current implementation removes the
relation and the document gets corrupted because of the invalid link.

The proposed fix is to iterate on the pictures of the slide and only remove the
relation if that is the only one.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62736] [PATCH] Relations on XSLFPictureShape are removed unconditionally

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62736

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from PJ Fanning <fa...@yahoo.com> ---
https://svn.apache.org/viewvc?view=revision&revision=1842055

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62736] [PATCH] Relations on XSLFPictureShape are removed unconditionally

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62736

--- Comment #3 from PJ Fanning <fa...@yahoo.com> ---
Comment on attachment 36155
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36155
change in removePictureRelation function and testcase

Would it be better if the new code threw an exception if it isn't safe to
remove the picture relation?

+        if (numberOfRelations <= 1) {
+            removeRelation(pictureShape.getBlipId());
+        } else {
+            throw new IllegalStateException("Cannot remove picture relation
because there are other references to the picture");
+        }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62736] [PATCH] Relations on XSLFPictureShape are removed unconditionally

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62736

Mate Borcsok <bm...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #4 from Mate Borcsok <bm...@gmail.com> ---
(In reply to PJ Fanning from comment #3)
> Comment on attachment 36155 [details]
> change in removePictureRelation function and testcase
> 
> Would it be better if the new code threw an exception if it isn't safe to
> remove the picture relation?
> 
> +        if (numberOfRelations <= 1) {
> +            removeRelation(pictureShape.getBlipId());
> +        } else {
> +            throw new IllegalStateException("Cannot remove picture relation
> because there are other references to the picture");
> +        }

As far as I understood, it wouldn't.
It is a valid case to remove just one PictureShape, but leave the relation
between the Slide and the media.
The new testcase would also fail at
TestXSLFBugs.bug62736(TestXSLFBugs.java:124)

The reason why I used <= 1 that in POIXMLDocumentPart.java we just return false
if there are no relations, and I wanted to keep the existing functionality in
that case.
        RelationPart rp = relations.get(partId);
        if (rp == null) {
            // part is not related with this POIXMLDocumentPart
            return false;
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62736] [PATCH] Relations on XSLFPictureShape are removed unconditionally

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62736

--- Comment #1 from Mate Borcsok <bm...@gmail.com> ---
Created attachment 36155
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36155&action=edit
change in removePictureRelation function and testcase

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 62736] [PATCH] Relations on XSLFPictureShape are removed unconditionally

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62736

--- Comment #2 from Mate Borcsok <bm...@gmail.com> ---
Created attachment 36156
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36156&action=edit
example pptx

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org