Package org.apache.poi.hslf.model

Examples of org.apache.poi.hslf.model.Slide


    // Add this new SlidePersistAtom to the SlideListWithText
    slist.addSlidePersistAtom(sp);

    // Create a new Slide
    Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
    slide.setSlideShow(this);
    slide.onCreate();

    // Add in to the list of Slides
    Slide[] s = new Slide[_slides.length + 1];
    System.arraycopy(_slides, 0, s, 0, _slides.length);
    s[_slides.length] = slide;
    _slides = s;
    logger.log(POILogger.INFO, "Added slide " + _slides.length + " with ref " + sp.getRefID()
        + " and identifier " + sp.getSlideIdentifier());

    // Add the core records for this new Slide to the record tree
    org.apache.poi.hslf.record.Slide slideRecord = slide.getSlideRecord();
    int psrId = addPersistentObject(slideRecord);
    sp.setRefID(psrId);
    slideRecord.setSheetId(psrId);
   
    slide.setMasterSheet(_masters[0]);
    // All done and added
    return slide;
  }
View Full Code Here


     * Test read/write Macintosh PICT
     */
    public void testPICT() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        byte[] src_bytes = slTests.readFile("cow.pict");
        int idx = ppt.addPicture(src_bytes, Picture.PICT);
        Picture pict = new Picture(idx);
        assertEquals(idx, pict.getPictureIndex());
        slide.addShape(pict);

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

     * Test read/write WMF
     */
    public void testWMF() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        byte[] src_bytes = slTests.readFile("santa.wmf");
        int idx = ppt.addPicture(src_bytes, Picture.WMF);
        Picture pict = new Picture(idx);
        assertEquals(idx, pict.getPictureIndex());
        slide.addShape(pict);

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

     * Test read/write EMF
     */
    public void testEMF() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        byte[] src_bytes = slTests.readFile("wrench.emf");
        int idx = ppt.addPicture(src_bytes, Picture.EMF);

        Picture pict = new Picture(idx);
        assertEquals(idx, pict.getPictureIndex());
        slide.addShape(pict);

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

     * Test read/write PNG
     */
    public void testPNG() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        byte[] src_bytes = slTests.readFile("tomcat.png");
        int idx = ppt.addPicture(src_bytes, Picture.PNG);
        Picture pict = new Picture(idx);
        assertEquals(idx, pict.getPictureIndex());
        slide.addShape(pict);

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

     * Test read/write JPEG
     */
    public void testJPEG() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        byte[] src_bytes = slTests.readFile("clock.jpg");
        int idx = ppt.addPicture(src_bytes, Picture.JPEG);

        Picture pict = new Picture(idx);
        assertEquals(idx, pict.getPictureIndex());
        slide.addShape(pict);

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

     * Test read/write DIB
     */
    public void testDIB() throws Exception {
        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();
        byte[] src_bytes = slTests.readFile("clock.dib");
        int idx = ppt.addPicture(src_bytes, Picture.DIB);
        Picture pict = new Picture(idx);
        assertEquals(idx, pict.getPictureIndex());
        slide.addShape(pict);

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

    }

    public void testGetPictureName() throws Exception {
        SlideShow ppt = new SlideShow(slTests.openResourceAsStream("ppt_with_png.ppt"));
        Slide slide = ppt.getSlides()[0];

        Picture p = (Picture)slide.getShapes()[0]; //the first slide contains JPEG
        assertEquals("test", p.getPictureName());
    }
View Full Code Here

    }

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

        Slide slide = ppt.createSlide();
        byte[] img = slTests.readFile("tomcat.png");
        int idx = ppt.addPicture(img, Picture.PNG);
        Picture pict = new Picture(idx);
        pict.setPictureName("tomcat.png");
        slide.addShape(pict);

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

        SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("43781.ppt"));

        assertTrue("No Exceptions while reading file", true);

        // Check the first slide
        Slide slide = ppt.getSlides()[0];
        TextRun[] slTr = slide.getTextRuns();
       
        // Has two text runs, one from slide text, one from drawing
        assertEquals(2, slTr.length);
        assertEquals(false, slTr[0].isDrawingBased());
        assertEquals(true, slTr[1].isDrawingBased());
        assertEquals("First run", slTr[0].getText());
        assertEquals("Second run", slTr[1].getText());

        // Check the shape based text runs
        List<TextRun> lst = new ArrayList<TextRun>();
        Shape[] shape = slide.getShapes();
        for (int i = 0; i < shape.length; i++) {
            if( shape[i] instanceof TextShape){
                TextRun textRun = ((TextShape)shape[i]).getTextRun();
                if(textRun != null) {
                    lst.add(textRun);
View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.model.Slide

Copyright © 2018 www.massapicom. 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.