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();
}
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();
}
Aggregations