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;
}
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;
}
Aggregations