mirror of https://github.com/apache/poi.git
Exceptions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752227 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef2af2d53d
commit
ce564f39dc
|
@ -16,6 +16,7 @@
|
|||
==================================================================== */
|
||||
package org.apache.poi.extractor;
|
||||
|
||||
import static org.apache.poi.hssf.model.InternalWorkbook.OLD_WORKBOOK_DIR_ENTRY_NAME;
|
||||
import static org.apache.poi.hssf.model.InternalWorkbook.WORKBOOK_DIR_ENTRY_NAMES;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -27,6 +28,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.poi.POIOLE2TextExtractor;
|
||||
import org.apache.poi.POITextExtractor;
|
||||
import org.apache.poi.hssf.OldExcelFormatException;
|
||||
import org.apache.poi.hssf.extractor.EventBasedExcelExtractor;
|
||||
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
|
@ -171,6 +173,10 @@ public class OLE2ExtractorFactory {
|
|||
return new ExcelExtractor(poifsDir);
|
||||
}
|
||||
}
|
||||
if (poifsDir.hasEntry(OLD_WORKBOOK_DIR_ENTRY_NAME)) {
|
||||
throw new OldExcelFormatException("Old Excel Spreadsheet format (1-95) "
|
||||
+ "found. Please call OldExcelExtractor directly for basic text extraction");
|
||||
}
|
||||
|
||||
// Ask Scratchpad, or fail trying
|
||||
Class<?> cls = getScratchpadClass();
|
||||
|
@ -178,6 +184,8 @@ public class OLE2ExtractorFactory {
|
|||
Method m = cls.getDeclaredMethod("createExtractor", DirectoryNode.class);
|
||||
POITextExtractor ext = (POITextExtractor)m.invoke(null, poifsDir);
|
||||
if (ext != null) return ext;
|
||||
} catch (IllegalArgumentException iae) {
|
||||
throw iae;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Error creating Scratchpad Extractor", e);
|
||||
}
|
||||
|
|
|
@ -34,11 +34,9 @@ import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
|
|||
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.OpenXML4JException;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.Entry;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
|
||||
/**
|
||||
* Scratchpad-specific logic for {@link OLE2ExtractorFactory} and
|
||||
|
@ -55,9 +53,7 @@ public class OLE2ScrachpadExtractorFactory {
|
|||
* Note - doesn't check for core-supported formats!
|
||||
* Note - doesn't check for OOXML-supported formats
|
||||
*/
|
||||
public static POITextExtractor createExtractor(DirectoryNode poifsDir) throws IOException,
|
||||
OpenXML4JException, XmlException
|
||||
{
|
||||
public static POITextExtractor createExtractor(DirectoryNode poifsDir) throws IOException {
|
||||
if (poifsDir.hasEntry("WordDocument")) {
|
||||
// Old or new style word document?
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue