Examples of HWPFDocument


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

  private HWPFDocument withFields;

    protected void setUp() throws Exception {
    String dirname = System.getProperty("HWPF.testdata.path");

    none = new HWPFDocument(
        new FileInputStream(new File(dirname, "NoHeadFoot.doc"))
    );
    header = new HWPFDocument(
        new FileInputStream(new File(dirname, "ThreeColHead.doc"))
    );
    footer = new HWPFDocument(
        new FileInputStream(new File(dirname, "ThreeColFoot.doc"))
    );
    headerFooter = new HWPFDocument(
        new FileInputStream(new File(dirname, "SimpleHeadThreeColFoot.doc"))
    );
    oddEven = new HWPFDocument(
        new FileInputStream(new File(dirname, "PageSpecificHeadFoot.doc"))
    );
    diffFirst = new HWPFDocument(
        new FileInputStream(new File(dirname, "DiffFirstPageHeadFoot.doc"))
    );
    unicode = new HWPFDocument(
        new FileInputStream(new File(dirname, "HeaderFooterUnicode.doc"))
    );
    withFields = new HWPFDocument(
        new FileInputStream(new File(dirname, "HeaderWithMacros.doc"))
    );
    }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    /**
     * two shapes, second is a group
     */
    public void testShapes() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/WithArtShapes.doc"));

    List shapes = doc.getShapesTable().getAllShapes();
    List vshapes = doc.getShapesTable().getVisibleShapes();

    assertEquals(2, shapes.size());
    assertEquals(2, vshapes.size());

    Shape s1 = (Shape)shapes.get(0);
    Shape s2 = (Shape)shapes.get(1);

    assertEquals(3616, s1.getWidth());
    assertEquals(1738, s1.getHeight());
    assertEquals(true, s1.isWithinDocument());

    assertEquals(4817, s2.getWidth());
    assertEquals(2164, s2.getHeight());
    assertEquals(true, s2.isWithinDocument());


    // Re-serialisze, check still there
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    doc.write(baos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    doc = new HWPFDocument(bais);

    shapes = doc.getShapesTable().getAllShapes();
    vshapes = doc.getShapesTable().getVisibleShapes();

    assertEquals(2, shapes.size());
    assertEquals(2, vshapes.size());

    s1 = (Shape)shapes.get(0);
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    /**
     * ListEntry passed no ListTable
     */
    public void testListEntryNoListTable() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(
          new File(dirname, "ListEntryNoListTable.doc")));

      Range r = doc.getRange();
      StyleSheet styleSheet = doc.getStyleSheet();
      for (int x = 0; x < r.numSections(); x++) {
        Section s = r.getSection(x);
        for (int y = 0; y < s.numParagraphs(); y++) {
          Paragraph paragraph = s.getParagraph(y);
          //System.out.println(paragraph.getCharacterRun(0).text());
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * AIOOB for TableSprmUncompressor.unCompressTAPOperation
   */
  public void testSprmAIOOB() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(
          new File(dirname, "AIOOB-Tap.doc")));

      Range r = doc.getRange();
      StyleSheet styleSheet = doc.getStyleSheet();
      for (int x = 0; x < r.numSections(); x++) {
        Section s = r.getSection(x);
        for (int y = 0; y < s.numParagraphs(); y++) {
          Paragraph paragraph = s.getParagraph(y);
          //System.out.println(paragraph.getCharacterRun(0).text());
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

  /**
   * Test for TableCell not skipping the last paragraph.
   * Bugs #45062 and #44292
   */
  public void testTableCellLastParagraph() throws Exception {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(
          new File(dirname, "Bug44292.doc")));
    Range r = doc.getRange();
    assertEquals(6, r.numParagraphs());
    assertEquals(0, r.getStartOffset());
    assertEquals(87, r.getEndOffset());

    // Paragraph with table
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

    assertEquals(1, cell.numParagraphs());
    assertEquals("One paragraph is ok\7", cell.getParagraph(0).text());
  }

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

      Range range = doc.getRange();
    int numParagraphs = range.numParagraphs();

    int totalLength = 0, deletedLength = 0;

    for (int i = 0; i < numParagraphs; i++) {
      Paragraph para = range.getParagraph(i);
      String text = para.text();

      totalLength += text.length();
      if (text.indexOf("{delete me}") > -1) {
        para.delete();
        deletedLength = text.length();
      }
    }

    // check the text length after deletion
    int newLength = 0;
      range = doc.getRange();
    numParagraphs = range.numParagraphs();

    for (int i = 0; i < numParagraphs; i++) {
      Paragraph para = range.getParagraph(i);
      String text = para.text();
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

   * With an encrypted file, we should give a suitable
   *  exception, and not OOM
   */
  public void testEncryptedFile() throws Exception {
    try {
      new HWPFDocument(new FileInputStream(
          new File(dirname, "PasswordProtected.doc")));
      fail();
    } catch(EncryptedDocumentException e) {
      // Good
    }
View Full Code Here

Examples of org.apache.poi.hwpf.HWPFDocument

      // Good
    }
  }

  public void testWriteProperties() throws Exception {
    HWPFDocument doc = new HWPFDocument(new FileInputStream(
          new File(dirname, "SampleDoc.doc")));
    assertEquals("Nick Burch", doc.getSummaryInformation().getAuthor());

    // Write and read
    HWPFDocument doc2 = writeOutAndRead(doc);
    assertEquals("Nick Burch", doc.getSummaryInformation().getAuthor());
  }
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.