Examples of OdfFileEntry


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

                        buf.append(" >\n");
      Iterator<String> it = new TreeSet<String>(mManifestEntries.keySet()).iterator();
      while (it.hasNext()) {
        String key = it.next();
        String s = null;
        OdfFileEntry fileEntry = mManifestEntries.get(key);
        if (fileEntry != null) {
          s = fileEntry.getPath();
          // only directories with a mimetype (documents) will be written into the manifest.xml
          if (s != null && !s.endsWith(SLASH) || !fileEntry.getMediaTypeString().equals(EMPTY_STRING)) {
            buf.append(" <manifest:file-entry");
            if (s != null) {
              buf.append(" manifest:full-path=\"");
              buf.append(encodeXMLAttributes(s));
              buf.append("\"");

            }
            s = fileEntry.getMediaTypeString();
            buf.append(" manifest:media-type=\"");
            buf.append(encodeXMLAttributes(s));
            buf.append("\"");

            int i = fileEntry.getSize();
            if (i > 0) {
              buf.append(" manifest:size=\"");
              buf.append(i);
              buf.append("\"");
            }
            EncryptionData enc = fileEntry.getEncryptionData();
            if (enc != null) {
              buf.append(">\n");
              buf.append("  <manifest:encryption-data>\n");
              Algorithm alg = enc.getAlgorithm();
              if (alg != null) {
View Full Code Here

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

   */
  public OutputStream insertOutputStream(String internalPath, String mediaType)
      throws Exception {
    internalPath = normalizeFilePath(internalPath);
    final String fPath = internalPath;
    final OdfFileEntry fFileEntry = getFileEntry(internalPath);
    final String fMediaType = mediaType;

    ByteArrayOutputStream baos = new ByteArrayOutputStream() {

      @Override
      public void close() {
        try {
          byte[] data = this.toByteArray();
          if (fMediaType == null || fMediaType.length() == 0) {
            insert(data, fPath, fFileEntry == null ? null
                : fFileEntry.getMediaTypeString());
          } else {
            insert(data, fPath, fMediaType);
          }
          super.close();
        } catch (Exception ex) {
View Full Code Here

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

            newObjPath = objectRenameMap.get(refObjPath);
            object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href", hasPrefix ? (prefix + newObjPath) : newObjPath);
            continue;
          }
          // check if the current document contains the same path
          OdfFileEntry fileEntry = getPackage().getFileEntry(refObjPath);
          // note: if refObjPath is a directory, it must end with '/'
          if (fileEntry == null) {
            fileEntry = getPackage().getFileEntry(refObjPath + "/");
          }
          newObjPath = refObjPath;
View Full Code Here

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

          if (refObjPath.startsWith(prefix)) {
            refObjPath = refObjPath.substring(2);
            hasPrefix = true;
          }
          // check if the current document contains the same path
          OdfFileEntry fileEntry = getPackage().getFileEntry(refObjPath);
          // note: if refObjPath is a directory, it must end with '/'
          if (fileEntry == null) {
            fileEntry = getPackage().getFileEntry(refObjPath + "/");
          }
          String newObjPath = refObjPath;
View Full Code Here

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

            // delete "./"
            if (refObjPath.startsWith("./")) {
              refObjPath = refObjPath.substring(2);
            }
            // check if the current document contains the same path
            OdfFileEntry fileEntry = getPackage().getFileEntry(refObjPath);
            if (fileEntry != null) {
              // it is a stream, such as image, binary file
              getPackage().remove(refObjPath);
            } else {
              // note: if refObjPath is a directory, it must end
View Full Code Here

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

            //delete "./"
            if (refObjPath.startsWith("./")) {
              refObjPath = refObjPath.substring(2);
            }
            //check if the current document contains the same path
            OdfFileEntry fileEntry = getPackage().getFileEntry(refObjPath);
            if (fileEntry != null) {
              //it is a stream, such as image, binary file
              getPackage().remove(refObjPath);
            } else {
              //note: if refObjPath is a directory, it must end with '/'
View Full Code Here

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

          if (refObjPath.startsWith(prefix)) {
            refObjPath = refObjPath.substring(2);
            hasPrefix = true;
          }
          //check if the current document contains the same path
          OdfFileEntry fileEntry = getPackage().getFileEntry(refObjPath);
          //note: if refObjPath is a directory, it must end with '/'
          if (fileEntry == null) {
            fileEntry = getPackage().getFileEntry(refObjPath + "/");
          }
          String newObjPath = refObjPath;
View Full Code Here

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

      // Check if it is a sub-document?
      // Our assumption: it is a document if it has a mimetype...
      String dirMimeType = mManifestEntries.get(path).getMediaTypeString();
      if (dirMimeType == null || EMPTY_STRING.equals(dirMimeType)) {
        logValidationWarning(OdfPackageConstraint.MANIFEST_LISTS_DIRECTORY, getBaseURI(), path);
        OdfFileEntry manifestEntry = mManifestEntries.remove(path);
        FileEntryElement manifestEle = manifestEntry.getOdfElement();
        manifestEle.getParentNode().removeChild(manifestEle);
      }
    }
  }
View Full Code Here

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

    }
  }
 
  /** @returns the media type of the root document from the manifest.xml */
  private String getMediaTypeFromManifest() {
    OdfFileEntry rootDocumentEntry = mManifestEntries.get(SLASH);
    if (rootDocumentEntry != null) {
      return rootDocumentEntry.getMediaTypeString();
    } else {
      return null;
    }
  }
View Full Code Here

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

    }
    return mediaType;
  }
 
  private String getMediaTypeFromEntry(String internalPath) {
    OdfFileEntry entry = getFileEntry(internalPath);
    // if the document is not in the package, the return is NULL
    if (entry != null) {
      return entry.getMediaTypeString();
    } else {
      return null;
    }
  }
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.