// test append paragraph
TextDocument doc = TextDocument.newTextDocument();
Table table = Table.newTable(doc, 2, 2);
Cell cell = table.getCellByPosition(0, 0);
for (int i = 0; i < plainText.length; i++) {
Paragraph para = cell.addParagraph(plainText[i]);
compareResults(para.getOdfElement(), plainText[i], elementResult[i]);
}
// test set paragraph content
cell = table.getCellByPosition(0, 1);
for (int i = 0; i < plainText.length; i++) {
Paragraph para = cell.addParagraph(plainText[i]);
compareResults(para.getOdfElement(), plainText[i], elementResult[i]);
String content = para.getTextContent();
Assert.assertEquals(plainText[i], content);
}
// test remove paragraph content
cell = table.getCellByPosition(1, 0);
for (int i = 0; i < plainText.length; i++) {
Paragraph para = cell.addParagraph(plainText[i]);
String content = para.getTextContent();
Assert.assertEquals(plainText[i], content);
para.removeTextContent();
content = para.getTextContent();
Assert.assertEquals("", content);
}
// test get paragraph by index
cell = table.getCellByPosition(1, 1);
Paragraph paragraph1 = cell.addParagraph("paragraph1");
Paragraph paragraphE = cell.addParagraph(null);
Paragraph paragraph2 = cell.addParagraph("p2");
Paragraph t1 = cell.getParagraphByIndex(0, false);
Assert.assertEquals(t1, paragraph1);
t1 = cell.getParagraphByIndex(2, false);
Assert.assertEquals(t1, paragraph2);
t1 = cell.getParagraphByIndex(1, true);
Assert.assertEquals(t1, paragraph2);