poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r998621 - in /poi/trunk: src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFOldDocument.java test-data/document/Word6_sections2.doc
Date Sun, 19 Sep 2010 09:59:11 GMT
Author: nick
Date: Sun Sep 19 09:59:10 2010
New Revision: 998621

URL: http://svn.apache.org/viewvc?rev=998621&view=rev
Log:
More fixes for bug #49933, workaround the fact that some word6/word95 SEPX entries are compressed
differently, and we don't have the specs for how they're stored

Added:
    poi/trunk/test-data/document/Word6_sections2.doc   (with props)
Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFOldDocument.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java?rev=998621&r1=998620&r2=998621&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java Sun Sep 19
09:59:10 2010
@@ -56,7 +56,11 @@ public final class OldSectionTable exten
       {
         // The first short at the offset is the size of the grpprl.
         int sepxSize = LittleEndian.getShort(documentStream, fileOffset);
-        byte[] buf = new byte[sepxSize];
+        // Because we don't properly know about all the details of the old
+        //  section properties, and we're trying to decode them as if they
+        //  were the new ones, we sometimes "need" more data than we have.
+        // As a workaround, have a few extra 0 bytes on the end!
+        byte[] buf = new byte[sepxSize+2];
         fileOffset += LittleEndian.SHORT_SIZE;
         System.arraycopy(documentStream, fileOffset, buf, 0, buf.length);
         _sections.add(new SEPX(sed, startAt, endAt, charConv, buf));

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFOldDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFOldDocument.java?rev=998621&r1=998620&r2=998621&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFOldDocument.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFOldDocument.java
Sun Sep 19 09:59:10 2010
@@ -119,4 +119,24 @@ public final class TestHWPFOldDocument e
       assertEquals("\u000c", doc.getRange().getParagraph(4).text()); // Section line?
       assertEquals("\r", doc.getRange().getParagraph(5).text());
    }
+   
+   /**
+    * Another word document with sections, this time with a 
+    *  few more section properties set on it
+    */
+   public void testWord6Sections2() throws Exception {
+      HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Word6_sections2.doc");
+      
+      assertEquals(1, doc.getRange().numSections());
+      assertEquals(57, doc.getRange().numParagraphs());
+      
+      assertEquals(
+            "\r",
+            doc.getRange().getParagraph(0).text()
+      );
+      assertEquals(
+            "STATEMENT  OF  INSOLVENCY  PRACTICE  10  (SCOTLAND)\r",
+            doc.getRange().getParagraph(1).text()
+      );
+   }
 }

Added: poi/trunk/test-data/document/Word6_sections2.doc
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/Word6_sections2.doc?rev=998621&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/Word6_sections2.doc
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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


Mime
View raw message