Search in sources :

Example 1 with PresetGeometries

use of org.apache.poi.sl.draw.geom.PresetGeometries in project poi by apache.

the class HSLFSimpleShape method getGeometry.

@Override
public CustomGeometry getGeometry() {
    PresetGeometries dict = PresetGeometries.getInstance();
    ShapeType st = getShapeType();
    String name = (st != null) ? st.getOoxmlName() : null;
    CustomGeometry geom = dict.get(name);
    if (geom == null) {
        if (name == null) {
            name = (st != null) ? st.toString() : "<unknown>";
        }
        LOG.log(POILogger.WARN, "No preset shape definition for shapeType: " + name);
    }
    return geom;
}
Also used : ShapeType(org.apache.poi.sl.usermodel.ShapeType) PresetGeometries(org.apache.poi.sl.draw.geom.PresetGeometries) CustomGeometry(org.apache.poi.sl.draw.geom.CustomGeometry)

Example 2 with PresetGeometries

use of org.apache.poi.sl.draw.geom.PresetGeometries in project poi by apache.

the class XSLFSimpleShape method getGeometry.

/**
     *
     * @return definition of the shape geometry
     */
@Override
public CustomGeometry getGeometry() {
    XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());
    if (gp == null) {
        return null;
    }
    CustomGeometry geom;
    PresetGeometries dict = PresetGeometries.getInstance();
    if (gp.isSetPrstGeom()) {
        String name = gp.getPrstGeom().getPrst().toString();
        geom = dict.get(name);
        if (geom == null) {
            throw new IllegalStateException("Unknown shape geometry: " + name + ", available geometries are: " + dict.keySet());
        }
    } else if (gp.isSetCustGeom()) {
        XMLStreamReader staxReader = gp.getCustGeom().newXMLStreamReader();
        geom = PresetGeometries.convertCustomGeometry(staxReader);
        try {
            staxReader.close();
        } catch (XMLStreamException e) {
            LOG.log(POILogger.WARN, "An error occurred while closing a Custom Geometry XML Stream Reader: " + e.getMessage());
        }
    } else {
        geom = dict.get("rect");
    }
    return geom;
}
Also used : XSLFGeometryProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFGeometryProperties) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) PresetGeometries(org.apache.poi.sl.draw.geom.PresetGeometries) CustomGeometry(org.apache.poi.sl.draw.geom.CustomGeometry)

Aggregations

CustomGeometry (org.apache.poi.sl.draw.geom.CustomGeometry)2 PresetGeometries (org.apache.poi.sl.draw.geom.PresetGeometries)2 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 ShapeType (org.apache.poi.sl.usermodel.ShapeType)1 XSLFGeometryProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFGeometryProperties)1