Package org.apache.poi.hslf

Examples of org.apache.poi.hslf.HSLFSlideShow


    /**
     * Bug 42524:  NPE in Shape.getShapeType()
     */
    public void test42524 () throws Exception {
        FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt")); //test file is the same as for Bug 42486
        HSLFSlideShow hslf = new HSLFSlideShow(is);
        is.close();

        SlideShow ppt = new SlideShow(hslf);
        //walk down the tree and see if there were no errors while reading
        Slide[] slide = ppt.getSlides();
View Full Code Here


    /**
     * Bug 42520:  NPE in Picture.getPictureData()
     */
    public void test42520 () throws Exception {
        FileInputStream is = new FileInputStream(new File(cwd, "42520.ppt")); //test file is the same as for Bug 42486
        HSLFSlideShow hslf = new HSLFSlideShow(is);
        is.close();

        SlideShow ppt = new SlideShow(hslf);

        //test case from the bug report
View Full Code Here

    public void testExtractFromEmbeded() throws Exception {
      String filename3 = pdirname + "/excel_with_embeded.xls";
      POIFSFileSystem fs = new POIFSFileSystem(
          new FileInputStream(filename3)
      );
      HSLFSlideShow ss;
     
      DirectoryNode dirA = (DirectoryNode)
        fs.getRoot().getEntry("MBD0000A3B6");
    DirectoryNode dirB = (DirectoryNode)
      fs.getRoot().getEntry("MBD0000A3B3");
   
    assertNotNull(dirA.getEntry("PowerPoint Document"));
    assertNotNull(dirB.getEntry("PowerPoint Document"));
     
    // Check the first file
      ss = new HSLFSlideShow(dirA, fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
        ppe.getText(true, false)
    );

    // And the second
      ss = new HSLFSlideShow(dirB, fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n",
        ppe.getText(true, false)
    );
    }
View Full Code Here

    public void DISABLEDtestExtractFromOwnEmbeded() throws Exception {
      String filename3 = pdirname + "/ppt_with_embeded.ppt";
      POIFSFileSystem fs = new POIFSFileSystem(
          new FileInputStream(filename3)
      );
      HSLFSlideShow ss;
     
      DirectoryNode dirA = (DirectoryNode)
        fs.getRoot().getEntry("MBD0000A3B6");
    DirectoryNode dirB = (DirectoryNode)
      fs.getRoot().getEntry("MBD0000A3B3");
   
    assertNotNull(dirA.getEntry("PowerPoint Document"));
    assertNotNull(dirB.getEntry("PowerPoint Document"));
     
    // Check the first file
      ss = new HSLFSlideShow(dirA, fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
        ppe.getText(true, false)
    );

    // And the second
      ss = new HSLFSlideShow(dirB, fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n",
        ppe.getText(true, false)
    );
   
   
    // Check the master doc two ways
      ss = new HSLFSlideShow(fs.getRoot(), fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("I have embeded files in me\n",
        ppe.getText(true, false)
    );
   
      ss = new HSLFSlideShow(fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("I have embeded files in me\n",
        ppe.getText(true, false)
    );
    }
View Full Code Here

    public void testHeaderFooter() throws Exception {
    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);
View Full Code Here

     * @throws Exception if an error occurs.
     */
    public void testOleEmbedding2003() throws Exception {
        String dirname = System.getProperty("HSLF.testdata.path");
        File file = new File(dirname, "ole2-embedding-2003.ppt");
        HSLFSlideShow slideShow = new HSLFSlideShow(new FileInputStream(file));
        // Placeholder EMFs for clients that don't support the OLE components.
        PictureData[] pictures = slideShow.getPictures();
        assertEquals("Should be two pictures", 2, pictures.length);
        //assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData());
        //assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData());

        // Actual embedded objects.
        ObjectData[] objects = slideShow.getEmbeddedObjects();
        assertEquals("Should be two objects", 2, objects.length);
        //assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData());
        //assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData());
    }
View Full Code Here

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

        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
        sl = ppt.getSlides()[0];

        txtbox = (TextBox)sl.getShapes()[0];
        rt = txtbox.getTextRun().getRichTextRuns()[0];
View Full Code Here

   */
  public SlideShowRecordDumper(String fileName, boolean verbose, boolean escher) throws IOException
  {
  optVerbose = verbose;
    optEscher = escher;
  doc = new HSLFSlideShow(fileName);
  }
View Full Code Here

    /**
     * Constructs a Powerpoint document from an input stream.
     */
    public SlideShow(InputStream inputStream) throws IOException {
      this(new HSLFSlideShow(inputStream));
    }
View Full Code Here

  /**
   * Creates a PowerPointExtractor, from an open POIFSFileSystem
   * @param fs the POIFSFileSystem containing the PowerPoint document
   */
  public PowerPointExtractor(POIFSFileSystem fs) throws IOException {
    this(new HSLFSlideShow(fs));
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.HSLFSlideShow

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.