Summary: | XSLFTextParagraph uses the wrong text body when text shapes are copied from other slides | ||
---|---|---|---|
Product: | POI | Reporter: | Axel Richter <axel.richter.privat> |
Component: | XSLF | Assignee: | POI Developers List <dev> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 5.2.0-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: |
Sample Java code and sample *,pptx file
Sample *.pptx file |
Description
Axel Richter
2022-04-28 06:11:25 UTC
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. |