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 2016/08/25 10:13:03 UTC

[Bug 60042] New: PartAlreadyExistsException thrown when removing and adding slides.

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

            Bug ID: 60042
           Summary: PartAlreadyExistsException thrown when removing and
                    adding slides.
           Product: POI
           Version: 3.14-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLF
          Assignee: dev@poi.apache.org
          Reporter: john.littlewood@uk.thalesgroup.com

Created attachment 34172
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34172&action=edit
Presentation file which triggers the bug when used with the code in the
description.

I have a use case which requires taking a template presentation, deleting some
slides, and adding some more. When doing this, I get the following error
message when attempting to add a new slide after removing an old one:
Exception in thread "main"
org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException: A part with the
name '/ppt/slides/slide2.xml' already exists : Packages shall not contain
equivalent part names and package implementers shall neither create nor
recognize packages with equivalent part names. [M1.12]
    at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:811)
    at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:775)
    at
org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:536)
    at
org.apache.poi.xslf.usermodel.XMLSlideShow.createSlide(XMLSlideShow.java:220)
    at
org.apache.poi.xslf.usermodel.XMLSlideShow.createSlide(XMLSlideShow.java:243)
    at
com.thalesgroup.uk.airscape.investigations.briefinggenerator.PresentationBugger.main(PresentationBugger.java:35)

The following code results in the exception being thrown:

public class PresentationBugger {

  public static void main(String... args) throws IOException,
OpenXML4JException, XmlException {
    try (XMLSlideShow pptx = new XMLSlideShow(new FileInputStream(new
File("pres.pptx")))) {
      pptx.removeSlide(0);
      pptx.createSlide();
    }
  }
}

"pres.pptx" is a presentation (tested with PowerPoint 2010). With one slide in
the presentation, the bug doesn't occur, but with two or more, it does. I've
attached an example of pres.pptx which triggers the bug.

-- 
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 60042] PartAlreadyExistsException thrown when removing and adding slides.

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

--- Comment #1 from Javen O'Neal <on...@apache.org> ---
Should searching for file name (slide2.xml) be case insensitive?
https://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?revision=1753073&view=markup#l210

Also, slideNumber may not be computed correctly if the slides are out of order.

> for (CTSlideIdListEntry slideId : slideList.getSldIdArray()){
>     slideNumber = (int)Math.max(slideId.getId() + 1, slideNumber);
>     cnt++;
> }

It would be better to store slide numbers in a set and find the largest or
smallest slide number and find the next unused number.

-- 
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 60042] PartAlreadyExistsException thrown when removing and adding slides.

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

John Littlewood <jo...@uk.thalesgroup.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
                 CC|                            |john.littlewood@uk.thalesgr
                   |                            |oup.com

-- 
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 60042] PartAlreadyExistsException thrown when removing and adding slides.

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

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |60810


Referenced Bugs:

https://bz.apache.org/bugzilla/show_bug.cgi?id=60810
[Bug 60810] PartAlreadyExistsException when read slides note
-- 
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 60042] PartAlreadyExistsException thrown when removing and adding slides.

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

Dominik Stadler <do...@gmx.at> changed:

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

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
This seems to have been fixed shortly after version 3.14 was released, see bug
55791. I tried the test-code with the attached sample and it did work fine in
current trunk.

*** This bug has been marked as a duplicate of bug 55791 ***

-- 
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