From 03ea58049c660daa9fb8fc36849a10afb46e529a Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Thu, 7 Jul 2011 13:13:04 +0000 Subject: [PATCH] already fixed 48065 - Problems with save output of HWPF (losing formatting) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143809 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../poi/hwpf/usermodel/TestProblems.java | 47 ++++++++++++++++++ test-data/document/Bug48065.doc | Bin 0 -> 28160 bytes 3 files changed, 48 insertions(+) create mode 100644 test-data/document/Bug48065.doc diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 6506898626..175ed9c17a 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 48065 - Problems with save output of HWPF (losing formatting) 47563 - Exception when working with table 47287 - StringIndexOutOfBoundsException in CharacterRun.replaceText() 46817 - Regression: Text from some table cells missing diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java index f0664b3b03..38fba59fd7 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java @@ -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 index 0000000000000000000000000000000000000000..8dce3dbdfb75810edf05cae074ef49eb1d0499ba GIT binary patch literal 28160 zcmeHQ3p|v|`=4FAtXm``R2wSEosg4IDv}84rpscnT1!Z&lrFmH*Du|4b4t=ZaZc%` zn-sc9H&o}8bT3M$BB!*!=h^j28z=QU|Ih!N-`T0}`^-Eu&oeX6%=^AG^Um0k%k3++ z{G@%4NVxt)hI|yt6WL~b8u%@#uqq+e;78s^p-_ly3jlbf?r&s)s%?2hCP9-$NR8S_ zY(zq!Wx)Z*3DAxNgaw2>FM3`i;(m6KXJ`^@O+uEWi{bQH?3V$dP^F34nx9H=NaSHP zc0Z)<9mH{eMAa#Apx6i)oY*MW5>CCuWgk38jWhqRFWEj9y;hX z28ymN)Bw`m28*VHV0nkGltfy%cjqR~U~TcfDAxuf(^l&UwC2E(@@ zzy&!dBB^bxw|zfbO0F@QXo4Nklrw>v1I7M_j!JhD`T@EMNQ8E$!c@E{@=v%>dMQ;@ zdtp9oU{ZFbD3w1IrYI%f8l}=nQmQ{vv^9B(PvuXATceWsP+`i>RJb)t>809Nl71~- zGX0+wrrN8ua<|5(%KNRfHGTMOmWKyvdo}3a(Ce8*4X*e`k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