Examples of SlideShow


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

    /**
     * Test that ShapeFactory works properly and returns <code>Table</code>
     */
    public void testShapeFactory() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();

        Table tbl = new Table(2, 5);
        slide.addShape(tbl);

        TableCell cell = tbl.getCell(0, 0);
        //table cells have type=TextHeaderAtom.OTHER_TYPE, see bug #46033
        assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextRun().getRunType());

        assertTrue(slide.getShapes()[0] instanceof Table);
        Table tbl2 = (Table)slide.getShapes()[0];
        assertEquals(tbl.getNumberOfColumns(), tbl2.getNumberOfColumns());
        assertEquals(tbl.getNumberOfRows(), tbl2.getNumberOfRows());

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
        slide = ppt.getSlides()[0];
        assertTrue(slide.getShapes()[0] instanceof Table);
        Table tbl3 = (Table)slide.getShapes()[0];
        assertEquals(tbl.getNumberOfColumns(), tbl3.getNumberOfColumns());
        assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());
    }
View Full Code Here

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

    /**
     * Error constructing Table when rownum=1
     */
    public void test45889(){
        SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();
        Shape[] shapes;
        Table tbl1 = new Table(1, 5);
        assertEquals(5, tbl1.getNumberOfColumns());
        assertEquals(1, tbl1.getNumberOfRows());
        slide.addShape(tbl1);
View Full Code Here

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

public final class TestMovieShape extends TestCase {

    protected String cwd = System.getProperty("HSLF.testdata.path");

    public void testCreate() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();

        String path = cwd + "/test-movie.mpg";
        int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);
        int thumbnailIdx = ppt.addPicture(new File(cwd, "tomcat.png"), Picture.PNG);

        MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);
        shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
        slide.addShape(shape);

        assertEquals(path, shape.getPath());
        assertTrue(shape.isAutoPlay());
        shape.setAutoPlay(false);
        assertFalse(shape.isAutoPlay());

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);

        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
        slide = ppt.getSlides()[0];
        shape = (MovieShape)slide.getShapes()[0];
        assertEquals(path, shape.getPath());
        assertFalse(shape.isAutoPlay());

    }
View Full Code Here

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

    public void setUp() throws Exception {

    }

    public void testCreateLines() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();

        slide.addTitle().setText("Lines tester");

        Line line;
