You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by se...@apache.org on 2011/07/05 12:58:04 UTC
svn commit: r1142977 -
/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
Author: sergey
Date: Tue Jul 5 10:58:04 2011
New Revision: 1142977
URL: http://svn.apache.org/viewvc?rev=1142977&view=rev
Log:
correct range calculation for non-complex file
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java?rev=1142977&r1=1142976&r2=1142977&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java Tue Jul 5 10:58:04 2011
@@ -300,18 +300,40 @@ public final class HWPFDocument extends
* Returns the range which covers the whole of the
* document, but excludes any headers and footers.
*/
- public Range getRange() {
- // First up, trigger a full-recalculate
- // Needed in case of deletes etc
- getOverallRange();
+ public Range getRange()
+ {
+ // First up, trigger a full-recalculate
+ // Needed in case of deletes etc
+ getOverallRange();
+
+ if ( getFileInformationBlock().isFComplex() )
+ {
+ /*
+ * Page 31:
+ *
+ * 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();
- // Now, return the real one
- return new Range(
- _cpSplit.getMainDocumentStart(),
- _cpSplit.getMainDocumentEnd(),
- this
- );
- }
+ int charsStart = getTextTable().getCharIndex( bytesStart );
+ int charsEnd = charsStart + getFileInformationBlock().getCcpText();
+
+ return new Range( charsStart, charsEnd, this );
+ }
/**
* Returns the range which covers all the Footnotes.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org