]> source.dussan.org Git - poi.git/commitdiff
add the same boundaries check to CHPX / PAPX / SEPX for Word95 as for Word97
authorSergey Vladimirov <sergey@apache.org>
Sat, 9 Jul 2011 14:47:19 +0000 (14:47 +0000)
committerSergey Vladimirov <sergey@apache.org>
Sat, 9 Jul 2011 14:47:19 +0000 (14:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144681 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java
src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java

index 089207dfb216b532a93af78a14875e1ca245c698..146fd3b3f7bc4984f2fb1434be73834e825ecc2c 100644 (file)
@@ -61,7 +61,9 @@ public final class OldCHPBinTable extends CHPBinTable
 
       for (int y = 0; y < fkpSize; y++)
       {
-        _textRuns.add(cfkp.getCHPX(y));
+        CHPX chpx = cfkp.getCHPX(y);
+        if (chpx != null && tpt.isIndexInTable( chpx.getStartBytes(), chpx.getEndBytes() ))
+            _textRuns.add(chpx);
       }
     }
     Collections.sort( _textRuns, PropertyNode.StartComparator.instance );
index b8b0fc3c23a76478a725b8215179e54f82da9937..9771e5efc9fdc2b1f7a45c758ec013f20ee43fa3 100644 (file)
@@ -53,7 +53,8 @@ public final class OldPAPBinTable extends PAPBinTable
       for (int y = 0; y < fkpSize; y++)
       {
        PAPX papx = pfkp.getPAPX(y);
-        _paragraphs.add(papx);
+        if (papx != null && tpt.isIndexInTable( papx.getStartBytes(), papx.getEndBytes() ))
+            _paragraphs.add(papx);
       }
     }
     Collections.sort( _paragraphs, PropertyNode.StartComparator.instance );
index db84825e08a8db9def2139960953304d4636a819..2c212a6e33a0a02e50d3343524924f84f82cea48 100644 (file)
@@ -49,10 +49,11 @@ public final class OldSectionTable extends SectionTable
       int startAt = node.getStart();
       int endAt = node.getEnd();
 
+      SEPX sepx;
       // check for the optimization
       if (fileOffset == 0xffffffff)
       {
-        _sections.add(new SEPX(sed, startAt, endAt, charConv, new byte[0]));
+        sepx = new SEPX(sed, startAt, endAt, charConv, new byte[0]);
       }
       else
       {
@@ -65,8 +66,11 @@ public final class OldSectionTable extends SectionTable
         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));
+        sepx = new SEPX(sed, startAt, endAt, charConv, buf);
       }
+
+      if (tpt.isIndexInTable( sepx.getStartBytes(), sepx.getEndBytes() ))
+        _sections.add(sepx);
     }
     Collections.sort( _sections, PropertyNode.StartComparator.instance );
   }