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);
}
}
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) {