Search in sources :

Example 1 with CTSdtCell

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell in project poi by apache.

the class XWPFTableRow method getTableICells.

/**
     * create and return a list of all XWPFTableCell
     * who belongs to this row
     *
     * @return a list of {@link XWPFTableCell}
     */
public List<ICell> getTableICells() {
    List<ICell> cells = new ArrayList<ICell>();
    //Can't use ctRow.getTcList because that only gets table cells
    //Can't use ctRow.getSdtList because that only gets sdts that are at cell level
    XmlCursor cursor = ctRow.newCursor();
    cursor.selectPath("./*");
    while (cursor.toNextSelection()) {
        XmlObject o = cursor.getObject();
        if (o instanceof CTTc) {
            cells.add(new XWPFTableCell((CTTc) o, this, table.getBody()));
        } else if (o instanceof CTSdtCell) {
            cells.add(new XWPFSDTCell((CTSdtCell) o, this, table.getBody()));
        }
    }
    cursor.dispose();
    return cells;
}
Also used : ArrayList(java.util.ArrayList) XmlObject(org.apache.xmlbeans.XmlObject) CTSdtCell(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell) XmlCursor(org.apache.xmlbeans.XmlCursor) CTTc(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc)

Aggregations

ArrayList (java.util.ArrayList)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTSdtCell (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell)1 CTTc (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc)1