use of org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry in project poi by apache.
the class XSLFSlideShow method getSlideMaster.
/**
* Returns the low level slide master object from
* the supplied slide master reference
*/
@Internal
public CTSlideMaster getSlideMaster(CTSlideMasterIdListEntry master) throws IOException, XmlException {
PackagePart masterPart = getSlideMasterPart(master);
SldMasterDocument masterDoc = SldMasterDocument.Factory.parse(masterPart.getInputStream(), DEFAULT_XML_OPTIONS);
return masterDoc.getSldMaster();
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry in project poi by apache.
the class TestXSLFSlideShow method testSlideBasics.
@Test
public void testSlideBasics() throws IOException, OpenXML4JException, XmlException {
XSLFSlideShow xml = new XSLFSlideShow(pack);
// Should have 1 master
assertEquals(1, xml.getSlideMasterReferences().sizeOfSldMasterIdArray());
// Should have three sheets
assertEquals(2, xml.getSlideReferences().sizeOfSldIdArray());
// Check they're as expected
CTSlideIdListEntry[] slides = xml.getSlideReferences().getSldIdArray();
assertEquals(256, slides[0].getId());
assertEquals(257, slides[1].getId());
assertEquals("rId2", slides[0].getId2());
assertEquals("rId3", slides[1].getId2());
// Now get those objects
assertNotNull(xml.getSlide(slides[0]));
assertNotNull(xml.getSlide(slides[1]));
// And check they have notes as expected
assertNotNull(xml.getNotes(slides[0]));
assertNotNull(xml.getNotes(slides[1]));
// And again for the master
CTSlideMasterIdListEntry[] masters = xml.getSlideMasterReferences().getSldMasterIdArray();
// see SlideAtom.USES_MASTER_SLIDE_ID
assertEquals(0x80000000L, masters[0].getId());
assertEquals("rId1", masters[0].getId2());
assertNotNull(xml.getSlideMaster(masters[0]));
xml.close();
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry 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.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry in project poi by apache.
the class TestXMLSlideShow method testSlideBasics.
@Test
public void testSlideBasics() throws IOException {
XMLSlideShow xml = new XMLSlideShow(pack);
// Should have 1 master
assertEquals(1, xml.getSlideMasters().size());
// Should have two sheets
assertEquals(2, xml.getSlides().size());
// Check they're as expected
CTSlideIdListEntry[] slides = xml.getCTPresentation().getSldIdLst().getSldIdArray();
assertEquals(256, slides[0].getId());
assertEquals(257, slides[1].getId());
assertEquals("rId2", slides[0].getId2());
assertEquals("rId3", slides[1].getId2());
// Now get those objects
assertNotNull(xml.getSlides().get(0));
assertNotNull(xml.getSlides().get(1));
// And check they have notes as expected
assertNotNull(xml.getSlides().get(0).getNotes());
assertNotNull(xml.getSlides().get(1).getNotes());
// Next up look for the slide master
CTSlideMasterIdListEntry[] masters = xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdArray();
// see SlideAtom.USES_MASTER_SLIDE_ID
assertEquals(0x80000000L, masters[0].getId());
assertEquals("rId1", masters[0].getId2());
assertNotNull(xml.getSlideMasters().get(0));
// Finally look for the notes master
CTNotesMasterIdListEntry notesMaster = xml.getCTPresentation().getNotesMasterIdLst().getNotesMasterId();
assertNotNull(notesMaster);
assertNotNull(xml.getNotesMaster());
xml.close();
}
Aggregations