use of org.apache.poi.hwpf.HWPFOldDocument in project poi by apache.
the class TestBugs method test57843.
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void test57843() throws IOException {
File f = POIDataSamples.getDocumentInstance().getFile("57843.doc");
POIFSFileSystem fs = new POIFSFileSystem(f, true);
try {
HWPFOldDocument doc = new HWPFOldDocument(fs);
assertNotNull(doc);
doc.close();
} finally {
fs.close();
}
}
use of org.apache.poi.hwpf.HWPFOldDocument in project poi by apache.
the class TestHWPFOldDocument method testWord6Sections2.
/**
* Another word document with sections, this time with a few more section
* properties set on it
*/
@Test
public void testWord6Sections2() throws IOException {
HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Word6_sections2.doc");
assertEquals(1, doc.getRange().numSections());
assertEquals(57, doc.getRange().numParagraphs());
assertEquals("\r", doc.getRange().getParagraph(0).text());
assertEquals("STATEMENT OF INSOLVENCY PRACTICE 10 (SCOTLAND)\r", doc.getRange().getParagraph(1).text());
doc.close();
}
use of org.apache.poi.hwpf.HWPFOldDocument in project poi by apache.
the class TestHWPFOldDocument method testCodePageBug50955.
@Test
public void testCodePageBug50955() throws IOException {
//windows 1251
HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Bug50955.doc");
Word6Extractor ex = new Word6Extractor(doc);
StringBuilder sb = new StringBuilder();
for (String p : ex.getParagraphText()) {
sb.append(p);
}
//Greetings!
assertContains(sb.toString(), "привет");
ex.close();
doc.close();
}
use of org.apache.poi.hwpf.HWPFOldDocument in project poi by apache.
the class TestHWPFOldDocument method testWord95hwpfOld.
@Test
public void testWord95hwpfOld() throws IOException {
// Open
HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Word95.doc");
// Check
assertEquals(1, doc.getRange().numSections());
assertEquals(7, doc.getRange().numParagraphs());
assertEquals("The quick brown fox jumps over the lazy dog\r", doc.getRange().getParagraph(0).text());
assertEquals("\r", doc.getRange().getParagraph(1).text());
assertEquals("Paragraph 2\r", doc.getRange().getParagraph(2).text());
assertEquals("\r", doc.getRange().getParagraph(3).text());
assertEquals("Paragraph 3. Has some RED text and some " + "BLUE BOLD text in it.\r", doc.getRange().getParagraph(4).text());
assertEquals("\r", doc.getRange().getParagraph(5).text());
assertEquals("Last (4th) paragraph.\r", doc.getRange().getParagraph(6).text());
assertEquals(1, doc.getRange().getParagraph(0).numCharacterRuns());
assertEquals(1, doc.getRange().getParagraph(1).numCharacterRuns());
assertEquals(1, doc.getRange().getParagraph(2).numCharacterRuns());
assertEquals(1, doc.getRange().getParagraph(3).numCharacterRuns());
// Normal, red, normal, blue+bold, normal
assertEquals(5, doc.getRange().getParagraph(4).numCharacterRuns());
assertEquals(1, doc.getRange().getParagraph(5).numCharacterRuns());
// Normal, superscript for 4th, normal
assertEquals(3, doc.getRange().getParagraph(6).numCharacterRuns());
doc.close();
}
use of org.apache.poi.hwpf.HWPFOldDocument in project poi by apache.
the class TestHWPFOldDocument method testOldFontTableEncoding.
@Test
public void testOldFontTableEncoding() throws IOException {
HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Bug51944.doc");
OldFontTable oldFontTable = doc.getOldFontTable();
assertEquals(5, oldFontTable.getFontNames().length);
assertEquals("細明體", oldFontTable.getFontNames()[0].getMainFontName());
assertEquals(HwmfFont.WmfCharset.CHINESEBIG5_CHARSET.getCharset(), Charset.forName("Big5"));
assertEquals("Times New Roman", oldFontTable.getFontNames()[1].getMainFontName());
doc.close();
}
Aggregations