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 slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
      _records = _hslfSlideShow.getRecords();


      // Add the new Slide into the PersistPtr stuff
View Full Code Here


        SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));

        Slide[] slide = ppt.getSlides();
        for (int i = 0; i < slide.length; i++) {
            Slide sl = slide[i];
            Shape[] sh = sl.getShapes();
            for (int j = 0; j < sh.length; j++) {
                Shape shape = sh[j];
                if (shape instanceof Picture){
                    Picture picture = (Picture)shape;
View Full Code Here

        assertNotNull(pict);
    }

    public void testAddPictures() throws Exception {
        int idx;
        Slide slide;
        Picture pict;

        SlideShow ppt = new SlideShow();

        idx = ppt.addPicture(new File(dirname + "/clock.jpg"), Picture.JPEG);
        slide = ppt.createSlide();
        pict = new Picture(idx);
        slide.addShape(pict);

        idx = ppt.addPicture(new File(dirname + "/painting.png"), Picture.PNG);
        pict = new Picture(idx);
        slide.addShape(pict);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ppt.write(out);
        out.close();
View Full Code Here

  /**
   * Test the stuff about getting/setting bold
   *  on a non rich text run
   */
  public void testBoldNonRich() throws Exception {
    Slide slideOne = ss.getSlides()[0];
    TextRun[] textRuns = slideOne.getTextRuns();
    RichTextRun rtr = textRuns[0].getRichTextRuns()[0];
   
    assertNull(rtr._getRawCharacterStyle());
    assertNull(rtr._getRawParagraphStyle());
    assertFalse(rtr.isBold());
View Full Code Here

  /**
   * Test the stuff about getting/setting bold
   *  on a rich text run
   */
  public void testBoldRich() throws Exception {
    Slide slideOneR = ssRichA.getSlides()[0];
    TextRun[] textRunsR = slideOneR.getTextRuns();
    RichTextRun[] rtrs = textRunsR[1].getRichTextRuns();
    assertEquals(3, rtrs.length);
   
    assertTrue(rtrs[0].isBold());
    assertFalse(rtrs[1].isBold());
View Full Code Here

  /**
   * Tests getting and setting the font size on rich and non
   *  rich text runs
   */
  public void testFontSize() throws Exception {
    Slide slideOne = ss.getSlides()[0];
    TextRun[] textRuns = slideOne.getTextRuns();
    RichTextRun rtr = textRuns[0].getRichTextRuns()[0];
   
    Slide slideOneR = ssRichB.getSlides()[0];
    TextRun[] textRunsR = slideOneR.getTextRuns();
    RichTextRun rtrRa = textRunsR[0].getRichTextRuns()[0];
    RichTextRun rtrRb = textRunsR[1].getRichTextRuns()[0];
    RichTextRun rtrRc = textRunsR[1].getRichTextRuns()[3];

    // Start off with rich one
View Full Code Here

    HSLFSlideShow[] h = new HSLFSlideShow[] { hss, hssRichA, hssRichB };
    Slide[] s = new Slide[] { ss.getSlides()[0], ssRichA.getSlides()[0], ssRichB.getSlides()[0] };
   
    for(int i=0; i<h.length; i++) {
      // Change
      Slide slideOne = s[i];
      TextRun[] textRuns = slideOne.getTextRuns();
      RichTextRun rtr = textRuns[0].getRichTextRuns()[0];
     
      rtr.setBold(true);
      rtr.setFontSize(18);
      rtr.setFontName("Courier");
     
      // Check it took those
      assertEquals(true, rtr.isBold());
      assertEquals(18, rtr.getFontSize());
      assertEquals("Courier", rtr.getFontName());
     
      // Write out and back in
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      h[i].write(baos);
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
     
      HSLFSlideShow readHSLF = new HSLFSlideShow(bais);
      SlideShow readS = new SlideShow(readHSLF);
     
      // Tweak existing one again, to ensure really worked
      rtr.setBold(false);
      rtr.setFontSize(17);
      rtr.setFontName("CourierZZ");
     
      // Check it took those changes
      assertEquals(false, rtr.isBold());
      assertEquals(17, rtr.getFontSize());
      assertEquals("CourierZZ", rtr.getFontName());

     
      // Now, look at the one we changed, wrote out, and read back in
      // Ensure it does contain our original modifications
      Slide slideOneRR = readS.getSlides()[0];
      TextRun[] textRunsRR = slideOneRR.getTextRuns();
      RichTextRun rtrRRa = textRunsRR[0].getRichTextRuns()[0];
     
      assertEquals(true, rtrRRa.isBold());
      assertEquals(18, rtrRRa.getFontSize());
      assertEquals("Courier", rtrRRa.getFontName());
View Full Code Here

    // Check we have the right number of sheets
    Slide[] slides = ssRichC.getSlides();
    assertEquals(14, slides.length);
   
    // Check the number of text runs on interesting sheets
    Slide slideThreeC = ssRichC.getSlides()[2];
    Slide slideSevenC = ssRichC.getSlides()[6];
    assertEquals(3, slideThreeC.getTextRuns().length);
    assertEquals(5, slideSevenC.getTextRuns().length);
   
    // On slide three, we should have:
    // TR:
    //   You are an important supplier of various items that I need
    //   .
    // TR:
    //   Source: Internal focus groups
    // TR:
    //   Illustrative Example
    //   .
   
    TextRun[] s3tr = slideThreeC.getTextRuns();
    RichTextRun[] s3rtr0 = s3tr[0].getRichTextRuns();
    RichTextRun[] s3rtr1 = s3tr[1].getRichTextRuns();
    RichTextRun[] s3rtr2 = s3tr[2].getRichTextRuns();
   
    assertEquals(2, s3rtr0.length);
    assertEquals(1, s3rtr1.length);
    assertEquals(2, s3rtr2.length);
   
    assertEquals("You are an important supplier of various items that I need", s3rtr0[0].getText());
    assertEquals("", s3rtr0[1].getText());
    assertEquals("Source: Internal focus groups", s3rtr1[0].getText());
    assertEquals("Illustrative Example", s3rtr2[0].getText());
    assertEquals("", s3rtr2[1].getText());
   
    assertTrue(s3rtr0[0]._isParagraphStyleShared());
    assertTrue(s3rtr0[1]._isParagraphStyleShared());
    assertFalse(s3rtr1[0]._isParagraphStyleShared());
    assertTrue(s3rtr2[0]._isParagraphStyleShared());
    assertTrue(s3rtr2[1]._isParagraphStyleShared());
   
    assertFalse(s3rtr0[0]._isCharacterStyleShared());
    assertFalse(s3rtr0[1]._isCharacterStyleShared());
    assertFalse(s3rtr1[0]._isCharacterStyleShared());
    assertFalse(s3rtr2[0]._isCharacterStyleShared());
    assertFalse(s3rtr2[1]._isCharacterStyleShared());
   
    // On slide seven, we have:
    // TR:
    //  (text)
    // TR:
    //  <ps>(text a)</ps><ps>(text a)(text b)</ps>
    // TR:   
    //  (text)
    TextRun[] s7tr = slideSevenC.getTextRuns();
    RichTextRun[] s7rtr0 = s7tr[0].getRichTextRuns();
    RichTextRun[] s7rtr1 = s7tr[1].getRichTextRuns();
    RichTextRun[] s7rtr2 = s7tr[2].getRichTextRuns();
   
    assertEquals(1, s7rtr0.length);
View Full Code Here

   */
  public void testParagraphStylesShorterTheCharStylesWrite() throws Exception {
    assertMatchesSLTWC(ssRichC);
    assertMatchesFileC(ssRichC);
   
    Slide slideSevenC = ssRichC.getSlides()[6];
    TextRun[] s7tr = slideSevenC.getTextRuns();
    RichTextRun[] s7rtr0 = s7tr[0].getRichTextRuns();
    RichTextRun[] s7rtr1 = s7tr[1].getRichTextRuns();
    RichTextRun[] s7rtr2 = s7tr[2].getRichTextRuns();
   
    String oldText;
View Full Code Here

        else
          logger.log(POILogger.ERROR, "Notes not found for noteId=" + noteId);
      }

      // Now, build our slide
      _slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
      _slides[i].setSlideShow(this);
    }
  }
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.