correct range calculation for non-complex file

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-05 10:58:04 +00:00
parent 0e6e9f649c
commit 8bbbf6996f

View File

@ -300,18 +300,40 @@ public final class HWPFDocument extends HWPFDocumentCore
* Returns the range which covers the whole of the * Returns the range which covers the whole of the
* document, but excludes any headers and footers. * document, but excludes any headers and footers.
*/ */
public Range getRange() { public Range getRange()
// First up, trigger a full-recalculate {
// Needed in case of deletes etc // First up, trigger a full-recalculate
getOverallRange(); // Needed in case of deletes etc
getOverallRange();
// Now, return the real one if ( getFileInformationBlock().isFComplex() )
return new Range( {
_cpSplit.getMainDocumentStart(), /*
_cpSplit.getMainDocumentEnd(), * Page 31:
this *
); * main document must be found by examining the piece table entries
} * from the 0th piece table entry from the piece table entry that
* describes cp=fib.ccpText.
*/
// TODO: review
return new Range( _cpSplit.getMainDocumentStart(),
_cpSplit.getMainDocumentEnd(), this );
}
/*
* Page 31:
*
* "In a non-complex file, this means text of the: main document begins
* at fib.fcMin in the file and continues through
* fib.fcMin+fib.ccpText."
*/
int bytesStart = getFileInformationBlock().getFcMin();
int charsStart = getTextTable().getCharIndex( bytesStart );
int charsEnd = charsStart + getFileInformationBlock().getCcpText();
return new Range( charsStart, charsEnd, this );
}
/** /**
* Returns the range which covers all the Footnotes. * Returns the range which covers all the Footnotes.