public XSLFObjectShape createOleShape(String pictureRel) { CTGraphicalObjectFrame sp = _spTree.addNewGraphicFrame(); sp.set(XSLFObjectShape.prototype(_sheet.allocateShapeId(), pictureRel)); XSLFObjectShape shape = new XSLFObjectShape(sp, _sheet); shape.setAnchor(new Rectangle2D.Double()); return shape; } }
protected String getBlipId(){ String id = getBlip().getEmbed(); if (id.isEmpty()) { return null; } return id; }
protected CTBlip getBlip(){ return getBlipFill().getBlip(); }
@Override public XSLFObjectData getObjectData() { String oleRel = getCTOleObject().getId(); return getSheet().getRelationPartById(oleRel).getDocumentPart(); }
/** * Return the data on the (internal) picture. * For an external linked picture, will return null */ @Override public XSLFPictureData getPictureData() { if(_data == null){ String blipId = getBlipId(); if (blipId == null) { return null; } PackagePart p = getSheet().getPackagePart(); PackageRelationship rel = p.getRelationship(blipId); if (rel != null) { try { PackagePart imgPart = p.getRelatedPart(rel); _data = new XSLFPictureData(imgPart); } catch (Exception e) { throw new POIXMLException(e); } } } return _data; }
@Override public XSLFObjectShape createOleShape(PictureData pictureData) { if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = 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; }
static XSLFGraphicFrame create(CTGraphicalObjectFrame shape, XSLFSheet sheet){ final String uri = getUri(shape); switch (uri == null ? "" : uri) { case XSLFTable.TABLE_URI: return new XSLFTable(shape, sheet); case XSLFObjectShape.OLE_URI: return new XSLFObjectShape(shape, sheet); default: return new XSLFGraphicFrame(shape, sheet); } }
protected CTBlipFillProperties getBlipFill() { String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' " + ".//p:blipFill" ; XmlObject xo = selectProperty(XmlObject.class, xquery); try { xo = CTPicture.Factory.parse(xo.getDomNode()); } catch (XmlException xe) { return null; } return ((CTPicture)xo).getBlipFill(); }
@Override public OutputStream updateObjectData(final Application application, final ObjectMetaData metaData) throws IOException { final ObjectMetaData md = (application != null) ? application.getMetaData() : metaData; if (md == null || md.getClassID() == null) { throw new IllegalArgumentException("either application and/or metaData needs to be set."); } final XSLFSheet sheet = getSheet(); final RelationPart rp; if (_oleObject.isSetId()) { // object data was already set rp = sheet.getRelationPartById(_oleObject.getId()); } else { // object data needs to be initialized try { final XSLFRelation descriptor = XSLFRelation.OLE_OBJECT; final OPCPackage pack = sheet.getPackagePart().getPackage(); int nextIdx = pack.getUnusedPartIndex(descriptor.getDefaultFileName()); rp = sheet.createRelationship(descriptor, XSLFFactory.getInstance(), nextIdx, false); _oleObject.setId(rp.getRelationship().getId()); } catch (InvalidFormatException e) { throw new IOException("Unable to add new ole embedding", e); } // setting spid only works with a vml drawing object // oleObj.setSpid("_x0000_s"+(1025+objectIdx)); } _oleObject.setProgId(md.getProgId()); _oleObject.setName(md.getObjectName()); return new XSLFObjectOutputStream(rp.getDocumentPart().getPackagePart(),md); }
@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; }
@Override public XSLFObjectData getObjectData() { String oleRel = getCTOleObject().getId(); return getSheet().getRelationPartById(oleRel).getDocumentPart(); }
/** * Return the data on the (internal) picture. * For an external linked picture, will return null */ @Override public XSLFPictureData getPictureData() { if(_data == null){ String blipId = getBlipId(); if (blipId == null) { return null; } PackagePart p = getSheet().getPackagePart(); PackageRelationship rel = p.getRelationship(blipId); if (rel != null) { try { PackagePart imgPart = p.getRelatedPart(rel); _data = new XSLFPictureData(imgPart); } catch (Exception e) { throw new POIXMLException(e); } } } return _data; }
static XSLFGraphicFrame create(CTGraphicalObjectFrame shape, XSLFSheet sheet){ final String uri = getUri(shape); switch (uri == null ? "" : uri) { case XSLFTable.TABLE_URI: return new XSLFTable(shape, sheet); case XSLFObjectShape.OLE_URI: return new XSLFObjectShape(shape, sheet); default: return new XSLFGraphicFrame(shape, sheet); } }
protected CTBlipFillProperties getBlipFill() { String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' " + ".//p:blipFill" ; XmlObject xo = selectProperty(XmlObject.class, xquery); try { xo = CTPicture.Factory.parse(xo.getDomNode()); } catch (XmlException xe) { return null; } return ((CTPicture)xo).getBlipFill(); }
@Override public OutputStream updateObjectData(final Application application, final ObjectMetaData metaData) throws IOException { final ObjectMetaData md = (application != null) ? application.getMetaData() : metaData; if (md == null || md.getClassID() == null) { throw new IllegalArgumentException("either application and/or metaData needs to be set."); } final XSLFSheet sheet = getSheet(); final RelationPart rp; if (_oleObject.isSetId()) { // object data was already set rp = sheet.getRelationPartById(_oleObject.getId()); } else { // object data needs to be initialized try { final XSLFRelation descriptor = XSLFRelation.OLE_OBJECT; final OPCPackage pack = sheet.getPackagePart().getPackage(); int nextIdx = pack.getUnusedPartIndex(descriptor.getDefaultFileName()); rp = sheet.createRelationship(descriptor, XSLFFactory.getInstance(), nextIdx, false); _oleObject.setId(rp.getRelationship().getId()); } catch (InvalidFormatException e) { throw new IOException("Unable to add new ole embedding", e); } // setting spid only works with a vml drawing object // oleObj.setSpid("_x0000_s"+(1025+objectIdx)); } _oleObject.setProgId(md.getProgId()); _oleObject.setName(md.getObjectName()); return new XSLFObjectOutputStream(rp.getDocumentPart().getPackagePart(),md); }
public XSLFObjectShape createOleShape(String pictureRel) { CTGraphicalObjectFrame sp = _spTree.addNewGraphicFrame(); sp.set(XSLFObjectShape.prototype(_sheet.allocateShapeId(), pictureRel)); XSLFObjectShape shape = new XSLFObjectShape(sp, _sheet); shape.setAnchor(new Rectangle2D.Double()); return shape; } }
@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; }
protected String getBlipId(){ String id = getBlip().getEmbed(); if (id.isEmpty()) { return null; } return id; }
protected CTBlip getBlip(){ return getBlipFill().getBlip(); }
@Override public XSLFObjectShape createOleShape(PictureData pictureData) { if (!(pictureData instanceof XSLFPictureData)) { throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData"); } RelationPart rp = 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; }