Bug 62928 - XSLFSlide.appendContent changes the PictureData of an existing picture
Summary: XSLFSlide.appendContent changes the PictureData of an existing picture
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 4.0.0-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-20 08:57 UTC by francesco.gatta
Modified: 2018-11-20 09:22 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description francesco.gatta 2018-11-20 08:57:26 UTC
I have one slide originalSlide which is empty.

I have a second slide contentSlide which contains a few shapes including one picture.

I create a new picture into originalSlide like this:

                Integer imgIdx = null;
		for (XSLFPictureData p : output.getPictureData()) {
			if (Arrays.equals(p.getData(), img.getData())) {
				//img exists, no need to add
				imgIdx = p.getIndex();
				break;
			}
		}
		
		if (imgIdx == null) {
			imgIdx = output.addPicture(img.getData(), img.getType()).getIndex(); //output is the XMLSlideShow
		}
                XSLFPictureShape s2 = originalSlide.createPicture(output.getPictureData().get(imgIdx));

I create a third slide cloneSlide and import all content from the original slide.

                XSLFSlide cloneSlide = output.createSlide().importContent(originalSlide);

Then, I try to append all content from contentSlide, and the content of my picture s2 gets replaced with the image from contentSlide, but in originalSlide the content of s2 is correct:


cloneSlide.appendContent(contentSlide);