ignore CHPX references zero-length text pieces

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1145275 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-11 18:34:26 +00:00
parent a61064e853
commit 2ee84d720a

View File

@ -74,21 +74,18 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
* This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array * This constructs a CHPFormattedDiskPage from a raw fkp (512 byte array
* read from a Word file). * read from a Word file).
*/ */
public CHPFormattedDiskPage( byte[] documentStream, int offset, TextPieceTable tpt, public CHPFormattedDiskPage( byte[] documentStream, int offset,
boolean ignoreChpxWithoutTextPieces ) TextPieceTable tpt, boolean ignoreChpxWithoutTextPieces )
{ {
super(documentStream, offset); super( documentStream, offset );
for (int x = 0; x < _crun; x++) for ( int x = 0; x < _crun; x++ )
{ {
int startAt = getStart(x); int startAt = getStart( x );
int endAt = getEnd(x); int endAt = getEnd( x );
if (!ignoreChpxWithoutTextPieces || tpt.isIndexInTable( startAt, endAt ) ) if ( ignoreChpxWithoutTextPieces
{ && !tpt.isIndexInTable( startAt, endAt ) )
_chpxList.add(new CHPX(startAt, endAt, tpt, getGrpprl(x)));
}
else
{ {
logger.log( POILogger.WARN, "CHPX [", logger.log( POILogger.WARN, "CHPX [",
Integer.valueOf( startAt ), "; ", Integer.valueOf( startAt ), "; ",
@ -96,8 +93,22 @@ public final class CHPFormattedDiskPage extends FormattedDiskPage
") (bytes) doesn't have corresponding text pieces " ") (bytes) doesn't have corresponding text pieces "
+ "and will be skipped" ); + "and will be skipped" );
_chpxList.add(null); _chpxList.add( null );
continue;
} }
CHPX chpx = new CHPX( startAt, endAt, tpt, getGrpprl( x ) );
if ( ignoreChpxWithoutTextPieces
&& chpx.getStart() == chpx.getEnd() )
{
logger.log( POILogger.WARN, chpx
+ " references zero-length range and will be skipped" );
_chpxList.add( null );
continue;
}
_chpxList.add( chpx );
} }
} }