From 984c180adec738c29d2ea5beeacc6483a2f41b7a Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Mon, 11 Jul 2011 18:39:18 +0000 Subject: [PATCH] ignore PAPX references zero-length text pieces git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145281 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hwpf/model/PAPFormattedDiskPage.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java index 1035698b8..4e357b38f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java @@ -82,20 +82,32 @@ public final class PAPFormattedDiskPage extends FormattedDiskPage { { int startAt = getStart( x ); int endAt = getEnd( x ); - if ( !ignorePapxWithoutTextPieces - || tpt.isIndexInTable( startAt, endAt ) ) - _papxList.add( new PAPX( startAt, endAt, tpt, getGrpprl( x ), - getParagraphHeight( x ), dataStream ) ); - else + + if ( ignorePapxWithoutTextPieces + && !tpt.isIndexInTable( startAt, endAt ) ) { logger.log( POILogger.WARN, "PAPX [", Integer.valueOf( startAt ), "; ", Integer.valueOf( endAt ), ") (bytes) doesn't have corresponding text pieces " + "and will be skipped" ); - _papxList.add( null ); + continue; } + + PAPX papx = new PAPX( startAt, endAt, tpt, getGrpprl( x ), + getParagraphHeight( x ), dataStream ); + + if ( ignorePapxWithoutTextPieces + && papx.getStart() == papx.getEnd() ) + { + logger.log( POILogger.WARN, papx + + " references zero-length range and will be skipped" ); + _papxList.add( null ); + continue; + } + + _papxList.add( papx ); } _fkp = null; _dataStream = dataStream;