diff options
author | Yegor Kozlov <yegor@apache.org> | 2011-12-28 12:32:07 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2011-12-28 12:32:07 +0000 |
commit | 463c68c6b374a110b3ec688ef85d5fcaeda85afd (patch) | |
tree | 79682589ac96be70eb2ee1450c0878144e236eff /src/ooxml/java/org/apache/poi/xslf | |
parent | 7a49fa7ad4a4cc6a5bb56e6634e3c9defde9d98f (diff) | |
download | poi-463c68c6b374a110b3ec688ef85d5fcaeda85afd.tar.gz poi-463c68c6b374a110b3ec688ef85d5fcaeda85afd.zip |
more progress with merging external slides
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1225169 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xslf')
3 files changed, 65 insertions, 5 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java index 66cb5abb53..920cf8beaf 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java @@ -25,6 +25,7 @@ import org.apache.poi.openxml4j.opc.TargetMode; import org.apache.poi.util.Beta;
import org.apache.poi.util.Units;
import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
@@ -33,6 +34,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
import java.awt.Graphics2D;
@@ -309,4 +311,18 @@ public class XSLFGroupShape extends XSLFShape { }
+ @Override
+ void copy(XSLFShape src){
+ XSLFGroupShape gr = (XSLFGroupShape)src;
+ // recursively update each shape
+ XSLFShape[] tgtShapes = getShapes();
+ XSLFShape[] srcShapes = gr.getShapes();
+ for(int i = 0; i < tgtShapes.length; i++){
+ XSLFShape s1 = srcShapes[i];
+ XSLFShape s2 = tgtShapes[i];
+
+ s2.copy(s1);
+ }
+ }
+
}
\ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java index ce568f0ff6..0c64947b9c 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java @@ -286,10 +286,11 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements Iterable<X _shapes = null; _spTree = null; _drawing = null; + _spTree = null; // first copy the source xml - getXmlObject().set(src.getXmlObject()); + getSpTree().set(src.getSpTree()); - // recursively update each shape + // recursively update each shape List<XSLFShape> tgtShapes = getShapeList(); List<XSLFShape> srcShapes = src.getShapeList(); for(int i = 0; i < tgtShapes.size(); i++){ @@ -302,10 +303,52 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements Iterable<X } /** + * Append content to this sheet. + * + * @param src the source sheet + * @return modified <code>this</code>. + */ + public XSLFSheet appendContent(XSLFSheet src){ + CTGroupShape spTree = getSpTree(); + int numShapes = getShapeList().size(); + + CTGroupShape srcTree = src.getSpTree(); + for(XmlObject ch : srcTree.selectPath("*")){ + if(ch instanceof CTShape){ // simple shape + spTree.addNewSp().set(ch); + } else if (ch instanceof CTGroupShape){ + spTree.addNewGrpSp().set(ch); + } else if (ch instanceof CTConnector){ + spTree.addNewCxnSp().set(ch); + } else if (ch instanceof CTPicture){ + spTree.addNewPic().set(ch); + } else if (ch instanceof CTGraphicalObjectFrame){ + spTree.addNewGraphicFrame().set(ch); + } + } + + _shapes = null; + _spTree = null; + _drawing = null; + _spTree = null; + + // recursively update each shape + List<XSLFShape> tgtShapes = getShapeList(); + List<XSLFShape> srcShapes = src.getShapeList(); + for(int i = 0; i < srcShapes.size(); i++){ + XSLFShape s1 = srcShapes.get(i); + XSLFShape s2 = tgtShapes.get(numShapes + i); + + s2.copy(s1); + } + return this; + } + + /** * @return theme (shared styles) associated with this theme. * By default returns <code>null</code> which means that this sheet is theme-less. * Sheets that support the notion of themes (slides, masters, layouts, etc.) should override this - * method and return the corresposnding package part. + * method and return the corresponding package part. */ XSLFTheme getTheme(){ return null; diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java index 91566cb09a..f2d4b6eff1 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java @@ -225,8 +225,9 @@ public final class XSLFSlide extends XSLFSheet { public XSLFSlide importContent(XSLFSheet src){ super.importContent(src); - CTBackground bg = ((CTSlide)src.getXmlObject()).getCSld().getBg(); - if(bg != null) { + 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(); |