@Override
public XSLFSlide importContent(XSLFSheet src){
super.importContent(src);
+ if (!(src instanceof XSLFSlide)) {
+ return this;
+ }
- XSLFBackground bgShape = getBackground();
- if(bgShape != null) {
- CTBackground bg = (CTBackground)bgShape.getXmlObject();
- if(bg.isSetBgPr() && bg.getBgPr().isSetBlipFill()){
- CTBlip blip = bg.getBgPr().getBlipFill().getBlip();
- String blipId = blip.getEmbed();
-
- String relId = importBlip(blipId, src.getPackagePart());
- blip.setEmbed(relId);
+ // only copy direct backgrounds - not backgrounds of master sheet
+ CTBackground bgOther = ((XSLFSlide)src)._slide.getCSld().getBg();
+ if (bgOther == null) {
+ return this;
+ }
+
+ CTBackground bgThis = _slide.getCSld().getBg();
+ // remove existing background
+ if (bgThis != null) {
+ if (bgThis.isSetBgPr() && bgThis.getBgPr().isSetBlipFill()) {
+ String oldId = bgThis.getBgPr().getBlipFill().getBlip().getEmbed();
+ removeRelation(getRelationById(oldId));
}
+ _slide.getCSld().unsetBg();
+ }
+
+ bgThis = (CTBackground)_slide.getCSld().addNewBg().set(bgOther);
+
+ if(bgOther.isSetBgPr() && bgOther.getBgPr().isSetBlipFill()){
+ String idOther = bgOther.getBgPr().getBlipFill().getBlip().getEmbed();
+ String idThis = importBlip(idOther, src.getPackagePart());
+ bgThis.getBgPr().getBlipFill().getBlip().setEmbed(idThis);
+
}
+
return this;
}
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.URI;
import java.util.Collection;
import org.apache.poi.sl.draw.DrawPaint;
import org.apache.poi.sl.usermodel.PaintStyle;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.sl.usermodel.ShapeType;
float actRGB[] = actual.getRGBComponents(null);
assertArrayEquals(expRGB, actRGB, 0.0001f);
}
+
+ @Test
+ public void bug55714() throws IOException {
+ XMLSlideShow srcPptx = XSLFTestDataSamples.openSampleDocument("pptx2svg.pptx");
+ XMLSlideShow newPptx = new XMLSlideShow();
+ XSLFSlide srcSlide = srcPptx.getSlides().get(0);
+ XSLFSlide newSlide = newPptx.createSlide();
+
+ XSLFSlideLayout srcSlideLayout = srcSlide.getSlideLayout();
+ XSLFSlideLayout newSlideLayout = newSlide.getSlideLayout();
+ newSlideLayout.importContent(srcSlideLayout);
+
+ XSLFSlideMaster srcSlideMaster = srcSlide.getSlideMaster();
+ XSLFSlideMaster newSlideMaster = newSlide.getSlideMaster();
+ newSlideMaster.importContent(srcSlideMaster);
+
+ newSlide.importContent(srcSlide);
+ XMLSlideShow rwPptx = XSLFTestDataSamples.writeOutAndReadBack(newPptx);
+
+ PaintStyle ps = rwPptx.getSlides().get(0).getBackground().getFillStyle().getPaint();
+ assertTrue(ps instanceof TexturePaint);
+
+ rwPptx.close();
+ newPptx.close();
+ srcPptx.close();
+ }
}