for (TextPiece textPiece : _textPiecesFCOrder) {
final int tpStart = textPiece.getPieceDescriptor()
.getFilePosition();
+ if (endBytePosExclusive <= tpStart)
+ break;
+
final int tpEnd = textPiece.getPieceDescriptor().getFilePosition()
+ textPiece.bytesLength();
if (startBytePosInclusive > tpEnd)
continue;
- if (endBytePosExclusive <= tpStart)
- break;
- final int rangeStartBytes = Math.max(tpStart,
- startBytePosInclusive);
+ final int rangeStartBytes = Math.max(tpStart, startBytePosInclusive);
final int rangeEndBytes = Math.min(tpEnd, endBytePosExclusive);
- final int rangeLengthBytes = rangeEndBytes - rangeStartBytes;
if (rangeStartBytes > rangeEndBytes)
continue;
final int rangeStartCp = textPiece.getStart()
+ (rangeStartBytes - tpStart) / encodingMultiplier;
+ final int rangeLengthBytes = rangeEndBytes - rangeStartBytes;
final int rangeEndCp = rangeStartCp + rangeLengthBytes
/ encodingMultiplier;
logger.log(
POILogger.WARN,
"Text piece has boundaries [",
- Integer.valueOf(textPiece.getStart()),
+ textPiece.getStart(),
"; ",
- Integer.valueOf(textPiece.getEnd()),
+ textPiece.getEnd(),
") but length ",
- Integer.valueOf(textPiece.getEnd()
- - textPiece.getStart()));
+ textPiece.getEnd() - textPiece.getStart());
}
docText.replace(textPiece.getStart(), textPiece.getStart()
}
logger.log(POILogger.DEBUG, "Document text were rebuilded in ",
- Long.valueOf(System.currentTimeMillis() - start), " ms (",
- Integer.valueOf(docText.length()), " chars)");
+ System.currentTimeMillis() - start, " ms (",
+ docText.length(), " chars)");
return docText;
}
continue;
}
- if (pieceStart > bytePos) {
- return false;
- }
-
- return true;
+ return pieceStart <= bytePos;
}
return false;
int left = Math.max(startBytePos, pieceStart);
int right = Math.min(endBytePos, pieceStart + tp.bytesLength());
- if (left >= right)
- return false;
-
- return true;
+ return left < right;
}
return false;