git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1834729 13f79535-47bb-0310-9956-ffa450edef68tags/REL_4_0_0_FINAL
* @since by POI 3.14-Beta1 | * @since by POI 3.14-Beta1 | ||||
*/ | */ | ||||
public POIXMLDocumentPart createDocumentPart(POIXMLDocumentPart parent, PackagePart part) { | 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()); | LOGGER.log(POILogger.DEBUG, "using default POIXMLDocumentPart for " + rel.getRelationshipType()); | ||||
return new POIXMLDocumentPart(parent, part); | return new POIXMLDocumentPart(parent, part); | ||||
} | } |
null | 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( | public static final XSLFRelation WORKBOOK = new XSLFRelation( | ||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||||
POIXMLDocument.PACK_OBJECT_REL_TYPE, | POIXMLDocument.PACK_OBJECT_REL_TYPE, |
open.close(); | 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 | @Test | ||||
public void testOSGIClassLoading() { | public void testOSGIClassLoading() { | ||||
// the schema type loader is cached per thread in POIXMLTypeLoader. | // the schema type loader is cached per thread in POIXMLTypeLoader. |