View | Details | Raw Unified | Return to bug 47517
Collapse All | Expand All

(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRelation.java (+6 lines)
Lines 63-68 Link Here
63
			"/xl/workbook.xml",
63
			"/xl/workbook.xml",
64
			null
64
			null
65
	);
65
	);
66
        public static final XSSFRelation TEMPLATE_WORKBOOK = new XSSFRelation(
67
                  "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml",
68
                  "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
69
                  "/xl/workbook.xml",
70
                  null
71
        );
66
	public static final XSSFRelation WORKSHEET = new XSSFRelation(
72
	public static final XSSFRelation WORKSHEET = new XSSFRelation(
67
			"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
73
			"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
68
			"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
74
			"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java (+6 lines)
Lines 40-45 Link Here
40
            "/word/document.xml",
40
            "/word/document.xml",
41
            null
41
            null
42
    );
42
    );
43
    public static final XWPFRelation TEMPLATE = new XWPFRelation(
44
          "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml",
45
          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
46
          "/word/document.xml",
47
          null
48
    );
43
    public static final XWPFRelation FONT_TABLE = new XWPFRelation(
49
    public static final XWPFRelation FONT_TABLE = new XWPFRelation(
44
            "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml",
50
            "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml",
45
            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
51
            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
(-)src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java (-1 / +7 lines)
Lines 99-111 Link Here
99
		if(corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType())) {
99
		if(corePart.getContentType().equals(XSSFRelation.WORKBOOK.getContentType())) {
100
			return new XSSFExcelExtractor(pkg);
100
			return new XSSFExcelExtractor(pkg);
101
		}
101
		}
102
                if(corePart.getContentType().equals(XSSFRelation.TEMPLATE_WORKBOOK.getContentType())) {
103
                        return new XSSFExcelExtractor(pkg);
104
                }
102
		if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
105
		if(corePart.getContentType().equals(XWPFRelation.DOCUMENT.getContentType())) {
103
			return new XWPFWordExtractor(pkg);
106
			return new XWPFWordExtractor(pkg);
104
		}
107
		}
108
                if(corePart.getContentType().equals(XWPFRelation.TEMPLATE.getContentType())) {
109
                        return new XWPFWordExtractor(pkg);
110
                }
105
		if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
111
		if(corePart.getContentType().equals(XSLFSlideShow.MAIN_CONTENT_TYPE)) {
106
			return new XSLFPowerPointExtractor(pkg);
112
			return new XSLFPowerPointExtractor(pkg);
107
		}
113
		}
108
		throw new IllegalArgumentException("No supported documents found in the OOXML package");
114
		throw new IllegalArgumentException("No supported documents found in the OOXML package (found "+corePart.getContentType()+")");
109
	}
115
	}
110
	
116
	
111
	public static POIOLE2TextExtractor createExtractor(POIFSFileSystem fs) throws IOException {
117
	public static POIOLE2TextExtractor createExtractor(POIFSFileSystem fs) throws IOException {
(-)src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java (-4 / +25 lines)
Lines 50-58 Link Here
50
	
50
	
51
	private File xls;
51
	private File xls;
52
	private File xlsx;
52
	private File xlsx;
53
	
53
        private File xltx;
54
54
	private File doc;
55
	private File doc;
55
	private File docx;
56
	private File docx;
57
        private File dotx;
56
58
57
	private File ppt;
59
	private File ppt;
58
	private File pptx;
60
	private File pptx;
Lines 77-86 Link Here
77
		
79
		
78
		xls = new File(excel_dir, "SampleSS.xls");
80
		xls = new File(excel_dir, "SampleSS.xls");
79
		xlsx = new File(excel_dir, "SampleSS.xlsx");
81
		xlsx = new File(excel_dir, "SampleSS.xlsx");
80
		
82
                xltx = new File(excel_dir, "test.xltx");
83
81
		doc = new File(word_dir, "SampleDoc.doc");
84
		doc = new File(word_dir, "SampleDoc.doc");
82
		docx = new File(word_dir, "SampleDoc.docx");
85
		docx = new File(word_dir, "SampleDoc.docx");
83
		
86
                dotx = new File(word_dir, "test.dotx");
87
84
		ppt = new File(powerpoint_dir, "SampleShow.ppt");
88
		ppt = new File(powerpoint_dir, "SampleShow.ppt");
85
		pptx = new File(powerpoint_dir, "SampleShow.pptx");
89
		pptx = new File(powerpoint_dir, "SampleShow.pptx");
86
		
90
		
Lines 104-109 Link Here
104
		assertTrue(
108
		assertTrue(
105
				ExtractorFactory.createExtractor(xlsx).getText().length() > 200
109
				ExtractorFactory.createExtractor(xlsx).getText().length() > 200
106
		);
110
		);
111
112
                assertTrue(
113
                                ExtractorFactory.createExtractor(xltx)
114
                                instanceof XSSFExcelExtractor
115
                );
116
                assertTrue(
117
                                ExtractorFactory.createExtractor(xltx).getText().contains("test")
118
                );
119
107
		
120
		
108
		// Word
121
		// Word
109
		assertTrue(
122
		assertTrue(
Lines 121-127 Link Here
121
		assertTrue(
134
		assertTrue(
122
				ExtractorFactory.createExtractor(docx).getText().length() > 120
135
				ExtractorFactory.createExtractor(docx).getText().length() > 120
123
		);
136
		);
124
		
137
138
                assertTrue(
139
                                ExtractorFactory.createExtractor(dotx)
140
                                instanceof XWPFWordExtractor
141
                );
142
                assertTrue(
143
                                ExtractorFactory.createExtractor(dotx).getText().contains("Test")
144
                );
145
125
		// PowerPoint
146
		// PowerPoint
126
		assertTrue(
147
		assertTrue(
127
				ExtractorFactory.createExtractor(ppt)
148
				ExtractorFactory.createExtractor(ppt)

Return to bug 47517