use of org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument 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);
}
}
Aggregations