Examples of Slide


Examples of org.apache.poi.hslf.model.Slide

        SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("43781.ppt"));

        assertTrue("No Exceptions while reading file", true);

        // Check the first slide
        Slide slide = ppt.getSlides()[0];
        TextRun[] slTr = slide.getTextRuns();
       
        // Has two text runs, one from slide text, one from drawing
        assertEquals(2, slTr.length);
        assertEquals(false, slTr[0].isDrawingBased());
        assertEquals(true, slTr[1].isDrawingBased());
        assertEquals("First run", slTr[0].getText());
        assertEquals("Second run", slTr[1].getText());

        // Check the shape based text runs
        List<TextRun> lst = new ArrayList<TextRun>();
        Shape[] shape = slide.getShapes();
        for (int i = 0; i < shape.length; i++) {
            if( shape[i] instanceof TextShape){
                TextRun textRun = ((TextShape)shape[i]).getTextRun();
                if(textRun != null) {
                    lst.add(textRun);
View Full Code Here

Examples of org.apache.poi.hslf.model.Slide

     */
    @Test
    public void bug44296  () throws Exception {
        SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("44296.ppt"));

        Slide slide = ppt.getSlides()[0];

        Background b = slide.getBackground();
        Fill f = b.getFill();
        assertEquals(Fill.FILL_PICTURE, f.getFillType());

        PictureData pict = f.getPictureData();
        assertNotNull(pict);
View Full Code Here

Examples of org.apache.poi.hslf.model.Slide

     */
    @Test
    public void bug41071() throws Exception {
        SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("41071.ppt"));

        Slide slide = ppt.getSlides()[0];
        Shape[] sh = slide.getShapes();
        assertEquals(1, sh.length);
        assertTrue(sh[0] instanceof TextShape);
        TextShape tx = (TextShape)sh[0];
        assertEquals("Fundera, planera och involvera.", tx.getTextRun().getText());

        TextRun[] run = slide.getTextRuns();
        assertEquals(1, run.length);
        assertEquals("Fundera, planera och involvera.", run[0].getText());
    }
View Full Code Here

Examples of org.apache.poi.hslf.model.Slide

    public static void main(String[] args) throws Exception {

        SlideShow ppt = new SlideShow();

        Slide slide = ppt.createSlide();

        TextBox shape = new TextBox();
        RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
        shape.setText(
                "January\r" +
                "February\r" +
                "March\r" +
                "April");
        rt.setFontSize(42);
        rt.setBullet(true);
        rt.setBulletOffset(0)//bullet offset
        rt.setTextOffset(50);   //text offset (should be greater than bullet offset)
        rt.setBulletChar('\u263A'); //bullet character
        slide.addShape(shape);

        shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300))//position of the text box in the slide
        slide.addShape(shape);

        FileOutputStream out = new FileOutputStream("bullets.ppt");
        ppt.write(out);
        out.close();
   }
View Full Code Here

Examples of org.apache.poi.hslf.model.Slide

            if (notesPos != null) notes = _notes[notesPos.intValue()];
            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

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);
      // 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();
      slideRecord.setSheetId(sp.getRefID());
      int slideRecordPos = _hslfSlideShow.appendRootLevelRecord(slideRecord);
      _records = _hslfSlideShow.getRecords();

      // Add the new Slide into the PersistPtr stuff
      int offset = 0;
      int slideOffset = 0;
      PersistPtrHolder ptr = null;
      UserEditAtom usr = null;
      for (int i = 0; i < _records.length; i++) {
        Record record = _records[i];
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        record.writeOut(out);
       
        // Grab interesting records as they come past
        if(_records[i].getRecordType() == RecordTypes.PersistPtrIncrementalBlock.typeID){
          ptr = (PersistPtrHolder)_records[i];
        }
        if(_records[i].getRecordType() == RecordTypes.UserEditAtom.typeID) {
          usr = (UserEditAtom)_records[i];
        }
       
        if(i == slideRecordPos) {
          slideOffset = offset;
        }
        offset += out.size();
      }
     
    // Add the new slide into the last PersistPtr
      // (Also need to tell it where it is)
    slideRecord.setLastOnDiskOffset(slideOffset);
    ptr.addSlideLookup(sp.getRefID(), slideOffset);
    logger.log(POILogger.INFO, "New slide ended up at " + slideOffset);

    // Last view is now of the slide
      usr.setLastViewType((short)UserEditAtom.LAST_VIEW_SLIDE_VIEW);
      usr.setMaxPersistWritten(_highestSheetId);

      // All done and added
      slide.setSlideShow(this);
      return slide;
  }
View Full Code Here

Examples of org.apache.poi.hslf.model.Slide

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

Examples of org.apache.poi.hslf.model.Slide

   * Tests getting and setting the font size on rich and non
   *  rich text runs
   */
  public void testFontSize() throws Exception {
    SlideMaster master;
        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];

        String defaultFont = "Arial";
View Full Code Here

Examples of org.apache.poi.hslf.model.Slide

    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

Examples of org.apache.poi.hslf.model.Slide

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