Package org.apache.poi.hpbf

Examples of org.apache.poi.hpbf.HPBFDocument


  public PLCDumper(HPBFDocument hpbfDoc) {
    doc = hpbfDoc;
    qc = doc.getQuillContents();
  }
  public PLCDumper(POIFSFileSystem fs) throws IOException {
    this(new HPBFDocument(fs));
  }
View Full Code Here


    dir = System.getProperty("HPBF.testdata.path");
  }

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

    EscherStm es = doc.getEscherStm();
    EscherDelayStm eds = doc.getEscherDelayStm();
   
    assertNotNull(es);
    assertNotNull(eds);
   
    assertEquals(13, es.getEscherRecords().length);
View Full Code Here

    // TODO - check the contents
  }
 
  public void testComplex() throws Exception {
    File f = new File(dir, "SampleBrochure.pub");
    HPBFDocument doc = new HPBFDocument(
        new FileInputStream(f)
    );

    EscherStm es = doc.getEscherStm();
    EscherDelayStm eds = doc.getEscherDelayStm();
   
    assertNotNull(es);
    assertNotNull(eds);
   
    assertEquals(30, es.getEscherRecords().length);
    assertEquals(19, eds.getEscherRecords().length);
   
    // TODO - check contents
   
   
    // Now do another complex file
    f = new File(dir, "SampleNewsletter.pub");
    doc = new HPBFDocument(
        new FileInputStream(f)
    );

    es = doc.getEscherStm();
    eds = doc.getEscherDelayStm();
   
    assertNotNull(es);
    assertNotNull(eds);
   
    assertEquals(51, es.getEscherRecords().length);
View Full Code Here

    dir = System.getProperty("HPBF.testdata.path");
  }

  public void testBasics() throws Exception {
    File f = new File(dir, "Sample.pub");
    HPBFDocument doc = new HPBFDocument(
        new FileInputStream(f)
    );
   
    QuillContents qc = doc.getQuillContents();
    assertEquals(20, qc.getBits().length);
    for(int i=0; i<19; i++) {
      assertNotNull(qc.getBits()[i]);
    }
    // Last one is blank
View Full Code Here

    assertEquals(2, qc.getBits()[3].getOptA());
  }
 
  public void testText() throws Exception {
    File f = new File(dir, "Sample.pub");
    HPBFDocument doc = new HPBFDocument(
        new FileInputStream(f)
    );
   
    QuillContents qc = doc.getQuillContents();
    assertEquals(20, qc.getBits().length);
   
    QCTextBit text = (QCTextBit)qc.getBits()[0];
    String t = text.getText();
    assertTrue(t.startsWith("This is some text on the first page"));
View Full Code Here

    assertTrue(t.endsWith("Within doc to page 1\r"));
  }
 
  public void testPLC() throws Exception {
    File f = new File(dir, "Simple.pub");
    HPBFDocument doc = new HPBFDocument(
        new FileInputStream(f)
    );
   
    QuillContents qc = doc.getQuillContents();
    assertEquals(20, qc.getBits().length);
   
    assertTrue(qc.getBits()[9] instanceof Type4);
    assertTrue(qc.getBits()[10] instanceof Type4);
    assertTrue(qc.getBits()[12] instanceof Type8);
View Full Code Here

    assertEquals(0x04, plc12.getPlcValB()[1]);
  }
 
  public void testComplexPLC() throws Exception {
    File f = new File(dir, "Sample.pub");
    HPBFDocument doc = new HPBFDocument(
        new FileInputStream(f)
    );
   
    QuillContents qc = doc.getQuillContents();
    assertEquals(20, qc.getBits().length);
   
    assertTrue(qc.getBits()[10] instanceof Type4);
    assertTrue(qc.getBits()[11] instanceof Type4);
    assertTrue(qc.getBits()[13] instanceof Type0);
View Full Code Here

    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

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.