Examples of SlideShow


Examples of org.apache.poi.hslf.usermodel.SlideShow

    /**
     * Test adding shapes to <code>ShapeGroup</code>
     */
    public void testShapeGroup() throws Exception {
        String cwd = System.getProperty("HSLF.testdata.path");
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        Dimension pgsize = ppt.getPageSize();

        ShapeGroup group = new ShapeGroup();

        group.setAnchor(new Rectangle(0, 0, (int)pgsize.getWidth(), (int)pgsize.getHeight()));
        slide.addShape(group);

        File img = new File(cwd, "clock.jpg");
        int idx = ppt.addPicture(img, Picture.JPEG);
        Picture pict = new Picture(idx, group);
        pict.setAnchor(new Rectangle(0, 0, 200, 200));
        group.addShape(pict);

        Line line = new Line(group);
        line.setAnchor(new Rectangle(300, 300, 500, 0));
        group.addShape(line);

        //serialize and read again.
        ByteArrayOutputStream  out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ByteArrayInputStream is = new ByteArrayInputStream(out.toByteArray());
        ppt = new SlideShow(is);
        is.close();

        slide = ppt.getSlides()[0];

        Shape[] shape = slide.getShapes();
        assertEquals(1, shape.length);
        assertTrue(shape[0] instanceof ShapeGroup);

View Full Code Here

Examples of org.apache.poi.hslf.usermodel.SlideShow

    /**
     * Test functionality of Sheet.removeShape(Shape shape)
     */
    public void testRemoveShapes() throws IOException {
        String file = System.getProperty("HSLF.testdata.path")+ "/with_textbox.ppt";
        SlideShow ppt = new SlideShow(new HSLFSlideShow(file));
        Slide sl = ppt.getSlides()[0];
        Shape[] sh = sl.getShapes();
        assertEquals("expected four shaped in " + file, 4, sh.length);
        //remove all
        for (int i = 0; i < sh.length; i++) {
            boolean ok = sl.removeShape(sh[i]);
            assertTrue("Failed to delete shape #" + i, ok);
        }
        //now Slide.getShapes() should return an empty array
        assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);

        //serialize and read again. The file should be readable and contain no shapes
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
        sl = ppt.getSlides()[0];
        assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.