Package org.apache.poi.hslf.usermodel

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


        sl = ppt.getSlides()[0];
        assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length);
    }

    public void testShapeId() throws IOException {
        SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();
        Shape shape = null;

        //EscherDgg is a document-level record which keeps track of the drawing groups
        EscherDggRecord dgg = ppt.getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
        EscherDgRecord dg = slide.getSheetContainer().getPPDrawing().getEscherDgRecord();

        int dggShapesUsed = dgg.getNumShapesSaved();   //total number of shapes in the ppt
        int dggMaxId = dgg.getShapeIdMax();            //max number of shapeId
View Full Code Here

     * This is important when the same image appears multiple times in a slide show.
     *
     */
    public void testMultiplePictures() throws Exception {
        String cwd = System.getProperty("HSLF.testdata.path");
        SlideShow ppt = new SlideShow();

        Slide s = ppt.createSlide();
        Slide s2 = ppt.createSlide();
        Slide s3 = ppt.createSlide();

        int idx = ppt.addPicture(new File(cwd, "clock.jpg"), Picture.JPEG);
        Picture pict = new Picture(idx);
        Picture pict2 = new Picture(idx);
        Picture pict3 = new Picture(idx);

        pict.setAnchor(new Rectangle(10,10,100,100));
View Full Code Here

    /**
     * Picture#getEscherBSERecord threw NullPointerException if EscherContainerRecord.BSTORE_CONTAINER
     * was not found. The correct behaviour is to return null.
     */
    public void test46122() throws IOException {
        SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();

        Picture pict = new Picture(-1); //index to non-existing picture data
        pict.setSheet(slide);
        PictureData data = pict.getPictureData();
        assertNull(data);
View Full Code Here

      // We need to identify and fix that first
      //assertSlideShowWritesOutTheSame(hssB, pfsB);
    }
    public void assertSlideShowWritesOutTheSame(HSLFSlideShow hss, POIFSFileSystem pfs) throws Exception {
      // Create a slideshow covering it
      SlideShow ss = new SlideShow(hss);
      ss.getSlides();
      ss.getNotes();

    // Now write out to a byte array
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    hss.write(baos);
View Full Code Here

     * Returns the picture data for this picture.
     *
     * @return the picture data for this picture.
     */
    public PictureData getPictureData(){
        SlideShow ppt = getSheet().getSlideShow();
        PictureData[] pict = ppt.getPictureData();

        EscherBSERecord bse = getEscherBSERecord();
        if (bse == null){
            logger.log(POILogger.ERROR, "no reference to picture data found ");
        } else {
View Full Code Here

        }
        return null;
    }

    protected EscherBSERecord getEscherBSERecord(){
        SlideShow ppt = getSheet().getSlideShow();
        Document doc = ppt.getDocumentRecord();
        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
        if(bstore == null) {
            logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
            return null;
View Full Code Here

    String filename, text;
   
    // With a header on the notes
    filename = dirname + "/45537_Header.ppt";
    HSLFSlideShow hslf = new HSLFSlideShow(new FileInputStream(filename));
    SlideShow ss = new SlideShow(hslf);
    assertNotNull(ss.getNotesHeadersFooters());
    assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getHeaderText());
   
    ppe = new PowerPointExtractor(hslf);

    text = ppe.getText();
    assertFalse("Unable to find expected word in text\n" + text, contains(text, "testdoc"));
        assertFalse("Unable to find expected word in text\n" + text, contains(text, "test phrase"));
       
        ppe.setNotesByDefault(true);
    text = ppe.getText();
    assertTrue("Unable to find expected word in text\n" + text, contains(text, "testdoc"));
        assertTrue("Unable to find expected word in text\n" + text, contains(text, "test phrase"));

       
    // And with a footer, also on notes
    filename = dirname + "/45537_Footer.ppt";
    hslf = new HSLFSlideShow(new FileInputStream(filename));
    ss = new SlideShow(hslf);
    assertNotNull(ss.getNotesHeadersFooters());
    assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getFooterText());
   
    ppe = new PowerPointExtractor(filename);

    text = ppe.getText();
    assertFalse("Unable to find expected word in text\n" + text, contains(text, "testdoc"));
View Full Code Here

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

    // Basic (non rich) test file
    String filename = dirname + "/basic_test_ppt_file.ppt";
    hss = new HSLFSlideShow(filename);
    ss = new SlideShow(hss);

    // Rich test file
    filename = dirname + "/Single_Coloured_Page.ppt";
    hssRich = new HSLFSlideShow(filename);
    ssRich = new SlideShow(hssRich);
  }
View Full Code Here

   *
   */
  public void testBug41015() throws Exception {
    RichTextRun[] rt;

    SlideShow ppt = new SlideShow(new HSLFSlideShow(System.getProperty("HSLF.testdata.path") + "/bug-41015.ppt"));
    Slide sl = ppt.getSlides()[0];
    TextRun[] txt = sl.getTextRuns();
    assertEquals(2, txt.length);

    rt = txt[0].getRichTextRuns();
    assertEquals(1, rt.length);
View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.usermodel.SlideShow

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.