use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc in project poi by apache.
the class XWPFFootnote method getTableCell.
/**
* get the TableCell which belongs to the TableCell
*
* @param cell
* @see org.apache.poi.xwpf.usermodel.IBody#getTableCell(CTTc cell)
*/
public XWPFTableCell getTableCell(CTTc cell) {
XmlCursor cursor = cell.newCursor();
cursor.toParent();
XmlObject o = cursor.getObject();
if (!(o instanceof CTRow)) {
return null;
}
CTRow row = (CTRow) o;
cursor.toParent();
o = cursor.getObject();
cursor.dispose();
if (!(o instanceof CTTbl)) {
return null;
}
CTTbl tbl = (CTTbl) o;
XWPFTable table = getTable(tbl);
if (table == null) {
return null;
}
XWPFTableRow tableRow = table.getRow(row);
if (tableRow == null) {
return null;
}
return tableRow.getTableCell(cell);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc in project poi by apache.
the class XWPFHeaderFooter method getTableCell.
/**
* get the TableCell which belongs to the TableCell
*
* @param cell
*/
public XWPFTableCell getTableCell(CTTc cell) {
XmlCursor cursor = cell.newCursor();
cursor.toParent();
XmlObject o = cursor.getObject();
if (!(o instanceof CTRow)) {
cursor.dispose();
return null;
}
CTRow row = (CTRow) o;
cursor.toParent();
o = cursor.getObject();
cursor.dispose();
if (!(o instanceof CTTbl)) {
return null;
}
CTTbl tbl = (CTTbl) o;
XWPFTable table = getTable(tbl);
if (table == null) {
return null;
}
XWPFTableRow tableRow = table.getRow(row);
return tableRow.getTableCell(cell);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc in project poi by apache.
the class XWPFTableRow method addNewTableCell.
/**
* adds a new TableCell at the end of this tableRow
*/
public XWPFTableCell addNewTableCell() {
CTTc cell = ctRow.addNewTc();
XWPFTableCell tableCell = new XWPFTableCell(cell, this, table.getBody());
tableCells.add(tableCell);
return tableCell;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc in project poi by apache.
the class XWPFTableRow method getTableCells.
/**
* create and return a list of all XWPFTableCell
* who belongs to this row
*
* @return a list of {@link XWPFTableCell}
*/
public List<XWPFTableCell> getTableCells() {
if (tableCells == null) {
List<XWPFTableCell> cells = new ArrayList<XWPFTableCell>();
for (CTTc tableCell : ctRow.getTcArray()) {
cells.add(new XWPFTableCell(tableCell, this, table.getBody()));
}
//TODO: it is possible to have an SDT that contains a cell in within a row
//need to modify this code so that it pulls out SDT wrappers around cells, too.
this.tableCells = cells;
}
return tableCells;
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc in project poi by apache.
the class XWPFTableCell method getTableCell.
/**
* get the TableCell which belongs to the TableCell
*/
public XWPFTableCell getTableCell(CTTc cell) {
XmlCursor cursor = cell.newCursor();
cursor.toParent();
XmlObject o = cursor.getObject();
if (!(o instanceof CTRow)) {
return null;
}
CTRow row = (CTRow) o;
cursor.toParent();
o = cursor.getObject();
cursor.dispose();
if (!(o instanceof CTTbl)) {
return null;
}
CTTbl tbl = (CTTbl) o;
XWPFTable table = getTable(tbl);
if (table == null) {
return null;
}
XWPFTableRow tr = table.getRow(row);
if (tr == null) {
return null;
}
return tr.getTableCell(cell);
}
Aggregations