diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-07-12 12:25:01 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-07-12 12:25:01 +0000 |
commit | e1bb2a73c83893db399addf28544800310432afc (patch) | |
tree | d9cf6fbc846a3b8a322f65e2fb67e8178aa5edc5 /poi-ooxml/src/main | |
parent | a9a0acc232deee5dc3a256e68264f23795120805 (diff) | |
download | poi-e1bb2a73c83893db399addf28544800310432afc.tar.gz poi-e1bb2a73c83893db399addf28544800310432afc.zip |
[bug-66675] fix issue with writing xlsx (core properties being added twice)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1910949 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src/main')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java | 6 | ||||
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java index 1146711705..35f3c10c01 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java @@ -940,7 +940,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { throw new IllegalArgumentException("part"); } - if (partList.containsKey(part._partName)) { + if (hasPackagePart(part)) { if (!partList.get(part._partName).isDeleted()) { throw new InvalidOperationException( "A part with the name '" @@ -958,6 +958,10 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { return part; } + protected boolean hasPackagePart(PackagePart part) { + return partList.containsKey(part._partName); + } + /** * Remove the specified part in this package. If this part is relationship * part, then delete all relationships in the source part. diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java index 3567e66074..dc176b441b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -542,7 +542,9 @@ public final class ZipPackage extends OPCPackage { // Ensure that core properties are added if missing getPackageProperties(); // Add core properties to part list ... - addPackagePart(this.packageProperties); + if (!hasPackagePart(this.packageProperties)) { + addPackagePart(this.packageProperties); + } // ... and to add its relationship ... this.relationships.addRelationship(this.packageProperties .getPartName().getURI(), TargetMode.INTERNAL, |