<changes>
<release version="3.7-beta2" date="2010-??-??">
+ <action dev="POI-DEVELOPERS" type="add">Text Extraction support for older Word 6 and Word 95 files via HWPF</action>
<action dev="POI-DEVELOPERS" type="add">49508 - Allow the addition of paragraphs to XWPF Table Cells</action>
<action dev="POI-DEVELOPERS" type="fix">49446 - Don't consider 17.16.23 field codes as properly part of the paragraph's text</action>
<action dev="POI-DEVELOPERS" type="fix">XSLFSlideShow shouldn't break on .thmx (theme) files. Support for them is still very limited though</action>
import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
import org.apache.poi.hssf.extractor.EventBasedExcelExtractor;
import org.apache.poi.hssf.extractor.ExcelExtractor;
+import org.apache.poi.hwpf.OldWordFileFormatException;
+import org.apache.poi.hwpf.extractor.Word6Extractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
}
}
if(entry.getName().equals("WordDocument")) {
- return new WordExtractor(poifsDir, fs);
+ // Old or new style word document?
+ try {
+ return new WordExtractor(poifsDir, fs);
+ } catch(OldWordFileFormatException e) {
+ return new Word6Extractor(poifsDir, fs);
+ }
}
if(entry.getName().equals("PowerPoint Document")) {
return new PowerPointExtractor(poifsDir, fs);
return new PublisherTextExtractor(poifsDir, fs);
}
if(
- entry.getName().equals("__substg1.0_1000001E") ||
- entry.getName().equals("__substg1.0_1000001F") ||
- entry.getName().equals("__substg1.0_0047001E") ||
- entry.getName().equals("__substg1.0_0047001F") ||
- entry.getName().equals("__substg1.0_0037001E") ||
- entry.getName().equals("__substg1.0_0037001F")
+ entry.getName().equals("__substg1.0_1000001E") ||
+ entry.getName().equals("__substg1.0_1000001F") ||
+ entry.getName().equals("__substg1.0_0047001E") ||
+ entry.getName().equals("__substg1.0_0047001F") ||
+ entry.getName().equals("__substg1.0_0037001E") ||
+ entry.getName().equals("__substg1.0_0037001F")
) {
return new OutlookTextExtactor(poifsDir, fs);
}
import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
import org.apache.poi.hssf.extractor.EventBasedExcelExtractor;
import org.apache.poi.hssf.extractor.ExcelExtractor;
+import org.apache.poi.hwpf.extractor.Word6Extractor;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
private File xlsEmb;
private File doc;
+ private File doc6;
+ private File doc95;
private File docx;
private File dotx;
private File docEmb;
POIDataSamples wpTests = POIDataSamples.getDocumentInstance();
doc = wpTests.getFile("SampleDoc.doc");
+ doc6 = wpTests.getFile("Word6.doc");
+ doc95 = wpTests.getFile("Word95.doc");
docx = wpTests.getFile("SampleDoc.docx");
dotx = wpTests.getFile("test.dotx");
docEmb = wpTests.getFile("word_with_embeded.doc");
ExtractorFactory.createExtractor(doc).getText().length() > 120
);
+ assertTrue(
+ ExtractorFactory.createExtractor(doc6)
+ instanceof Word6Extractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(doc6).getText().length() > 20
+ );
+
+ assertTrue(
+ ExtractorFactory.createExtractor(doc95)
+ instanceof Word6Extractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(doc95).getText().length() > 120
+ );
+
+
assertTrue(
ExtractorFactory.createExtractor(docx)
instanceof XWPFWordExtractor
ExtractorFactory.createExtractor(new FileInputStream(doc)).getText().length() > 120
);
+ assertTrue(
+ ExtractorFactory.createExtractor(new FileInputStream(doc6))
+ instanceof Word6Extractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(new FileInputStream(doc6)).getText().length() > 20
+ );
+
+ assertTrue(
+ ExtractorFactory.createExtractor(new FileInputStream(doc95))
+ instanceof Word6Extractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(new FileInputStream(doc95)).getText().length() > 120
+ );
+
assertTrue(
ExtractorFactory.createExtractor(new FileInputStream(docx))
instanceof XWPFWordExtractor
ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(doc))).getText().length() > 120
);
+ assertTrue(
+ ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(doc6)))
+ instanceof Word6Extractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(doc6))).getText().length() > 20
+ );
+
+ assertTrue(
+ ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(doc95)))
+ instanceof Word6Extractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(doc95))).getText().length() > 120
+ );
+
// PowerPoint
assertTrue(
ExtractorFactory.createExtractor(new POIFSFileSystem(new FileInputStream(ppt)))
// Is this document too old for us?
if(_fib.getNFib() < 106) {
- throw new OldWordFileFormatException("The document is too old (Word 95 or older) ");
+ throw new OldWordFileFormatException("The document is too old - Word 95 or older. Try HWPFOldDocument instead?");
}
// use the fib to determine the name of the table stream.