import org.apache.poi.util.Beta;\r
import org.apache.poi.util.Units;\r
import org.apache.xmlbeans.XmlObject;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;\r
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;\r
import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;\r
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;\r
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;\r
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;\r
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;\r
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;\r
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;\r
\r
import java.awt.Graphics2D;\r
\r
}\r
\r
+ @Override\r
+ void copy(XSLFShape src){\r
+ XSLFGroupShape gr = (XSLFGroupShape)src;\r
+ // recursively update each shape\r
+ XSLFShape[] tgtShapes = getShapes();\r
+ XSLFShape[] srcShapes = gr.getShapes();\r
+ for(int i = 0; i < tgtShapes.length; i++){\r
+ XSLFShape s1 = srcShapes[i];\r
+ XSLFShape s2 = tgtShapes[i];\r
+\r
+ s2.copy(s1);\r
+ }\r
+ }\r
+\r
}
\ No newline at end of file
_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++){
}
/**
+ * 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;
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();