You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:22:17 UTC

svn commit: r1890119 [3/10] - in /poi/trunk/poi-ooxml/src: main/java/org/apache/poi/ooxml/extractor/ main/java/org/apache/poi/ooxml/util/ main/java/org/apache/poi/openxml4j/exceptions/ main/java/org/apache/poi/openxml4j/opc/ main/java/org/apache/poi/op...

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageNamespaces.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageNamespaces.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageNamespaces.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageNamespaces.java Sat May 22 20:22:16 2021
@@ -24,28 +24,28 @@ package org.apache.poi.openxml4j.opc;
  */
 public interface PackageNamespaces {
 
-	/**
-	 * Content Types.
-	 */
-	public static final String CONTENT_TYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
+    /**
+     * Content Types.
+     */
+    public static final String CONTENT_TYPES = "http://schemas.openxmlformats.org/package/2006/content-types";
 
-	/**
-	 * Core Properties.
-	 */
-	public static final String CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
+    /**
+     * Core Properties.
+     */
+    public static final String CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
 
-	/**
-	 * Digital Signatures.
-	 */
-	public static final String DIGITAL_SIGNATURE = "http://schemas.openxmlformats.org/package/2006/digital-signature";
+    /**
+     * Digital Signatures.
+     */
+    public static final String DIGITAL_SIGNATURE = "http://schemas.openxmlformats.org/package/2006/digital-signature";
 
-	/**
-	 * Relationships.
-	 */
-	public static final String RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
+    /**
+     * Relationships.
+     */
+    public static final String RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships";
 
-	/**
-	 * Markup Compatibility.
-	 */
-	public static final String MARKUP_COMPATIBILITY = "http://schemas.openxmlformats.org/markup-compatibility/2006";
+    /**
+     * Markup Compatibility.
+     */
+    public static final String MARKUP_COMPATIBILITY = "http://schemas.openxmlformats.org/markup-compatibility/2006";
 }

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartCollection.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartCollection.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartCollection.java Sat May 22 20:22:16 2021
@@ -36,7 +36,7 @@ import org.apache.poi.openxml4j.exceptio
  */
 public final class PackagePartCollection implements Serializable {
 
-	private static final long serialVersionUID = 2515031135957635517L;
+    private static final long serialVersionUID = 2515031135957635517L;
 
     /**
      * HashSet use to store this collection part names as string for rule
@@ -44,73 +44,73 @@ public final class PackagePartCollection
      */
     private final Set<String> registerPartNameStr = new HashSet<>();
 
-	private final TreeMap<String, PackagePart> packagePartLookup =
+    private final TreeMap<String, PackagePart> packagePartLookup =
         new TreeMap<>(PackagePartName::compare);
 
 
-	/**
-	 * Check rule [M1.11]: a package implementer shall neither create nor
-	 * recognize a part with a part name derived from another part name by
-	 * appending segments to it.
-	 *
-	 * @param partName name of part
-	 * @param part part to put
+    /**
+     * Check rule [M1.11]: a package implementer shall neither create nor
+     * recognize a part with a part name derived from another part name by
+     * appending segments to it.
+     *
+     * @param partName name of part
+     * @param part part to put
      * @return the previous value associated with {@code partName}, or
      *         {@code null} if there was no mapping for {@code partName}.
-	 * @exception InvalidOperationException
-	 *                Throws if you try to add a part with a name derived from
-	 *                another part name.
-	 */
-	public PackagePart put(final PackagePartName partName, final PackagePart part) {
-	    final String ppName = partName.getName();
+     * @exception InvalidOperationException
+     *                Throws if you try to add a part with a name derived from
+     *                another part name.
+     */
+    public PackagePart put(final PackagePartName partName, final PackagePart part) {
+        final String ppName = partName.getName();
         final StringBuilder concatSeg = new StringBuilder();
         // split at slash, but keep leading slash
         final String delim = "(?=["+PackagingURIHelper.FORWARD_SLASH_STRING+".])";
-		for (String seg : ppName.split(delim)) {
-			concatSeg.append(seg);
-			if (registerPartNameStr.contains(concatSeg.toString())) {
-				throw new InvalidOperationException(
-					"You can't add a part with a part name derived from another part ! [M1.11]");
-			}
-		}
-		registerPartNameStr.add(ppName);
-		return packagePartLookup.put(ppName, part);
-	}
-
-	public PackagePart remove(PackagePartName key) {
-	    if (key == null) {
-	        return null;
-	    }
+        for (String seg : ppName.split(delim)) {
+            concatSeg.append(seg);
+            if (registerPartNameStr.contains(concatSeg.toString())) {
+                throw new InvalidOperationException(
+                    "You can't add a part with a part name derived from another part ! [M1.11]");
+            }
+        }
+        registerPartNameStr.add(ppName);
+        return packagePartLookup.put(ppName, part);
+    }
+
+    public PackagePart remove(PackagePartName key) {
+        if (key == null) {
+            return null;
+        }
         final String ppName = key.getName();
-	    PackagePart pp = packagePartLookup.remove(ppName);
-	    if (pp != null) {
-	        this.registerPartNameStr.remove(ppName);
-	    }
-		return pp;
-	}
+        PackagePart pp = packagePartLookup.remove(ppName);
+        if (pp != null) {
+            this.registerPartNameStr.remove(ppName);
+        }
+        return pp;
+    }
 
 
-	/**
-	 * The values themselves should be returned in sorted order. Doing it here
-	 * avoids paying the high cost of Natural Ordering per insertion.
+    /**
+     * The values themselves should be returned in sorted order. Doing it here
+     * avoids paying the high cost of Natural Ordering per insertion.
      * @return unmodifiable collection of parts
-	 */
-	public Collection<PackagePart> sortedValues() {
-	    return Collections.unmodifiableCollection(packagePartLookup.values());
-
-	}
-
-	public boolean containsKey(PackagePartName partName) {
-		return partName != null && packagePartLookup.containsKey(partName.getName());
-	}
-
-	public PackagePart get(PackagePartName partName) {
-		return partName == null ? null : packagePartLookup.get(partName.getName());
-	}
-
-	public int size() {
-		return packagePartLookup.size();
-	}
+     */
+    public Collection<PackagePart> sortedValues() {
+        return Collections.unmodifiableCollection(packagePartLookup.values());
+
+    }
+
+    public boolean containsKey(PackagePartName partName) {
+        return partName != null && packagePartLookup.containsKey(partName.getName());
+    }
+
+    public PackagePart get(PackagePartName partName) {
+        return partName == null ? null : packagePartLookup.get(partName.getName());
+    }
+
+    public int size() {
+        return packagePartLookup.size();
+    }
 
 
 

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartName.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartName.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartName.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackagePartName.java Sat May 22 20:22:16 2021
@@ -32,271 +32,271 @@ import org.apache.poi.openxml4j.exceptio
  */
 public final class PackagePartName implements Comparable<PackagePartName> {
 
-	/**
-	 * Part name stored as an URI.
-	 */
-	private final URI partNameURI;
-
-	/*
-	 * URI Characters definition (RFC 3986)
-	 */
-
-	/**
-	 * Reserved characters for sub delimiters.
-	 */
-	private static final String RFC3986_PCHAR_SUB_DELIMS = "!$&'()*+,;=";
-
-	/**
-	 * Unreserved character (+ ALPHA & DIGIT).
-	 */
-	private static final String RFC3986_PCHAR_UNRESERVED_SUP = "-._~";
-
-	/**
-	 * Authorized reserved characters for pChar.
-	 */
-	private static final String RFC3986_PCHAR_AUTHORIZED_SUP = ":@";
-
-	/**
-	 * Flag to know if this part name is from a relationship part name.
-	 */
-	private final boolean isRelationship;
-
-	/**
-	 * Constructor. Makes a ValidPartName object from a java.net.URI
-	 *
-	 * @param uri
-	 *            The URI to validate and to transform into ValidPartName.
-	 * @param checkConformance
-	 *            Flag to specify if the constructor have to validate the OPC
-	 *            conformance. Must be always <code>true</code> except for
-	 *            special URI like '/' which is needed for internal use by
-	 *            OpenXML4J but is not valid.
-	 * @throws InvalidFormatException
-	 *             Throw if the specified part name is not conform to Open
-	 *             Packaging Convention specifications.
-	 * @see java.net.URI
-	 */
-	PackagePartName(URI uri, boolean checkConformance)
-			throws InvalidFormatException {
-		if (checkConformance) {
-			throwExceptionIfInvalidPartUri(uri);
-		} else {
-			if (!PackagingURIHelper.PACKAGE_ROOT_URI.equals(uri)) {
-				throw new OpenXML4JRuntimeException(
-						"OCP conformance must be check for ALL part name except special cases : ['/']");
-			}
-		}
-		this.partNameURI = uri;
-		this.isRelationship = isRelationshipPartURI(this.partNameURI);
-	}
-
-	/**
-	 * Constructor. Makes a ValidPartName object from a String part name.
-	 *
-	 * @param partName
-	 *            Part name to valid and to create.
-	 * @param checkConformance
-	 *            Flag to specify if the constructor have to validate the OPC
-	 *            conformance. Must be always <code>true</code> except for
-	 *            special URI like '/' which is needed for internal use by
-	 *            OpenXML4J but is not valid.
-	 * @throws InvalidFormatException
-	 *             Throw if the specified part name is not conform to Open
-	 *             Packaging Convention specifications.
-	 */
-	PackagePartName(String partName, boolean checkConformance)
-			throws InvalidFormatException {
-		URI partURI;
-		try {
-			partURI = new URI(partName);
-		} catch (URISyntaxException e) {
-			throw new IllegalArgumentException(
-					"partName argmument is not a valid OPC part name !");
-		}
-
-		if (checkConformance) {
-			throwExceptionIfInvalidPartUri(partURI);
-		} else {
-			if (!PackagingURIHelper.PACKAGE_ROOT_URI.equals(partURI)) {
-				throw new OpenXML4JRuntimeException(
-						"OCP conformance must be check for ALL part name except special cases : ['/']");
-			}
-		}
-		this.partNameURI = partURI;
-		this.isRelationship = isRelationshipPartURI(this.partNameURI);
-	}
-
-	/**
-	 * Check if the specified part name is a relationship part name.
-	 *
-	 * @param partUri
-	 *            The URI to check.
-	 * @return <code>true</code> if this part name respect the relationship
-	 *         part naming convention else <code>false</code>.
-	 */
-	private boolean isRelationshipPartURI(URI partUri) {
-		if (partUri == null) {
+    /**
+     * Part name stored as an URI.
+     */
+    private final URI partNameURI;
+
+    /*
+     * URI Characters definition (RFC 3986)
+     */
+
+    /**
+     * Reserved characters for sub delimiters.
+     */
+    private static final String RFC3986_PCHAR_SUB_DELIMS = "!$&'()*+,;=";
+
+    /**
+     * Unreserved character (+ ALPHA & DIGIT).
+     */
+    private static final String RFC3986_PCHAR_UNRESERVED_SUP = "-._~";
+
+    /**
+     * Authorized reserved characters for pChar.
+     */
+    private static final String RFC3986_PCHAR_AUTHORIZED_SUP = ":@";
+
+    /**
+     * Flag to know if this part name is from a relationship part name.
+     */
+    private final boolean isRelationship;
+
+    /**
+     * Constructor. Makes a ValidPartName object from a java.net.URI
+     *
+     * @param uri
+     *            The URI to validate and to transform into ValidPartName.
+     * @param checkConformance
+     *            Flag to specify if the constructor have to validate the OPC
+     *            conformance. Must be always <code>true</code> except for
+     *            special URI like '/' which is needed for internal use by
+     *            OpenXML4J but is not valid.
+     * @throws InvalidFormatException
+     *             Throw if the specified part name is not conform to Open
+     *             Packaging Convention specifications.
+     * @see java.net.URI
+     */
+    PackagePartName(URI uri, boolean checkConformance)
+            throws InvalidFormatException {
+        if (checkConformance) {
+            throwExceptionIfInvalidPartUri(uri);
+        } else {
+            if (!PackagingURIHelper.PACKAGE_ROOT_URI.equals(uri)) {
+                throw new OpenXML4JRuntimeException(
+                        "OCP conformance must be check for ALL part name except special cases : ['/']");
+            }
+        }
+        this.partNameURI = uri;
+        this.isRelationship = isRelationshipPartURI(this.partNameURI);
+    }
+
+    /**
+     * Constructor. Makes a ValidPartName object from a String part name.
+     *
+     * @param partName
+     *            Part name to valid and to create.
+     * @param checkConformance
+     *            Flag to specify if the constructor have to validate the OPC
+     *            conformance. Must be always <code>true</code> except for
+     *            special URI like '/' which is needed for internal use by
+     *            OpenXML4J but is not valid.
+     * @throws InvalidFormatException
+     *             Throw if the specified part name is not conform to Open
+     *             Packaging Convention specifications.
+     */
+    PackagePartName(String partName, boolean checkConformance)
+            throws InvalidFormatException {
+        URI partURI;
+        try {
+            partURI = new URI(partName);
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException(
+                    "partName argmument is not a valid OPC part name !");
+        }
+
+        if (checkConformance) {
+            throwExceptionIfInvalidPartUri(partURI);
+        } else {
+            if (!PackagingURIHelper.PACKAGE_ROOT_URI.equals(partURI)) {
+                throw new OpenXML4JRuntimeException(
+                        "OCP conformance must be check for ALL part name except special cases : ['/']");
+            }
+        }
+        this.partNameURI = partURI;
+        this.isRelationship = isRelationshipPartURI(this.partNameURI);
+    }
+
+    /**
+     * Check if the specified part name is a relationship part name.
+     *
+     * @param partUri
+     *            The URI to check.
+     * @return <code>true</code> if this part name respect the relationship
+     *         part naming convention else <code>false</code>.
+     */
+    private boolean isRelationshipPartURI(URI partUri) {
+        if (partUri == null) {
             throw new IllegalArgumentException("partUri");
         }
 
-		return partUri.getPath().matches(
-				"^.*/" + PackagingURIHelper.RELATIONSHIP_PART_SEGMENT_NAME + "/.*\\"
-						+ PackagingURIHelper.RELATIONSHIP_PART_EXTENSION_NAME
-						+ "$");
-	}
-
-	/**
-	 * Know if this part name is a relationship part name.
-	 *
-	 * @return <code>true</code> if this part name respect the relationship
-	 *         part naming convention else <code>false</code>.
-	 */
-	public boolean isRelationshipPartURI() {
-		return this.isRelationship;
-	}
-
-	/**
-	 * Throws an exception (of any kind) if the specified part name does not
-	 * follow the Open Packaging Convention specifications naming rules.
-	 *
-	 * @param partUri
-	 *            The part name to check.
-	 * @throws InvalidFormatException
-	 *             Throws if the part name is invalid.
-	 */
-	private static void throwExceptionIfInvalidPartUri(URI partUri)
-			throws InvalidFormatException {
-		if (partUri == null) {
+        return partUri.getPath().matches(
+                "^.*/" + PackagingURIHelper.RELATIONSHIP_PART_SEGMENT_NAME + "/.*\\"
+                        + PackagingURIHelper.RELATIONSHIP_PART_EXTENSION_NAME
+                        + "$");
+    }
+
+    /**
+     * Know if this part name is a relationship part name.
+     *
+     * @return <code>true</code> if this part name respect the relationship
+     *         part naming convention else <code>false</code>.
+     */
+    public boolean isRelationshipPartURI() {
+        return this.isRelationship;
+    }
+
+    /**
+     * Throws an exception (of any kind) if the specified part name does not
+     * follow the Open Packaging Convention specifications naming rules.
+     *
+     * @param partUri
+     *            The part name to check.
+     * @throws InvalidFormatException
+     *             Throws if the part name is invalid.
+     */
+    private static void throwExceptionIfInvalidPartUri(URI partUri)
+            throws InvalidFormatException {
+        if (partUri == null) {
             throw new IllegalArgumentException("partUri");
         }
-		// Check if the part name URI is empty [M1.1]
-		throwExceptionIfEmptyURI(partUri);
+        // Check if the part name URI is empty [M1.1]
+        throwExceptionIfEmptyURI(partUri);
+
+        // Check if the part name URI is absolute
+        throwExceptionIfAbsoluteUri(partUri);
 
-		// Check if the part name URI is absolute
-		throwExceptionIfAbsoluteUri(partUri);
+        // Check if the part name URI starts with a forward slash [M1.4]
+        throwExceptionIfPartNameNotStartsWithForwardSlashChar(partUri);
 
-		// Check if the part name URI starts with a forward slash [M1.4]
-		throwExceptionIfPartNameNotStartsWithForwardSlashChar(partUri);
+        // Check if the part name URI ends with a forward slash [M1.5]
+        throwExceptionIfPartNameEndsWithForwardSlashChar(partUri);
 
-		// Check if the part name URI ends with a forward slash [M1.5]
-		throwExceptionIfPartNameEndsWithForwardSlashChar(partUri);
-
-		// Check if the part name does not have empty segments. [M1.3]
-		// Check if a segment ends with a dot ('.') character. [M1.9]
-		throwExceptionIfPartNameHaveInvalidSegments(partUri);
-	}
-
-	/**
-	 * Throws an exception if the specified URI is empty. [M1.1]
-	 *
-	 * @param partURI
-	 *            Part URI to check.
-	 * @throws InvalidFormatException
-	 *             If the specified URI is empty.
-	 */
-	private static void throwExceptionIfEmptyURI(URI partURI)
-			throws InvalidFormatException {
-		if (partURI == null) {
+        // Check if the part name does not have empty segments. [M1.3]
+        // Check if a segment ends with a dot ('.') character. [M1.9]
+        throwExceptionIfPartNameHaveInvalidSegments(partUri);
+    }
+
+    /**
+     * Throws an exception if the specified URI is empty. [M1.1]
+     *
+     * @param partURI
+     *            Part URI to check.
+     * @throws InvalidFormatException
+     *             If the specified URI is empty.
+     */
+    private static void throwExceptionIfEmptyURI(URI partURI)
+            throws InvalidFormatException {
+        if (partURI == null) {
             throw new IllegalArgumentException("partURI");
         }
 
-		String uriPath = partURI.getPath();
-		if (uriPath.length() == 0
-				|| ((uriPath.length() == 1) && (uriPath.charAt(0) == PackagingURIHelper.FORWARD_SLASH_CHAR))) {
+        String uriPath = partURI.getPath();
+        if (uriPath.length() == 0
+                || ((uriPath.length() == 1) && (uriPath.charAt(0) == PackagingURIHelper.FORWARD_SLASH_CHAR))) {
             throw new InvalidFormatException(
-					"A part name shall not be empty [M1.1]: "
-							+ partURI.getPath());
+                    "A part name shall not be empty [M1.1]: "
+                            + partURI.getPath());
+        }
+    }
+
+    /**
+     * Throws an exception if the part name has empty segments. [M1.3]
+     *
+     * Throws an exception if a segment any characters other than pchar
+     * characters. [M1.6]
+     *
+     * Throws an exception if a segment contain percent-encoded forward slash
+     * ('/'), or backward slash ('\') characters. [M1.7]
+     *
+     * Throws an exception if a segment contain percent-encoded unreserved
+     * characters. [M1.8]
+     *
+     * Throws an exception if the specified part name's segments end with a dot
+     * ('.') character. [M1.9]
+     *
+     * Throws an exception if a segment doesn't include at least one non-dot
+     * character. [M1.10]
+     *
+     * @param partUri
+     *            The part name to check.
+     * @throws InvalidFormatException
+     *             if the specified URI contain an empty segments or if one the
+     *             segments contained in the part name, ends with a dot ('.')
+     *             character.
+     */
+    private static void throwExceptionIfPartNameHaveInvalidSegments(URI partUri)
+            throws InvalidFormatException {
+        if (partUri == null) {
+            throw new IllegalArgumentException("partUri");
         }
-	}
 
-	/**
-	 * Throws an exception if the part name has empty segments. [M1.3]
-	 *
-	 * Throws an exception if a segment any characters other than pchar
-	 * characters. [M1.6]
-	 *
-	 * Throws an exception if a segment contain percent-encoded forward slash
-	 * ('/'), or backward slash ('\') characters. [M1.7]
-	 *
-	 * Throws an exception if a segment contain percent-encoded unreserved
-	 * characters. [M1.8]
-	 *
-	 * Throws an exception if the specified part name's segments end with a dot
-	 * ('.') character. [M1.9]
-	 *
-	 * Throws an exception if a segment doesn't include at least one non-dot
-	 * character. [M1.10]
-	 *
-	 * @param partUri
-	 *            The part name to check.
-	 * @throws InvalidFormatException
-	 *             if the specified URI contain an empty segments or if one the
-	 *             segments contained in the part name, ends with a dot ('.')
-	 *             character.
-	 */
-	private static void throwExceptionIfPartNameHaveInvalidSegments(URI partUri)
-			throws InvalidFormatException {
-		if (partUri == null) {
-			throw new IllegalArgumentException("partUri");
-		}
-
-		// Split the URI into several part and analyze each
-		String[] segments = partUri.toASCIIString()
-	        .replaceFirst("^"+PackagingURIHelper.FORWARD_SLASH_CHAR,"")
-	        .split(PackagingURIHelper.FORWARD_SLASH_STRING);
+        // Split the URI into several part and analyze each
+        String[] segments = partUri.toASCIIString()
+            .replaceFirst("^"+PackagingURIHelper.FORWARD_SLASH_CHAR,"")
+            .split(PackagingURIHelper.FORWARD_SLASH_STRING);
 
-		if (segments.length < 1) {
+        if (segments.length < 1) {
             throw new InvalidFormatException(
-				"A part name shall not have empty segments [M1.3]: " + partUri.getPath());
+                "A part name shall not have empty segments [M1.3]: " + partUri.getPath());
+        }
+
+        for (final String seg : segments) {
+            if (seg == null || seg.isEmpty()) {
+                throw new InvalidFormatException(
+                    "A part name shall not have empty segments [M1.3]: " + partUri.getPath());
+            }
+
+            if (seg.endsWith(".")) {
+                throw new InvalidFormatException(
+                    "A segment shall not end with a dot ('.') character [M1.9]: " + partUri.getPath());
+            }
+
+            if (seg.replaceAll("\\\\.", "").isEmpty()) {
+                // Normally will never been invoked with the previous
+                // implementation rule [M1.9]
+                throw new InvalidFormatException(
+                    "A segment shall include at least one non-dot character. [M1.10]: " + partUri.getPath());
+            }
+
+            // Check for rule M1.6, M1.7, M1.8
+            checkPCharCompliance(seg);
         }
+    }
 
-		for (final String seg : segments) {
-			if (seg == null || seg.isEmpty()) {
-				throw new InvalidFormatException(
-					"A part name shall not have empty segments [M1.3]: " + partUri.getPath());
-			}
-
-			if (seg.endsWith(".")) {
-				throw new InvalidFormatException(
-					"A segment shall not end with a dot ('.') character [M1.9]: " + partUri.getPath());
-			}
-
-			if (seg.replaceAll("\\\\.", "").isEmpty()) {
-				// Normally will never been invoked with the previous
-				// implementation rule [M1.9]
-				throw new InvalidFormatException(
-					"A segment shall include at least one non-dot character. [M1.10]: " + partUri.getPath());
-			}
-
-			// Check for rule M1.6, M1.7, M1.8
-			checkPCharCompliance(seg);
-		}
-	}
-
-	/**
-	 * Throws an exception if a segment any characters other than pchar
-	 * characters. [M1.6]
-	 *
-	 * Throws an exception if a segment contain percent-encoded forward slash
-	 * ('/'), or backward slash ('\') characters. [M1.7]
-	 *
-	 * Throws an exception if a segment contain percent-encoded unreserved
-	 * characters. [M1.8]
-	 *
-	 * @param segment
-	 *            The segment to check
-	 */
-	private static void checkPCharCompliance(String segment)
-			throws InvalidFormatException {
-		final int length = segment.length();
-		for (int i = 0; i < length; ++i) {
-			final char c = segment.charAt(i);
-
-			/* Check rule M1.6 */
-
-			if (
-    			// Check for digit or letter
-		        isDigitOrLetter(c) ||
+    /**
+     * Throws an exception if a segment any characters other than pchar
+     * characters. [M1.6]
+     *
+     * Throws an exception if a segment contain percent-encoded forward slash
+     * ('/'), or backward slash ('\') characters. [M1.7]
+     *
+     * Throws an exception if a segment contain percent-encoded unreserved
+     * characters. [M1.8]
+     *
+     * @param segment
+     *            The segment to check
+     */
+    private static void checkPCharCompliance(String segment)
+            throws InvalidFormatException {
+        final int length = segment.length();
+        for (int i = 0; i < length; ++i) {
+            final char c = segment.charAt(i);
+
+            /* Check rule M1.6 */
+
+            if (
+                // Check for digit or letter
+                isDigitOrLetter(c) ||
                 // Check "-", ".", "_", "~"
                 RFC3986_PCHAR_UNRESERVED_SUP.indexOf(c) > -1 ||
                 // Check ":", "@"
@@ -304,108 +304,108 @@ public final class PackagePartName imple
                 // Check "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
                 RFC3986_PCHAR_SUB_DELIMS.indexOf(c) > -1
             ) {
-			    continue;
-			}
+                continue;
+            }
 
 
-			if (c != '%') {
-	            throw new InvalidFormatException(
+            if (c != '%') {
+                throw new InvalidFormatException(
                     "A segment shall not hold any characters other than pchar characters. [M1.6]");
-			}
+            }
+
+            // We certainly found an encoded character, check for length
+            // now ( '%' HEXDIGIT HEXDIGIT)
+            if ((length - i) < 2 || !isHexDigit(segment.charAt(i+1)) || !isHexDigit(segment.charAt(i+2))) {
+                throw new InvalidFormatException("The segment " + segment + " contain invalid encoded character !");
+            }
+
+            // Decode the encoded character
+            final char decodedChar = (char) Integer.parseInt(segment.substring(i + 1, i + 3), 16);
+            i += 2;
+
+            /* Check rule M1.7 */
+            if (decodedChar == '/' || decodedChar == '\\') {
+                throw new InvalidFormatException(
+                    "A segment shall not contain percent-encoded forward slash ('/'), or backward slash ('\') characters. [M1.7]");
+            }
 
-			// We certainly found an encoded character, check for length
-			// now ( '%' HEXDIGIT HEXDIGIT)
-			if ((length - i) < 2 || !isHexDigit(segment.charAt(i+1)) || !isHexDigit(segment.charAt(i+2))) {
-				throw new InvalidFormatException("The segment " + segment + " contain invalid encoded character !");
-			}
-
-			// Decode the encoded character
-			final char decodedChar = (char) Integer.parseInt(segment.substring(i + 1, i + 3), 16);
-			i += 2;
-
-			/* Check rule M1.7 */
-			if (decodedChar == '/' || decodedChar == '\\') {
-				throw new InvalidFormatException(
-					"A segment shall not contain percent-encoded forward slash ('/'), or backward slash ('\') characters. [M1.7]");
-			}
-
-			/* Check rule M1.8 */
-			if (
-			     // Check for unreserved character like define in RFC3986
-		        isDigitOrLetter(decodedChar) ||
-		        // Check for unreserved character "-", ".", "_", "~"
-		        RFC3986_PCHAR_UNRESERVED_SUP.indexOf(decodedChar) > -1
-	        ) {
+            /* Check rule M1.8 */
+            if (
+                 // Check for unreserved character like define in RFC3986
+                isDigitOrLetter(decodedChar) ||
+                // Check for unreserved character "-", ".", "_", "~"
+                RFC3986_PCHAR_UNRESERVED_SUP.indexOf(decodedChar) > -1
+            ) {
                 throw new InvalidFormatException(
                     "A segment shall not contain percent-encoded unreserved characters. [M1.8]");
-			}
-		}
-	}
-
-	/**
-	 * Throws an exception if the specified part name doesn't start with a
-	 * forward slash character '/'. [M1.4]
-	 *
-	 * @param partUri
-	 *            The part name to check.
-	 * @throws InvalidFormatException
-	 *             If the specified part name doesn't start with a forward slash
-	 *             character '/'.
-	 */
-	private static void throwExceptionIfPartNameNotStartsWithForwardSlashChar(
-			URI partUri) throws InvalidFormatException {
-		String uriPath = partUri.getPath();
-		if (uriPath.length() > 0
-				&& uriPath.charAt(0) != PackagingURIHelper.FORWARD_SLASH_CHAR) {
+            }
+        }
+    }
+
+    /**
+     * Throws an exception if the specified part name doesn't start with a
+     * forward slash character '/'. [M1.4]
+     *
+     * @param partUri
+     *            The part name to check.
+     * @throws InvalidFormatException
+     *             If the specified part name doesn't start with a forward slash
+     *             character '/'.
+     */
+    private static void throwExceptionIfPartNameNotStartsWithForwardSlashChar(
+            URI partUri) throws InvalidFormatException {
+        String uriPath = partUri.getPath();
+        if (uriPath.length() > 0
+                && uriPath.charAt(0) != PackagingURIHelper.FORWARD_SLASH_CHAR) {
             throw new InvalidFormatException(
-					"A part name shall start with a forward slash ('/') character [M1.4]: "
-							+ partUri.getPath());
+                    "A part name shall start with a forward slash ('/') character [M1.4]: "
+                            + partUri.getPath());
         }
-	}
+    }
 
-	/**
-	 * Throws an exception if the specified part name ends with a forwar slash
-	 * character '/'. [M1.5]
-	 *
-	 * @param partUri
-	 *            The part name to check.
-	 * @throws InvalidFormatException
-	 *             If the specified part name ends with a forwar slash character
-	 *             '/'.
-	 */
-	private static void throwExceptionIfPartNameEndsWithForwardSlashChar(
-			URI partUri) throws InvalidFormatException {
-		String uriPath = partUri.getPath();
-		if (uriPath.length() > 0
-				&& uriPath.charAt(uriPath.length() - 1) == PackagingURIHelper.FORWARD_SLASH_CHAR) {
+    /**
+     * Throws an exception if the specified part name ends with a forwar slash
+     * character '/'. [M1.5]
+     *
+     * @param partUri
+     *            The part name to check.
+     * @throws InvalidFormatException
+     *             If the specified part name ends with a forwar slash character
+     *             '/'.
+     */
+    private static void throwExceptionIfPartNameEndsWithForwardSlashChar(
+            URI partUri) throws InvalidFormatException {
+        String uriPath = partUri.getPath();
+        if (uriPath.length() > 0
+                && uriPath.charAt(uriPath.length() - 1) == PackagingURIHelper.FORWARD_SLASH_CHAR) {
             throw new InvalidFormatException(
-					"A part name shall not have a forward slash as the last character [M1.5]: "
-							+ partUri.getPath());
+                    "A part name shall not have a forward slash as the last character [M1.5]: "
+                            + partUri.getPath());
         }
-	}
+    }
 
-	/**
-	 * Throws an exception if the specified URI is absolute.
-	 *
-	 * @param partUri
-	 *            The URI to check.
-	 * @throws InvalidFormatException
-	 *             Throws if the specified URI is absolute.
-	 */
-	private static void throwExceptionIfAbsoluteUri(URI partUri) throws InvalidFormatException {
-		if (partUri.isAbsolute()) {
+    /**
+     * Throws an exception if the specified URI is absolute.
+     *
+     * @param partUri
+     *            The URI to check.
+     * @throws InvalidFormatException
+     *             Throws if the specified URI is absolute.
+     */
+    private static void throwExceptionIfAbsoluteUri(URI partUri) throws InvalidFormatException {
+        if (partUri.isAbsolute()) {
             throw new InvalidFormatException("Absolute URI forbidden: " + partUri);
         }
-	}
+    }
 
-	/**
-	 * Compare two part names following the rule M1.12 :
-	 *
-	 * Part name equivalence is determined by comparing part names as
-	 * case-insensitive ASCII strings. Packages shall not contain equivalent
-	 * part names and package implementers shall neither create nor recognize
-	 * packages with equivalent part names. [M1.12]
-	 */
+    /**
+     * Compare two part names following the rule M1.12 :
+     *
+     * Part name equivalence is determined by comparing part names as
+     * case-insensitive ASCII strings. Packages shall not contain equivalent
+     * part names and package implementers shall neither create nor recognize
+     * packages with equivalent part names. [M1.12]
+     */
     @Override
     public int compareTo(PackagePartName other) {
         // compare with natural sort order
@@ -413,64 +413,64 @@ public final class PackagePartName imple
     }
 
 
-	/**
-	 * Retrieves the extension of the part name if any. If there is no extension
-	 * returns an empty String. Example : '/document/content.xml' =&gt; 'xml'
-	 *
-	 * @return The extension of the part name.
-	 */
-	public String getExtension() {
-		String fragment = this.partNameURI.getPath();
-		if (fragment.length() > 0) {
-			int i = fragment.lastIndexOf('.');
-			if (i > -1) {
+    /**
+     * Retrieves the extension of the part name if any. If there is no extension
+     * returns an empty String. Example : '/document/content.xml' =&gt; 'xml'
+     *
+     * @return The extension of the part name.
+     */
+    public String getExtension() {
+        String fragment = this.partNameURI.getPath();
+        if (fragment.length() > 0) {
+            int i = fragment.lastIndexOf('.');
+            if (i > -1) {
                 return fragment.substring(i + 1);
             }
-		}
-		return "";
-	}
-
-	/**
-	 * Get this part name.
-	 *
-	 * @return The name of this part name.
-	 */
-	public String getName() {
-		return getURI().toASCIIString();
-	}
-
-	/**
-	 * Part name equivalence is determined by comparing part names as
-	 * case-insensitive ASCII strings. Packages shall not contain equivalent
-	 * part names and package implementers shall neither create nor recognize
-	 * packages with equivalent part names. [M1.12]
-	 */
-	@Override
-	public boolean equals(Object other) {
+        }
+        return "";
+    }
+
+    /**
+     * Get this part name.
+     *
+     * @return The name of this part name.
+     */
+    public String getName() {
+        return getURI().toASCIIString();
+    }
+
+    /**
+     * Part name equivalence is determined by comparing part names as
+     * case-insensitive ASCII strings. Packages shall not contain equivalent
+     * part names and package implementers shall neither create nor recognize
+     * packages with equivalent part names. [M1.12]
+     */
+    @Override
+    public boolean equals(Object other) {
         return (other instanceof PackagePartName) &&
             compare(this.getName(), ((PackagePartName)other).getName()) == 0;
     }
 
-	@Override
-	public int hashCode() {
-		return getName().toLowerCase(Locale.ROOT).hashCode();
-	}
-
-	@Override
-	public String toString() {
-		return getName();
-	}
-
-	/* Getters and setters */
-
-	/**
-	 * Part name property getter.
-	 *
-	 * @return This part name URI.
-	 */
-	public URI getURI() {
-		return this.partNameURI;
-	}
+    @Override
+    public int hashCode() {
+        return getName().toLowerCase(Locale.ROOT).hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return getName();
+    }
+
+    /* Getters and setters */
+
+    /**
+     * Part name property getter.
+     *
+     * @return This part name URI.
+     */
+    public URI getURI() {
+        return this.partNameURI;
+    }
 
 
     /**
@@ -489,10 +489,10 @@ public final class PackagePartName imple
      * case-insensitive ASCII strings. Packages shall not contain equivalent
      * part names and package implementers shall neither create nor recognize
      * packages with equivalent part names. [M1.12]
-	 *
-	 * @param obj1 first {@code PackagePartName} to compare
-	 * @param obj2 second {@code PackagePartName} to compare
-	 * @return a negative integer, zero, or a positive integer as the first argument is less than,
+     *
+     * @param obj1 first {@code PackagePartName} to compare
+     * @param obj2 second {@code PackagePartName} to compare
+     * @return a negative integer, zero, or a positive integer as the first argument is less than,
      *         equal to, or greater than the second.
      */
     public static int compare(PackagePartName obj1, PackagePartName obj2) {

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageRelationship.java Sat May 22 20:22:16 2021
@@ -27,182 +27,182 @@ import java.util.Objects;
  */
 public final class PackageRelationship {
 
-	private static URI containerRelationshipPart;
+    private static URI containerRelationshipPart;
 
-	static {
-		try {
-			containerRelationshipPart = new URI("/_rels/.rels");
-		} catch (URISyntaxException e) {
-			// Do nothing
-		}
-	}
-
-	/* XML markup */
-
-	public static final String ID_ATTRIBUTE_NAME = "Id";
-
-	public static final String RELATIONSHIPS_TAG_NAME = "Relationships";
-
-	public static final String RELATIONSHIP_TAG_NAME = "Relationship";
-
-	public static final String TARGET_ATTRIBUTE_NAME = "Target";
-
-	public static final String TARGET_MODE_ATTRIBUTE_NAME = "TargetMode";
-
-	public static final String TYPE_ATTRIBUTE_NAME = "Type";
-
-	/* End XML markup */
-
-	/**
-	 * Relation id.
-	 */
-	private final String id;
-
-	/**
-	 * Reference to the package.
-	 */
-	private final OPCPackage container;
-
-	/**
-	 * Relationship type
-	 */
-	private final String relationshipType;
-
-	/**
-	 * Part of this relationship source
-	 */
-	private final PackagePart source;
-
-	/**
-	 * Targeting mode [Internal|External]
-	 */
-	private final TargetMode targetMode;
-
-	/**
-	 * Target URI
-	 */
-	private final URI targetUri;
-
-	/**
-	 * Constructor.
-	 */
-	public PackageRelationship(OPCPackage pkg, PackagePart sourcePart,
-			URI targetUri, TargetMode targetMode, String relationshipType,
-			String id) {
-		if (pkg == null)
-			throw new IllegalArgumentException("pkg");
-		if (targetUri == null)
-			throw new IllegalArgumentException("targetUri");
-		if (relationshipType == null)
-			throw new IllegalArgumentException("relationshipType");
-		if (id == null)
-			throw new IllegalArgumentException("id");
-
-		this.container = pkg;
-		this.source = sourcePart;
-		this.targetUri = targetUri;
-		this.targetMode = targetMode;
-		this.relationshipType = relationshipType;
-		this.id = id;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (!(obj instanceof PackageRelationship)) {
-			return false;
-		}
-		PackageRelationship rel = (PackageRelationship) obj;
-		return (this.id.equals(rel.id)
-				&& this.relationshipType.equals(rel.relationshipType)
-				&& (rel.source == null || rel.source.equals(this.source))
-				&& this.targetMode == rel.targetMode && this.targetUri
-				.equals(rel.targetUri));
-	}
-
-	@Override
-	public int hashCode() {
-		return Objects.hash(id,relationshipType,source,targetMode,targetUri);
-	}
-
-	/* Getters */
-
-	public static URI getContainerPartRelationship() {
-		return containerRelationshipPart;
-	}
-
-	/**
-	 * @return the container
-	 */
-	public OPCPackage getPackage() {
-		return container;
-	}
-
-	/**
-	 * @return the id
-	 */
-	public String getId() {
-		return id;
-	}
-
-	/**
-	 * @return the relationshipType
-	 */
-	public String getRelationshipType() {
-		return relationshipType;
-	}
-
-	/**
-	 * @return the source
-	 */
-	public PackagePart getSource() {
-		return source;
-	}
-
-	/**
-	 *
-	 * @return URL of the source part of this relationship
-	 */
-	public URI getSourceURI() {
-		if (source == null) {
-			return PackagingURIHelper.PACKAGE_ROOT_URI;
-		}
-		return source._partName.getURI();
-	}
-
-	/**
-	 * @return the targetMode
-	 */
-	public TargetMode getTargetMode() {
-		return targetMode;
-	}
-
-	/**
-	 * @return the targetUri
-	 */
-	public URI getTargetURI() {
-		// If it's an external target, we don't
-		//  need to apply our normal validation rules
-		if(targetMode == TargetMode.EXTERNAL) {
-			return targetUri;
-		}
-
-		// Internal target
-		// If it isn't absolute, resolve it relative
-		//  to ourselves
-		if (!targetUri.toASCIIString().startsWith("/")) {
-			// So it's a relative part name, try to resolve it
-			return PackagingURIHelper.resolvePartUri(getSourceURI(), targetUri);
-		}
-		return targetUri;
-	}
-
-	@Override
-	public String toString() {
-		return "id=" + id +
-				" - container=" + container +
-				" - relationshipType=" + relationshipType +
-				(source == null ? " - source=null" : " - source=" + getSourceURI().toASCIIString()) +
-				" - target=" + getTargetURI().toASCIIString() +
-				(targetMode == null ? ",targetMode=null" : ",targetMode=" + targetMode);
-	}
+    static {
+        try {
+            containerRelationshipPart = new URI("/_rels/.rels");
+        } catch (URISyntaxException e) {
+            // Do nothing
+        }
+    }
+
+    /* XML markup */
+
+    public static final String ID_ATTRIBUTE_NAME = "Id";
+
+    public static final String RELATIONSHIPS_TAG_NAME = "Relationships";
+
+    public static final String RELATIONSHIP_TAG_NAME = "Relationship";
+
+    public static final String TARGET_ATTRIBUTE_NAME = "Target";
+
+    public static final String TARGET_MODE_ATTRIBUTE_NAME = "TargetMode";
+
+    public static final String TYPE_ATTRIBUTE_NAME = "Type";
+
+    /* End XML markup */
+
+    /**
+     * Relation id.
+     */
+    private final String id;
+
+    /**
+     * Reference to the package.
+     */
+    private final OPCPackage container;
+
+    /**
+     * Relationship type
+     */
+    private final String relationshipType;
+
+    /**
+     * Part of this relationship source
+     */
+    private final PackagePart source;
+
+    /**
+     * Targeting mode [Internal|External]
+     */
+    private final TargetMode targetMode;
+
+    /**
+     * Target URI
+     */
+    private final URI targetUri;
+
+    /**
+     * Constructor.
+     */
+    public PackageRelationship(OPCPackage pkg, PackagePart sourcePart,
+            URI targetUri, TargetMode targetMode, String relationshipType,
+            String id) {
+        if (pkg == null)
+            throw new IllegalArgumentException("pkg");
+        if (targetUri == null)
+            throw new IllegalArgumentException("targetUri");
+        if (relationshipType == null)
+            throw new IllegalArgumentException("relationshipType");
+        if (id == null)
+            throw new IllegalArgumentException("id");
+
+        this.container = pkg;
+        this.source = sourcePart;
+        this.targetUri = targetUri;
+        this.targetMode = targetMode;
+        this.relationshipType = relationshipType;
+        this.id = id;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof PackageRelationship)) {
+            return false;
+        }
+        PackageRelationship rel = (PackageRelationship) obj;
+        return (this.id.equals(rel.id)
+                && this.relationshipType.equals(rel.relationshipType)
+                && (rel.source == null || rel.source.equals(this.source))
+                && this.targetMode == rel.targetMode && this.targetUri
+                .equals(rel.targetUri));
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id,relationshipType,source,targetMode,targetUri);
+    }
+
+    /* Getters */
+
+    public static URI getContainerPartRelationship() {
+        return containerRelationshipPart;
+    }
+
+    /**
+     * @return the container
+     */
+    public OPCPackage getPackage() {
+        return container;
+    }
+
+    /**
+     * @return the id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * @return the relationshipType
+     */
+    public String getRelationshipType() {
+        return relationshipType;
+    }
+
+    /**
+     * @return the source
+     */
+    public PackagePart getSource() {
+        return source;
+    }
+
+    /**
+     *
+     * @return URL of the source part of this relationship
+     */
+    public URI getSourceURI() {
+        if (source == null) {
+            return PackagingURIHelper.PACKAGE_ROOT_URI;
+        }
+        return source._partName.getURI();
+    }
+
+    /**
+     * @return the targetMode
+     */
+    public TargetMode getTargetMode() {
+        return targetMode;
+    }
+
+    /**
+     * @return the targetUri
+     */
+    public URI getTargetURI() {
+        // If it's an external target, we don't
+        //  need to apply our normal validation rules
+        if(targetMode == TargetMode.EXTERNAL) {
+            return targetUri;
+        }
+
+        // Internal target
+        // If it isn't absolute, resolve it relative
+        //  to ourselves
+        if (!targetUri.toASCIIString().startsWith("/")) {
+            // So it's a relative part name, try to resolve it
+            return PackagingURIHelper.resolvePartUri(getSourceURI(), targetUri);
+        }
+        return targetUri;
+    }
+
+    @Override
+    public String toString() {
+        return "id=" + id +
+                " - container=" + container +
+                " - relationshipType=" + relationshipType +
+                (source == null ? " - source=null" : " - source=" + getSourceURI().toASCIIString()) +
+                " - target=" + getTargetURI().toASCIIString() +
+                (targetMode == null ? ",targetMode=null" : ",targetMode=" + targetMode);
+    }
 }

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/RelationshipSource.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/RelationshipSource.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/RelationshipSource.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/RelationshipSource.java Sat May 22 20:22:16 2021
@@ -22,137 +22,137 @@ import org.apache.poi.openxml4j.exceptio
 
 public interface RelationshipSource {
 
-	/**
-	 * Add a relationship to a part (except relationships part).
-	 *
-	 * @param targetPartName
-	 *            Name of the target part. This one must be relative to the
-	 *            source root directory of the part.
-	 * @param targetMode
-	 *            Mode [Internal|External].
-	 * @param relationshipType
-	 *            Type of relationship.
-	 * @return The newly created and added relationship
-	 */
-	PackageRelationship addRelationship(
-			PackagePartName targetPartName, TargetMode targetMode,
-			String relationshipType);
-
-	/**
-	 * Add a relationship to a part (except relationships part).
-	 * <p>
-	 * Check rule M1.25: The Relationships part shall not have relationships to
-	 * any other part. Package implementers shall enforce this requirement upon
-	 * the attempt to create such a relationship and shall treat any such
-	 * relationship as invalid.
-	 * </p>
-	 * @param targetPartName
-	 *            Name of the target part. This one must be relative to the
-	 *            source root directory of the part.
-	 * @param targetMode
-	 *            Mode [Internal|External].
-	 * @param relationshipType
-	 *            Type of relationship.
-	 * @param id
-	 *            Relationship unique id.
-	 * @return The newly created and added relationship
-	 */
-	PackageRelationship addRelationship(
-			PackagePartName targetPartName, TargetMode targetMode,
-			String relationshipType, String id);
-
-	/**
-	 * Adds an external relationship to a part
-	 *  (except relationships part).
-	 *
-	 * The targets of external relationships are not
-	 *  subject to the same validity checks that internal
-	 *  ones are, as the contents is potentially
-	 *  any file, URL or similar.
-	 *
-	 * @param target External target of the relationship
-	 * @param relationshipType Type of relationship.
-	 * @return The newly created and added relationship
-	 */
-	PackageRelationship addExternalRelationship(String target, String relationshipType);
-
-	/**
-	 * Adds an external relationship to a part
-	 *  (except relationships part).
-	 *
-	 * The targets of external relationships are not
-	 *  subject to the same validity checks that internal
-	 *  ones are, as the contents is potentially
-	 *  any file, URL or similar.
-	 *
-	 * @param target External target of the relationship
-	 * @param relationshipType Type of relationship.
-	 * @param id Relationship unique id.
-	 * @return The newly created and added relationship
-	 * @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String)
-	 */
-	PackageRelationship addExternalRelationship(String target, String relationshipType, String id);
-
-	/**
-	 * Delete all the relationships attached to this.
-	 */
-	void clearRelationships();
-
-	/**
-	 * Delete the relationship specified by its id.
-	 *
-	 * @param id
-	 *            The ID identified the part to delete.
-	 */
-	void removeRelationship(String id);
-
-	/**
-	 * Retrieve all the relationships attached to this.
-	 *
-	 * @return This part's relationships.
-	 */
-	PackageRelationshipCollection getRelationships() throws OpenXML4JException;
-
-	/**
-	 * Retrieves a package relationship from its id.
-	 *
-	 * @param id
-	 *            ID of the package relationship to retrieve.
-	 * @return The package relationship
-	 */
-	PackageRelationship getRelationship(String id);
-
-	/**
-	 * Retrieve all relationships attached to this part which have the specified
-	 * type.
-	 *
-	 * @param relationshipType
-	 *            Relationship type filter.
-	 * @return All relationships from this part that have the specified type.
-	 * @throws InvalidFormatException
-	 *             If an error occurs while parsing the part.
-	 * @throws InvalidOperationException
-	 *             If the package is open in write only mode.
-	 */
-	PackageRelationshipCollection getRelationshipsByType(String relationshipType)
-		throws IllegalArgumentException, OpenXML4JException;
-
-	/**
-	 * Knows if the part have any relationships.
-	 *
-	 * @return <b>true</b> if the part have at least one relationship else
-	 *         <b>false</b>.
-	 */
-	boolean hasRelationships();
-
-	/**
-	 * Checks if the specified relationship is part of this package part.
-	 *
-	 * @param rel
-	 *            The relationship to check.
-	 * @return <b>true</b> if the specified relationship exists in this part,
-	 *         else returns <b>false</b>
-	 */
-	boolean isRelationshipExists(PackageRelationship rel);
+    /**
+     * Add a relationship to a part (except relationships part).
+     *
+     * @param targetPartName
+     *            Name of the target part. This one must be relative to the
+     *            source root directory of the part.
+     * @param targetMode
+     *            Mode [Internal|External].
+     * @param relationshipType
+     *            Type of relationship.
+     * @return The newly created and added relationship
+     */
+    PackageRelationship addRelationship(
+            PackagePartName targetPartName, TargetMode targetMode,
+            String relationshipType);
+
+    /**
+     * Add a relationship to a part (except relationships part).
+     * <p>
+     * Check rule M1.25: The Relationships part shall not have relationships to
+     * any other part. Package implementers shall enforce this requirement upon
+     * the attempt to create such a relationship and shall treat any such
+     * relationship as invalid.
+     * </p>
+     * @param targetPartName
+     *            Name of the target part. This one must be relative to the
+     *            source root directory of the part.
+     * @param targetMode
+     *            Mode [Internal|External].
+     * @param relationshipType
+     *            Type of relationship.
+     * @param id
+     *            Relationship unique id.
+     * @return The newly created and added relationship
+     */
+    PackageRelationship addRelationship(
+            PackagePartName targetPartName, TargetMode targetMode,
+            String relationshipType, String id);
+
+    /**
+     * Adds an external relationship to a part
+     *  (except relationships part).
+     *
+     * The targets of external relationships are not
+     *  subject to the same validity checks that internal
+     *  ones are, as the contents is potentially
+     *  any file, URL or similar.
+     *
+     * @param target External target of the relationship
+     * @param relationshipType Type of relationship.
+     * @return The newly created and added relationship
+     */
+    PackageRelationship addExternalRelationship(String target, String relationshipType);
+
+    /**
+     * Adds an external relationship to a part
+     *  (except relationships part).
+     *
+     * The targets of external relationships are not
+     *  subject to the same validity checks that internal
+     *  ones are, as the contents is potentially
+     *  any file, URL or similar.
+     *
+     * @param target External target of the relationship
+     * @param relationshipType Type of relationship.
+     * @param id Relationship unique id.
+     * @return The newly created and added relationship
+     * @see org.apache.poi.openxml4j.opc.RelationshipSource#addExternalRelationship(java.lang.String, java.lang.String)
+     */
+    PackageRelationship addExternalRelationship(String target, String relationshipType, String id);
+
+    /**
+     * Delete all the relationships attached to this.
+     */
+    void clearRelationships();
+
+    /**
+     * Delete the relationship specified by its id.
+     *
+     * @param id
+     *            The ID identified the part to delete.
+     */
+    void removeRelationship(String id);
+
+    /**
+     * Retrieve all the relationships attached to this.
+     *
+     * @return This part's relationships.
+     */
+    PackageRelationshipCollection getRelationships() throws OpenXML4JException;
+
+    /**
+     * Retrieves a package relationship from its id.
+     *
+     * @param id
+     *            ID of the package relationship to retrieve.
+     * @return The package relationship
+     */
+    PackageRelationship getRelationship(String id);
+
+    /**
+     * Retrieve all relationships attached to this part which have the specified
+     * type.
+     *
+     * @param relationshipType
+     *            Relationship type filter.
+     * @return All relationships from this part that have the specified type.
+     * @throws InvalidFormatException
+     *             If an error occurs while parsing the part.
+     * @throws InvalidOperationException
+     *             If the package is open in write only mode.
+     */
+    PackageRelationshipCollection getRelationshipsByType(String relationshipType)
+        throws IllegalArgumentException, OpenXML4JException;
+
+    /**
+     * Knows if the part have any relationships.
+     *
+     * @return <b>true</b> if the part have at least one relationship else
+     *         <b>false</b>.
+     */
+    boolean hasRelationships();
+
+    /**
+     * Checks if the specified relationship is part of this package part.
+     *
+     * @param rel
+     *            The relationship to check.
+     * @return <b>true</b> if the specified relationship exists in this part,
+     *         else returns <b>false</b>
+     */
+    boolean isRelationshipExists(PackageRelationship rel);
 
 }

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/StreamHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/StreamHelper.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/StreamHelper.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/StreamHelper.java Sat May 22 20:22:16 2021
@@ -36,68 +36,68 @@ import org.w3c.dom.Document;
 
 public final class StreamHelper {
 
-	private StreamHelper() {
-		// Do nothing
-	}
+    private StreamHelper() {
+        // Do nothing
+    }
 
-	/**
-	 * Save the document object in the specified output stream.
-	 *
-	 * @param xmlContent
-	 *            The XML document.
-	 * @param outStream
-	 *            The OutputStream in which the XML document will be written.
-	 * @return <b>true</b> if the xml is successfully written in the stream,
-	 *         else <b>false</b>.
-	 */
-	public static boolean saveXmlInStream(Document xmlContent,
-										  OutputStream outStream) {
-		try {
-			Transformer trans = XMLHelper.newTransformer();
-			Source xmlSource = new DOMSource(xmlContent);
-			// prevent close of stream by transformer:
-			Result outputTarget = new StreamResult(new FilterOutputStream(
-					outStream) {
-				@Override
-				public void write(byte[] b, int off, int len)
-						throws IOException {
-					out.write(b, off, len);
-				}
+    /**
+     * Save the document object in the specified output stream.
+     *
+     * @param xmlContent
+     *            The XML document.
+     * @param outStream
+     *            The OutputStream in which the XML document will be written.
+     * @return <b>true</b> if the xml is successfully written in the stream,
+     *         else <b>false</b>.
+     */
+    public static boolean saveXmlInStream(Document xmlContent,
+                                          OutputStream outStream) {
+        try {
+            Transformer trans = XMLHelper.newTransformer();
+            Source xmlSource = new DOMSource(xmlContent);
+            // prevent close of stream by transformer:
+            Result outputTarget = new StreamResult(new FilterOutputStream(
+                    outStream) {
+                @Override
+                public void write(byte[] b, int off, int len)
+                        throws IOException {
+                    out.write(b, off, len);
+                }
 
-				@Override
-				public void close() throws IOException {
-					out.flush(); // only flush, don't close!
-				}
-			});
-			// xmlContent.setXmlStandalone(true);
-			trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-			// don't indent xml documents, the indent will cause errors in calculating the xml signature
-			// because of different handling of linebreaks in Windows/Unix
-			// see https://stackoverflow.com/questions/36063375
-			trans.setOutputProperty(OutputKeys.INDENT, "no");
-			trans.setOutputProperty(OutputKeys.STANDALONE, "yes");
-			trans.transform(xmlSource, outputTarget);
-		} catch (TransformerException e) {
-			return false;
-		}
-		return true;
-	}
+                @Override
+                public void close() throws IOException {
+                    out.flush(); // only flush, don't close!
+                }
+            });
+            // xmlContent.setXmlStandalone(true);
+            trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            // don't indent xml documents, the indent will cause errors in calculating the xml signature
+            // because of different handling of linebreaks in Windows/Unix
+            // see https://stackoverflow.com/questions/36063375
+            trans.setOutputProperty(OutputKeys.INDENT, "no");
+            trans.setOutputProperty(OutputKeys.STANDALONE, "yes");
+            trans.transform(xmlSource, outputTarget);
+        } catch (TransformerException e) {
+            return false;
+        }
+        return true;
+    }
 
-	/**
-	 * Copy the input stream into the output stream.
-	 *
-	 * @param inStream
-	 *            The source stream.
-	 * @param outStream
-	 *            The destination stream.
-	 * @return <b>true</b> if the operation succeed, else return <b>false</b>.
-	 */
-	public static boolean copyStream(InputStream inStream, OutputStream outStream) {
-		try {
-			IOUtils.copy(inStream, outStream);
-			return true;
-		} catch (Exception e) {
-			return false;
-		}
-	}
+    /**
+     * Copy the input stream into the output stream.
+     *
+     * @param inStream
+     *            The source stream.
+     * @param outStream
+     *            The destination stream.
+     * @return <b>true</b> if the operation succeed, else return <b>false</b>.
+     */
+    public static boolean copyStream(InputStream inStream, OutputStream outStream) {
+        try {
+            IOUtils.copy(inStream, outStream);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
 }

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/TargetMode.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/TargetMode.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/TargetMode.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/TargetMode.java Sat May 22 20:22:16 2021
@@ -24,7 +24,7 @@ package org.apache.poi.openxml4j.opc;
  */
 public enum TargetMode {
     /** The relationship references a part that is inside the package. */
-	INTERNAL,
+    INTERNAL,
     /** The relationship references a resource that is external to the package. */
-	EXTERNAL
+    EXTERNAL
 }

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java Sat May 22 20:22:16 2021
@@ -407,151 +407,151 @@ public final class ZipPackage extends OP
         // Flush the package
         flush();
 
-		if (this.originalPackagePath == null || this.originalPackagePath.isEmpty()) {
-		    return;
-		}
-
-		// Save the content
-		File targetFile = new File(this.originalPackagePath);
-		if (!targetFile.exists()) {
+        if (this.originalPackagePath == null || this.originalPackagePath.isEmpty()) {
+            return;
+        }
+
+        // Save the content
+        File targetFile = new File(this.originalPackagePath);
+        if (!targetFile.exists()) {
             throw new InvalidOperationException(
                 "Can't close a package not previously open with the open() method !");
         }
 
-		// Case of a package previously open
-		String tempFileName = generateTempFileName(FileHelper.getDirectory(targetFile));
-		File tempFile = TempFile.createTempFile(tempFileName, ".tmp");
+        // Case of a package previously open
+        String tempFileName = generateTempFileName(FileHelper.getDirectory(targetFile));
+        File tempFile = TempFile.createTempFile(tempFileName, ".tmp");
 
-		// Save the final package to a temporary file
+        // Save the final package to a temporary file
         boolean success = false;
-		try {
-			save(tempFile);
+        try {
+            save(tempFile);
             success = true;
-		} finally {
+        } finally {
             // Close the current zip file, so we can overwrite it on all platforms
             IOUtils.closeQuietly(this.zipArchive);
-			try {
-				// Copy the new file over the old one if save() succeed
+            try {
+                // Copy the new file over the old one if save() succeed
                 if(success) {
-				    FileHelper.copyFile(tempFile, targetFile);
+                    FileHelper.copyFile(tempFile, targetFile);
                 }
-			} finally {
-				// Either the save operation succeed or not, we delete the temporary file
-				if (!tempFile.delete()) {
+            } finally {
+                // Either the save operation succeed or not, we delete the temporary file
+                if (!tempFile.delete()) {
                     LOG.atWarn().log("The temporary file: '{}' cannot be deleted ! Make sure that no other application use it.", targetFile.getAbsolutePath());
-				}
-			}
-		}
-	}
-
-	/**
-	 * Create a unique identifier to be use as a temp file name.
-	 *
-	 * @return A unique identifier use to be use as a temp file name.
-	 */
-	private synchronized String generateTempFileName(File directory) {
-		File tmpFilename;
-		do {
-			tmpFilename = new File(directory.getAbsoluteFile() + File.separator
-					+ "OpenXML4J" + System.nanoTime());
-		} while (tmpFilename.exists());
-		return FileHelper.getFilename(tmpFilename.getAbsoluteFile());
-	}
-
-	/**
-	 * Close the package without saving the document. Discard all the changes
-	 * made to this package.
-	 */
-	@Override
-	protected void revertImpl() {
-		try {
-			if (this.zipArchive != null) {
+                }
+            }
+        }
+    }
+
+    /**
+     * Create a unique identifier to be use as a temp file name.
+     *
+     * @return A unique identifier use to be use as a temp file name.
+     */
+    private synchronized String generateTempFileName(File directory) {
+        File tmpFilename;
+        do {
+            tmpFilename = new File(directory.getAbsoluteFile() + File.separator
+                    + "OpenXML4J" + System.nanoTime());
+        } while (tmpFilename.exists());
+        return FileHelper.getFilename(tmpFilename.getAbsoluteFile());
+    }
+
+    /**
+     * Close the package without saving the document. Discard all the changes
+     * made to this package.
+     */
+    @Override
+    protected void revertImpl() {
+        try {
+            if (this.zipArchive != null) {
                 this.zipArchive.close();
             }
-		} catch (IOException e) {
-			// Do nothing, user dont have to know
-		}
-	}
-
-	/**
-	 * Save this package into the specified stream
-	 *
-	 *
-	 * @param outputStream
-	 *            The stream use to save this package.
-	 *
-	 * @see #save(OutputStream)
-	 */
-	@Override
-	public void saveImpl(OutputStream outputStream) {
-		// Check that the document was open in write mode
-		throwExceptionIfReadOnly();
+        } catch (IOException e) {
+            // Do nothing, user dont have to know
+        }
+    }
+
+    /**
+     * Save this package into the specified stream
+     *
+     *
+     * @param outputStream
+     *            The stream use to save this package.
+     *
+     * @see #save(OutputStream)
+     */
+    @Override
+    public void saveImpl(OutputStream outputStream) {
+        // Check that the document was open in write mode
+        throwExceptionIfReadOnly();
 
-		final ZipArchiveOutputStream zos = (outputStream instanceof ZipArchiveOutputStream)
+        final ZipArchiveOutputStream zos = (outputStream instanceof ZipArchiveOutputStream)
             ? (ZipArchiveOutputStream) outputStream : new ZipArchiveOutputStream(outputStream);
 
-		try {
-			// If the core properties part does not exist in the part list,
-			// we save it as well
-			if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
+        try {
+            // If the core properties part does not exist in the part list,
+            // we save it as well
+            if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 &&
                 this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0    ) {
-				LOG.atDebug().log("Save core properties part");
+                LOG.atDebug().log("Save core properties part");
 
-				// Ensure that core properties are added if missing
-				getPackageProperties();
-				// Add core properties to part list ...
-				addPackagePart(this.packageProperties);
-				// ... and to add its relationship ...
-				this.relationships.addRelationship(this.packageProperties
-						.getPartName().getURI(), TargetMode.INTERNAL,
-						PackageRelationshipTypes.CORE_PROPERTIES, null);
-				// ... and the content if it has not been added yet.
-				if (!this.contentTypeManager
-						.isContentTypeRegister(ContentTypes.CORE_PROPERTIES_PART)) {
-					this.contentTypeManager.addContentType(
-							this.packageProperties.getPartName(),
-							ContentTypes.CORE_PROPERTIES_PART);
-				}
-			}
+                // Ensure that core properties are added if missing
+                getPackageProperties();
+                // Add core properties to part list ...
+                addPackagePart(this.packageProperties);
+                // ... and to add its relationship ...
+                this.relationships.addRelationship(this.packageProperties
+                        .getPartName().getURI(), TargetMode.INTERNAL,
+                        PackageRelationshipTypes.CORE_PROPERTIES, null);
+                // ... and the content if it has not been added yet.
+                if (!this.contentTypeManager
+                        .isContentTypeRegister(ContentTypes.CORE_PROPERTIES_PART)) {
+                    this.contentTypeManager.addContentType(
+                            this.packageProperties.getPartName(),
+                            ContentTypes.CORE_PROPERTIES_PART);
+                }
+            }
 
             // Save content type part.
             LOG.atDebug().log("Save content types part");
             this.contentTypeManager.save(zos);
 
-			// Save package relationships part.
-			LOG.atDebug().log("Save package relationships");
-			ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
-					PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
-					zos);
-
-			// Save parts.
-			for (PackagePart part : getParts()) {
-				// If the part is a relationship part, we don't save it, it's
-				// the source part that will do the job.
-				if (part.isRelationshipPart()) {
+            // Save package relationships part.
+            LOG.atDebug().log("Save package relationships");
+            ZipPartMarshaller.marshallRelationshipPart(this.getRelationships(),
+                    PackagingURIHelper.PACKAGE_RELATIONSHIPS_ROOT_PART_NAME,
+                    zos);
+
+            // Save parts.
+            for (PackagePart part : getParts()) {
+                // If the part is a relationship part, we don't save it, it's
+                // the source part that will do the job.
+                if (part.isRelationshipPart()) {
                     continue;
                 }
 
-				final PackagePartName ppn = part.getPartName();
+                final PackagePartName ppn = part.getPartName();
                 LOG.atDebug().log(() -> new SimpleMessage("Save part '" + ZipHelper.getZipItemNameFromOPCName(ppn.getName()) + "'"));
-				final PartMarshaller marshaller = partMarshallers.get(part._contentType);
+                final PartMarshaller marshaller = partMarshallers.get(part._contentType);
 
-				final PartMarshaller pm = (marshaller != null) ? marshaller : defaultPartMarshaller;
+                final PartMarshaller pm = (marshaller != null) ? marshaller : defaultPartMarshaller;
                 if (!pm.marshall(part, zos)) {
                     String errMsg = "The part " + ppn.getURI() + " failed to be saved in the stream with marshaller " + pm +
                             ". Enable logging via Log4j 2 for more details.";
                     throw new OpenXML4JException(errMsg);
                 }
-			}
+            }
 
             zos.finish();
-		} catch (OpenXML4JRuntimeException e) {
-			// no need to wrap this type of Exception
-			throw e;
-		} catch (Exception e) {
+        } catch (OpenXML4JRuntimeException e) {
+            // no need to wrap this type of Exception
+            throw e;
+        } catch (Exception e) {
             throw new OpenXML4JRuntimeException(
                 "Fail to save: an error occurs while saving the package : "
-				+ e.getMessage(), e);
+                + e.getMessage(), e);
         }
     }
 

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java?rev=1890119&r1=1890118&r2=1890119&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackagePart.java Sat May 22 20:22:16 2021
@@ -37,111 +37,111 @@ import org.apache.poi.util.NotImplemente
  */
 public class ZipPackagePart extends PackagePart {
 
-	/**
-	 * The zip entry corresponding to this part.
-	 */
-	private ZipArchiveEntry zipEntry;
-
-	/**
-	 * Constructor.
-	 *
-	 * @param container
-	 *            The container package.
-	 * @param zipEntry
-	 *            The zip entry corresponding to this part.
-	 * @param partName
-	 *            The part name.
-	 * @param contentType
-	 *            Content type.
-	 * @throws InvalidFormatException
-	 *             Throws if the content of this part is invalid.
-	 */
-	public ZipPackagePart(OPCPackage container, ZipArchiveEntry zipEntry,
-			PackagePartName partName, String contentType)
-			throws InvalidFormatException {
-		this(container, zipEntry, partName, contentType, true);
-	}
-
-	/**
-	 * Constructor.
-	 *
-	 * @param container
-	 *            The container package.
-	 * @param zipEntry
-	 *            The zip entry corresponding to this part.
-	 * @param partName
-	 *            The part name.
-	 * @param contentType
-	 *            Content type.
-	 * @throws InvalidFormatException
-	 *             Throws if the content of this part is invalid.
-	 */
-	/* package */ ZipPackagePart(OPCPackage container, ZipArchiveEntry zipEntry,
-						  PackagePartName partName, String contentType, boolean loadRelationships)
-			throws InvalidFormatException {
-		super(container, partName, new ContentType(contentType), loadRelationships);
-		this.zipEntry = zipEntry;
-	}
-
-	/**
-	 * Get the zip entry of this part.
-	 *
-	 * @return The zip entry in the zip structure coresponding to this part.
-	 */
-	public ZipArchiveEntry getZipArchive() {
-		return zipEntry;
-	}
-
-	/**
-	 * Implementation of the getInputStream() which return the inputStream of
-	 * this part zip entry.
-	 *
-	 * @return Input stream of this part zip entry.
-	 */
-	@Override
-	protected InputStream getInputStreamImpl() throws IOException {
-		// We use the getInputStream() method from java.util.zip.ZipFile
-		// class which return an InputStream to this part zip entry.
-		return ((ZipPackage) _container).getZipArchive()
-				.getInputStream(zipEntry);
-	}
-
-	/**
-	 * Implementation of the getOutputStream(). Return <b>null</b>. Normally
-	 * will never be called since the MemoryPackage is use instead.
-	 *
-	 * @return <b>null</b>
-	 */
-	@Override
-	protected OutputStream getOutputStreamImpl() {
-		return null;
-	}
-
-	@Override
-	public long getSize() {
-		return zipEntry.getSize();
-	}
-
-	@Override
-	public boolean save(OutputStream os) throws OpenXML4JException {
-		return new ZipPartMarshaller().marshall(this, os);
-	}
-
-	@Override
-	@NotImplemented
-	public boolean load(InputStream ios) {
-		throw new InvalidOperationException("Method not implemented !");
-	}
-
-	@Override
-	@NotImplemented
-	public void close() {
-		throw new InvalidOperationException("Method not implemented !");
-	}
-
-	@Override
-	@NotImplemented
-	public void flush() {
-		throw new InvalidOperationException("Method not implemented !");
-	}
+    /**
+     * The zip entry corresponding to this part.
+     */
+    private ZipArchiveEntry zipEntry;
+
+    /**
+     * Constructor.
+     *
+     * @param container
+     *            The container package.
+     * @param zipEntry
+     *            The zip entry corresponding to this part.
+     * @param partName
+     *            The part name.
+     * @param contentType
+     *            Content type.
+     * @throws InvalidFormatException
+     *             Throws if the content of this part is invalid.
+     */
+    public ZipPackagePart(OPCPackage container, ZipArchiveEntry zipEntry,
+            PackagePartName partName, String contentType)
+            throws InvalidFormatException {
+        this(container, zipEntry, partName, contentType, true);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param container
+     *            The container package.
+     * @param zipEntry
+     *            The zip entry corresponding to this part.
+     * @param partName
+     *            The part name.
+     * @param contentType
+     *            Content type.
+     * @throws InvalidFormatException
+     *             Throws if the content of this part is invalid.
+     */
+    /* package */ ZipPackagePart(OPCPackage container, ZipArchiveEntry zipEntry,
+                          PackagePartName partName, String contentType, boolean loadRelationships)
+            throws InvalidFormatException {
+        super(container, partName, new ContentType(contentType), loadRelationships);
+        this.zipEntry = zipEntry;
+    }
+
+    /**
+     * Get the zip entry of this part.
+     *
+     * @return The zip entry in the zip structure coresponding to this part.
+     */
+    public ZipArchiveEntry getZipArchive() {
+        return zipEntry;
+    }
+
+    /**
+     * Implementation of the getInputStream() which return the inputStream of
+     * this part zip entry.
+     *
+     * @return Input stream of this part zip entry.
+     */
+    @Override
+    protected InputStream getInputStreamImpl() throws IOException {
+        // We use the getInputStream() method from java.util.zip.ZipFile
+        // class which return an InputStream to this part zip entry.
+        return ((ZipPackage) _container).getZipArchive()
+                .getInputStream(zipEntry);
+    }
+
+    /**
+     * Implementation of the getOutputStream(). Return <b>null</b>. Normally
+     * will never be called since the MemoryPackage is use instead.
+     *
+     * @return <b>null</b>
+     */
+    @Override
+    protected OutputStream getOutputStreamImpl() {
+        return null;
+    }
+
+    @Override
+    public long getSize() {
+        return zipEntry.getSize();
+    }
+
+    @Override
+    public boolean save(OutputStream os) throws OpenXML4JException {
+        return new ZipPartMarshaller().marshall(this, os);
+    }
+
+    @Override
+    @NotImplemented
+    public boolean load(InputStream ios) {
+        throw new InvalidOperationException("Method not implemented !");
+    }
+
+    @Override
+    @NotImplemented
+    public void close() {
+        throw new InvalidOperationException("Method not implemented !");
+    }
+
+    @Override
+    @NotImplemented
+    public void flush() {
+        throw new InvalidOperationException("Method not implemented !");
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org