Package org.apache.poi.hslf.model

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


      return (startPos+8);
    }

    // Otherwise, check the type to see if it's text
    long type = LittleEndian.getUShort(pptContents,startPos+2);
    TextRun trun = null;

    // TextBytesAtom
    if(type == 4008l) {
      TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tba);
    }
    // TextCharsAtom
    if(type == 4000l) {
      TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tca);
    }

    // If we found text, save it in the vector
    if(trun != null) {
      textV.add(trun.getText());
    }
   
    // Wind on by the atom length, and check we're not at the end
    int newPos = (startPos + 8 + len);
    if(newPos > (pptContents.length - 8)) {
View Full Code Here


      return (startPos+8);
    }

    // Otherwise, check the type to see if it's text
    long type = LittleEndian.getUShort(pptContents,startPos+2);
    TextRun trun = null;

    // TextBytesAtom
    if(type == RecordTypes.TextBytesAtom.typeID) {
      TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tba,(StyleTextPropAtom)null);
    }
    // TextCharsAtom
    if(type == RecordTypes.TextCharsAtom.typeID) {
      TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
    }

    // CString (doesn't go via a TextRun)
    if(type == RecordTypes.CString.typeID) {
      CString cs = (CString)Record.createRecordForType(type, pptContents, startPos, len+8);
      String text = cs.getText();

      // Ignore the ones we know to be rubbish
      if(text.equals("___PPT10")) {
      } else if(text.equals("Default Design")) {
      } else {
        textV.add(text);
      }
    }

    // If we found text via a TextRun, save it in the vector
    if(trun != null) {
      textV.add(trun.getText());
    }

    // Wind on by the atom length, and check we're not at the end
    int newPos = (startPos + 8 + len);
    if(newPos > (pptContents.length - 8)) {
View Full Code Here

      }

      // Slide text
      TextRun[] runs = slide.getTextRuns();
      for(int j=0; j<runs.length; j++) {
        TextRun run = runs[j];
        if(run != null) {
          String text = run.getText();
          ret.append(text);
          if(! text.endsWith("\n")) {
            ret.append("\n");
          }
        }
      }

      // Slide footer, if set
      if(hf != null && hf.isFooterVisible() && hf.getFooterText() != null) {
        ret.append(hf.getFooterText() + "\n");
      }

      // Comments, if requested and present
      if(getCommentText) {
        Comment[] comments = slide.getComments();
        for(int j=0; j<comments.length; j++) {
          ret.append(
              comments[j].getAuthor() +
              " - " +
              comments[j].getText() +
              "\n"
          );
        }
      }
    }
    if(getNoteText) {
      ret.append("\n");
    }
  }

  if(getNoteText) {
    // Not currently using _notes, as that can have the notes of
    //  master sheets in. Grab Slide list, then work from there,
    //  but ensure no duplicates
    HashSet seenNotes = new HashSet();
    HeadersFooters hf = _show.getNotesHeadersFooters();

    for(int i=0; i<_slides.length; i++) {
      Notes notes = _slides[i].getNotesSheet();
      if(notes == null) { continue; }
      Integer id = new Integer(notes._getSheetNumber());
      if(seenNotes.contains(id)) { continue; }
      seenNotes.add(id);

      // Repeat the Notes header, if set
      if(hf != null && hf.isHeaderVisible() && hf.getHeaderText() != null) {
        ret.append(hf.getHeaderText() + "\n");
      }

      // Notes text
      TextRun[] runs = notes.getTextRuns();
      if(runs != null && runs.length > 0) {
        for(int j=0; j<runs.length; j++) {
          TextRun run = runs[j];
          String text = run.getText();
          ret.append(text);
          if(! text.endsWith("\n")) {
            ret.append("\n");
          }
        }
View Full Code Here

      return (startPos+8);
    }

    // Otherwise, check the type to see if it's text
    long type = LittleEndian.getUShort(pptContents,startPos+2);
    TextRun trun = null;

    // TextBytesAtom
    if(type == RecordTypes.TextBytesAtom.typeID) {
      TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tba,(StyleTextPropAtom)null);
    }
    // TextCharsAtom
    if(type == RecordTypes.TextCharsAtom.typeID) {
      TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
    }

    // CString (doesn't go via a TextRun)
    if(type == RecordTypes.CString.typeID) {
      CString cs = (CString)Record.createRecordForType(type, pptContents, startPos, len+8);
      String text = cs.getText();

      // Ignore the ones we know to be rubbish
      if(text.equals("___PPT10")) {
      } else if(text.equals("Default Design")) {
      } else {
        textV.add(text);
      }
    }

    // If we found text via a TextRun, save it in the vector
    if(trun != null) {
      textV.add(trun.getText());
    }

    // Wind on by the atom length, and check we're not at the end
    int newPos = (startPos + 8 + len);
    if(newPos > (pptContents.length - 8)) {
View Full Code Here

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

        TextRun txrun;
        Notes notes;

        notes = ppt.getSlides()[0].getNotesSheet();
        assertNotNull(notes);
        txrun = notes.getTextRuns()[0];
        assertEquals("Notes-1", txrun.getRawText());
        assertEquals(false, txrun.getRichTextRuns()[0].isBold());

        //notes for the second slide are in bold
        notes = ppt.getSlides()[1].getNotesSheet();
        assertNotNull(notes);
        txrun = notes.getTextRuns()[0];
        assertEquals("Notes-2", txrun.getRawText());
        assertEquals(true, txrun.getRichTextRuns()[0].isBold());

    }
View Full Code Here

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

                if (!str.contains("$$DATE$$")) continue;
                str = str.replace("$$DATE$$", new Date().toString());
                tb.setText(str);
               
                TextRun tr = tb.getTextRun();
                assertEquals(str.length()+1,tr.getStyleTextPropAtom().getParagraphStyles().getFirst().getCharactersCovered());
                assertEquals(str.length()+1,tr.getStyleTextPropAtom().getCharacterStyles().getFirst().getCharactersCovered());
            }
        }
    }
