* @since by POI 3.14-Beta1
*/
public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackagePart part) {
- PackageRelationship rel = getPackageRelationship(parent, part);
- POIXMLRelation descriptor = getDescriptor(rel.getRelationshipType());
-
- if (descriptor == null || descriptor.getRelationClass() == null) {
+ final PackageRelationship rel = getPackageRelationship(parent, part);
+ final String relType = rel.getRelationshipType();
+ final POIXMLRelation descriptor = getDescriptor(relType);
+
+ // don't parse the document parts, if its class can't be determined
+ // or if it's a package relation of another embedded resource
+ if (descriptor == null || descriptor.getRelationClass() == null || POIXMLDocument.PACK_OBJECT_REL_TYPE.equals(relType)) {
LOGGER.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType());
return new POIXMLDocumentPart(parent, part);
}
null
);
+ // this is not the same as in XSSFRelation.WORKBOOK, as it is usually used by embedded charts
+ // referencing the original embedded excel workbook
public static final XSLFRelation WORKBOOK = new XSLFRelation(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
POIXMLDocument.PACK_OBJECT_REL_TYPE,
open.close();
}
}
-
+
+ @Test
+ public void dontParseEmbeddedDocuments() throws IOException {
+ // bug #62513
+ POIDataSamples pds = POIDataSamples.getSlideShowInstance();
+ try (InputStream is = pds.openResourceAsStream("bug62513.pptx");
+ XMLSlideShow ppt = new XMLSlideShow(is)) {
+ POIXMLDocumentPart doc = ppt.getSlides().get(12).getRelationById("rId3");
+ assertEquals(POIXMLDocumentPart.class, doc.getClass());
+ }
+ }
+
@Test
public void testOSGIClassLoading() {
// the schema type loader is cached per thread in POIXMLTypeLoader.