When a textrun is deleted, programmatically it seems as if the deletion has been applied. However, the textrun is still visible in the slide of the slideshow. (The same problem occurs with textparagraphs, cf. another filed bug 65934.) Steps to reproduce: @Test void removeTextRun() throws IOException { final XMLSlideShow ppt = new XMLSlideShow(); final XSLFSlide slide = ppt.createSlide();; final XSLFTextBox textBox = slide.createTextBox(); textBox.setAnchor(new Rectangle(0,0,250,100)); final XSLFTextParagraph textParagraph = textBox.getTextParagraphs().get(0); textParagraph.getTextRuns().get(0).setText("lorem "); textParagraph.addNewTextRun().setText("ipsum "); textParagraph.addNewTextRun().setText("dolor"); assertEquals(1, textBox.getTextParagraphs().size()); assertEquals(3, textBox.getTextParagraphs().get(0).getTextRuns().size()); assertEquals("lorem ipsum dolor", textBox.getText()); assertEquals("lorem ipsum dolor", textBox.getTextParagraphs().get(0).getText()); assertEquals("lorem ", textBox.getTextParagraphs().get(0).getTextRuns().get(0).getRawText()); assertEquals("ipsum ", textBox.getTextParagraphs().get(0).getTextRuns().get(1).getRawText()); assertEquals("dolor", textBox.getTextParagraphs().get(0).getTextRuns().get(2).getRawText()); textBox.getTextParagraphs().get(0).getTextRuns().remove(textBox.getTextParagraphs().get(0).getTextRuns().get(1)); assertEquals(1, textBox.getTextParagraphs().size()); assertEquals(2, textBox.getTextParagraphs().get(0).getTextRuns().size()); assertEquals("lorem dolor", textBox.getText()); assertEquals("lorem dolor", textBox.getTextParagraphs().get(0).getText()); assertEquals("lorem ", textBox.getTextParagraphs().get(0).getTextRuns().get(0).getRawText()); assertEquals("dolor", textBox.getTextParagraphs().get(0).getTextRuns().get(1).getRawText()); String filepath = System.getProperty("java.io.tmpdir") + "tmp.pptx"; FileOutputStream fos = new FileOutputStream(filepath); ppt.write(fos); fos.close(); System.out.println("file written to " + filepath); }
added r1898672
I was able to verify that the change works. The above test initially failed with an UnsupportedOperationException. Great idea to change the list of textruns to Collections.unmodifiableList. :-) After replacing the line textBox.getTextParagraphs().get(0).getTextRuns().remove(textBox.getTextParagraphs().get(0).getTextRuns().get(1)); with textBox.getTextParagraphs().get(0).removeTextRun(textBox.getTextParagraphs().get(0).getTextRuns().get(1)); the test passed again and the slide finally looks as expected. Thanks for fixing the issue!