Search in sources :

Example 1 with HSLFTitleMaster

use of org.apache.poi.hslf.usermodel.HSLFTitleMaster in project poi by apache.

the class TestSlideMaster method testTitleMasterTextAttributes.

/**
     * Test we can read default text attributes for a title master sheet
     */
@Test
public void testTitleMasterTextAttributes() throws IOException {
    HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
    List<HSLFTitleMaster> master = ppt.getTitleMasters();
    assertEquals(1, master.size());
    assertEquals(32, master.get(0).getStyleAttribute(TextHeaderAtom.CENTER_TITLE_TYPE, 0, "font.size", true).getValue());
    CharFlagsTextProp prop1 = (CharFlagsTextProp) master.get(0).getStyleAttribute(TextHeaderAtom.CENTER_TITLE_TYPE, 0, "char_flags", true);
    assertEquals(true, prop1.getSubValue(CharFlagsTextProp.BOLD_IDX));
    assertEquals(false, prop1.getSubValue(CharFlagsTextProp.ITALIC_IDX));
    assertEquals(true, prop1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX));
    assertEquals(20, master.get(0).getStyleAttribute(TextHeaderAtom.CENTRE_BODY_TYPE, 0, "font.size", true).getValue());
    CharFlagsTextProp prop2 = (CharFlagsTextProp) master.get(0).getStyleAttribute(TextHeaderAtom.CENTRE_BODY_TYPE, 0, "char_flags", true);
    assertEquals(true, prop2.getSubValue(CharFlagsTextProp.BOLD_IDX));
    assertEquals(false, prop2.getSubValue(CharFlagsTextProp.ITALIC_IDX));
    assertEquals(false, prop2.getSubValue(CharFlagsTextProp.UNDERLINE_IDX));
    ppt.close();
}
Also used : HSLFSlideShow(org.apache.poi.hslf.usermodel.HSLFSlideShow) CharFlagsTextProp(org.apache.poi.hslf.model.textproperties.CharFlagsTextProp) HSLFTitleMaster(org.apache.poi.hslf.usermodel.HSLFTitleMaster) Test(org.junit.Test)

Example 2 with HSLFTitleMaster

use of org.apache.poi.hslf.usermodel.HSLFTitleMaster in project poi by apache.

the class TestSlideMaster method testTitleMaster.

/**
     * Slide 3 has title layout and follows the TitleMaster. Verify that.
     */
@Test
public void testTitleMaster() throws IOException {
    HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
    HSLFSlide slide = ppt.getSlides().get(2);
    HSLFMasterSheet masterSheet = slide.getMasterSheet();
    assertTrue(masterSheet instanceof HSLFTitleMaster);
    for (List<HSLFTextParagraph> txt : slide.getTextParagraphs()) {
        HSLFTextRun rt = txt.get(0).getTextRuns().get(0);
        switch(txt.get(0).getRunType()) {
            case TextHeaderAtom.CENTER_TITLE_TYPE:
                assertEquals("Arial", rt.getFontFamily());
                assertEquals(32, rt.getFontSize(), 0);
                assertEquals(true, rt.isBold());
                assertEquals(true, rt.isUnderlined());
                break;
            case TextHeaderAtom.CENTRE_BODY_TYPE:
                assertEquals("Courier New", rt.getFontFamily());
                assertEquals(20, rt.getFontSize(), 0);
                assertEquals(true, rt.isBold());
                assertEquals(false, rt.isUnderlined());
                break;
        }
    }
    ppt.close();
}
Also used : HSLFTextRun(org.apache.poi.hslf.usermodel.HSLFTextRun) HSLFMasterSheet(org.apache.poi.hslf.usermodel.HSLFMasterSheet) HSLFTextParagraph(org.apache.poi.hslf.usermodel.HSLFTextParagraph) HSLFSlideShow(org.apache.poi.hslf.usermodel.HSLFSlideShow) HSLFSlide(org.apache.poi.hslf.usermodel.HSLFSlide) HSLFTitleMaster(org.apache.poi.hslf.usermodel.HSLFTitleMaster) Test(org.junit.Test)

Aggregations

HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)2 HSLFTitleMaster (org.apache.poi.hslf.usermodel.HSLFTitleMaster)2 Test (org.junit.Test)2 CharFlagsTextProp (org.apache.poi.hslf.model.textproperties.CharFlagsTextProp)1 HSLFMasterSheet (org.apache.poi.hslf.usermodel.HSLFMasterSheet)1 HSLFSlide (org.apache.poi.hslf.usermodel.HSLFSlide)1 HSLFTextParagraph (org.apache.poi.hslf.usermodel.HSLFTextParagraph)1 HSLFTextRun (org.apache.poi.hslf.usermodel.HSLFTextRun)1