Package org.docx4j.openpackaging.packages

Examples of org.docx4j.openpackaging.packages.OpcPackage


    }
   
     
    // Load the Package as an OpcPackage, since this
    // works for docx, pptx, and xlsx
    OpcPackage opcPackage = OpcPackage.load(new java.io.File(inputfilepath));   
   
    if (printContentTypes)
      printContentTypes(opcPackage);
   
    // List the parts by walking the rels tree
    RelationshipsPart rp = opcPackage.getRelationshipsPart();
    StringBuilder sb = new StringBuilder();
    printInfo(rp, sb, "");
    traverseRelationships(opcPackage, rp, sb, "    ");
   
    System.out.println(sb.toString());
View Full Code Here


//    _loadFromZipFile = new LoadFromZipFile(ctm);
//    _loadFromZipFile.loadExternalTargets(loadExternalTargets);
//  }
 
  public OpcPackage get(String filepath) throws Docx4JException {
    OpcPackage thePackage = null;
    try {
      FileObject fo = VFS.getManager().resolveFile(filepath);
      thePackage = getPackageFromFileObject(fo);
    } catch (FileSystemException exc) {
      exc.printStackTrace();
View Full Code Here

    }
    return thePackage;
  }
 
  public OpcPackage getPackageFromFileObject(FileObject fo) throws Docx4JException {
    OpcPackage thePackage = null;
   
    if (!(fo instanceof LocalFile)) {
      //Non-Local file such as webdav file.
      //We make a temporary local copy of the file.
      //TODO: 28/03/08 - This is a second approach of dealing with non-local file.
View Full Code Here

   
    return thePackage;
  }
 
  public OpcPackage getPackageFromLocalFile(LocalFile fo) throws Docx4JException {
    OpcPackage thePackage = null;
   
    String localPath = VFSUtils.getLocalFilePath(fo);
    if (localPath == null) {
      throw new Docx4JException("Couldn't get local path");
    }
View Full Code Here

        hfTemplates.put(rel, part);
      }
    }
   
    // Create WordprocessingMLPackage target, by cloning
    OpcPackage result = null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SaveToZipFile saver = new SaveToZipFile(input);
    saver.save(baos);
    byte[] template = baos.toByteArray();
    WordprocessingMLPackage target = WordprocessingMLPackage.load(
View Full Code Here

 
  public static void main(String[] args) throws Exception {
   
//    String inputfilepath = System.getProperty("user.dir") + "/ole_tests/OUT_wmv_f.pptx";
    String inputfilepath = System.getProperty("user.dir") + "/ole_tests/wmv_CT.pptx";
    OpcPackage wordMLPackage = OpcPackage.load(new java.io.File(inputfilepath));
   
    FlatOpcXmlCreator worker = new FlatOpcXmlCreator(wordMLPackage);
   
    org.docx4j.xmlPackage.Package result = worker.get();
   
View Full Code Here

    this.runFontSelector = runFontSelector;    
  }

  @Override
  protected OpcPackage initializeOpcPackage(AbstractConversionSettings conversionSettings, OpcPackage opcPackage) {
  OpcPackage ret = super.initializeOpcPackage(conversionSettings, opcPackage);
    if (!(ret instanceof WordprocessingMLPackage)) {
      throw new IllegalArgumentException("The opcPackage isn't a WordprocessingMLPackage, it is a " + ret.getClass().getName());
    }
    resolveLinkedAbstractNum((WordprocessingMLPackage)ret);
    return ret;
  }
View Full Code Here

  protected static Logger log = LoggerFactory.getLogger(PartialDeepCopy.class);
 
 
  public static OpcPackage process(OpcPackage opcPackage, Set<String> relationshipTypes) throws Docx4JException {
   
    OpcPackage ret = null;
    RelationshipsPart relPart = null;
    if (opcPackage != null) {
      if ((relationshipTypes != null) && (relationshipTypes.isEmpty())) {
        ret = opcPackage;
      }
View Full Code Here

    return ret;
  }

  protected static OpcPackage createPackage(OpcPackage opcPackage) throws Docx4JException {
   
    OpcPackage ret = null;
    try {
      ret = opcPackage.getClass().newInstance();
    } catch (InstantiationException e) {
      throw new Docx4JException("InstantiationException duplicating package", e);
    } catch (IllegalAccessException e) {
      throw new Docx4JException("IllegalAccessException duplicating package", e);
    }
   
//    contentType
    ret.setContentType(new ContentType(opcPackage.getContentType()));
//    partName
    ret.setPartName(opcPackage.getPartName());
//    relationships
    //is done in an another method
//    userData
//    ret.setUserData(opcPackage.getUserData());
//    contentTypeManager
    ret.setContentTypeManager(opcPackage.getContentTypeManager());
//    customXmlDataStorageParts
    ret.getCustomXmlDataStorageParts().putAll(opcPackage.getCustomXmlDataStorageParts());
//    docPropsCorePart
    ret.setPartShortcut(opcPackage.getDocPropsCorePart(), Namespaces.PROPERTIES_CORE);
//    docPropsCustomPart
    ret.setPartShortcut(opcPackage.getDocPropsCustomPart(), Namespaces.PROPERTIES_CUSTOM);
//    docPropsExtendedPart
    ret.setPartShortcut(opcPackage.getDocPropsExtendedPart(), Namespaces.PROPERTIES_EXTENDED);
   
   
//    externalResources
    ret.getExternalResources().putAll(opcPackage.getExternalResources());
//    handled
    //isn't needed as it is already loaded
//    parts
    //is done in an another method
//    partStore
    ret.setSourcePartStore(opcPackage.getSourcePartStore());
       
    return ret;
  }
View Full Code Here

    return childListItemList;
  }
 
  public static void main(String[] args) throws Exception {

    OpcPackage pkg = OpcPackage
        .load(new java.io.File(
            System.getProperty("user.dir")
            + "/sample-docs/glox/extracted/apes.pptx"));
   

    DiagramDataPart thisPart = null;
    for (Entry<PartName,Part> entry : pkg.getParts().getParts().entrySet() ) {
     
      if (entry.getValue().getContentType().equals( ContentTypes.DRAWINGML_DIAGRAM_DATA )) {
        thisPart = (DiagramDataPart)entry.getValue();
        break;
      }
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.packages.OpcPackage

Copyright © 2018 www.massapicom. 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.