_grpSpPr = shape.getGrpSpPr();
}
+ @Override
protected CTGroupShapeProperties getGrpSpPr() {
return _grpSpPr;
}
*
* @return an iterator over the shapes in this sheet
*/
+ @Override
public Iterator<XSLFShape> iterator(){
return _shapes.iterator();
}
/**
* Remove the specified shape from this group
*/
+ @Override
public boolean removeShape(XSLFShape xShape) {
XmlObject obj = xShape.getXmlObject();
CTGroupShape grpSp = (CTGroupShape)getXmlObject();
return _drawing;
}
+ @Override
public XSLFAutoShape createAutoShape(){
XSLFAutoShape sh = getDrawing().createAutoShape();
_shapes.add(sh);
return sh;
}
+ @Override
public XSLFFreeformShape createFreeform(){
XSLFFreeformShape sh = getDrawing().createFreeform();
_shapes.add(sh);
return sh;
}
+ @Override
public XSLFTextBox createTextBox(){
XSLFTextBox sh = getDrawing().createTextBox();
_shapes.add(sh);
return sh;
}
+ @Override
public XSLFConnectorShape createConnector(){
XSLFConnectorShape sh = getDrawing().createConnector();
_shapes.add(sh);
return sh;
}
+ @Override
public XSLFGroupShape createGroup(){
XSLFGroupShape sh = getDrawing().createGroup();
_shapes.add(sh);
return sh;
}
+ @Override
public XSLFPictureShape createPicture(PictureData pictureData){
if (!(pictureData instanceof XSLFPictureData)) {
throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
@Override
void copy(XSLFShape src){
XSLFGroupShape gr = (XSLFGroupShape)src;
-
- // clear shapes
- clear();
-
+
// recursively update each shape
- for(XSLFShape shape : gr.getShapes()) {
- XSLFShape newShape;
- if (shape instanceof XSLFTextBox) {
- newShape = createTextBox();
- } else if (shape instanceof XSLFAutoShape) {
- newShape = createAutoShape();
- } else if (shape instanceof XSLFConnectorShape) {
- newShape = createConnector();
- } else if (shape instanceof XSLFFreeformShape) {
- newShape = createFreeform();
- } else if (shape instanceof XSLFPictureShape) {
- XSLFPictureShape p = (XSLFPictureShape)shape;
- XSLFPictureData pd = p.getPictureData();
- XSLFPictureData pdNew = getSheet().getSlideShow().addPicture(pd.getData(), pd.getType());
- newShape = createPicture(pdNew);
- } else if (shape instanceof XSLFGroupShape) {
- newShape = createGroup();
- } else if (shape instanceof XSLFTable) {
- newShape = createTable();
- } else {
- _logger.log(POILogger.WARN, "copying of class "+shape.getClass()+" not supported.");
- continue;
+ List<XSLFShape> tgtShapes = getShapes();
+ List<XSLFShape> srcShapes = gr.getShapes();
+
+ // workaround for a call by XSLFSheet.importContent:
+ // if we have already the same amount of child shapes
+ // then assume, that we've been called by import content and only need to update the children
+ if (tgtShapes.size() == srcShapes.size()) {
+ for(int i = 0; i < tgtShapes.size(); i++){
+ XSLFShape s1 = srcShapes.get(i);
+ XSLFShape s2 = tgtShapes.get(i);
+
+ s2.copy(s1);
+ }
+ } else {
+ // otherwise recreate the shapes from scratch
+ clear();
+
+ // recursively update each shape
+ for(XSLFShape shape : srcShapes) {
+ XSLFShape newShape;
+ if (shape instanceof XSLFTextBox) {
+ newShape = createTextBox();
+ } else if (shape instanceof XSLFAutoShape) {
+ newShape = createAutoShape();
+ } else if (shape instanceof XSLFConnectorShape) {
+ newShape = createConnector();
+ } else if (shape instanceof XSLFFreeformShape) {
+ newShape = createFreeform();
+ } else if (shape instanceof XSLFPictureShape) {
+ XSLFPictureShape p = (XSLFPictureShape)shape;
+ XSLFPictureData pd = p.getPictureData();
+ XSLFPictureData pdNew = getSheet().getSlideShow().addPicture(pd.getData(), pd.getType());
+ newShape = createPicture(pdNew);
+ } else if (shape instanceof XSLFGroupShape) {
+ newShape = createGroup();
+ } else if (shape instanceof XSLFTable) {
+ newShape = createTable();
+ } else {
+ _logger.log(POILogger.WARN, "copying of class "+shape.getClass()+" not supported.");
+ continue;
+ }
+
+ newShape.copy(shape);
}
-
- newShape.copy(shape);
}
}
* Removes all of the elements from this container (optional operation).
* The container will be empty after this call returns.
*/
+ @Override
public void clear() {
List<XSLFShape> shapes = new ArrayList<XSLFShape>(getShapes());
for(XSLFShape shape : shapes){
}
}
+ @Override
public void addShape(XSLFShape shape) {
throw new UnsupportedOperationException(
"Adding a shape from a different container is not supported -"
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFAutoShape;
+import org.apache.poi.xslf.usermodel.XSLFGroupShape;
import org.apache.poi.xslf.usermodel.XSLFHyperlink;
import org.apache.poi.xslf.usermodel.XSLFPictureData;
import org.apache.poi.xslf.usermodel.XSLFPictureShape;
import org.apache.poi.xslf.usermodel.XSLFTextRun;
import org.junit.Ignore;
import org.junit.Test;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
public class TestXSLFBugs {
ppt.createSlide();
ppt.close();
}
+
+ @Test
+ public void bug60662() throws IOException {
+ XMLSlideShow src = new XMLSlideShow();
+ XSLFSlide sl = src.createSlide();
+ XSLFGroupShape gs = sl.createGroup();
+ gs.setAnchor(new Rectangle2D.Double(100,100,100,100));
+ gs.setInteriorAnchor(new Rectangle2D.Double(0,0,100,100));
+ XSLFAutoShape as = gs.createAutoShape();
+ as.setAnchor(new Rectangle2D.Double(0,0,100,100));
+ as.setShapeType(ShapeType.STAR_24);
+ as.setFillColor(Color.YELLOW);
+ CTShape csh = (CTShape)as.getXmlObject();
+ CTOuterShadowEffect shadow = csh.getSpPr().addNewEffectLst().addNewOuterShdw();
+ shadow.setDir(270000);
+ shadow.setDist(100000);
+ shadow.addNewSrgbClr().setVal(new byte[] {0x00, (byte)0xFF, 0x00});
+
+ XMLSlideShow dst = new XMLSlideShow();
+ XSLFSlide sl2 = dst.createSlide();
+ sl2.importContent(sl);
+ XSLFGroupShape gs2 = (XSLFGroupShape)sl2.getShapes().get(0);
+ XSLFAutoShape as2 = (XSLFAutoShape)gs2.getShapes().get(0);
+ CTShape csh2 = (CTShape)as2.getXmlObject();
+ assertTrue(csh2.getSpPr().isSetEffectLst());
+
+ dst.close();
+ src.close();
+ }
}
\ No newline at end of file