Fix bug #47147 - XWPF table cells adding extra paragraph - test from Stefan Stern
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1128331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a3206374e5
commit
481a325c45
@ -34,6 +34,7 @@
|
||||
|
||||
<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>
|
||||
|
@ -51,7 +51,6 @@ public class XWPFTable implements IBodyElement{
|
||||
this(table, part);
|
||||
for (int i = 0; i < row; i++) {
|
||||
XWPFTableRow tabRow = (getRow(i) == null) ? createRow() : getRow(i);
|
||||
tableRows.add(tabRow);
|
||||
for (int k = 0; k < col; k++) {
|
||||
XWPFTableCell tabCell = (tabRow.getCell(k) == null) ? tabRow
|
||||
.createCell() : null;
|
||||
|
@ -17,9 +17,11 @@
|
||||
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;
|
||||
@ -130,4 +132,30 @@ public class TestXWPFTable extends TestCase {
|
||||
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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user