use of org.apache.poi.hslf.usermodel.HSLFSlide in project poi by apache.
the class TestBackground method defaults.
/**
* Default background for slide, shape and slide master.
*/
@Test
public void defaults() throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
assertEquals(HSLFFill.FILL_SOLID, ppt.getSlideMasters().get(0).getBackground().getFill().getFillType());
HSLFSlide slide = ppt.createSlide();
assertTrue(slide.getFollowMasterBackground());
assertEquals(HSLFFill.FILL_SOLID, slide.getBackground().getFill().getFillType());
HSLFShape shape = new HSLFAutoShape(ShapeType.RECT);
assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType());
ppt.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlide in project poi by apache.
the class TestHeadersFooters method testReadNoHeadersFooters.
/**
* If Headers / Footers are not set, all the getters should return <code>false</code> or <code>null</code>
*/
@Test
public void testReadNoHeadersFooters() throws Exception {
InputStream is = _slTests.openResourceAsStream("basic_test_ppt_file.ppt");
HSLFSlideShow ppt = new HSLFSlideShow(is);
is.close();
HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
assertFalse(slideHdd.isFooterVisible());
assertNull(slideHdd.getFooterText());
assertFalse(slideHdd.isSlideNumberVisible());
assertFalse(slideHdd.isHeaderVisible());
assertNull(slideHdd.getHeaderText());
assertFalse(slideHdd.isUserDateVisible());
assertNull(slideHdd.getDateTimeText());
HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
assertFalse(notesHdd.isFooterVisible());
assertNull(notesHdd.getFooterText());
assertFalse(notesHdd.isHeaderVisible());
assertNull(notesHdd.getHeaderText());
assertFalse(notesHdd.isUserDateVisible());
assertNull(notesHdd.getDateTimeText());
for (HSLFSlide s : ppt.getSlides()) {
HeadersFooters hd1 = s.getHeadersFooters();
assertFalse(hd1.isFooterVisible());
assertNull(hd1.getFooterText());
assertFalse(hd1.isHeaderVisible());
assertNull(hd1.getHeaderText());
assertFalse(hd1.isUserDateVisible());
assertNull(hd1.getDateTimeText());
}
ppt.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlide in project poi by apache.
the class TestHeadersFooters method testRead.
@Test
public void testRead() throws IOException {
InputStream is = _slTests.openResourceAsStream("headers_footers.ppt");
HSLFSlideShow ppt = new HSLFSlideShow(is);
is.close();
HeadersFooters slideHdd = ppt.getSlideHeadersFooters();
assertTrue(slideHdd.isFooterVisible());
assertEquals("Global Slide Footer", slideHdd.getFooterText());
assertTrue(slideHdd.isSlideNumberVisible());
assertFalse(slideHdd.isHeaderVisible());
assertNull(slideHdd.getHeaderText());
assertFalse(slideHdd.isUserDateVisible());
assertNull(slideHdd.getDateTimeText());
HeadersFooters notesHdd = ppt.getNotesHeadersFooters();
assertTrue(notesHdd.isFooterVisible());
assertEquals("Notes Footer", notesHdd.getFooterText());
assertTrue(notesHdd.isHeaderVisible());
assertEquals("Notes Header", notesHdd.getHeaderText());
assertTrue(notesHdd.isUserDateVisible());
assertNull(notesHdd.getDateTimeText());
List<HSLFSlide> slide = ppt.getSlides();
//the first slide uses presentation-scope headers / footers
HeadersFooters hd1 = slide.get(0).getHeadersFooters();
assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible());
assertEquals(slideHdd.getFooterText(), hd1.getFooterText());
assertEquals(slideHdd.isSlideNumberVisible(), hd1.isSlideNumberVisible());
assertEquals(slideHdd.isHeaderVisible(), hd1.isHeaderVisible());
assertEquals(slideHdd.getHeaderText(), hd1.getHeaderText());
assertEquals(slideHdd.isUserDateVisible(), hd1.isUserDateVisible());
assertEquals(slideHdd.getDateTimeText(), hd1.getDateTimeText());
//the first slide uses per-slide headers / footers
HeadersFooters hd2 = slide.get(1).getHeadersFooters();
assertEquals(true, hd2.isFooterVisible());
assertEquals("per-slide footer", hd2.getFooterText());
assertEquals(true, hd2.isUserDateVisible());
assertEquals("custom date format", hd2.getDateTimeText());
ppt.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlide in project poi by apache.
the class TestHyperlink method bug47291.
@Test
public void bug47291() throws IOException {
HSLFSlideShow ppt1 = new HSLFSlideShow();
HSLFSlide slide1 = ppt1.createSlide();
HSLFTextRun r1 = slide1.createTextBox().setText("page1");
HSLFHyperlink hl1 = r1.createHyperlink();
hl1.linkToEmail("dev@poi.apache.org");
HSLFTextRun r2 = ppt1.createSlide().createTextBox().setText("page2");
HSLFHyperlink hl2 = r2.createHyperlink();
hl2.linkToLastSlide();
HSLFSlide sl1 = ppt1.createSlide();
HSLFTextBox tb1 = sl1.createTextBox();
tb1.setAnchor(new Rectangle2D.Double(100, 100, 100, 100));
tb1.appendText("text1 ", false);
HSLFTextRun r3 = tb1.appendText("link", false);
tb1.appendText(" text2", false);
HSLFHyperlink hl3 = r3.createHyperlink();
hl3.linkToSlide(slide1);
HSLFTextRun r4 = ppt1.createSlide().createTextBox().setText("page4");
HSLFHyperlink hl4 = r4.createHyperlink();
hl4.linkToUrl("http://poi.apache.org");
HSLFTextBox tb5 = ppt1.createSlide().createTextBox();
tb5.setText("page5");
HSLFHyperlink hl5 = tb5.createHyperlink();
hl5.linkToFirstSlide();
HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1);
ppt1.close();
List<HSLFSlide> slides = ppt2.getSlides();
tb1 = (HSLFTextBox) slides.get(0).getShapes().get(0);
hl1 = tb1.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
assertNotNull(hl1);
assertEquals("dev@poi.apache.org", hl1.getLabel());
assertEquals(HyperlinkType.EMAIL, hl1.getTypeEnum());
HSLFTextBox tb2 = (HSLFTextBox) slides.get(1).getShapes().get(0);
hl2 = tb2.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
assertNotNull(hl2);
assertEquals(InteractiveInfoAtom.LINK_LastSlide, hl2.getInfo().getInteractiveInfoAtom().getHyperlinkType());
assertEquals(HyperlinkType.DOCUMENT, hl2.getTypeEnum());
HSLFTextBox tb3 = (HSLFTextBox) slides.get(2).getShapes().get(0);
hl3 = tb3.getTextParagraphs().get(0).getTextRuns().get(1).getHyperlink();
assertNotNull(hl3);
assertEquals(ppt2.getSlides().get(0)._getSheetNumber(), Integer.parseInt(hl3.getAddress().split(",")[0]));
assertEquals(HyperlinkType.DOCUMENT, hl3.getTypeEnum());
HSLFTextBox tb4 = (HSLFTextBox) slides.get(3).getShapes().get(0);
hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
assertNotNull(hl4);
assertEquals("http://poi.apache.org", hl4.getLabel());
assertEquals(HyperlinkType.URL, hl4.getTypeEnum());
tb5 = (HSLFTextBox) slides.get(4).getShapes().get(0);
hl5 = tb5.getHyperlink();
assertNotNull(hl5);
assertEquals(InteractiveInfoAtom.LINK_FirstSlide, hl5.getInfo().getInteractiveInfoAtom().getHyperlinkType());
assertEquals(HyperlinkType.DOCUMENT, hl5.getTypeEnum());
ppt2.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlide in project poi by apache.
the class TestLine method testCreateLines.
@Test
public void testCreateLines() throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
HSLFSlide slide = ppt.createSlide();
slide.addTitle().setText("Lines tester");
HSLFLine line;
/**
* line styles
*/
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 200, 300, 0));
line.setLineCompound(LineCompound.SINGLE);
line.setLineColor(Color.blue);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 230, 300, 0));
line.setLineCompound(LineCompound.DOUBLE);
line.setLineWidth(3.5);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 260, 300, 0));
line.setLineCompound(LineCompound.TRIPLE);
line.setLineWidth(6);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 290, 300, 0));
line.setLineCompound(LineCompound.THICK_THIN);
line.setLineWidth(4.5);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 320, 300, 0));
line.setLineCompound(LineCompound.THIN_THICK);
line.setLineWidth(5.5);
slide.addShape(line);
/**
* line dashing
*/
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 200, 300, 0));
line.setLineDash(LineDash.SOLID);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 230, 300, 0));
line.setLineDash(LineDash.DASH);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 260, 300, 0));
line.setLineDash(LineDash.DOT);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 290, 300, 0));
line.setLineDash(LineDash.DASH_DOT);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 320, 300, 0));
line.setLineDash(LineDash.LG_DASH_DOT_DOT);
slide.addShape(line);
/**
* Combinations
*/
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 400, 300, 0));
line.setLineDash(LineDash.DASH_DOT);
line.setLineCompound(LineCompound.TRIPLE);
line.setLineWidth(5.0);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 430, 300, 0));
line.setLineDash(LineDash.DASH);
line.setLineCompound(LineCompound.THICK_THIN);
line.setLineWidth(4.0);
slide.addShape(line);
line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 460, 300, 0));
line.setLineDash(LineDash.DOT);
line.setLineCompound(LineCompound.DOUBLE);
line.setLineWidth(8.0);
slide.addShape(line);
ppt.close();
}
Aggregations