Search in sources :

Example 11 with HSLFTextParagraph

use of org.apache.poi.hslf.usermodel.HSLFTextParagraph 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

HSLFTextParagraph (org.apache.poi.hslf.usermodel.HSLFTextParagraph)11 HSLFSlide (org.apache.poi.hslf.usermodel.HSLFSlide)8 HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)8 HSLFTextRun (org.apache.poi.hslf.usermodel.HSLFTextRun)8 Test (org.junit.Test)7 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 HSLFHyperlink (org.apache.poi.hslf.usermodel.HSLFHyperlink)2 HSLFShape (org.apache.poi.hslf.usermodel.HSLFShape)2 HSLFTextBox (org.apache.poi.hslf.usermodel.HSLFTextBox)2 DirectoryNode (org.apache.poi.poifs.filesystem.DirectoryNode)2 DocumentEntry (org.apache.poi.poifs.filesystem.DocumentEntry)2 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)2 Rectangle2D (java.awt.geom.Rectangle2D)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 Hyperlink (org.apache.poi.common.usermodel.Hyperlink)1 HSLFMasterSheet (org.apache.poi.hslf.usermodel.HSLFMasterSheet)1 HSLFSimpleShape (org.apache.poi.hslf.usermodel.HSLFSimpleShape)1