<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>
}
}
+ /**
+ * [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
*/