diff options
author | Yegor Kozlov <yegor@apache.org> | 2011-06-30 15:39:47 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2011-06-30 15:39:47 +0000 |
commit | 586645ade856d55179a9c49c7e38a26d594f8e9f (patch) | |
tree | cf3c37657466eb981d9db82991eb74860448ece8 /src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java | |
parent | bade89b292a63acb5a34caba9064eae2d1809e86 (diff) | |
download | poi-586645ade856d55179a9c49c7e38a26d594f8e9f.tar.gz poi-586645ade856d55179a9c49c7e38a26d594f8e9f.zip |
Bug 51444 - Prevent corrupted output when saving files created by LibreOffice 3.3
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1141576 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java index 52a871411e..bc65412bc7 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -30,6 +30,7 @@ import java.util.zip.ZipOutputStream; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidOperationException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; +import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException; import org.apache.poi.openxml4j.opc.internal.ContentTypeManager; import org.apache.poi.openxml4j.opc.internal.FileHelper; import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart; @@ -384,13 +385,13 @@ public final class ZipPackage extends Package { // 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) { + if (this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES).size() == 0 && + this.getPartsByRelationshipType(PackageRelationshipTypes.CORE_PROPERTIES_ECMA376).size() == 0 ) { logger.log(POILogger.DEBUG,"Save core properties part"); // We have to save the core properties part ... new ZipPackagePropertiesMarshaller().marshall( - this.packageProperties, zos); + this.packageProperties, zos); // ... and to add its relationship ... this.relationships.addRelationship(this.packageProperties .getPartName().getURI(), TargetMode.INTERNAL, @@ -445,9 +446,9 @@ public final class ZipPackage extends Package { } zos.close(); } catch (Exception e) { - logger - .log(POILogger.ERROR,"Fail to save: an error occurs while saving the package : " - + e.getMessage()); + throw new OpenXML4JRuntimeException( + "Fail to save: an error occurs while saving the package : " + + e.getMessage(), e); } } |