|
21 | 21 | import java.io.InputStream; |
22 | 22 | import java.nio.file.Files; |
23 | 23 | import java.util.Locale; |
| 24 | +import java.util.Set; |
24 | 25 |
|
25 | 26 | import org.apache.poi.extractor.ExtractorFactory; |
26 | 27 | import org.apache.poi.ooxml.POIXMLDocument; |
@@ -182,6 +183,10 @@ public static void parse(InputStream stream, ContentHandler baseHandler, Metadat |
182 | 183 | XSLFEventBasedPowerPointExtractor.class.getCanonicalName()); |
183 | 184 | } else if (poiExtractor instanceof XPSTextExtractor) { |
184 | 185 | extractor = new XPSExtractorDecorator(context, poiExtractor); |
| 186 | + } else if (isVisioType(type)) { |
| 187 | + //SAX-based .vsdx extractor; the XDGF-based poiExtractor is used only for its |
| 188 | + //OPCPackage (VSDXExtractorDecorator reads the package directly) |
| 189 | + extractor = new VSDXExtractorDecorator(context, poiExtractor); |
185 | 190 | } else if (document == null) { |
186 | 191 | throw new TikaException( |
187 | 192 | "Expecting UserModel based POI OOXML extractor with a document, but none" + |
@@ -295,5 +300,17 @@ private static POIXMLTextExtractor tryXSLF(OPCPackage pkg, boolean eventBased) |
295 | 300 | return null; |
296 | 301 | } |
297 | 302 |
|
| 303 | + private static final Set<String> VISIO_SUBTYPES = Set.of( |
| 304 | + "vnd.ms-visio.drawing", |
| 305 | + "vnd.ms-visio.drawing.macroenabled.12", |
| 306 | + "vnd.ms-visio.stencil", |
| 307 | + "vnd.ms-visio.stencil.macroenabled.12", |
| 308 | + "vnd.ms-visio.template", |
| 309 | + "vnd.ms-visio.template.macroenabled.12" |
| 310 | + ); |
| 311 | + |
| 312 | + private static boolean isVisioType(MediaType type) { |
| 313 | + return type != null && VISIO_SUBTYPES.contains(type.getSubtype()); |
| 314 | + } |
298 | 315 |
|
299 | 316 | } |
0 commit comments