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(); ppt.removeSlide(11); 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.
Reproducer with existing sample documents, so it is not really related to layout/master slides: @Test public void bug55791a() { XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("45541_Footer.pptx"); removeAndCreateSlide(ppt); } @Test public void bug55791b() { XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("SampleShow.pptx"); removeAndCreateSlide(ppt); } private void removeAndCreateSlide(XMLSlideShow ppt) { assertTrue(ppt.getSlides().length > 1); ppt.removeSlide(1); assertNotNull(ppt.createSlide()); }
There was a similar problem for XSSF reported in bug 57165, maybe a similar fix will be neceswsary here.
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.
*** Bug 60042 has been marked as a duplicate of this bug. ***