<changes>
<release version="3.8-beta4" date="2011-??-??">
+ <action dev="poi-developers" type="add">51444 - Prevent corrupted output when saving files created by LibreOffice 3.3 </action>
<action dev="poi-developers" type="add">51422 - Support using RecalcIdRecord to trigger a full formula recalculation on load </action>
<action dev="poi-developers" type="add">50474 - Example demonstrating how to update Excel workbook embedded in a WordprocessingML document </action>
<action dev="poi-developers" type="fix">51431 - Avoid IndexOutOfBoundException when removing freeze panes in XSSF </action>
public OpenXML4JRuntimeException(String msg) {
super(msg);
}
+
+ public OpenXML4JRuntimeException(String msg, Throwable reason) {
+ super(msg, reason);
+ }
}
/**
* Core properties relationship type.
+ *
+ * <p>
+ * The standard specifies a source relations ship for the Core File Properties part as follows:
+ * <code>http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties.</code>
+ * </p>
+ * <p>
+ * Office uses the following source relationship for the Core File Properties part:
+ * <code>http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties.</code>
+ * </p>
+ * See 2.1.33 Part 1 Section 15.2.11.1, Core File Properties Part in [MS-OE376].pdf
*/
String CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
+ /**
+ * Core properties relationship type as defiend in ECMA 376.
+ */
+ String CORE_PROPERTIES_ECMA376 = "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties";
+
/**
* Digital signature relationship type.
*/
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;
// 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,
}
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);
}
}
package org.apache.poi.openxml4j.opc;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.ParsePosition;
assertEquals(date, props.getModifiedProperty().getValue());
}
+ public void testGetPropertiesLO() throws Exception {
+ // Open the package
+ OPCPackage pkg1 = OPCPackage.open(OpenXML4JTestDataSamples.openSampleStream("51444.xlsx"));
+ PackageProperties props1 = pkg1.getPackageProperties();
+ assertEquals(null, props1.getTitleProperty().getValue());
+ props1.setTitleProperty("Bug 51444 fixed");
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ pkg1.save(out);
+ out.close();
+
+ OPCPackage pkg2 = OPCPackage.open(new ByteArrayInputStream(out.toByteArray()));
+ PackageProperties props2 = pkg2.getPackageProperties();
+ props2.setTitleProperty("Bug 51444 fixed");
+ }
+
}