diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java index 089207dfb2..146fd3b3f7 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java @@ -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 ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java index b8b0fc3c23..9771e5efc9 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java @@ -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 ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java index db84825e08..2c212a6e33 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java @@ -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 ); }