addDefaultContentType( defaultCT.getExtension(), defaultCT ); overrideCT = (CTOverride)o; URI uri = new URI(overrideCT.getPartName() ); addOverrideContentType(uri, overrideCT );
ContentTypeManager ctm = new ContentTypeManager(); ctm.parseContentTypesFile(is); } catch (IOException e) { throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e); String pkgContentType = ctm.getContentType(new PartName("/" + mainPartName)); OpcPackage p = ctm.createPackage(pkgContentType); log.info("Instantiated package of type " + p.getClass().getName() );
return CreateMainDocumentPartObject(partName); return CreateMainDocumentPartObject(partName); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_TEMPLATE)) { return CreateMainDocumentPartObject(partName); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_TEMPLATE_MACROENABLED)) { return CreateMainDocumentPartObject(partName); } else if (contentType.equals(ContentTypes.PACKAGE_COREPROPERTIES)) { return CreateDocPropsCorePartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_CUSTOMPROPERTIES)) { return CreateDocPropsCustomPartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_EXTENDEDPROPERTIES)) { return CreateDocPropsExtendedPartObject(partName ); return CreateCustomXmlDataStoragePropertiesPartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_FONT)) { return CreateObfuscatedFontPartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_OLE_OBJECT) || contentType.equals(ContentTypes.OFFICEDOCUMENT_ACTIVEX_OBJECT)) { return new org.docx4j.openpackaging.parts.ActiveXControlXmlPart(new PartName(partName)); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_THEME)) { return CreateThemePartObject(partName ); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_COMMENTS)) { return CreateCommentsPartObject(partName ); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_COMMENTS_EXTENDED)) { return new CommentsExtendedPart(new PartName(partName)); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_ENDNOTES)) { return CreateEndnotesPartObject(partName );
ctm = new ContentTypeManager(); ctm.addDefaultContentType("rels", "application/vnd.openxmlformats-package.relationships+xml"); ctm.addDefaultContentType("xml", "application/xml"); packageResult = ctm.createPackage(officeDocument.getContentType()); log.info("Creating " + packageResult.getClass().getName() );
public void registerInContentTypeManager() { ContentTypeManager ctm = this.getPackage().getContentTypeManager(); if (altChunkType != null) { ctm.addDefaultContentType(altChunkType.getExtension(), altChunkType.getContentType()); } } }
ContentTypeManager newCTM = new ContentTypeManager(); newCTM.parseContentTypesFile( new ByteArrayInputStream(alterations.getContentTypes())); otherPackage.setContentTypeManager(newCTM);
/** * Constructor. Also creates a new content type manager * */ public OpcPackage() { try { this.setPartName(new PartName("/", false)); contentTypeManager = new ContentTypeManager(); } catch (Exception e) { log.error(e.getMessage()); // TODO: handle exception } }
public static RelationshipsPart createRelationshipsPartForPart( Base sourcePart) { if (sourcePart.relationships != null) return sourcePart.relationships; RelationshipsPart rp = null; try { rp = new RelationshipsPart(sourcePart); } catch (InvalidFormatException e) { // shouldn't happen log.error(e.getMessage(), e); } rp.setPackage(sourcePart.getPackage()); // Make sure content manager knows how to handle .rels sourcePart .getPackage() .getContentTypeManager() .addDefaultContentType( "rels", org.docx4j.openpackaging.contenttype.ContentTypes.RELATIONSHIPS_PART); return rp; }
ctm = new ContentTypeManager(); ctm.addDefaultContentType("rels", "application/vnd.openxmlformats-package.relationships+xml"); ctm.addDefaultContentType("xml", "application/xml"); packageResult = ctm.createPackage(officeDocument.getContentType()); log.info("Creating " + packageResult.getClass().getName() );
ContentTypeManager newCTM = new ContentTypeManager(); newCTM.parseContentTypesFile( new ByteArrayInputStream(alterations.getContentTypes())); otherPackage.setContentTypeManager(newCTM);
ContentTypeManager ctm = new ContentTypeManager();
return CreateMainDocumentPartObject(partName); return CreateMainDocumentPartObject(partName); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_TEMPLATE)) { return CreateMainDocumentPartObject(partName); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_TEMPLATE_MACROENABLED)) { return CreateMainDocumentPartObject(partName); } else if (contentType.equals(ContentTypes.PACKAGE_COREPROPERTIES)) { return CreateDocPropsCorePartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_CUSTOMPROPERTIES)) { return CreateDocPropsCustomPartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_EXTENDEDPROPERTIES)) { return CreateDocPropsExtendedPartObject(partName ); return CreateCustomXmlDataStoragePropertiesPartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_FONT)) { return CreateObfuscatedFontPartObject(partName ); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_OLE_OBJECT) || contentType.equals(ContentTypes.OFFICEDOCUMENT_ACTIVEX_OBJECT)) { return new org.docx4j.openpackaging.parts.ActiveXControlXmlPart(new PartName(partName)); } else if (contentType.equals(ContentTypes.OFFICEDOCUMENT_THEME)) { return CreateThemePartObject(partName ); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_COMMENTS)) { return CreateCommentsPartObject(partName ); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_COMMENTS_EXTENDED)) { return new CommentsExtendedPart(new PartName(partName)); } else if (contentType.equals(ContentTypes.WORDPROCESSINGML_ENDNOTES)) { return CreateEndnotesPartObject(partName );
ctm.addDefaultContentType(ext,ContentTypes.IMAGE_JPEG ); } else if ( part.getContentType().equals( ContentTypes.EXTENSION_GIF ) ) { ctm.addDefaultContentType(ext, ContentTypes.EXTENSION_GIF); } else if ( part.getContentType().equals( ContentTypes.EXTENSION_PNG ) ) { ctm.addDefaultContentType(ext, ContentTypes.IMAGE_PNG); ctm.addOverrideContentType(part.getPartName().getURI(), part.getContentType());
ContentTypeManager ctm = new ContentTypeManager(); InputStream is = null; try { is = partStore.loadPart("[Content_Types].xml"); ctm.parseContentTypesFile(is); } catch (Docx4JException e) { throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e); String pkgContentType = ctm.getContentType(mainPartNameObj); OpcPackage p = ctm.createPackage(pkgContentType); if (existingPkg==null) { p = ctm.createPackage(pkgContentType); } else { if (existingPkg.getClass()!=p.getClass()) {
public void inlineToDocx(WordprocessingMLPackage wordPackage, Text text, Object paramValue, Matcher matcher) { try { R run = (R) text.getParent(); wordPackage.getContentTypeManager().addDefaultContentType("xhtml", "text/xhtml"); MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart(); mainDocumentPart.addAltChunk(AltChunkType.Xhtml, paramValue.toString().getBytes(), run); text.setValue(""); } catch (Exception e) { throw new ReportFormattingException("An error occurred while inserting html to docx file", e); } }
/** * Constructor. Also creates a new content type manager * */ public OpcPackage() { try { this.setPartName(new PartName("/", false)); contentTypeManager = new ContentTypeManager(); } catch (Exception e) { log.error(e.getMessage()); // TODO: handle exception } }
addDefaultContentType( defaultCT.getExtension(), defaultCT ); overrideCT = (CTOverride)o; URI uri = new URI(overrideCT.getPartName() ); addOverrideContentType(uri, overrideCT );
ContentTypeManager ctm = new ContentTypeManager(); ctm.parseContentTypesFile(is); } catch (IOException e) { throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e); String pkgContentType = ctm.getContentType(new PartName("/" + mainPartName)); OpcPackage p = ctm.createPackage(pkgContentType); log.info("Instantiated package of type " + p.getClass().getName() );
public void inlineToDocx(WordprocessingMLPackage wordPackage, Text text, Object paramValue, Matcher matcher) { try { R run = (R) text.getParent(); wordPackage.getContentTypeManager().addDefaultContentType("xhtml", "text/xhtml"); MainDocumentPart mainDocumentPart = wordPackage.getMainDocumentPart(); mainDocumentPart.addAltChunk(AltChunkType.Xhtml, paramValue.toString().getBytes(), run); text.setValue(""); } catch (Exception e) { throw new ReportFormattingException("An error occurred while inserting html to docx file", e); } }
ContentTypeManager ctm = new ContentTypeManager();