Examples of ContentTypeManager


Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

//    org.docx4j.xmlPackage.Package wmlPackageEl = (org.docx4j.xmlPackage.Package)je.getValue();
    org.docx4j.xmlPackage.Package wmlPackageEl = (org.docx4j.xmlPackage.Package)XmlUtils.unwrap(result.getResult());
   
    org.docx4j.convert.in.FlatOpcXmlImporter xmlPackage = new org.docx4j.convert.in.FlatOpcXmlImporter( wmlPackageEl);
   
    ContentTypeManager ctm = new ContentTypeManager();
   
    Part tmpDocPart = xmlPackage.getRawPart(ctm,  "/word/document.xml", null);
    Part tmpStylesPart = xmlPackage.getRawPart(ctm,  "/word/styles.xml", null);
   
    // This code assumes all the existing rels etc of
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

  public static void apply(WordprocessingMLPackage otherPackage,
      Alterations alterations) throws Docx4JException, JAXBException {
   
    if (alterations.getContentTypes()!=null) {
      log.info("replacing [Content_Types].xml");
      ContentTypeManager newCTM = new ContentTypeManager();
      newCTM.parseContentTypesFile(
          new ByteArrayInputStream(alterations.getContentTypes()));
      otherPackage.setContentTypeManager(newCTM);
    }
   
    if (alterations.isEmpty() ) return;
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

//  public HashMap unusedJCRNodes = null;
 
  public NodeMapper nodeMapper = null;
 
  public LoadFromJCR(NodeMapper nodeMapper) {
    this(new ContentTypeManager(), nodeMapper );
  }
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

   
    // Create skeletal package, including a MainPresentationPart and a SlideLayoutPart
    PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
   
    if (MACRO_ENABLE) {
      ContentTypeManager ctm = presentationMLPackage.getContentTypeManager();
      ctm.removeContentType(new PartName("/ppt/presentation.xml") );
      ctm.addOverrideContentType(new URI("/ppt/presentation.xml"), ContentTypes.PRESENTATIONML_MACROENABLED);
    }
    
    // Need references to these parts to create a slide
    // Please note that these parts *already exist* - they are
    // created by createPackage() above.  See that method
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

      
        p.getTargetPartStore().setOutputStream(realOS);
      

      // 3. Save [Content_Types].xml
      ContentTypeManager ctm = p.getContentTypeManager();
      p.getTargetPartStore().saveContentTypes(ctm);
     
      // 4. Start with _rels/.rels

//      <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

  public OpcPackage get() throws Docx4JException {
   
    long startTime = System.currentTimeMillis();       

    // 1. Get [Content_Types].xml
    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);
    } catch (NullPointerException e) {
      throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e);
    } finally {
      IOUtils.closeQuietly(is);
    }
   
    // .. now find the name of the main part
    RelationshipsPart rp = RelationshipsPart.createPackageRels();
    populatePackageRels(rp);
   
    String mainPartName = PackageRelsUtil.getNameOfMainPart(rp);
    PartName mainPartNameObj;
    if (mainPartName.startsWith("/")) {
      // OpenXML SDK 2.0 writes Target="/word/document.xml" (note leading "/")
      mainPartNameObj = new PartName(mainPartName);
    } else {
      // Microsoft Word, docx4j etc write Target="word/document.xml"
      mainPartNameObj = new PartName("/" + mainPartName);
    }
    String pkgContentType = ctm.getContentType(mainPartNameObj);

    // 2. Create a new Package; this'll return the appropriate subclass
    OpcPackage p = ctm.createPackage(pkgContentType);
    log.info("Instantiated package of type " + p.getClass().getName() );
    p.setSourcePartStore(partStore);

    p.setRelationships(rp);
    rp.setSourceP(p); //
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

     
//          // Create the ZIP file
//          ZipOutputStream out = new ZipOutputStream(new FileOutputStream(filepath));

      // 3. Get [Content_Types].xml
      ContentTypeManager ctm = p.getContentTypeManager();
      org.w3c.dom.Document w3cDoc = XmlUtils.getNewDocumentBuilder().newDocument();
     
      ctm.marshal( w3cDoc );
     
      saveRawXmlPart(jcrSession, baseNode, "[Content_Types].xml", w3cDoc);
     
         
      // 4. Start with _rels/.rels
View Full Code Here

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager

    // 2. Create a new Package
    //    Eventually, you'll also be able to create an Excel package etc
    //    but only the WordML package exists at present
   
    ContentTypeManager ctm = new ContentTypeManager();

    try {
      InputStream is = getInputStreamFromZippedPart( partByteArrays,  "[Content_Types].xml");   
      ctm.parseContentTypesFile(is);
    } catch (IOException e) {
      throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e);
    } catch (NullPointerException e) {
      throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e);
    }
   
    // .. now find the name of the main part
    RelationshipsPart rp = RelationshipsPart.createPackageRels();
    populatePackageRels(partByteArrays, rp);
   
    String mainPartName = PackageRelsUtil.getNameOfMainPart(rp);
    String pkgContentType = ctm.getContentType(new PartName("/" + mainPartName));

    // 2. Create a new Package; this'll return the appropriate subclass
    OpcPackage p = ctm.createPackage(pkgContentType);
    log.info("Instantiated package of type " + p.getClass().getName() );

    p.setRelationships(rp);
    rp.setSourceP(p); //
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.