Bug 57930: Add support for inlineString in FromHowTo

Also do not require an Apache Xerces Parser, let the JDK choose an available one instead

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737247 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-03-31 14:39:11 +00:00
parent 12f99cc9d5
commit 316c1fe307

View File

@ -73,10 +73,7 @@ public class FromHowTo {
} }
public XMLReader fetchSheetParser(SharedStringsTable sst) throws SAXException { public XMLReader fetchSheetParser(SharedStringsTable sst) throws SAXException {
XMLReader parser = XMLReader parser = XMLReaderFactory.createXMLReader();
XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser"
);
ContentHandler handler = new SheetHandler(sst); ContentHandler handler = new SheetHandler(sst);
parser.setContentHandler(handler); parser.setContentHandler(handler);
return parser; return parser;
@ -89,6 +86,7 @@ public class FromHowTo {
private SharedStringsTable sst; private SharedStringsTable sst;
private String lastContents; private String lastContents;
private boolean nextIsString; private boolean nextIsString;
private boolean inlineStr;
private SheetHandler(SharedStringsTable sst) { private SheetHandler(SharedStringsTable sst) {
this.sst = sst; this.sst = sst;
@ -102,11 +100,8 @@ public class FromHowTo {
System.out.print(attributes.getValue("r") + " - "); System.out.print(attributes.getValue("r") + " - ");
// Figure out if the value is an index in the SST // Figure out if the value is an index in the SST
String cellType = attributes.getValue("t"); String cellType = attributes.getValue("t");
if(cellType != null && cellType.equals("s")) { nextIsString = cellType != null && cellType.equals("s");
nextIsString = true; inlineStr = cellType != null && cellType.equals("inlineStr");
} else {
nextIsString = false;
}
} }
// Clear contents cache // Clear contents cache
lastContents = ""; lastContents = "";
@ -124,7 +119,7 @@ public class FromHowTo {
// v => contents of a cell // v => contents of a cell
// Output after we've seen the string contents // Output after we've seen the string contents
if(name.equals("v")) { if(name.equals("v") || (inlineStr && name.equals("c"))) {
System.out.println(lastContents); System.out.println(lastContents);
} }
} }