Examples of HWPFDocument


Examples of org.apache.poi.hwpf.HWPFDocument

  private String dirname;

  protected void setUp() throws Exception {
    dirname = System.getProperty("HWPF.testdata.path");
    u = new HWPFDocument(
        new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc"))
    );
    a = new HWPFDocument(
        new FileInputStream(new File(dirname, "SampleDoc.doc"))
    );
  }
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(3, section.numParagraphs());
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * Test that we can insert text in our CharacterRun with Unicode text.
   */
  public void testRangeInsertion() throws Exception {

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

    /*
      Range range = daDoc.getRange();
      Section section = range.getSection(0);
      Paragraph para = section.getParagraph(2);
      String text = para.getCharacterRun(0).text() + para.getCharacterRun(1).text() +
      para.getCharacterRun(2).text();

      System.out.println(text);
    */

    Range range = new Range(insertionPoint, (insertionPoint + 2), daDoc);
    range.insertBefore(textToInsert);

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

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

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

Examples of org.apache.poi.hwpf.HWPFDocument

                    assertEquals(2, sheet.getRow(2).getCell(0).getNumericCellValue(), 0);
                    assertEquals(3, sheet.getRow(3).getCell(0).getNumericCellValue(), 0);
                    assertEquals(8, sheet.getRow(5).getCell(0).getNumericCellValue(), 0);
                } else if ("Document".equals(ole.getInstanceName())){
                    //creating a HWPF document
                    HWPFDocument doc = new HWPFDocument(data.getData());
                    String txt = doc.getRange().getParagraph(0).text();
                    assertEquals("OLE embedding is thoroughly unremarkable.\r", txt);
                }
            }

        }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    /**
     * two jpegs
     */
    public void testTwoImages() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/two_images.doc"));
      List pics = doc.getPicturesTable().getAllPictures();

      assertNotNull(pics);
      assertEquals(pics.size(), 2);
      for(int i=0; i<pics.size(); i++) {
        Object p = pics.get(i);
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    /**
     * pngs and jpegs
     */
    public void testDifferentImages() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/testPictures.doc"));
      List pics = doc.getPicturesTable().getAllPictures();

      assertNotNull(pics);
      assertEquals(7, pics.size());
      for(int i=0; i<pics.size(); i++) {
        Object p = pics.get(i);
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    /**
     * emf image, nice and simple
     */
    public void testEmfImage() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/vector_image.doc"));
      List pics = doc.getPicturesTable().getAllPictures();

      assertNotNull(pics);
      assertEquals(1, pics.size());

      Picture pic = (Picture)pics.get(0);
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

      assertEquals(0x80000000l, LittleEndian.getUInt(pic.getRawContent()));
      */
    }

    public void testPicturesWithTable() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(
          new File(dirname, "Bug44603.doc")));

      List pics = doc.getPicturesTable().getAllPictures();
      assertEquals(pics.size(), 2);
    }
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
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.