Bug 55791 - PartAlreadyExistsException when removing and adding slides
Summary: PartAlreadyExistsException when removing and adding slides
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.9-dev
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
: 60042 (view as bug list)
Depends on: 57165
Blocks: 60810
  Show dependency tree
Reported: 2013-11-18 12:29 UTC by Monica
Modified: 2017-03-19 20:41 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Monica 2013-11-18 12:29:29 UTC
Whenever am trying to delete slides of a simple PPT , it is possible. But am working on a program where i have to use the previous layouts to create new slides dynamically for more data. 

Now when i try to delete a slide, it starts throwing error on that layout part of code irrespective of the slide i want to delete.

The error is as shown

Exception in thread "main" org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException: A part with the name '/ppt/slides/slide22.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:774)
       at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:738)
       at org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:350)
       at org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:334)
       at org.apache.poi.xslf.usermodel.XMLSlideShow.createSlide(XMLSlideShow.java:206)
       at Table.main(Table.java:9)

And my code is:

XMLSlideShow ppt = new XMLSlideShow(new FileInputStream("Template.pptx"));
XSLFSlide[] slide = ppt.getSlides();
XSLFTable tbl = slide[1].createTable();
tbl.setAnchor(new Rectangle2D.Double(30, 100, 600, 800));
XSLFSlideMaster master = ppt.getSlideMasters()[0];
XSLFSlideLayout layout1 = master.getLayout(SlideLayout.TITLE_ONLY);
XSLFSlide slide1 = ppt.createSlide(layout1) ;
String str1 = slide[1].getTitle();
XSLFTextShape[] pht = slide1.getPlaceholders();

Thank you.
Comment 1 Dominik Stadler 2015-03-01 20:28:07 UTC
Reproducer with existing sample documents, so it is not really related to layout/master slides: 

    public void bug55791a() {
        XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("45541_Footer.pptx");

    public void bug55791b() {
        XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("SampleShow.pptx");

	private void removeAndCreateSlide(XMLSlideShow ppt) {
		assertTrue(ppt.getSlides().length > 1);
Comment 2 Dominik Stadler 2015-03-18 19:09:12 UTC
There was a similar problem for XSSF reported in bug 57165, maybe a similar fix will be neceswsary here.
Comment 3 Dominik Stadler 2016-03-13 21:35:15 UTC
With r1734862 we now try harder to find a unique name for new slides to avoid name-clashes when some parts of the previous slide still linger on for some reason.
Comment 4 Dominik Stadler 2017-03-19 20:41:19 UTC
*** Bug 60042 has been marked as a duplicate of this bug. ***