Package org.apache.poi.hpbf

Examples of org.apache.poi.hpbf.HPBFDocument


    assertEquals(0x000004, plc16.getPlcValB()[5]);
  }

  public void testNoHyperlinks() throws Exception {
    File f = new File(dir, "SampleNewsletter.pub");
    HPBFDocument doc = new HPBFDocument(
        new FileInputStream(f)
    );

    QuillContents qc = doc.getQuillContents();
    assertEquals(20, qc.getBits().length);

    Type12 plc18 = (Type12)qc.getBits()[18];

    assertEquals(1, plc18.getNumberOfPLCs());
View Full Code Here


    assertEquals(601, plc18.getAllTextEndAt());
  }

  public void testSimpleHyperlink() throws Exception {
    File f;
    HPBFDocument doc;
    QuillContents qc;
    Type12 hlBit;

    // Link at 10
    f = new File(dir, "LinkAt10.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBit = (Type12)qc.getBits()[12];
    assertEquals(1, hlBit.getNumberOfPLCs());
    assertEquals(1, hlBit.getNumberOfHyperlinks());

    assertEquals(10, hlBit.getTextStartAt(0));
    assertEquals(15, hlBit.getAllTextEndAt());
    assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));

    // Longer link at 10
    f = new File(dir, "LinkAt10Longer.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBit = (Type12)qc.getBits()[12];
    assertEquals(1, hlBit.getNumberOfPLCs());
    assertEquals(1, hlBit.getNumberOfHyperlinks());

    assertEquals(10, hlBit.getTextStartAt(0));
    assertEquals(15, hlBit.getAllTextEndAt());
    assertEquals("http://poi.apache.org/hpbf/", hlBit.getHyperlink(0));

    // Link at 20
    f = new File(dir, "LinkAt20.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBit = (Type12)qc.getBits()[12];
    assertEquals(1, hlBit.getNumberOfPLCs());
    assertEquals(1, hlBit.getNumberOfHyperlinks());
View Full Code Here

    assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
  }

  public void testManyHyperlinks() throws Exception {
    File f;
    HPBFDocument doc;
    QuillContents qc;
    Type12 hlBit;

    // Link at 10
    f = new File(dir, "LinkAt10.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBit = (Type12)qc.getBits()[12];
    assertEquals(1, hlBit.getNumberOfPLCs());
    assertEquals(1, hlBit.getNumberOfHyperlinks());
View Full Code Here

  }

  public void testHyperlinkDifferentVersions() throws Exception {
    File f;
    HPBFDocument doc;
    QuillContents qc;
    Type12 hlBitA;
    Type12 hlBitB;

    // Latest version
    f = new File(dir, "Sample.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBitA = (Type12)qc.getBits()[14];
    assertEquals(2, hlBitA.getNumberOfPLCs());
    assertEquals(2, hlBitA.getNumberOfHyperlinks());

    assertEquals(25, hlBitA.getTextStartAt(0));
    assertEquals(72, hlBitA.getTextStartAt(1));
    assertEquals(87, hlBitA.getAllTextEndAt());
    assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
    assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));

    hlBitB = (Type12)qc.getBits()[15];
    assertEquals(3, hlBitB.getNumberOfPLCs());
    assertEquals(3, hlBitB.getNumberOfHyperlinks());

    assertEquals(27, hlBitB.getTextStartAt(0));
    assertEquals(37, hlBitB.getTextStartAt(1));
    assertEquals(54, hlBitB.getTextStartAt(2));
    assertEquals(75, hlBitB.getAllTextEndAt());
    assertEquals("", hlBitB.getHyperlink(0));
    assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
    assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));

    // 2000 version
    f = new File(dir, "Sample2000.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBitA = (Type12)qc.getBits()[13];
    assertEquals(2, hlBitA.getNumberOfPLCs());
    assertEquals(2, hlBitA.getNumberOfHyperlinks());

    assertEquals(25, hlBitA.getTextStartAt(0));
    assertEquals(72, hlBitA.getTextStartAt(1));
    assertEquals(87, hlBitA.getAllTextEndAt());
    assertEquals("http://poi.apache.org/", hlBitA.getHyperlink(0));
    assertEquals("C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx", hlBitA.getHyperlink(1));

    hlBitB = (Type12)qc.getBits()[14];
    assertEquals(3, hlBitB.getNumberOfPLCs());
    assertEquals(3, hlBitB.getNumberOfHyperlinks());

    assertEquals(27, hlBitB.getTextStartAt(0));
    assertEquals(37, hlBitB.getTextStartAt(1));
    assertEquals(54, hlBitB.getTextStartAt(2));
    assertEquals(75, hlBitB.getAllTextEndAt());
    assertEquals("", hlBitB.getHyperlink(0));
    assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(1));
    assertEquals("mailto:dev@poi.apache.org?subject=HPBF", hlBitB.getHyperlink(2));

    // 98 version
    f = new File(dir, "Sample98.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );
    qc = doc.getQuillContents();

    hlBitA = (Type12)qc.getBits()[13];
    assertEquals(2, hlBitA.getNumberOfPLCs());
    assertEquals(2, hlBitA.getNumberOfHyperlinks());
View Full Code Here

       "0123456789abcdef\n" +
       "0123456789abcdef0123456789abcdef\n" +
       "0123456789abcdef0123456789abcdef0123456789abcdef\n";

  public void testBasics() throws Exception {
    HPBFDocument doc = new HPBFDocument(
        _samples.openResourceAsStream("Sample.pub")
    );

    PublisherTextExtractor ext =
      new PublisherTextExtractor(doc);
View Full Code Here

     PublisherTextExtractor ext;
     File sample = _samples.getFile("Sample.pub");
      File simple = _samples.getFile("Simple.pub");
    
     // Check this complicated file using POIFS
    HPBFDocument docOPOIFS = new HPBFDocument(
          new FileInputStream(sample)
    );
      ext = new PublisherTextExtractor(docOPOIFS);
      assertEquals( SAMPLE_TEXT, ext.getText() );

      // And with NPOIFS
      NPOIFSFileSystem fs = new NPOIFSFileSystem(sample);
    HPBFDocument docNPOIFS = new HPBFDocument(
            fs
      );
    ext = new PublisherTextExtractor(docNPOIFS);
    assertEquals( SAMPLE_TEXT, ext.getText() );
View Full Code Here

   2000 and Publisher 2007. Check they all agree.
   * @throws Exception
   */
  public void testMultipleVersions() throws Exception {
    File f;
    HPBFDocument doc;

    doc = new HPBFDocument(
                _samples.openResourceAsStream("Sample.pub")
    );
    String s2007 = (new PublisherTextExtractor(doc)).getText();

    doc = new HPBFDocument(
                _samples.openResourceAsStream("Sample2000.pub")
    );
    String s2000 = (new PublisherTextExtractor(doc)).getText();

    doc = new HPBFDocument(
                _samples.openResourceAsStream("Sample98.pub")
    );
    String s98 = (new PublisherTextExtractor(doc)).getText();

    // Check they all agree
View Full Code Here

  /**
   * Test that the hyperlink extraction stuff works as well
   *  as we can hope it to.
   */
  public void testWithHyperlinks() throws Exception {
    HPBFDocument doc = new HPBFDocument(
                _samples.openResourceAsStream("LinkAt10.pub")
    );

    PublisherTextExtractor ext =
      new PublisherTextExtractor(doc);
View Full Code Here

  public PublisherTextExtractor(HPBFDocument doc) {
    super(doc);
    this.doc = doc;
  }
  public PublisherTextExtractor(POIFSFileSystem fs) throws IOException {
    this(new HPBFDocument(fs));
  }
View Full Code Here

public final class TextPublisherTextExtractor extends TestCase {
    private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();

  public void testBasics() throws Exception {
    HPBFDocument doc = new HPBFDocument(
        _samples.openResourceAsStream("Sample.pub")
    );

    PublisherTextExtractor ext =
      new PublisherTextExtractor(doc);
View Full Code Here

TOP

Related Classes of org.apache.poi.hpbf.HPBFDocument

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.