diff options
author | Alain Béarez <abearez@apache.org> | 2020-03-27 03:13:37 +0000 |
---|---|---|
committer | Alain Béarez <abearez@apache.org> | 2020-03-27 03:13:37 +0000 |
commit | 4342180475bb36efb7b9b58ed7e3c62365cedd01 (patch) | |
tree | f3111c2d14d85ed7e3c7e3999e1c74e27e3d9c5e /src/ooxml/testcases/org/apache/poi/xwpf | |
parent | 6e6a638ca0c126564e40ab3ff5e4e7b0c6254fce (diff) | |
download | poi-4342180475bb36efb7b9b58ed7e3c62365cedd01.tar.gz poi-4342180475bb36efb7b9b58ed7e3c62365cedd01.zip |
XWPFTableCell does not process bodyElements when handle paragraph
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1875746 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/xwpf')
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java index 47076649f9..8b65434ec0 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTableCell.java @@ -151,6 +151,58 @@ public class TestXWPFTableCell { } @Test + public void testAddParagraph() throws Exception { + XWPFDocument doc = new XWPFDocument(); + XWPFTable table = doc.createTable(); + XWPFTableRow tr = table.createRow(); + XWPFTableCell cell = tr.addNewTableCell(); + + // cell have at least one paragraph by default + assertEquals(1, cell.getParagraphs().size()); + assertEquals(1, cell.getBodyElements().size()); + assertEquals(cell.getParagraphArray(0), cell.getBodyElements().get(0)); + + XWPFParagraph p = cell.addParagraph(); + assertEquals(2, cell.getParagraphs().size()); + assertEquals(2, cell.getBodyElements().size()); + assertEquals(p, cell.getParagraphArray(1)); + assertEquals(cell.getParagraphArray(1), cell.getBodyElements().get(1)); + + doc.close(); + } + + @Test + public void testRemoveParagraph() throws Exception { + XWPFDocument doc = new XWPFDocument(); + XWPFTable table = doc.createTable(); + XWPFTableRow tr = table.createRow(); + XWPFTableCell cell = tr.addNewTableCell(); + + // cell have at least one paragraph by default + XWPFParagraph p0 = cell.getParagraphArray(0); + XWPFParagraph p1 = cell.addParagraph(); + cell.addParagraph(); + + // remove 3rd + cell.removeParagraph(2); + assertEquals(2, cell.getParagraphs().size()); + assertEquals(2, cell.getBodyElements().size()); + assertEquals(p0, cell.getParagraphArray(0)); + assertEquals(p1, cell.getParagraphArray(1)); + assertEquals(p0, cell.getBodyElements().get(0)); + assertEquals(p1, cell.getBodyElements().get(1)); + + // remove 2nd + cell.removeParagraph(1); + assertEquals(1, cell.getParagraphs().size()); + assertEquals(1, cell.getBodyElements().size()); + assertEquals(p0, cell.getParagraphArray(0)); + assertEquals(p0, cell.getBodyElements().get(0)); + + doc.close(); + } + + @Test public void testBug63624() throws Exception { XWPFDocument doc = new XWPFDocument(); XWPFTable table = doc.createTable(1, 1); |