poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r795333 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf: extractor/WordExtractor.java usermodel/Range.java
Date Sat, 18 Jul 2009 10:03:02 GMT
Author: yegor
Date: Sat Jul 18 10:03:01 2009
New Revision: 795333

URL: http://svn.apache.org/viewvc?rev=795333&view=rev
Log:
fixed WordExtractor to avoid ArrayIndexOutOfBoundsException when encountering empty footnote
block

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java?rev=795333&r1=795332&r2=795333&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/WordExtractor.java Sat Jul
18 10:03:01 2009
@@ -23,6 +23,7 @@
 import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 import java.util.Arrays;
+import java.util.ArrayList;
 
 import org.apache.poi.POIOLE2TextExtractor;
 import org.apache.poi.hwpf.HWPFDocument;
@@ -252,9 +253,13 @@
 
 		ret.append(getHeaderText());
 
-		String[] text = getParagraphText();
-		for(int i=0; i<text.length; i++) {
-			ret.append(text[i]);
+                ArrayList<String> text = new ArrayList<String>();
+                text.addAll(Arrays.asList(getParagraphText()));
+                text.addAll(Arrays.asList(getFootnoteText()));
+                text.addAll(Arrays.asList(getEndnoteText()));
+
+		for(String p : text) {
+			ret.append(p);
 		}
 
 		ret.append(getFooterText());

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java?rev=795333&r1=795332&r2=795333&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java Sat Jul 18 10:03:01
2009
@@ -978,6 +978,10 @@
       node = (PropertyNode)rpl.get(x);
     }
 
+    if (node.getEnd() <= start) {
+        return new int[] {rpl.size(), rpl.size()};
+    }
+
     int y = x;
     node = (PropertyNode)rpl.get(y);
     while(node.getEnd() < end && y < rpl.size()-1)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message