Search in sources :

Example 1 with DrawPictureShape

use of org.apache.poi.sl.draw.DrawPictureShape in project poi by apache.

the class XSLFGroupShape method createPicture.

@Override
public XSLFPictureShape createPicture(PictureData pictureData) {
    if (!(pictureData instanceof XSLFPictureData)) {
        throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
    }
    XSLFPictureData xPictureData = (XSLFPictureData) pictureData;
    PackagePart pic = xPictureData.getPackagePart();
    PackageRelationship rel = getSheet().getPackagePart().addRelationship(pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());
    XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
    new DrawPictureShape(sh).resize();
    _shapes.add(sh);
    sh.setParent(this);
    return sh;
}
Also used : PackageRelationship(org.apache.poi.openxml4j.opc.PackageRelationship) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) DrawPictureShape(org.apache.poi.sl.draw.DrawPictureShape)

Example 2 with DrawPictureShape

use of org.apache.poi.sl.draw.DrawPictureShape in project poi by apache.

the class HSLFPictureShape method afterInsert.

/**
     * By default set the orininal image size
     */
@Override
protected void afterInsert(HSLFSheet sh) {
    super.afterInsert(sh);
    EscherBSERecord bse = getEscherBSERecord();
    bse.setRef(bse.getRef() + 1);
    Rectangle2D anchor = getAnchor();
    if (anchor.isEmpty()) {
        new DrawPictureShape(this).resize();
    }
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) DrawPictureShape(org.apache.poi.sl.draw.DrawPictureShape) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 3 with DrawPictureShape

use of org.apache.poi.sl.draw.DrawPictureShape in project poi by apache.

the class XSLFSheet method createPicture.

@Override
public XSLFPictureShape createPicture(PictureData pictureData) {
    if (!(pictureData instanceof XSLFPictureData)) {
        throw new IllegalArgumentException("pictureData needs to be of type XSLFPictureData");
    }
    XSLFPictureData xPictureData = (XSLFPictureData) pictureData;
    PackagePart pic = xPictureData.getPackagePart();
    RelationPart rp = addRelation(null, XSLFRelation.IMAGES, new XSLFPictureData(pic));
    XSLFPictureShape sh = getDrawing().createPicture(rp.getRelationship().getId());
    new DrawPictureShape(sh).resize();
    getShapes().add(sh);
    sh.setParent(this);
    return sh;
}
Also used : PackagePart(org.apache.poi.openxml4j.opc.PackagePart) DrawPictureShape(org.apache.poi.sl.draw.DrawPictureShape)

Aggregations

DrawPictureShape (org.apache.poi.sl.draw.DrawPictureShape)3 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)2 Rectangle2D (java.awt.geom.Rectangle2D)1 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)1 PackageRelationship (org.apache.poi.openxml4j.opc.PackageRelationship)1