]> source.dussan.org Git - poi.git/commitdiff
already fixed 48065 - Problems with save output of HWPF (losing formatting)
authorSergey Vladimirov <sergey@apache.org>
Thu, 7 Jul 2011 13:13:04 +0000 (13:13 +0000)
committerSergey Vladimirov <sergey@apache.org>
Thu, 7 Jul 2011 13:13:04 +0000 (13:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143809 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
test-data/document/Bug48065.doc [new file with mode: 0644]

index 65068986266547bd6d254abbbd629c5e3ca7bb70..175ed9c17aad1d049f0aa3998649f9d74b0b7820 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta4" date="2011-??-??">
+           <action dev="poi-developers" type="fix">48065 - Problems with save output of HWPF (losing formatting)</action>
            <action dev="poi-developers" type="fix">47563 - Exception when working with table</action>
            <action dev="poi-developers" type="fix">47287 - StringIndexOutOfBoundsException in CharacterRun.replaceText()</action>
            <action dev="poi-developers" type="fix">46817 - Regression: Text from some table cells missing</action>
index f0664b3b03180fc200ad1710e5a343a104705248..38fba59fd711b697b37cc0d246341bd6dfd1f5d1 100644 (file)
@@ -691,6 +691,53 @@ public final class TestProblems extends HWPFTestCase {
         }
     }
 
+    /**
+     * [RESOLVED FIXED] Bug 48065 - Problems with save output of HWPF (losing
+     * formatting)
+     */
+    public void test48065()
+    {
+        HWPFDocument doc1 = HWPFTestDataSamples.openSampleFile( "Bug48065.doc" );
+        HWPFDocument doc2 = HWPFTestDataSamples.writeOutAndReadBack( doc1 );
+
+        Range expected = doc1.getRange();
+        Range actual = doc2.getRange();
+
+        assertEquals(
+                expected.text().replace( "\r", "\n" ).replaceAll( "\n\n", "\n" ),
+                actual.text().replace( "\r", "\n" ).replaceAll( "\n\n", "\n" ) );
+
+        assertEquals( expected.numParagraphs(), actual.numParagraphs() );
+        for ( int p = 0; p < expected.numParagraphs(); p++ )
+        {
+            Paragraph expParagraph = expected.getParagraph( p );
+            Paragraph actParagraph = actual.getParagraph( p );
+
+            assertEquals( expParagraph.text(), actParagraph.text() );
+            assertEquals( expParagraph.isInTable(), actParagraph.isInTable() );
+            assertEquals( expParagraph.isTableRowEnd(),
+                    actParagraph.isTableRowEnd() );
+
+            if ( expParagraph.isInTable() && actParagraph.isInTable() )
+            {
+                Table expTable, actTable;
+                try
+                {
+                    expTable = expected.getTable( expParagraph );
+                    actTable = actual.getTable( actParagraph );
+                }
+                catch ( Exception exc )
+                {
+                    continue;
+                }
+
+                assertEquals( expTable.numRows(), actTable.numRows() );
+                assertEquals( expTable.numParagraphs(),
+                        actTable.numParagraphs() );
+            }
+        }
+    }
+
     /**
      * Bug 50936  - HWPF fails to read a file
      */
diff --git a/test-data/document/Bug48065.doc b/test-data/document/Bug48065.doc
new file mode 100644 (file)
index 0000000..8dce3db
Binary files /dev/null and b/test-data/document/Bug48065.doc differ