Package org.odftoolkit.odfdom.pkg.manifest

Examples of org.odftoolkit.odfdom.pkg.manifest.ManifestElement


  private void parseManifest() throws Exception {
    // ToDo: manifest.xml will be held in the future as DOM, now its
    // being generated for each save()
    // try {
    mManifestDom = (OdfManifestDom) OdfFileDom.newFileDom(this, OdfFile.MANIFEST.getPath());
    ManifestElement manifestEle = mManifestDom.getRootElement();
    if (manifestEle != null) {
      setManifestVersion(manifestEle.getVersionAttribute());
    } else {
      logValidationError(OdfPackageConstraint.MANIFEST_NOT_IN_PACKAGE, getBaseURI());
    }
    Map<String, OdfFileEntry> entries = getManifestEntries();
    FileEntryElement fileEntryEle = OdfElement.findFirstChildNode(FileEntryElement.class, manifestEle);
View Full Code Here


  }
 
  // Add the given path and all its subdirectories to the internalPath list
  // to be written later to the manifest
  private void createSubEntries(String internalPath) {
    ManifestElement manifestEle = getManifestDom().getRootElement();
    StringTokenizer tok = new StringTokenizer(internalPath, SLASH);
    if (tok.countTokens() > 1) {
      String path = EMPTY_STRING;
      while (tok.hasMoreTokens()) {
        String directory = tok.nextToken();
        // it is a directory, if there are more token
        if (tok.hasMoreTokens()) {
          path = path + directory + SLASH;
          OdfFileEntry fileEntry = mManifestEntries.get(path);
          if (fileEntry == null) {
            mManifestEntries.put(path, new OdfFileEntry(manifestEle.newFileEntryElement(path, null)));
          }
        }
      }
    }
  }
View Full Code Here

          Logger.getLogger(OdfPackage.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    }
    // make sure the media type of embedded Document is right set.
    ManifestElement manifestEle = mManifestDom.getRootElement();
    OdfFileEntry embedDocumentRootEntry = new OdfFileEntry(manifestEle.newFileEntryElement(internalPath, sourceDocument.getMediaTypeString()));
    mManifestEntries.put(internalPath, embedDocumentRootEntry);
    // the new document will be attached to its new package (it has been
    // inserted to)
    sourceDocument.setPackage(this);
    cacheDocument(sourceDocument, internalPath);
View Full Code Here

  private Map<String, OdfFileEntry> getSubDirectoryEntries(OdfPackage destinationPackage, String directory) {
    directory = normalizeDirectoryPath(directory);
    Map<String, OdfFileEntry> subEntries = new HashMap<String, OdfFileEntry>();
    Map<String, OdfFileEntry> allEntries = getManifestEntries();
    Set<String> rootEntryNameSet = getFilePaths();
    ManifestElement manifestEle = destinationPackage.getManifestDom().getRootElement();
    for (String entryName : rootEntryNameSet) {
      if (entryName.startsWith(directory)) {
        String newEntryName = entryName.substring(directory.length());
        if (newEntryName.length() == 0) {
          newEntryName = SLASH;
        }
        OdfFileEntry srcFileEntry = allEntries.get(entryName);
        OdfFileEntry newFileEntry = new OdfFileEntry(manifestEle.newFileEntryElement(newEntryName, srcFileEntry.getMediaTypeString()));
        newFileEntry.setEncryptionData(srcFileEntry.getEncryptionData());
        newFileEntry.setSize(srcFileEntry.getSize());
        subEntries.put(entryName, newFileEntry);
      }
    }
View Full Code Here

        mManifestEntries = new HashMap<String, OdfFileEntry>();
      }
      fileEntry = mManifestEntries.get(internalPath);
      // for every new file entry
      if (fileEntry == null) {
        ManifestElement manifestEle = getManifestDom().getRootElement();
        if (manifestEle == null)
          return null;
        fileEntry = new OdfFileEntry(manifestEle.newFileEntryElement(internalPath, ""));
        mManifestEntries.put(internalPath, fileEntry);
        // creates recursive file entries for all sub directories
        createSubEntries(internalPath);
      }
    }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.pkg.manifest.ManifestElement

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.