* @throws InvalidFormatException
*/
private void getPart( OpcPackage pkg, RelationshipsPart rp, Relationship r)
throws Docx4JException, InvalidFormatException, URISyntaxException {
Base source = null;
String resolvedPartUri = null;
if (r.getTargetMode() == null
|| !r.getTargetMode().equals("External") ) {
// Usual case
// source = r.getSource();
// resolvedPartUri = URIHelper.resolvePartUri(r.getSourceURI(), r.getTargetURI() ).toString();
source = rp.getSourceP();
resolvedPartUri = URIHelper.resolvePartUri(rp.getSourceURI(), new URI(r.getTarget() ) ).toString();
// Don't drop leading "/' in Xml Package
// resolvedPartUri = resolvedPartUri.substring(1);
} else {
// EXTERNAL
/* "When set to External, the target attribute may be a relative
* reference or a URI. If the target attribute is a relative
* reference, then that reference is interpreted relative to the
* location of the package."
*/
log.info("Encountered external resource " + r.getTarget()
+ " of type " + r.getType() );
// As of 1 May 2008, we don't do anything with these yet.
// No need to create a Part out of them until such time as
// we need to read the contents. (External resources don't
// seem to necessarily be described in [ContentTypes].xml )
// When the document is saved, the relationship is simply
// written again.
return;
}
if (handled.get(resolvedPartUri)!=null) return;
String relationshipType = r.getType();
Part part = getRawPart(ctm, resolvedPartUri,r);
rp.loadPart(part, r);
handled.put(resolvedPartUri, resolvedPartUri);
// The source Part (or Package) might have a convenience
// method for this
if (source.setPartShortcut(part, relationshipType ) ) {
log.debug("Convenience method established from " + source.getPartName()
+ " to " + part.getPartName());
}
// log.info(".. added." );