Locale locale = context.get(Locale.class, Locale.getDefault());
try {
OOXMLExtractor extractor;
POIXMLTextExtractor poiExtractor;
if(stream instanceof TikaInputStream &&
((TikaInputStream)stream).getOpenContainer() != null) {
poiExtractor = ExtractorFactory.createExtractor(
(OPCPackage)((TikaInputStream)stream).getOpenContainer()
);
} else {
poiExtractor = (POIXMLTextExtractor) ExtractorFactory.createExtractor(stream);
}
POIXMLDocument document = poiExtractor.getDocument();
if (document instanceof XSLFSlideShow) {
extractor = new XSLFPowerPointExtractorDecorator(
(XSLFPowerPointExtractor) poiExtractor);
} else if (document instanceof XSSFWorkbook) {
extractor = new XSSFExcelExtractorDecorator(