use of org.apache.xmlbeans.XmlException in project poi by apache.
the class SharedStringsTable method readFrom.
/**
* Read this shared strings table from an XML file.
*
* @param is The input stream containing the XML document.
* @throws IOException if an error occurs while reading.
*/
public void readFrom(InputStream is) throws IOException {
try {
int cnt = 0;
_sstDoc = SstDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
CTSst sst = _sstDoc.getSst();
count = (int) sst.getCount();
uniqueCount = (int) sst.getUniqueCount();
for (CTRst st : sst.getSiArray()) {
stmap.put(getKey(st), cnt);
strings.add(st);
cnt++;
}
} catch (XmlException e) {
throw new IOException("unable to parse shared strings table", e);
}
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class MapInfo method readFrom.
public void readFrom(InputStream is) throws IOException {
try {
MapInfoDocument doc = MapInfoDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
mapInfo = doc.getMapInfo();
maps = new HashMap<Integer, XSSFMap>();
for (CTMap map : mapInfo.getMapArray()) {
maps.put((int) map.getID(), new XSSFMap(map, this));
}
} catch (XmlException e) {
throw new IOException(e.getLocalizedMessage());
}
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class SingleXmlCells method readFrom.
public void readFrom(InputStream is) throws IOException {
try {
SingleXmlCellsDocument doc = SingleXmlCellsDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
singleXMLCells = doc.getSingleXmlCells();
} catch (XmlException e) {
throw new IOException(e.getLocalizedMessage());
}
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class ExternalLinksTable method readFrom.
public void readFrom(InputStream is) throws IOException {
try {
ExternalLinkDocument doc = ExternalLinkDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
link = doc.getExternalLink();
} catch (XmlException e) {
throw new IOException(e.getLocalizedMessage());
}
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class XSSFSheet method readOleObject.
/**
* Determine the OleObject which links shapes with embedded resources
*
* @param shapeId the shape id
* @return the CTOleObject of the shape
*/
protected CTOleObject readOleObject(long shapeId) {
if (!getCTWorksheet().isSetOleObjects()) {
return null;
}
// we use a XmlCursor here to handle oleObject with-/out AlternateContent wrappers
String xquery = "declare namespace p='" + XSSFRelation.NS_SPREADSHEETML + "' .//p:oleObject";
XmlCursor cur = getCTWorksheet().getOleObjects().newCursor();
try {
cur.selectPath(xquery);
CTOleObject coo = null;
while (cur.toNextSelection()) {
String sId = cur.getAttributeText(new QName(null, "shapeId"));
if (sId == null || Long.parseLong(sId) != shapeId) {
continue;
}
XmlObject xObj = cur.getObject();
if (xObj instanceof CTOleObject) {
// the unusual case ...
coo = (CTOleObject) xObj;
} else {
XMLStreamReader reader = cur.newXMLStreamReader();
try {
CTOleObjects coos = CTOleObjects.Factory.parse(reader);
if (coos.sizeOfOleObjectArray() == 0) {
continue;
}
coo = coos.getOleObjectArray(0);
} catch (XmlException e) {
logger.log(POILogger.INFO, "can't parse CTOleObjects", e);
} finally {
try {
reader.close();
} catch (XMLStreamException e) {
logger.log(POILogger.INFO, "can't close reader", e);
}
}
}
// which is in the choice element
if (cur.toChild(XSSFRelation.NS_SPREADSHEETML, "objectPr")) {
break;
}
}
return (coo == null) ? null : coo;
} finally {
cur.dispose();
}
}
Aggregations