Examples of SlideShow


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

    /**
     * Add 3 slides to an empty ppt
     * @throws Exception
     */
    public void testAddSlides3() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") ));
        assertTrue(ppt.getSlides().length == 0);
       
        Slide s1 = ppt.createSlide();
        assertTrue(ppt.getSlides().length == 1);
        assertEquals(3, s1._getSheetRefId());
        assertEquals(256, s1._getSheetNumber());
        assertEquals(1, s1.getSlideNumber());
       
        Slide s2 = ppt.createSlide();
        assertTrue(ppt.getSlides().length == 2);
        assertEquals(4, s2._getSheetRefId());
        assertEquals(257, s2._getSheetNumber());
        assertEquals(2, s2.getSlideNumber());

        Slide s3 = ppt.createSlide();
        assertTrue(ppt.getSlides().length == 3);
        assertEquals(5, s3._getSheetRefId());
        assertEquals(258, s3._getSheetNumber());
        assertEquals(3, s3.getSlideNumber());

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

        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
        assertTrue(ppt.getSlides().length == 3);
       
        // Check IDs are still right
        s1 = ppt.getSlides()[0];
        assertEquals(256, s1._getSheetNumber());
        assertEquals(3, s1._getSheetRefId());
        s2 = ppt.getSlides()[1];
        assertEquals(257, s2._getSheetNumber());
        assertEquals(4, s2._getSheetRefId());
        s3 = ppt.getSlides()[2];;
        assertTrue(ppt.getSlides().length == 3);
        assertEquals(258, s3._getSheetNumber());
        assertEquals(5, s3._getSheetRefId());
    }
View Full Code Here

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

    /**
     * Add slides to ppt which already has two slides
     */
    public void testAddSlides2to3() throws Exception {
    String dirname = System.getProperty("HSLF.testdata.path");
        SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname + "/basic_test_ppt_file.ppt"));
       
        assertTrue(ppt.getSlides().length == 2);
       
        // First slide is 256 / 4
        Slide s1 = ppt.getSlides()[0];
        assertEquals(256, s1._getSheetNumber());
        assertEquals(4, s1._getSheetRefId());
       
        // Last slide is 257 / 6
        Slide s2 = ppt.getSlides()[1];
        assertEquals(257, s2._getSheetNumber());
        assertEquals(6, s2._getSheetRefId());
       
        // Add another slide, goes in at the end
        Slide s3 = ppt.createSlide();
        assertTrue(ppt.getSlides().length == 3);
        assertEquals(258, s3._getSheetNumber());
        assertEquals(8, s3._getSheetRefId());

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

        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
        assertTrue(ppt.getSlides().length == 3);
       
       
        // Check IDs are still right
        s1 = ppt.getSlides()[0];
        assertEquals(256, s1._getSheetNumber());
        assertEquals(4, s1._getSheetRefId());
        s2 = ppt.getSlides()[1];
        assertEquals(257, s2._getSheetNumber());
        assertEquals(6, s2._getSheetRefId());
        s3 = ppt.getSlides()[2];;
        assertTrue(ppt.getSlides().length == 3);
        assertEquals(258, s3._getSheetNumber());
        assertEquals(8, s3._getSheetRefId());
    }
View Full Code Here

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

    /**
     * The reference ppt has two masters.
     * Check we can read their attributes.
     */
    public void testSlideMaster() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(home + "/slide_master.ppt"));

        Environment env = ppt.getDocumentRecord().getEnvironment();

        SlideMaster[] master = ppt.getSlidesMasters();
        assertEquals(2, master.length);

        //character attributes
        assertEquals(40, master[0].getStyleAttribute(TextHeaderAtom.TITLE_TYPE, 0, "font.size", true).getValue());
        assertEquals(48, master[1].getStyleAttribute(TextHeaderAtom.TITLE_TYPE, 0, "font.size", true).getValue());
