You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2009/07/18 11:09:11 UTC
svn commit: r795327 - in /poi/trunk/src: ooxml/java/org/apache/poi/extractor/
ooxml/testcases/org/apache/poi/extractor/
scratchpad/testcases/org/apache/poi/hwpf/data/
testcases/org/apache/poi/hssf/data/
Author: yegor
Date: Sat Jul 18 09:09:11 2009
New Revision: 795327
URL: http://svn.apache.org/viewvc?rev=795327&view=rev
Log:
Fixed ExtractorFactory to support .xltx and .dotx files, see Bugzilla 47517
Added:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/test.dotx (with props)
poi/trunk/src/testcases/org/apache/poi/hssf/data/test.xltx (with props)
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java
poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java?rev=795327&r1=795326&r2=795327&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java Sat Jul 18 09:09:11 2009
@@ -94,18 +94,27 @@
if(core.size() != 1) {
throw new IllegalArgumentException("Invalid OOXML Package received - expected 1 core document, found " + core.size());
}
-
- PackagePart corePart = pkg.getPart(core.getRelationship(0));
- if(corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType())) {
- return new XSSFExcelExtractor(pkg);
- }
- if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
+
+ PackagePart corePart = pkg.getPart(core.getRelationship(0));
+ if (corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType()) ||
+ corePart.getContentType().equals(XSSFRelation.MACRO_TEMPLATE_WORKBOOK.getContentType()) ||
+ corePart.getContentType().equals(XSSFRelation.MACRO_ADDIN_WORKBOOK.getContentType()) ||
+ corePart.getContentType().equals(XSSFRelation.TEMPLATE_WORKBOOK.getContentType()) ||
+ corePart.getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType())) {
+ return new XSSFExcelExtractor(pkg);
+ }
+
+ if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType()) ||
+ corePart.getContentType().equals(XWPFRelation.TEMPLATE.getContentType()) ||
+ corePart.getContentType().equals(XWPFRelation.MACRO_DOCUMENT.getContentType()) ||
+ corePart.getContentType().equals(XWPFRelation.MACRO_TEMPLATE_DOCUMENT.getContentType()) ) {
return new XWPFWordExtractor(pkg);
}
+
if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
return new XSLFPowerPointExtractor(pkg);
}
- throw new IllegalArgumentException("No supported documents found in the OOXML package");
+ throw new IllegalArgumentException("No supported documents found in the OOXML package (found "+corePart.getContentType()+")");
}
public static POIOLE2TextExtractor createExtractor(POIFSFileSystem fs) throws IOException {
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java?rev=795327&r1=795326&r2=795327&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java Sat Jul 18 09:09:11 2009
@@ -50,9 +50,11 @@
private File xls;
private File xlsx;
-
+ private File xltx;
+
private File doc;
private File docx;
+ private File dotx;
private File ppt;
private File pptx;
@@ -77,10 +79,12 @@
xls = new File(excel_dir, "SampleSS.xls");
xlsx = new File(excel_dir, "SampleSS.xlsx");
-
+ xltx = new File(excel_dir, "test.xltx");
+
doc = new File(word_dir, "SampleDoc.doc");
docx = new File(word_dir, "SampleDoc.docx");
-
+ dotx = new File(word_dir, "test.dotx");
+
ppt = new File(powerpoint_dir, "SampleShow.ppt");
pptx = new File(powerpoint_dir, "SampleShow.pptx");
@@ -104,6 +108,15 @@
assertTrue(
ExtractorFactory.createExtractor(xlsx).getText().length() > 200
);
+
+ assertTrue(
+ ExtractorFactory.createExtractor(xltx)
+ instanceof XSSFExcelExtractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(xltx).getText().contains("test")
+ );
+
// Word
assertTrue(
@@ -121,7 +134,15 @@
assertTrue(
ExtractorFactory.createExtractor(docx).getText().length() > 120
);
-
+
+ assertTrue(
+ ExtractorFactory.createExtractor(dotx)
+ instanceof XWPFWordExtractor
+ );
+ assertTrue(
+ ExtractorFactory.createExtractor(dotx).getText().contains("Test")
+ );
+
// PowerPoint
assertTrue(
ExtractorFactory.createExtractor(ppt)
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/test.dotx
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/test.dotx?rev=795327&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/test.dotx
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/test.dotx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/test.xltx
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/test.xltx?rev=795327&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/test.xltx
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/test.xltx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org