Examples of HWPFDocument


Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * Create a new Word Extractor
   * @param fs POIFSFileSystem containing the word file
   */
  public WordExtractor(POIFSFileSystem fs) throws IOException {
    this(new HWPFDocument(fs));
    this.fs = fs;
  }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * Test just opening the files
   */
  public void testOpen() throws Exception {

    HWPFDocument docA = new HWPFDocument(new FileInputStream(illustrativeDocFile));
  }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * Test (more "confirm" than test) that we have the general structure that we expect to have.
   */
  public void testDocStructure() throws Exception {

    HWPFDocument daDoc = new HWPFDocument(new FileInputStream(illustrativeDocFile));

    Range range = daDoc.getRange();

    assertEquals(1, range.numSections());
    Section section = range.getSection(0);

    assertEquals(5, section.numParagraphs());
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * Test that we can replace text in our Range with Unicode text.
   */
  public void testRangeReplacement() throws Exception {

    HWPFDocument daDoc = new HWPFDocument(new FileInputStream(illustrativeDocFile));

    Range range = daDoc.getRange();
    assertEquals(1, range.numSections());

    Section section = range.getSection(0);
    assertEquals(5, section.numParagraphs());

    Paragraph para = section.getParagraph(2);

    String text = para.text();
    assertEquals(originalText, text);

    int offset = text.indexOf(searchText);
    assertEquals(181, offset);

    para.replaceText(searchText, replacementText, offset);

    // we need to let the model re-calculate the Range before we evaluate it
    range = daDoc.getRange();

    assertEquals(1, range.numSections());
    section = range.getSection(0);

    assertEquals(5, section.numParagraphs());
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

 
    protected void setUp() throws Exception {
    String dirname = System.getProperty("HWPF.testdata.path");
   
    String filename = dirname + "/test2.doc";
    doc = new HWPFDocument(new FileInputStream(filename));
    }     
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    pfs = new POIFSFileSystem(fisHSLF);
    doc = new HSLFSlideShow(pfs);
   
    FileInputStream fisHWPF = new FileInputStream(filenameHWPF);
    pfs2 = new POIFSFileSystem(fisHWPF);
    doc2 = new HWPFDocument(pfs2);
  }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

         if (is.available() == 0)
         {
            return "";
         }
        
         HWPFDocument doc;
         try
         {
            doc = new HWPFDocument(is);
         }
         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

Examples of org.apache.poi.hwpf.HWPFDocument

    }

    protected void parse(
            DirectoryNode root, XHTMLContentHandler xhtml)
            throws IOException, SAXException, TikaException {
        HWPFDocument document;
        try {
            document = new HWPFDocument(root);
        } catch(OldWordFileFormatException e) {
            parseWord6(root, xhtml);
            return;
        }
        org.apache.poi.hwpf.extractor.WordExtractor wordExtractor =
            new org.apache.poi.hwpf.extractor.WordExtractor(document);
        HeaderStories headerFooter = new HeaderStories(document);

        // Grab the list of pictures. As far as we can tell,
        //  the pictures should be in order, and may be directly
        //  placed or referenced from an anchor
        PicturesTable pictureTable = document.getPicturesTable();
        PicturesSource pictures = new PicturesSource(document);

        // Do any headers, if present
        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);
        }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

         if (is.available() == 0)
         {
            return "";
         }
        
         HWPFDocument doc;
         try
         {
            doc = SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<HWPFDocument>()
            {
               public HWPFDocument run() throws Exception
               {
                  return new HWPFDocument(is);
               }
            });
         }
         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

Examples of org.apache.poi.hwpf.HWPFDocument

         throw new NullPointerException("InputStream is null.");
      }
      String text = "";
      try
      {
         HWPFDocument doc;
         try
         {
            doc = new HWPFDocument(is);
         }
         catch (IOException e)
         {
            return "";
         }

         Range range = doc.getRange();
         text = range.text();
      }
      finally
      {
         if (is != null)
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.