Package org.apache.poi.hwpf.usermodel

Examples of org.apache.poi.hwpf.usermodel.Range


          // These are \u0008 escher floating ones, ones
          //  found outside the normal text, and who
          //  knows what else...
          nonU1based = new ArrayList<Picture>();
          nonU1based.addAll(all);
          Range r = doc.getRange();
          for(int i=0; i<r.numCharacterRuns(); i++) {
             CharacterRun cr = r.getCharacterRun(i);
             if(picturesTable.hasPicture(cr)) {
                Picture p = getFor(cr);
                int at = nonU1based.indexOf(p);
                nonU1based.set(at, null);
             }
View Full Code Here


        //  placed or referenced from an anchor
        PicturesTable pictureTable = document.getPicturesTable();
        PicturesSource pictures = new PicturesSource(document);
       
        // Do the main paragraph text
        Range r = document.getRange();
        for(int i=0; i<r.numParagraphs(); i++) {
           Paragraph p = r.getParagraph(i);
           i += handleParagraph(p, 0, r, document, pictures, pictureTable, xhtml);
        }

        // Do everything else
        for (String paragraph: wordExtractor.getMainTextboxText()) {
View Full Code Here

          // These are \u0008 escher floating ones, ones
          //  found outside the normal text, and who
          //  knows what else...
          nonU1based = new ArrayList<Picture>();
          nonU1based.addAll(all);
          Range r = doc.getRange();
          for(int i=0; i<r.numCharacterRuns(); i++) {
             CharacterRun cr = r.getCharacterRun(i);
             if(picturesTable.hasPicture(cr)) {
                Picture p = getFor(cr);
                int at = nonU1based.indexOf(p);
                nonU1based.set(at, null);
             }
View Full Code Here

                        is.close();
                        out.close();
                    } else if ("Document".equals(name)) {
                        HWPFDocument doc = new HWPFDocument(data.getData());
                        //read the word document
                        Range r = doc.getRange();     
                        for(int k = 0; k < r.numParagraphs(); k++) {
                            Paragraph p = r.getParagraph(k);
                            System.out.println(p.text());
                         }

                        //save on disk
                        FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc");
View Full Code Here

  public String[] getParagraphText() {
    String[] ret;
   
    // Extract using the model code
    try {
        Range r = doc.getRange();

      ret = new String[r.numParagraphs()];
      for(int i=0; i<ret.length; i++) {
        Paragraph p = r.getParagraph(i);
        ret[i] = p.text();
       
        // Fix the line ending
        if(ret[i].endsWith("\r")) {
          ret[i] = ret[i] + "\n";
View Full Code Here

   * @return a list of Picture objects found in current document
   */
  public List getAllPictures() {
    ArrayList pictures = new ArrayList();
 
    Range range = _document.getRange();
    for (int i = 0; i < range.numCharacterRuns(); i++) {
      CharacterRun run = range.getCharacterRun(i);
      String text = run.text();
      int j = text.charAt(0);
      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
View Full Code Here

   
    /**
     * Test model based extraction
     */
    public void testExtractFromModel() {
      Range r = doc.getRange();
     
      String[] text = new String[r.numParagraphs()];
      for(int i=0; i < r.numParagraphs(); i++) {
        Paragraph p = r.getParagraph(i);
        text[i] = p.text();
      }
     
      assertEquals(p_text.length, text.length);
      for(int i=0; i<p_text.length; i++) {
View Full Code Here

  public String[] getParagraphText() {
    String[] ret;
   
    // Extract using the model code
    try {
        Range r = doc.getRange();

      ret = new String[r.numParagraphs()];
      for(int i=0; i<ret.length; i++) {
        Paragraph p = r.getParagraph(i);
        ret[i] = p.text();
       
        // Fix the line ending
        if(ret[i].endsWith("\r")) {
          ret[i] = ret[i] + "\n";
View Full Code Here

   * @return a list of Picture objects found in current document
   */
  public List getAllPictures() {
    ArrayList pictures = new ArrayList();
 
    Range range = _document.getRange();
    for (int i = 0; i < range.numCharacterRuns(); i++) {
      CharacterRun run = range.getCharacterRun(i);
      String text = run.text();
      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
      }
View Full Code Here

        docAscii._cpSplit.getHeaderStoryEnd()
    );
  }

  public void testContents() {
    Range r;

    // Now check the real ranges
    r = docAscii.getRange();
    assertEquals(
        a_page_1 +
        page_break + "\r" +
        a_page_2,
        r.text()
    );

    r = docAscii.getHeaderStoryRange();
    assertEquals(
        headerDef +
        a_header +
        footerDef +
        a_footer +
        endHeaderFooter,
        r.text()
    );

    r = docAscii.getOverallRange();
    assertEquals(
        a_page_1 +
        page_break + "\r" +
        a_page_2 +
        headerDef +
        a_header +
        footerDef +
        a_footer +
        endHeaderFooter +
        "\r",
        r.text()
    );
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hwpf.usermodel.Range

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.