]> source.dussan.org Git - poi.git/commitdiff
Correctly handle the last paragraph via a fix to TableCell - patch from bug #44292
authorNick Burch <nick@apache.org>
Fri, 25 Jan 2008 11:52:39 +0000 (11:52 +0000)
committerNick Burch <nick@apache.org>
Fri, 25 Jan 2008 11:52:39 +0000 (11:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@615190 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java
src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44292.doc [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java

index 51aeb22461679d232a938b021a28d59ad1c724cb..f11d64ad267e9b486de47cac5041370a431ca4da 100644 (file)
@@ -36,6 +36,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.0.2-FINAL" date="2008-??-??">
+            <action dev="POI-DEVELOPERS" type="fix">44292 - Correctly process the last paragraph in a word file</action>
             <action dev="POI-DEVELOPERS" type="fix">44254 - Avoid some unread byte warnings, and properly understand DVALRecord</action>
             <action dev="POI-DEVELOPERS" type="add">Add another formula evaluation method, evaluateFormulaCell(cell), which will re-calculate the value for a formula, without affecting the formula itself.</action>
             <action dev="POI-DEVELOPERS" type="fix">41726 - Fix how we handle signed cell offsets in relative areas and references</action>
index feabdf76b40b9917fd6a8f0ebb4ed7a973c303d8..73375a336e93964fe414ecbc4ad3f2c213a50743 100644 (file)
@@ -33,6 +33,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.0.2-FINAL" date="2008-??-??">
+            <action dev="POI-DEVELOPERS" type="fix">44292 - Correctly process the last paragraph in a word file</action>
             <action dev="POI-DEVELOPERS" type="fix">44254 - Avoid some unread byte warnings, and properly understand DVALRecord</action>
             <action dev="POI-DEVELOPERS" type="add">Add another formula evaluation method, evaluateFormulaCell(cell), which will re-calculate the value for a formula, without affecting the formula itself.</action>
             <action dev="POI-DEVELOPERS" type="fix">41726 - Fix how we handle signed cell offsets in relative areas and references</action>
index ff9cf2b9c834cc7960ccccca63ac79fc8ad44d9b..a88e32360ee433114c6a2ad79c357102f22edba8 100644 (file)
@@ -58,7 +58,7 @@ public class TableRow
         p = getParagraph(end);
         s = p.text();
       }
-      _cells[cellIndex] = new TableCell(start, end, this, levelNum,
+      _cells[cellIndex] = new TableCell(start, end+1, this, levelNum,
                                         _tprops.getRgtc()[cellIndex],
                                         _tprops.getRgdxaCenter()[cellIndex],
                                         _tprops.getRgdxaCenter()[cellIndex+1]-_tprops.getRgdxaCenter()[cellIndex]);
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44292.doc b/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44292.doc
new file mode 100644 (file)
index 0000000..fd7ca6c
Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44292.doc differ
index 8e7f47ed96cb3e0652386b69ebf0f6bc094430a0..e82c4d13045f98f4277d6065a90fd59d807e087f 100644 (file)
@@ -74,4 +74,34 @@ public class TestProblems extends TestCase {
                }
        }
        }
+
+       /**
+        * Test for TableCell not skipping the last paragraph
+        */
+       public void testTableCellLastParagraph() throws Exception {
+       HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/Bug44292.doc"));
+               Range r = doc.getRange();
+                       
+               //get the table
+               Paragraph p = r.getParagraph(0);
+               Table t = r.getTable(p);
+               
+               //get the only row
+               TableRow row = t.getRow(0);
+               
+               //get the first cell
+               TableCell cell = row.getCell(0);
+               // First cell should have one paragraph
+               assertEquals(1, cell.numParagraphs());
+               
+               //get the second
+               cell = row.getCell(1);
+               // Second cell should be detected as having two paragraphs
+               assertEquals(2, cell.numParagraphs());
+                               
+               //get the last cell
+               cell = row.getCell(2);
+               // Last cell should have one paragraph
+               assertEquals(1, cell.numParagraphs());
+       }
 }