Package org.apache.poi.hwpf.usermodel

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


  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


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

         catch (IOException e)
         {
            throw new DocumentReadException("Can't open document.", e);
         }

         Range range = doc.getRange();
         text = range.text();
      }
      finally
      {
         if (is != null)
         {
View Full Code Here

        Range[] headers = new Range[] { headerFooter.getFirstHeaderSubrange(),
                headerFooter.getEvenHeaderSubrange(), headerFooter.getOddHeaderSubrange() };
        handleHeaderFooter(headers, "header", document, pictures, pictureTable, xhtml);

        // 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, FieldsDocumentPart.MAIN, 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

         catch (IOException e)
         {
            throw new DocumentReadException("Can't open document.", e);
         }

         Range range = doc.getRange();
         text = range.text();
      }
      finally
      {
         if (is != null)
         {
View Full Code Here

         catch (IOException e)
         {
            return "";
         }

         Range range = doc.getRange();
         text = range.text();
      }
      finally
      {
         if (is != null)
            try
View Full Code Here

        docAscii._cpSplit.getHeaderStoryEnd()
    );
  }

  public void testContents() throws Exception {
    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

        docUnicode._cpSplit.getHeaderStoryEnd()
    );
  }

  public void testContentsUnicode() throws Exception {
    Range r;

    // Now check the real ranges
    r = docUnicode.getRange();
    assertEquals(
        u_page_1 +
        page_break + "\r" +
        u_page_2,
        r.text()
    );

    r = docUnicode.getHeaderStoryRange();
    assertEquals(
        headerDef +
        u_header +
        footerDef +
        u_footer +
        endHeaderFooter,
        r.text()
    );

    r = docUnicode.getOverallRange();
    assertEquals(
        u_page_1 +
        page_break + "\r" +
        u_page_2 +
        headerDef +
        u_header +
        footerDef +
        u_footer +
        endHeaderFooter +
        "\r",
        r.text()
    );
  }
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

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.