Search in sources :

Example 1 with CTOneCellAnchor

use of org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTOneCellAnchor in project poi by apache.

the class XSSFDrawing method getAnchorFromParent.

private XSSFAnchor getAnchorFromParent(XmlObject obj) {
    XSSFAnchor anchor = null;
    XmlObject parentXbean = null;
    XmlCursor cursor = obj.newCursor();
    if (cursor.toParent()) {
        parentXbean = cursor.getObject();
    }
    cursor.dispose();
    if (parentXbean != null) {
        if (parentXbean instanceof CTTwoCellAnchor) {
            CTTwoCellAnchor ct = (CTTwoCellAnchor) parentXbean;
            anchor = new XSSFClientAnchor(ct.getFrom(), ct.getTo());
        } else if (parentXbean instanceof CTOneCellAnchor) {
            CTOneCellAnchor ct = (CTOneCellAnchor) parentXbean;
            anchor = new XSSFClientAnchor(ct.getFrom(), CTMarker.Factory.newInstance());
        }
    }
    return anchor;
}
Also used : XmlObject(org.apache.xmlbeans.XmlObject) CTTwoCellAnchor(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor) CTOneCellAnchor(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTOneCellAnchor) XmlCursor(org.apache.xmlbeans.XmlCursor)

Aggregations

XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTOneCellAnchor (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTOneCellAnchor)1 CTTwoCellAnchor (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTTwoCellAnchor)1