use of org.apache.xmlbeans.XmlException in project poi by apache.
the class XWPFRun method getCTPictures.
private List<CTPicture> getCTPictures(XmlObject o) {
List<CTPicture> pics = new ArrayList<CTPicture>();
XmlObject[] picts = o.selectPath("declare namespace pic='" + CTPicture.type.getName().getNamespaceURI() + "' .//pic:pic");
for (XmlObject pict : picts) {
if (pict instanceof XmlAnyTypeImpl) {
// Pesky XmlBeans bug - see Bugzilla #49934
try {
pict = CTPicture.Factory.parse(pict.toString(), DEFAULT_XML_OPTIONS);
} catch (XmlException e) {
throw new POIXMLException(e);
}
}
if (pict instanceof CTPicture) {
pics.add((CTPicture) pict);
}
}
return pics;
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class XWPFStyles method onDocumentRead.
/**
* Read document
*/
@Override
protected void onDocumentRead() throws IOException {
StylesDocument stylesDoc;
InputStream is = getPackagePart().getInputStream();
try {
stylesDoc = StylesDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
setStyles(stylesDoc.getStyles());
latentStyles = new XWPFLatentStyles(ctStyles.getLatentStyles(), this);
} catch (XmlException e) {
throw new POIXMLException("Unable to read styles", e);
} finally {
is.close();
}
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class XMLSlideShow method onDocumentRead.
@Override
protected void onDocumentRead() throws IOException {
try {
PresentationDocument doc = PresentationDocument.Factory.parse(getCorePart().getInputStream(), DEFAULT_XML_OPTIONS);
_presentation = doc.getPresentation();
Map<String, XSLFSlideMaster> masterMap = new HashMap<String, XSLFSlideMaster>();
Map<String, XSLFSlide> shIdMap = new HashMap<String, XSLFSlide>();
for (RelationPart rp : getRelationParts()) {
POIXMLDocumentPart p = rp.getDocumentPart();
if (p instanceof XSLFSlide) {
shIdMap.put(rp.getRelationship().getId(), (XSLFSlide) p);
} else if (p instanceof XSLFSlideMaster) {
masterMap.put(getRelationId(p), (XSLFSlideMaster) p);
} else if (p instanceof XSLFTableStyles) {
_tableStyles = (XSLFTableStyles) p;
} else if (p instanceof XSLFNotesMaster) {
_notesMaster = (XSLFNotesMaster) p;
} else if (p instanceof XSLFCommentAuthors) {
_commentAuthors = (XSLFCommentAuthors) p;
}
}
_masters = new ArrayList<XSLFSlideMaster>(masterMap.size());
for (CTSlideMasterIdListEntry masterId : _presentation.getSldMasterIdLst().getSldMasterIdList()) {
XSLFSlideMaster master = masterMap.get(masterId.getId2());
_masters.add(master);
}
_slides = new ArrayList<XSLFSlide>(shIdMap.size());
if (_presentation.isSetSldIdLst()) {
for (CTSlideIdListEntry slId : _presentation.getSldIdLst().getSldIdList()) {
XSLFSlide sh = shIdMap.get(slId.getId2());
if (sh == null) {
LOG.log(POILogger.WARN, "Slide with r:id " + slId.getId() + " was defined, but didn't exist in package, skipping");
continue;
}
_slides.add(sh);
}
}
} catch (XmlException e) {
throw new POIXMLException(e);
}
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class XSSFSheet method read.
protected void read(InputStream is) throws IOException {
try {
worksheet = WorksheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS).getWorksheet();
} catch (XmlException e) {
throw new POIXMLException(e);
}
initRows(worksheet);
columnHelper = new ColumnHelper(worksheet);
// Look for bits we're interested in
for (RelationPart rp : getRelationParts()) {
POIXMLDocumentPart p = rp.getDocumentPart();
if (p instanceof CommentsTable) {
sheetComments = (CommentsTable) p;
}
if (p instanceof XSSFTable) {
tables.put(rp.getRelationship().getId(), (XSSFTable) p);
}
if (p instanceof XSSFPivotTable) {
getWorkbook().getPivotTables().add((XSSFPivotTable) p);
}
}
// Process external hyperlinks for the sheet, if there are any
initHyperlinks();
}
use of org.apache.xmlbeans.XmlException in project poi by apache.
the class XSSFTable method readFrom.
/**
* read table XML
* @param is
* @throws IOException
*/
public void readFrom(InputStream is) throws IOException {
try {
TableDocument doc = TableDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
ctTable = doc.getTable();
} catch (XmlException e) {
throw new IOException(e.getLocalizedMessage());
}
}
Aggregations