View Full Code Here

      return (startPos+8);
    }

    // Otherwise, check the type to see if it's text
    long type = LittleEndian.getUShort(pptContents,startPos+2);
    TextRun trun = null;

    // TextBytesAtom
    if(type == RecordTypes.TextBytesAtom.typeID) {
      TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tba,(StyleTextPropAtom)null);
    }
    // TextCharsAtom
    if(type == RecordTypes.TextCharsAtom.typeID) {
      TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
      trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
    }
   
    // CString (doesn't go via a TextRun)
    if(type == RecordTypes.CString.typeID) {
      CString cs = (CString)Record.createRecordForType(type, pptContents, startPos, len+8);
      String text = cs.getText();
     
      // Ignore the ones we know to be rubbish
      if(text.equals("___PPT10")) {
      } else if(text.equals("Default Design")) {
      } else {
        textV.add(text);
      }
    }

    // If we found text via a TextRun, save it in the vector
    if(trun != null) {
      textV.add(trun.getText());
    }
   
    // Wind on by the atom length, and check we're not at the end
    int newPos = (startPos + 8 + len);
    if(newPos > (pptContents.length - 8)) {
View Full Code Here

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

        TextRun txrun;
        Notes notes;

        notes = ppt.getSlides()[0].getNotesSheet();
        assertNotNull(notes);
        txrun = notes.getTextRuns()[0];
        assertEquals("Notes-1", txrun.getRawText());
        assertEquals(false, txrun.getRichTextRuns()[0].isBold());

        //notes for the second slide are in bold
        notes = ppt.getSlides()[1].getNotesSheet();
        assertNotNull(notes);
        txrun = notes.getTextRuns()[0];
        assertEquals("Notes-2", txrun.getRawText());
        assertEquals(true, txrun.getRichTextRuns()[0].isBold());

    }
View Full Code Here

        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

TOP

Related Classes of org.apache.poi.hslf.model.TextRun

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.