* @throws InvalidFormatException
*/
public static Part getRawPart(ContentTypeManager ctm, org.docx4j.xmlPackage.Part pkgPart, Relationship rel)
throws Docx4JException {
Part part = null;
try {
org.w3c.dom.Element el = null;
try {
String contentType = pkgPart.getContentType();
log.debug("contentType: " + contentType);
if (pkgPart.getXmlData()!=null) {
// if its not binary
el = pkgPart.getXmlData().getAny();
}
// part = ctm.newPartForContentType(contentType, resolvedPartUri,rel);
part = ctm.newPartForContentType(contentType, pkgPart.getName(), rel);
part.setContentType( new ContentType(contentType) );
// ctm.addOverrideContentType(new java.net.URI(resolvedPartUri),
ctm.addOverrideContentType(new java.net.URI(pkgPart.getName()),
contentType);
if (part instanceof org.docx4j.openpackaging.parts.ThemePart) {
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jcThemePart);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof org.docx4j.openpackaging.parts.DocPropsCorePart ) {
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jcDocPropsCore);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof org.docx4j.openpackaging.parts.DocPropsCustomPart ) {
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jcDocPropsCustom);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof org.docx4j.openpackaging.parts.DocPropsExtendedPart ) {
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jcDocPropsExtended);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof org.docx4j.openpackaging.parts.CustomXmlDataStoragePropertiesPart ) {
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jcCustomXmlProperties);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof org.docx4j.openpackaging.parts.digitalsignature.XmlSignaturePart ) {
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jcXmlDSig);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof JaxbPmlPart) {
// Presentation type part
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(org.pptx4j.jaxb.Context.jcPML);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
} else if (part instanceof org.docx4j.openpackaging.parts.JaxbXmlPart) {
// MainDocument part, Styles part, Font part etc
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).setJAXBContext(Context.jc);
((org.docx4j.openpackaging.parts.JaxbXmlPart)part).unmarshal( el );
// } else if (part instanceof org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart) {
} else if (part instanceof org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart) {
log.debug("Detected BinaryPart " + part.getClass().getName() );
((BinaryPart)part).setBinaryData( pkgPart.getBinaryData() );
} else if (part instanceof org.docx4j.openpackaging.parts.CustomXmlDataStoragePart) {
// Is it a part we know?
try {
Unmarshaller u = Context.jc.createUnmarshaller();
Object o = u.unmarshal( el );
log.debug(o.getClass().getName());
PartName name = part.getPartName();
if (o instanceof CoverPageProperties) {
part = new DocPropsCoverPagePart(name);
((DocPropsCoverPagePart)part).setJaxbElement(