use of org.apache.poi.hpbf.HPBFDocument in project poi by apache.
the class TestQuillContents method testManyHyperlinks.
@Test
public void testManyHyperlinks() throws IOException {
HPBFDocument doc;
QuillContents qc;
Type12 hlBit;
// Link at 10
doc = new HPBFDocument(_samples.openResourceAsStream("LinkAt10.pub"));
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));
doc.close();
}
use of org.apache.poi.hpbf.HPBFDocument in project poi by apache.
the class TestQuillContents method testNoHyperlinks.
@Test
public void testNoHyperlinks() throws IOException {
HPBFDocument doc = new HPBFDocument(_samples.openResourceAsStream("SampleNewsletter.pub"));
QuillContents qc = doc.getQuillContents();
assertEquals(20, qc.getBits().length);
Type12 plc18 = (Type12) qc.getBits()[18];
assertEquals(1, plc18.getNumberOfPLCs());
assertEquals(0, plc18.getNumberOfHyperlinks());
assertEquals(0, plc18.getTextStartAt(0));
assertEquals(601, plc18.getAllTextEndAt());
doc.close();
}
use of org.apache.poi.hpbf.HPBFDocument in project poi by apache.
the class TestPublisherTextExtractor method testWithHyperlinks.
/**
* Test that the hyperlink extraction stuff works as well as we can hope it
* to.
*/
@Test
public void testWithHyperlinks() throws Exception {
InputStream linkAt = _samples.openResourceAsStream("LinkAt10.pub");
HPBFDocument doc = new HPBFDocument(linkAt);
PublisherTextExtractor ext = new PublisherTextExtractor(doc);
// Default is no hyperlinks
assertEquals("1234567890LINK\n", ext.getText());
// Turn on
ext.setHyperlinksByDefault(true);
assertEquals("1234567890LINK\n<http://poi.apache.org/>\n", ext.getText());
ext.close();
doc.close();
linkAt.close();
// Now a much more complex document
InputStream sample = _samples.openResourceAsStream("Sample.pub");
ext = new PublisherTextExtractor(sample);
ext.setHyperlinksByDefault(true);
String text = ext.getText();
ext.close();
sample.close();
assertEndsWith(text, "<http://poi.apache.org/>\n" + "<C:\\Documents and Settings\\Nick\\My Documents\\Booleans.xlsx>\n" + "<>\n" + "<mailto:dev@poi.apache.org?subject=HPBF>\n" + "<mailto:dev@poi.apache.org?subject=HPBF>\n");
}
use of org.apache.poi.hpbf.HPBFDocument in project poi by apache.
the class TestPublisherTextExtractor method testMultipleVersions.
/**
* We have the same file saved for Publisher 98, Publisher 2000 and
* Publisher 2007. Check they all agree.
*
* @throws Exception
*/
@Test
public void testMultipleVersions() throws Exception {
InputStream sample = _samples.openResourceAsStream("Sample.pub");
HPBFDocument doc = new HPBFDocument(sample);
PublisherTextExtractor ext = new PublisherTextExtractor(doc);
String s2007 = ext.getText();
ext.close();
doc.close();
sample.close();
InputStream sample2000 = _samples.openResourceAsStream("Sample2000.pub");
doc = new HPBFDocument(sample2000);
ext = new PublisherTextExtractor(doc);
String s2000 = ext.getText();
ext.close();
doc.close();
sample2000.close();
InputStream sample98 = _samples.openResourceAsStream("Sample98.pub");
doc = new HPBFDocument(sample98);
ext = new PublisherTextExtractor(doc);
String s98 = ext.getText();
ext.close();
doc.close();
sample98.close();
// Check they all agree
assertEquals(s2007, s2000);
assertEquals(s2007, s98);
}
use of org.apache.poi.hpbf.HPBFDocument in project poi by apache.
the class TestEscherParts method testBasics.
@Test
public void testBasics() throws IOException {
InputStream is = _samples.openResourceAsStream("Sample.pub");
HPBFDocument doc = new HPBFDocument(is);
is.close();
EscherStm es = doc.getEscherStm();
EscherDelayStm eds = doc.getEscherDelayStm();
assertNotNull(es);
assertNotNull(eds);
assertEquals(13, es.getEscherRecords().length);
assertEquals(0, eds.getEscherRecords().length);
// TODO - check the contents
doc.close();
}
Aggregations