fixed WordExtractor to avoid ArrayIndexOutOfBoundsException when encountering empty footnote block
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@795333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
656114c69a
commit
77987258b8
@ -23,6 +23,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.poi.POIOLE2TextExtractor;
|
import org.apache.poi.POIOLE2TextExtractor;
|
||||||
import org.apache.poi.hwpf.HWPFDocument;
|
import org.apache.poi.hwpf.HWPFDocument;
|
||||||
@ -252,9 +253,13 @@ public final class WordExtractor extends POIOLE2TextExtractor {
|
|||||||
|
|
||||||
ret.append(getHeaderText());
|
ret.append(getHeaderText());
|
||||||
|
|
||||||
String[] text = getParagraphText();
|
ArrayList<String> text = new ArrayList<String>();
|
||||||
for(int i=0; i<text.length; i++) {
|
text.addAll(Arrays.asList(getParagraphText()));
|
||||||
ret.append(text[i]);
|
text.addAll(Arrays.asList(getFootnoteText()));
|
||||||
|
text.addAll(Arrays.asList(getEndnoteText()));
|
||||||
|
|
||||||
|
for(String p : text) {
|
||||||
|
ret.append(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.append(getFooterText());
|
ret.append(getFooterText());
|
||||||
|
@ -978,6 +978,10 @@ public class Range { // TODO -instantiable superclass
|
|||||||
node = (PropertyNode)rpl.get(x);
|
node = (PropertyNode)rpl.get(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node.getEnd() <= start) {
|
||||||
|
return new int[] {rpl.size(), rpl.size()};
|
||||||
|
}
|
||||||
|
|
||||||
int y = x;
|
int y = x;
|
||||||
node = (PropertyNode)rpl.get(y);
|
node = (PropertyNode)rpl.get(y);
|
||||||
while(node.getEnd() < end && y < rpl.size()-1)
|
while(node.getEnd() < end && y < rpl.size()-1)
|
||||||
|
Loading…
Reference in New Issue
Block a user