You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2011/05/27 16:48:22 UTC

svn commit: r1128331 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java

Author: nick
Date: Fri May 27 14:48:22 2011
New Revision: 1128331

URL: http://svn.apache.org/viewvc?rev=1128331&view=rev
Log:
Fix bug #47147 - XWPF table cells adding extra paragraph - test from Stefan Stern

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1128331&r1=1128330&r2=1128331&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri May 27 14:48:22 2011
@@ -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>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java?rev=1128331&r1=1128330&r2=1128331&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java Fri May 27 14:48:22 2011
@@ -51,7 +51,6 @@ public class XWPFTable implements IBodyE
         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;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java?rev=1128331&r1=1128330&r2=1128331&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFTable.java Fri May 27 14:48:22 2011
@@ -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 TestC
         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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org