<changes>
<release version="3.8-beta3" date="2011-??-??">
+ <action dev="poi-developers" type="fix">47147 - Correct extra paragraphs from XWPF Table Cells</action>
<action dev="poi-developers" type="add">51188 - Support for getting and setting XPWF zoom settings</action>
<action dev="poi-developers" type="add">51134 - Support for adding Numbering and Styles to a XWPF document that doesn't already have them</action>
<action dev="poi-developers" type="fix">51273 - Formula Value Cache fix for repeated evaluations</action>
package org.apache.poi.xwpf.usermodel;
import java.math.BigInteger;
+import java.util.List;
import junit.framework.TestCase;
+import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow;
assertEquals(20, row.getHeight());
}
+ public void testCreateTable() throws Exception {
+ // open an empty document
+ XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
+
+ // create a table with 5 rows and 7 coloumns
+ int noRows = 5;
+ int noCols = 7;
+ XWPFTable table = doc.createTable(noRows,noCols);
+
+ // assert the table is empty
+ List<XWPFTableRow> rows = table.getRows();
+ assertEquals("Table has less rows than requested.", noRows, rows.size());
+ for (XWPFTableRow xwpfRow : rows)
+ {
+ assertNotNull(xwpfRow);
+ for (int i = 0 ; i < 7 ; i++)
+ {
+ XWPFTableCell xwpfCell = xwpfRow.getCell(i);
+ assertNotNull(xwpfCell);
+ assertEquals("Empty cells should not have one paragraph.",1,xwpfCell.getParagraphs().size());
+ xwpfCell = xwpfRow.getCell(i);
+ assertEquals("Calling 'getCell' must not modify cells content.",1,xwpfCell.getParagraphs().size());
+ }
+ }
+ doc.getPackage().revert();
+ }
}
\ No newline at end of file