Search in sources :

Example 1 with CTOfficeArtExtension

use of org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension in project poi by apache.

the class XSSFObjectData method prototype.

/**
     * Prototype with the default structure of a new auto-shape.
     */
/**
     * Prototype with the default structure of a new auto-shape.
     */
protected static CTShape prototype() {
    final String drawNS = "http://schemas.microsoft.com/office/drawing/2010/main";
    if (prototype == null) {
        CTShape shape = CTShape.Factory.newInstance();
        CTShapeNonVisual nv = shape.addNewNvSpPr();
        CTNonVisualDrawingProps nvp = nv.addNewCNvPr();
        nvp.setId(1);
        nvp.setName("Shape 1");
        //            nvp.setHidden(true);
        CTOfficeArtExtensionList extLst = nvp.addNewExtLst();
        // https://msdn.microsoft.com/en-us/library/dd911027(v=office.12).aspx
        CTOfficeArtExtension ext = extLst.addNewExt();
        ext.setUri("{63B3BB69-23CF-44E3-9099-C40C66FF867C}");
        XmlCursor cur = ext.newCursor();
        cur.toEndToken();
        cur.beginElement(new QName(drawNS, "compatExt", "a14"));
        cur.insertNamespace("a14", drawNS);
        cur.insertAttributeWithValue("spid", "_x0000_s1");
        cur.dispose();
        nv.addNewCNvSpPr();
        CTShapeProperties sp = shape.addNewSpPr();
        CTTransform2D t2d = sp.addNewXfrm();
        CTPositiveSize2D p1 = t2d.addNewExt();
        p1.setCx(0);
        p1.setCy(0);
        CTPoint2D p2 = t2d.addNewOff();
        p2.setX(0);
        p2.setY(0);
        CTPresetGeometry2D geom = sp.addNewPrstGeom();
        geom.setPrst(STShapeType.RECT);
        geom.addNewAvLst();
        prototype = shape;
    }
    return prototype;
}
Also used : CTTransform2D(org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D) CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) QName(javax.xml.namespace.QName) CTShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape) XmlCursor(org.apache.xmlbeans.XmlCursor) CTPoint2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D) CTShapeNonVisual(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual) CTPresetGeometry2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D) CTNonVisualDrawingProps(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps) CTOfficeArtExtension(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension) CTPositiveSize2D(org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D) CTOfficeArtExtensionList(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList)

Example 2 with CTOfficeArtExtension

use of org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension in project poi by apache.

the class XSLFPictureShape method copy.

@Override
void copy(XSLFShape sh) {
    super.copy(sh);
    XSLFPictureShape p = (XSLFPictureShape) sh;
    String blipId = p.getBlipId();
    String relId = getSheet().importBlip(blipId, p.getSheet().getPackagePart());
    CTPicture ct = (CTPicture) getXmlObject();
    CTBlip blip = getBlipFill().getBlip();
    blip.setEmbed(relId);
    CTApplicationNonVisualDrawingProps nvPr = ct.getNvPicPr().getNvPr();
    if (nvPr.isSetCustDataLst()) {
        // discard any custom tags associated with the picture being copied
        nvPr.unsetCustDataLst();
    }
    if (blip.isSetExtLst()) {
        CTOfficeArtExtensionList extLst = blip.getExtLst();
        for (CTOfficeArtExtension ext : extLst.getExtArray()) {
            String xpath = "declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' $this//a14:imgProps/a14:imgLayer";
            XmlObject[] obj = ext.selectPath(xpath);
            if (obj != null && obj.length == 1) {
                XmlCursor c = obj[0].newCursor();
                //selectPath("declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' $this//[@embed]");
                String id = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"));
                String newId = getSheet().importBlip(id, p.getSheet().getPackagePart());
                c.setAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed"), newId);
                c.dispose();
            }
        }
    }
}
Also used : CTBlip(org.openxmlformats.schemas.drawingml.x2006.main.CTBlip) QName(javax.xml.namespace.QName) CTPicture(org.openxmlformats.schemas.presentationml.x2006.main.CTPicture) CTApplicationNonVisualDrawingProps(org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps) CTOfficeArtExtension(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension) XmlObject(org.apache.xmlbeans.XmlObject) CTOfficeArtExtensionList(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList) XmlCursor(org.apache.xmlbeans.XmlCursor)

Aggregations

QName (javax.xml.namespace.QName)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 CTOfficeArtExtension (org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension)2 CTOfficeArtExtensionList (org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList)2 XmlObject (org.apache.xmlbeans.XmlObject)1 CTBlip (org.openxmlformats.schemas.drawingml.x2006.main.CTBlip)1 CTNonVisualDrawingProps (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps)1 CTPoint2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D)1 CTPositiveSize2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D)1 CTPresetGeometry2D (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D)1 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)1 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)1 CTShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)1 CTShapeNonVisual (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual)1 CTApplicationNonVisualDrawingProps (org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps)1 CTPicture (org.openxmlformats.schemas.presentationml.x2006.main.CTPicture)1