mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
add xwpf test
This commit is contained in:
parent
a3cca6c017
commit
fa573c72da
@ -79,10 +79,16 @@ public class XWPFTableCell implements IBody, ICell {
|
||||
* If a table cell does not include at least one block-level element, then this document shall be considered corrupt
|
||||
*/
|
||||
public XWPFTableCell(CTTc cell, XWPFTableRow tableRow, IBody part) {
|
||||
if (cell == null) {
|
||||
throw new IllegalArgumentException("CTTc cannot be null");
|
||||
}
|
||||
if (tableRow == null) {
|
||||
throw new IllegalArgumentException("tableRow cannot be null");
|
||||
}
|
||||
this.ctTc = cell;
|
||||
this.part = part;
|
||||
this.tableRow = tableRow;
|
||||
this.xwpfDocument = part.getXWPFDocument();
|
||||
this.xwpfDocument = part == null ? null : part.getXWPFDocument();
|
||||
|
||||
bodyElements = new ArrayList<>();
|
||||
paragraphs = new ArrayList<>();
|
||||
@ -530,9 +536,10 @@ public class XWPFTableCell implements IBody, ICell {
|
||||
return xwpfDocument;
|
||||
} else if (part instanceof XWPFTableCell) {
|
||||
return getCellDocument((XWPFTableCell) part, 0);
|
||||
} else {
|
||||
} else if (part != null) {
|
||||
return part.getXWPFDocument();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final int MAX_RECURSION_DEPTH = 1000;
|
||||
|
||||
@ -271,6 +271,7 @@ class TestXWPFTableCell {
|
||||
XWPFDocument doc = new XWPFDocument();
|
||||
XWPFTable table = doc.createTable(1, 1);
|
||||
XWPFTableCell cell = table.getRow(0).getCell(0);
|
||||
assertEquals(doc, cell.getXWPFDocument());
|
||||
|
||||
// cell have at least one paragraph by default when creating a cell
|
||||
assertEquals(1, cell.getParagraphs().size());
|
||||
@ -282,6 +283,7 @@ class TestXWPFTableCell {
|
||||
XWPFDocument readDoc = XWPFTestDataSamples.writeOutAndReadBack(doc);
|
||||
XWPFTableCell readCell = readDoc.getTableArray(0).getRow(0).getCell(0);
|
||||
assertEquals(0, readCell.getParagraphs().size());
|
||||
assertEquals(readDoc, readCell.getXWPFDocument());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user