Since apache poi 4 the apache developers decided using org.apache.poi.xddf.usermodel.text.* for text paragraphs and text runs also in XSLF. Up to apache poi 3.17 XSLF had have it's own classes for text paragraphs and text runs. Those are further present (maybe for backwards compatibility) but in versions greater than apache po 3.17 they are using the wrong text body when text shapes are copied from other slides. See https://stackoverflow.com/questions/72017058/apache-poi-changes-applied-to-the-wrong-slide for a complete example.
I added some test cases - see r1903436 These test cases seem to pass ok - without any modifications to the core code. If someone can provide a reproducible test case, I'll look at this again. XDDF/XSLF are not code bases I work with very often.
I also added r1903437 with tests that clone slides and modify those new slides.
Created attachment 38365 [details] Sample Java code and sample *,pptx file OK, I will try to describe the problem again. Take the code of PPTXCCopyTemplateSlideAndChange.java from attachment java.zip. Do running it using the PPTXIn.pptx also attaches in java.zip. Using the code part ... ///* this works using apache poi 3.17 only but uses the wrong text body in version 5 List<XSLFTextParagraph> textBoxParagraphs = textShape.getTextParagraphs(); List<XSLFTextRun> textBoxParagraphTextRuns = textBoxParagraphs.stream().map(XSLFTextParagraph::getTextRuns).flatMap(List::stream).collect(Collectors.toList()); for (XSLFTextRun r : textBoxParagraphTextRuns) { r.setText("Replaced!"); } //*/ ... the wrong text runs in XSLFSlide template gets changed instead of the ones in XSLFSlide newSlide. Using the text part ... /* this works using apache poi 5.2.2 only but cannot work using version 3.17 because of usage of org.apache.poi.xddf.usermodel.text.* List<org.apache.poi.xddf.usermodel.text.XDDFTextParagraph> textBoxParagraphs = textShape.getTextBody().getParagraphs(); List<org.apache.poi.xddf.usermodel.text.XDDFTextRun> textBoxParagraphTextRuns = textBoxParagraphs.stream().map(org.apache.poi.xddf.usermodel.text.XDDFTextParagraph::getTextRuns).flatMap(List::stream).collect(Collectors.toList()); for (org.apache.poi.xddf.usermodel.text.XDDFTextRun r : textBoxParagraphTextRuns) { r.setText("Replaced!"); } */ ... the correct text runs in XSLFSlide newSlide get changed.
java.zip has PPTXOut.pptx but not PPTXIn.pptx - could you provide the PPTXIn.pptx file?
Created attachment 38367 [details] Sample *.pptx file Sorry, wrong file in ZIP archive.
Hi Alex - I haven't tested this yet but I applied the fix for https://bz.apache.org/bugzilla/show_bug.cgi?id=65473 today - is it possible that this fixes this? They do seem similar.