HWPFTestDataSamples.openSampleFile("Word95.doc");
fail("Shouldn't be openable");
} catch(OldFileFormatException e) {}
// 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(4, doc.getRange().getParagraph(6).numCharacterRuns());
}