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
|
* 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) {
|
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.ctTc = cell;
|
||||||
this.part = part;
|
this.part = part;
|
||||||
this.tableRow = tableRow;
|
this.tableRow = tableRow;
|
||||||
this.xwpfDocument = part.getXWPFDocument();
|
this.xwpfDocument = part == null ? null : part.getXWPFDocument();
|
||||||
|
|
||||||
bodyElements = new ArrayList<>();
|
bodyElements = new ArrayList<>();
|
||||||
paragraphs = new ArrayList<>();
|
paragraphs = new ArrayList<>();
|
||||||
@ -530,9 +536,10 @@ public class XWPFTableCell implements IBody, ICell {
|
|||||||
return xwpfDocument;
|
return xwpfDocument;
|
||||||
} else if (part instanceof XWPFTableCell) {
|
} else if (part instanceof XWPFTableCell) {
|
||||||
return getCellDocument((XWPFTableCell) part, 0);
|
return getCellDocument((XWPFTableCell) part, 0);
|
||||||
} else {
|
} else if (part != null) {
|
||||||
return part.getXWPFDocument();
|
return part.getXWPFDocument();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int MAX_RECURSION_DEPTH = 1000;
|
private static final int MAX_RECURSION_DEPTH = 1000;
|
||||||
|
|||||||
@ -271,6 +271,7 @@ class TestXWPFTableCell {
|
|||||||
XWPFDocument doc = new XWPFDocument();
|
XWPFDocument doc = new XWPFDocument();
|
||||||
XWPFTable table = doc.createTable(1, 1);
|
XWPFTable table = doc.createTable(1, 1);
|
||||||
XWPFTableCell cell = table.getRow(0).getCell(0);
|
XWPFTableCell cell = table.getRow(0).getCell(0);
|
||||||
|
assertEquals(doc, cell.getXWPFDocument());
|
||||||
|
|
||||||
// cell have at least one paragraph by default when creating a cell
|
// cell have at least one paragraph by default when creating a cell
|
||||||
assertEquals(1, cell.getParagraphs().size());
|
assertEquals(1, cell.getParagraphs().size());
|
||||||
@ -282,6 +283,7 @@ class TestXWPFTableCell {
|
|||||||
XWPFDocument readDoc = XWPFTestDataSamples.writeOutAndReadBack(doc);
|
XWPFDocument readDoc = XWPFTestDataSamples.writeOutAndReadBack(doc);
|
||||||
XWPFTableCell readCell = readDoc.getTableArray(0).getRow(0).getCell(0);
|
XWPFTableCell readCell = readDoc.getTableArray(0).getRow(0).getCell(0);
|
||||||
assertEquals(0, readCell.getParagraphs().size());
|
assertEquals(0, readCell.getParagraphs().size());
|
||||||
|
assertEquals(readDoc, readCell.getXWPFDocument());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user