Search in sources :

Example 1 with CTSlideMasterIdListEntry

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();
}
Also used : PackagePart(org.apache.poi.openxml4j.opc.PackagePart) SldMasterDocument(org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument) Internal(org.apache.poi.util.Internal)

Example 2 with CTSlideMasterIdListEntry

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();
}
Also used : XSLFSlideShow(org.apache.poi.xslf.usermodel.XSLFSlideShow) CTSlideIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry) CTSlideMasterIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry) Test(org.junit.Test)

Example 3 with CTSlideMasterIdListEntry

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);
    }
}
Also used : HashMap(java.util.HashMap) POIXMLDocumentPart(org.apache.poi.POIXMLDocumentPart) POIXMLException(org.apache.poi.POIXMLException) CTSlideMasterIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry) CTSlideIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry) XmlException(org.apache.xmlbeans.XmlException) PresentationDocument(org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument)

Example 4 with CTSlideMasterIdListEntry

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();
}
Also used : CTNotesMasterIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry) CTSlideIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry) CTSlideMasterIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry) Test(org.junit.Test)

Aggregations

CTSlideIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry)3 CTSlideMasterIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry)3 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 POIXMLDocumentPart (org.apache.poi.POIXMLDocumentPart)1 POIXMLException (org.apache.poi.POIXMLException)1 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)1 Internal (org.apache.poi.util.Internal)1 XSLFSlideShow (org.apache.poi.xslf.usermodel.XSLFSlideShow)1 XmlException (org.apache.xmlbeans.XmlException)1 CTNotesMasterIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry)1 PresentationDocument (org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument)1 SldMasterDocument (org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument)1