fix: too many PAPX were dropped due to too strict boundary checks
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5aaeaeb6b3
commit
4c670a3efe
@ -70,7 +70,7 @@ public class PAPBinTable
|
||||
PAPX papx = pfkp.getPAPX(y);
|
||||
|
||||
//we don't need PAPX if they are references nowhere
|
||||
if (tpt.isIndexInTable( papx.getStartBytes() ))
|
||||
if (tpt.isIndexInTable( papx.getStartBytes(), papx.getEndBytes() ))
|
||||
_paragraphs.add(papx);
|
||||
}
|
||||
}
|
||||
|
@ -292,6 +292,27 @@ public class TextPieceTable implements CharIndexTranslator {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isIndexInTable( int startBytePos, int endBytePos )
|
||||
{
|
||||
for(TextPiece tp : _textPiecesFCOrder) {
|
||||
int pieceStart = tp.getPieceDescriptor().getFilePosition();
|
||||
|
||||
if (startBytePos > pieceStart + tp.bytesLength()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int left = Math.max( startBytePos, pieceStart );
|
||||
int right = Math.min( endBytePos, pieceStart + tp.bytesLength() );
|
||||
|
||||
if (left >= right)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class FCComparator implements Comparator<TextPiece> {
|
||||
public int compare(TextPiece textPiece, TextPiece textPiece1) {
|
||||
if (textPiece.getPieceDescriptor().fc>textPiece1.getPieceDescriptor().fc) {
|
||||
|
Loading…
Reference in New Issue
Block a user