View Full Code Here

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

    /**
     * If a style attribute is not set ensure it is read from the master
     */
    public void testMasterAttributes() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(home + "/slide_master.ppt"));
        Slide[] slide = ppt.getSlides();
        assertEquals(2, slide.length);
        TextRun[] trun;

        trun = slide[0].getTextRuns();
        for (int i = 0; i < trun.length; i++) {
View Full Code Here

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

    /**
     * Check we can dynamically assign a slide master to a slide.
     */
    public void testChangeSlideMaster() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(home + "/slide_master.ppt"));
        SlideMaster[] master = ppt.getSlidesMasters();
        Slide[] slide = ppt.getSlides();
        int sheetNo;

        //each slide uses its own master
        assertEquals(slide[0].getMasterSheet()._getSheetNumber(), master[0]._getSheetNumber());
        assertEquals(slide[1].getMasterSheet()._getSheetNumber(), master[1]._getSheetNumber());

        //all slides use the first master slide
        sheetNo = master[0]._getSheetNumber();
        for (int i = 0; i < slide.length; i++) {
            slide[i].setMasterSheet(master[0]);
        }

        ByteArrayOutputStream out;

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

        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
        master = ppt.getSlidesMasters();
        slide = ppt.getSlides();
        for (int i = 0; i < slide.length; i++) {
            assertEquals(sheetNo, slide[i].getMasterSheet()._getSheetNumber());
        }
    }
View Full Code Here

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

    /**
     * Varify we can read attrubutes for different identtation levels.
     * (typical for the "bullted body" placeholder)
     */
    public void testIndentation() throws Exception {
        SlideShow ppt = new SlideShow(new HSLFSlideShow(home + "/slide_master.ppt"));
        Slide slide = ppt.getSlides()[0];
        TextRun[] trun;

        trun = slide.getTextRuns();
        for (int i = 0; i < trun.length; i++) {
            if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){
View Full Code Here

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

      // 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

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

    public PictureData getPictureData(){
        EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID);
        EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
        if (p == null) return null;

        SlideShow ppt = shape.getSheet().getSlideShow();
        PictureData[] pict = ppt.getPictureData();
        Document doc = ppt.getDocumentRecord();

        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);

        java.util.List lst = bstore.getChildRecords();
View Full Code Here

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

   
   protected void parse(
         DirectoryNode root, XHTMLContentHandler xhtml)
         throws IOException, SAXException, TikaException {
      HSLFSlideShow ss = new HSLFSlideShow(root);
      SlideShow _show = new SlideShow(ss);
      Slide[] _slides = _show.getSlides();

      xhtml.startElement("div", "class", "slideShow");

      /* Iterate over slides and extract text */
      for( Slide slide : _slides ) {
         xhtml.startElement("div", "class", "slide");

         // Slide header, if present
         HeadersFooters hf = slide.getHeadersFooters();
         if (hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
            xhtml.startElement("p", "class", "slide-header");

            xhtml.characters( hf.getHeaderText() );

            xhtml.endElement("p");
         }

         // Slide master, if present
         extractMaster(xhtml, slide.getMasterSheet());

         // Slide text
         {
            xhtml.startElement("p", "class", "slide-content");

            textRunsToText(xhtml, slide.getTextRuns());

            xhtml.endElement("p");
         }

         // Table text
         for (Shape shape: slide.getShapes()){
            if (shape instanceof Table){
               extractTableText(xhtml, (Table)shape);
            }
         }

         // Slide footer, if present
         if (hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
            xhtml.startElement("p", "class", "slide-footer");

            xhtml.characters( hf.getFooterText() );

            xhtml.endElement("p");
         }

         // Comments, if present
         for( Comment comment : slide.getComments() ) {
            xhtml.startElement("p", "class", "slide-comment");
            if (comment.getAuthor() != null) {
               xhtml.startElement("b");
               xhtml.characters( comment.getAuthor() );
               xhtml.endElement("b");
              
               if (comment.getText() != null) {
                  xhtml.characters( " - ");
               }
            }
            if (comment.getText() != null) {
               xhtml.characters( comment.getText() );
            }
            xhtml.endElement("p");
         }

         // Now any embedded resources
         handleSlideEmbeddedResources(slide, xhtml);

         // TODO Find the Notes for this slide and extract inline

         // Slide complete
         xhtml.endElement("div");
      }

      // All slides done
      xhtml.endElement("div");

      /* notes */
      xhtml.startElement("div", "class", "slideNotes");
      HashSet<Integer> seenNotes = new HashSet<Integer>();
      HeadersFooters hf = _show.getNotesHeadersFooters();

      for (Slide slide : _slides) {
         Notes notes = slide.getNotesSheet();
         if (notes == null) {
            continue;
View Full Code Here

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

   * @param ss the HSLFSlideShow to extract text from
   */
  public PowerPointExtractor(HSLFSlideShow ss) {
    super(ss);
    _hslfshow = ss;
    _show = new SlideShow(_hslfshow);
    _slides = _show.getSlides();
  }
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.