Search in sources :

Example 1 with CTNotesMasterIdListEntry

use of org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry 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)

Example 2 with CTNotesMasterIdListEntry

use of org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry in project poi by apache.

the class XMLSlideShow method createNotesMaster.

/**
     * Create a notes master.
     */
public void createNotesMaster() {
    RelationPart rp = createRelationship(XSLFRelation.NOTES_MASTER, XSLFFactory.getInstance(), 1, false);
    _notesMaster = rp.getDocumentPart();
    CTNotesMasterIdList notesMasterIdList = _presentation.addNewNotesMasterIdLst();
    CTNotesMasterIdListEntry notesMasterId = notesMasterIdList.addNewNotesMasterId();
    notesMasterId.setId(rp.getRelationship().getId());
    Integer themeIndex = 1;
    // TODO: check if that list can be replaced by idx = Math.max(idx,themeIdx)
    List<Integer> themeIndexList = new ArrayList<Integer>();
    for (POIXMLDocumentPart p : getRelations()) {
        if (p instanceof XSLFTheme) {
            themeIndexList.add(XSLFRelation.THEME.getFileNameIndex(p));
        }
    }
    if (!themeIndexList.isEmpty()) {
        Boolean found = false;
        for (Integer i = 1; i <= themeIndexList.size(); i++) {
            if (!themeIndexList.contains(i)) {
                found = true;
                themeIndex = i;
            }
        }
        if (!found) {
            themeIndex = themeIndexList.size() + 1;
        }
    }
    XSLFTheme theme = (XSLFTheme) createRelationship(XSLFRelation.THEME, XSLFFactory.getInstance(), themeIndex);
    theme.importTheme(getSlides().get(0).getTheme());
    _notesMaster.addRelation(null, XSLFRelation.THEME, theme);
}
Also used : CTNotesMasterIdList(org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdList) CTNotesMasterIdListEntry(org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry) POIXMLDocumentPart(org.apache.poi.POIXMLDocumentPart) ArrayList(java.util.ArrayList)

Aggregations

CTNotesMasterIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry)2 ArrayList (java.util.ArrayList)1 POIXMLDocumentPart (org.apache.poi.POIXMLDocumentPart)1 Test (org.junit.Test)1 CTNotesMasterIdList (org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdList)1 CTSlideIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry)1 CTSlideMasterIdListEntry (org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry)1