List of usage examples for org.apache.poi.openxml4j.opc PackagePart getRelationships
public PackageRelationshipCollection getRelationships() throws InvalidFormatException
From source file:mj.ocraptor.extraction.tika.parser.microsoft.ooxml.AbstractOOXMLExtractor.java
License:Apache License
private void handleEmbeddedParts(ContentHandler handler) throws TikaException, IOException, SAXException { try {//from w w w . ja v a2s. c o m for (PackagePart source : getMainDocumentParts()) { for (PackageRelationship rel : source.getRelationships()) { URI sourceURI = rel.getSourceURI(); String sourceDesc; if (sourceURI != null) { sourceDesc = getJustFileName(sourceURI.getPath()); if (sourceDesc.startsWith("slide")) { sourceDesc += "_"; } else { sourceDesc = ""; } } else { sourceDesc = ""; } if (rel.getTargetMode() == TargetMode.INTERNAL) { PackagePart target; try { target = source.getRelatedPart(rel); } catch (IllegalArgumentException ex) { continue; } String type = rel.getRelationshipType(); if (RELATION_OLE_OBJECT.equals(type) && TYPE_OLE_OBJECT.equals(target.getContentType())) { handleEmbeddedOLE(target, handler, sourceDesc + rel.getId()); } else if (RELATION_AUDIO.equals(type) || RELATION_IMAGE.equals(type) || RELATION_PACKAGE.equals(type) || RELATION_OLE_OBJECT.equals(type)) { handleEmbeddedFile(target, handler, sourceDesc + rel.getId()); } } } } } catch (InvalidFormatException e) { throw new TikaException("Broken OOXML file", e); } }