Package org.apache.poi.hslf

Examples of org.apache.poi.hslf.HSLFSlideShow


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

        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));

        //make sure we can read this picture shape and it refers to the correct picture data
        Shape[] sh = ppt.getSlides()[0].getShapes();
        assertEquals(1, sh.length);
        pict = (Picture)sh[0];
View Full Code Here


  /**
   * Test that on a party corrupt powerpoint document, which has
   *  crazy pictures of type 0, we do our best.
   */
  public void testZeroPictureType() throws Exception {
    HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("PictureTypeZero.ppt"));

    // Should still have 2 real pictures
    assertEquals(2, hslf.getPictures().length);
    // Both are real pictures, both WMF
    assertEquals(Picture.WMF, hslf.getPictures()[0].getType());
    assertEquals(Picture.WMF, hslf.getPictures()[1].getType());

    // Now test what happens when we use the SlideShow interface
    SlideShow ppt = new SlideShow(hslf);
        Slide[] slides = ppt.getSlides();
        PictureData[] pictures = ppt.getPictureData();
View Full Code Here

     * See "Please remove my file from your svn" on @poi-dev from Dec 12, 2013
     */
  public void disabled_testZeroPictureLength() throws Exception {
        // take the data from www instead of test directory
        URL url = new URL("http://www.cs.sfu.ca/~anoop/courses/CMPT-882-Fall-2002/chris.ppt");
    HSLFSlideShow hslf = new HSLFSlideShow(url.openStream());

    // Should still have 2 real pictures
    assertEquals(2, hslf.getPictures().length);
    // Both are real pictures, both WMF
    assertEquals(Picture.WMF, hslf.getPictures()[0].getType());
    assertEquals(Picture.WMF, hslf.getPictures()[1].getType());

    // Now test what happens when we use the SlideShow interface
    SlideShow ppt = new SlideShow(hslf);
        Slide[] slides = ppt.getSlides();
        PictureData[] pictures = ppt.getPictureData();
        assertEquals(27, slides.length);
        assertEquals(2, pictures.length);

    Picture pict;
    PictureData pdata;

        pict = (Picture)slides[6].getShapes()[13];
        pdata = pict.getPictureData();
        assertTrue(pdata instanceof WMF);
        assertEquals(Picture.WMF, pdata.getType());

        pict = (Picture)slides[7].getShapes()[13];
        pdata = pict.getPictureData();
        assertTrue(pdata instanceof WMF);
        assertEquals(Picture.WMF, pdata.getType());

        //add a new picture, it should be correctly appended to the Pictures stream
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        for(PictureData p : pictures) p.write(out);
        out.close();

        int streamSize = out.size();

        PictureData data = PictureData.create(Picture.JPEG);
        data.setData(new byte[100]);
        int offset = hslf.addPicture(data);
        assertEquals(streamSize, offset);
        assertEquals(3, ppt.getPictureData().length);

    }
View Full Code Here

    /**
     * Bug 41384: Array index wrong in record creation
     */
    @Test
    public void bug41384() throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("41384.ppt"));

        SlideShow ppt = new SlideShow(hslf);
        assertTrue("No Exceptions while reading file", true);

        assertEquals(1, ppt.getSlides().length);
View Full Code Here

     * First fix from Bug 42474: NPE in RichTextRun.isBold()
     * when the RichTextRun comes from a Notes model object
     */
    @Test
    public void bug42474_1() throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42474-1.ppt"));

        SlideShow ppt = new SlideShow(hslf);
        assertTrue("No Exceptions while reading file", true);
        assertEquals(2, ppt.getSlides().length);

View Full Code Here

    /**
     * Second fix from Bug 42474: Incorrect matching of notes to slides
     */
    @Test
    public void bug42474_2() throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42474-2.ppt"));

        SlideShow ppt = new SlideShow(hslf);

        //map slide number and starting phrase of its notes
        Map<Integer, String> notesMap = new HashMap<Integer, String>();
View Full Code Here

    /**
     * Bug 42485: All TextBoxes inside ShapeGroups have null TextRuns
     */
    @Test
    public void bug42485 () throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42485.ppt"));

        SlideShow ppt = new SlideShow(hslf);
        Shape[] shape = ppt.getSlides()[0].getShapes();
        for (int i = 0; i < shape.length; i++) {
            if(shape[i] instanceof ShapeGroup){
View Full Code Here

    /**
     * Bug 42484: NullPointerException from ShapeGroup.getAnchor()
     */
    @Test
    public void bug42484 () throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42485.ppt"));

        SlideShow ppt = new SlideShow(hslf);
        Shape[] shape = ppt.getSlides()[0].getShapes();
        for (int i = 0; i < shape.length; i++) {
            if(shape[i] instanceof ShapeGroup){
View Full Code Here

    /**
     * Bug 41381: Exception from Slide.getMasterSheet() on a seemingly valid PPT file
     */
    @Test
    public void bug41381() throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("alterman_security.ppt"));

        SlideShow ppt = new SlideShow(hslf);
        assertTrue("No Exceptions while reading file", true);

        assertEquals(1, ppt.getSlidesMasters().length);
View Full Code Here

    /**
     * Bug 42486:  Failure parsing a seemingly valid PPT
     */
    @Test
    public void bug42486 () throws Exception {
        HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42486.ppt"));

        SlideShow ppt = new SlideShow(hslf);
        Slide[] slide = ppt.getSlides();
        for (int i = 0; i < slide.length; i++) {
            @SuppressWarnings("unused")
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.