return Collections.unmodifiableList(bodyElements);
}
+ public Iterator<IBodyElement> getBodyElementsIterator() {
+ return bodyElements.iterator();
+ }
+
/**
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs()
*/
}
/**
- * Look up the paragraph at the specified position in the body elemnts list
+ * Look up the paragraph at the specified position in the body elements list
* and return this paragraphs position in the paragraphs list
*
* @param pos
cursor.toParent();
CTTbl t = (CTTbl) cursor.getObject();
XWPFTable newT = new XWPFTable(t, this);
- cursor.removeXmlContents();
XmlObject o = null;
while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) {
o = cursor.getObject();
tables.add(pos, newT);
}
int i = 0;
- cursor = t.newCursor();
+ XmlCursor tableCursor = t.newCursor();
+ try {
+ cursor.toCursor(tableCursor);
while (cursor.toPrevSibling()) {
o = cursor.getObject();
if (o instanceof CTP || o instanceof CTTbl)
i++;
}
bodyElements.add(i, newT);
- cursor = t.newCursor();
+ cursor.toCursor(tableCursor);
cursor.toEndToken();
return newT;
+ }
+ finally {
+ tableCursor.dispose();
+ }
}
return null;
}
return null;
}
XWPFTableRow tableRow = table.getRow(row);
- if(row == null){
+ if (tableRow == null) {
return null;
}
return tableRow.getTableCell(cell);