use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestPictures method testEquation.
@Test
public void testEquation() {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("equation.doc");
PicturesTable pictures = doc.getPicturesTable();
final List<Picture> allPictures = pictures.getAllPictures();
assertEquals(1, allPictures.size());
Picture picture = allPictures.get(0);
assertNotNull(picture);
assertEquals(PictureType.EMF, picture.suggestPictureType());
assertEquals(PictureType.EMF.getExtension(), picture.suggestFileExtension());
assertEquals(PictureType.EMF.getMime(), picture.getMimeType());
assertEquals("0.emf", picture.suggestFullFileName());
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestBugs method test56880.
/**
* java.lang.UnsupportedOperationException: Non-extended character
* Pascal strings are not supported right now
*
* Disabled pending a fix for the bug
*/
@Test
public void test56880() throws Exception {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("56880.doc");
assertEqualsIgnoreNewline("Check Request", doc.getRange().text());
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestBugs method getText.
private String getText(String samplefile) throws IOException {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile(samplefile);
WordExtractor extractor = new WordExtractor(doc);
try {
return extractor.getText();
} finally {
extractor.close();
doc.close();
}
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestBugs method test44431.
/**
* Bug 44331 - HWPFDocument.write destroys fields
*/
@SuppressWarnings("deprecation")
@Test
public void test44431() throws IOException {
HWPFDocument doc1 = HWPFTestDataSamples.openSampleFile("Bug44431.doc");
WordExtractor extractor1 = new WordExtractor(doc1);
try {
HWPFDocument doc2 = HWPFTestDataSamples.writeOutAndReadBack(doc1);
WordExtractor extractor2 = new WordExtractor(doc2);
try {
assertEqualsIgnoreNewline(extractor1.getFooterText(), extractor2.getFooterText());
assertEqualsIgnoreNewline(extractor1.getHeaderText(), extractor2.getHeaderText());
assertEqualsIgnoreNewline(Arrays.toString(extractor1.getParagraphText()), Arrays.toString(extractor2.getParagraphText()));
assertEqualsIgnoreNewline(extractor1.getText(), extractor2.getText());
} finally {
extractor2.close();
}
} finally {
extractor1.close();
doc1.close();
}
}
use of org.apache.poi.hwpf.HWPFDocument in project poi by apache.
the class TestProblems method testSprmAIOOB.
/**
* AIOOB for TableSprmUncompressor.unCompressTAPOperation
*/
@Test
public void testSprmAIOOB() throws IOException {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("AIOOB-Tap.doc");
StyleSheet styleSheet = doc.getStyleSheet();
assertNotNull(styleSheet);
Range r = doc.getRange();
for (int x = 0; x < r.numSections(); x++) {
Section s = r.getSection(x);
for (int y = 0; y < s.numParagraphs(); y++) {
Paragraph paragraph = s.getParagraph(y);
assertNotNull(paragraph);
}
}
doc.close();
}
Aggregations