View Full Code Here

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

     *  - normal TextBox object
     *  - text in auto-shapes
     */
    public void testRead() throws IOException {
        FileInputStream is = new FileInputStream(new File(cwd, "text_shapes.ppt"));
        SlideShow ppt = new SlideShow(is);
        is.close();

        ArrayList lst1 = new ArrayList();
        Slide slide = ppt.getSlides()[0];
        Shape[] shape = slide.getShapes();
        for (int i = 0; i < shape.length; i++) {
            assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof TextShape);
            TextShape tx = (TextShape)shape[i];
            TextRun run = tx.getTextRun();
View Full Code Here

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

        assertTrue(lst1.containsAll(lst2));
    }

    public void testReadWrite() throws IOException {
        SlideShow ppt = new SlideShow();
        Slide slide =  ppt.createSlide();

        TextShape shape1 = new TextBox();
        TextRun run1 = shape1.createTextRun();
        run1.setText("Hello, World!");
        slide.addShape(shape1);

        shape1.moveTo(100, 100);

        TextShape shape2 = new AutoShape(ShapeTypes.Arrow);
        TextRun run2 = shape2.createTextRun();
        run2.setText("Testing TextShape");
        slide.addShape(shape2);
        shape2.moveTo(300, 300);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();

        ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
        slide = ppt.getSlides()[0];
        Shape[] shape = slide.getShapes();

        assertTrue(shape[0] instanceof TextShape);
        shape1 = (TextShape)shape[0];
        assertEquals(ShapeTypes.TextBox, shape1.getShapeType());
View Full Code Here

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

        assertEquals("Testing TextShape", shape1.getTextRun().getText());
    }

    public void testMargins() throws IOException {
        FileInputStream is = new FileInputStream(new File(cwd, "text-margins.ppt"));
        SlideShow ppt = new SlideShow(is);
        is.close();

        Slide slide = ppt.getSlides()[0];

        HashMap map = new HashMap();
        Shape[] shape = slide.getShapes();
        for (int i = 0; i < shape.length; i++) {
            if(shape[i] instanceof TextShape){
View Full Code Here

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

    /**
     * Default background for slide, shape and slide master.
     */
    public void testDefaults() throws Exception {
        SlideShow ppt = new SlideShow();

        assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType());

        Slide slide = ppt.createSlide();
        assertTrue(slide.getFollowMasterBackground());
        assertEquals(Fill.FILL_SOLID, slide.getBackground().getFill().getFillType());

        Shape shape = new AutoShape(ShapeTypes.Rectangle);
        assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
View Full Code Here

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

    /**
     * Read fill information from an reference ppt file
     */
    public void testReadBackground() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(System.getProperty("HSLF.testdata.path") + "/backgrounds.ppt"));
        Fill fill;
        Shape shape;

        Slide[] slide = ppt.getSlides();

        fill = slide[0].getBackground().getFill();
        assertEquals(Fill.FILL_PICTURE, fill.getFillType());
        shape = slide[0].getShapes()[0];
        assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
View Full Code Here

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

    /**
     * Create a ppt with various fill effects
     */
    public void testBackgroundPicture() throws Exception {
        SlideShow ppt = new SlideShow();
        Slide slide;
        Fill fill;
        Shape shape;
        int idx;

        //slide 1
        slide = ppt.createSlide();
        slide.setFollowMasterBackground(false);
        fill = slide.getBackground().getFill();
        idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/tomcat.png"), Picture.PNG);
        fill.setFillType(Fill.FILL_PICTURE);
        fill.setPictureData(idx);

        shape = new AutoShape(ShapeTypes.Rectangle);
        shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
        fill = shape.getFill();
        fill.setFillType(Fill.FILL_SOLID);
        slide.addShape(shape);

        //slide 2
        slide = ppt.createSlide();
        slide.setFollowMasterBackground(false);
        fill = slide.getBackground().getFill();
        idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/tomcat.png"), Picture.PNG);
        fill.setFillType(Fill.FILL_PATTERN);
        fill.setPictureData(idx);
        fill.setBackgroundColor(Color.green);
        fill.setForegroundColor(Color.red);

        shape = new AutoShape(ShapeTypes.Rectangle);
        shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
        fill = shape.getFill();
        fill.setFillType(Fill.FILL_BACKGROUND);
        slide.addShape(shape);

        //slide 3
        slide = ppt.createSlide();
        slide.setFollowMasterBackground(false);
        fill = slide.getBackground().getFill();
        idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/tomcat.png"), Picture.PNG);
        fill.setFillType(Fill.FILL_TEXTURE);
        fill.setPictureData(idx);

        shape = new AutoShape(ShapeTypes.Rectangle);
        shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
        fill = shape.getFill();
        fill.setFillType(Fill.FILL_PICTURE);
        idx = ppt.addPicture(new File(System.getProperty("HSLF.testdata.path") + "/clock.jpg"), Picture.JPEG);
        fill.setPictureData(idx);
        slide.addShape(shape);

        // slide 4
        slide = ppt.createSlide();
        slide.setFollowMasterBackground(false);
        fill = slide.getBackground().getFill();
        fill.setFillType(Fill.FILL_SHADE_CENTER);
        fill.setBackgroundColor(Color.white);
        fill.setForegroundColor(Color.darkGray);

        shape = new AutoShape(ShapeTypes.Rectangle);
        shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
        fill = shape.getFill();
        fill.setFillType(Fill.FILL_SHADE);
        fill.setBackgroundColor(Color.red);
        fill.setForegroundColor(Color.green);
        slide.addShape(shape);

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

        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
        Slide[] slides = ppt.getSlides();

        fill = slides[0].getBackground().getFill();
        assertEquals(Fill.FILL_PICTURE, fill.getFillType());
        shape = slides[0].getShapes()[0];
        assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
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.