private XSLFDrawing getDrawing(){ if(_drawing == null) { _drawing = new XSLFDrawing(getSheet(), (CTGroupShape)getXmlObject()); } return _drawing; }
/** * Remove the specified shape from this group */ @Override public boolean removeShape(XSLFShape xShape) { XmlObject obj = xShape.getXmlObject(); CTGroupShape grpSp = (CTGroupShape)getXmlObject(); getSheet().deregisterShapeId(xShape.getShapeId()); if(obj instanceof CTShape){ grpSp.getSpList().remove(obj); } else if (obj instanceof CTGroupShape){ XSLFGroupShape gs = (XSLFGroupShape)xShape; new ArrayList<>(gs.getShapes()).forEach(gs::removeShape); grpSp.getGrpSpList().remove(obj); } else if (obj instanceof CTConnector){ grpSp.getCxnSpList().remove(obj); } else if (obj instanceof CTGraphicalObjectFrame) { grpSp.getGraphicFrameList().remove(obj); } else if (obj instanceof CTPicture) { XSLFPictureShape ps = (XSLFPictureShape)xShape; XSLFSheet sh = getSheet(); if (sh != null) { sh.removePictureRelation(ps); } grpSp.getPicList().remove(obj); } else { throw new IllegalArgumentException("Unsupported shape: " + xShape); } return _shapes.remove(xShape); }
@Override public XSLFPictureShape createPicture(PictureData pictureData){ if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); _shapes.add(sh); sh.setParent(this); return sh; }
@Override public XSLFObjectShape createOleShape(PictureData pictureData) { if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFObjectShape sh = getDrawing().createOleShape(rp.getRelationship().getId()); CTOleObject oleObj = sh.getCTOleObject(); Dimension dim = pictureData.getImageDimension(); oleObj.setImgW(Units.toEMU(dim.getWidth())); oleObj.setImgH(Units.toEMU(dim.getHeight())); getShapes().add(sh); sh.setParent(this); return sh; }
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) {
private XSLFDrawing getDrawing(){ if(_drawing == null) { _drawing = new XSLFDrawing(getSheet(), (CTGroupShape)getXmlObject()); } return _drawing; }
/** * Remove the specified shape from this group */ @Override public boolean removeShape(XSLFShape xShape) { XmlObject obj = xShape.getXmlObject(); CTGroupShape grpSp = (CTGroupShape)getXmlObject(); getSheet().deregisterShapeId(xShape.getShapeId()); if(obj instanceof CTShape){ grpSp.getSpList().remove(obj); } else if (obj instanceof CTGroupShape){ XSLFGroupShape gs = (XSLFGroupShape)xShape; new ArrayList<>(gs.getShapes()).forEach(gs::removeShape); grpSp.getGrpSpList().remove(obj); } else if (obj instanceof CTConnector){ grpSp.getCxnSpList().remove(obj); } else if (obj instanceof CTGraphicalObjectFrame) { grpSp.getGraphicFrameList().remove(obj); } else if (obj instanceof CTPicture) { XSLFPictureShape ps = (XSLFPictureShape)xShape; XSLFSheet sh = getSheet(); if (sh != null) { sh.removePictureRelation(ps); } grpSp.getPicList().remove(obj); } else { throw new IllegalArgumentException("Unsupported shape: " + xShape); } return _shapes.remove(xShape); }
@Override public XSLFPictureShape createPicture(PictureData pictureData){ if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId()); new DrawPictureShape(sh).resize(); _shapes.add(sh); sh.setParent(this); return sh; }
@Override public XSLFObjectShape createOleShape(PictureData pictureData) { if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = getSheet().addRelation(null, XSLFRelation.IMAGES, (XSLFPictureData)pictureData); XSLFObjectShape sh = getDrawing().createOleShape(rp.getRelationship().getId()); CTOleObject oleObj = sh.getCTOleObject(); Dimension dim = pictureData.getImageDimension(); oleObj.setImgW(Units.toEMU(dim.getWidth())); oleObj.setImgH(Units.toEMU(dim.getHeight())); getShapes().add(sh); sh.setParent(this); return sh; }
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) {