poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1765733 - in /poi: site/src/documentation/content/xdocs/status.xml trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
Date Wed, 19 Oct 2016 23:25:51 GMT
Author: kiwiwings
Date: Wed Oct 19 23:25:51 2016
New Revision: 1765733

URL: http://svn.apache.org/viewvc?rev=1765733&view=rev
Log:
Bug 55714 - Background image ignored on slide copy

Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1765733&r1=1765732&r2=1765733&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Wed Oct 19 23:25:51 2016
@@ -40,6 +40,7 @@
     </devs>
 
     <release version="3.16-beta1" date="2016-11-??">
+        <action dev="PD" type="fix" fixes-bug="55714">XSLF: background image ignored
on slide copy</action>
         <action dev="PD" type="fix" fixes-bug="60255">XSSF: create drawings when workbook
contains non-sequential drawing indices</action>
         <action dev="PD" type="fix" fixes-bug="59302,60273,59830,59858,60158">Various
improvements for reading VBA macros</action>
         <action dev="PD" type="fix" fixes-bug="53191">HSLF: Problems with line style
when converting ppt to png</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1765733&r1=1765732&r2=1765733&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Wed Oct 19 23:25:51
2016
@@ -241,18 +241,35 @@ implements Slide<XSLFShape,XSLFTextParag
     @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;
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java?rev=1765733&r1=1765732&r2=1765733&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java Wed Oct 19 23:25:51
2016
@@ -31,7 +31,10 @@ import java.awt.geom.AffineTransform;
 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;
 
@@ -43,6 +46,7 @@ import org.apache.poi.POIXMLDocumentPart
 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;
@@ -517,4 +521,30 @@ public class TestXSLFBugs {
         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();
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message