You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2011/12/28 13:32:08 UTC
svn commit: r1225169 - in
/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel:
XSLFGroupShape.java XSLFSheet.java XSLFSlide.java
Author: yegor
Date: Wed Dec 28 12:32:07 2011
New Revision: 1225169
URL: http://svn.apache.org/viewvc?rev=1225169&view=rev
Log:
more progress with merging external slides
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java?rev=1225169&r1=1225168&r2=1225169&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java Wed Dec 28 12:32:07 2011
@@ -25,6 +25,7 @@ import org.apache.poi.openxml4j.opc.Targ
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.drawin
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 XSLF
}
+ @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
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1225169&r1=1225168&r2=1225169&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Wed Dec 28 12:32:07 2011
@@ -286,10 +286,11 @@ public abstract class XSLFSheet extends
_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
}
/**
+ * 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;
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=1225169&r1=1225168&r2=1225169&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 Dec 28 12:32:07 2011
@@ -225,8 +225,9 @@ public final class XSLFSlide extends XSL
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();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org