aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2011-06-15 11:15:40 +0000
committerYegor Kozlov <yegor@apache.org>2011-06-15 11:15:40 +0000
commit8176097e37d7db7ef7897b7fe831799e4dd39f13 (patch)
tree8d1c63dd28921972c13be15f5f7387ba12038253 /src/ooxml
parentb09aedd0b2e86de122e59a8d55b8062498504b6e (diff)
downloadpoi-8176097e37d7db7ef7897b7fe831799e4dd39f13.tar.gz
poi-8176097e37d7db7ef7897b7fe831799e4dd39f13.zip
Bug 51374 - Fixed incorrect setting of lastPrinted OOXML core property
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1135997 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r--src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java57
2 files changed, 58 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
index 677a513226..e0b9a3721d 100644
--- a/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
+++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java
@@ -292,7 +292,7 @@ public final class PackagePropertiesPart extends PackagePart implements
* @return A string representation of the last printed date.
*/
public String getLastPrintedPropertyString() {
- return getDateValue(created);
+ return getDateValue(lastPrinted);
}
/**
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java
index b934aa308e..f2b2f7e1c3 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackageCoreProperties.java
@@ -29,6 +29,7 @@ import junit.framework.TestCase;
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
+import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart;
import org.apache.poi.openxml4j.util.Nullable;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.POILogFactory;
@@ -123,4 +124,60 @@ public final class TestPackageCoreProperties extends TestCase {
assertEquals("MyTitle", props.getTitleProperty().getValue());
assertEquals("2", props.getVersionProperty().getValue());
}
+
+ public void testCoreProperties_bug51374() throws Exception {
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String strDate = "2007-05-12T08:00:00Z";
+ Date date = df.parse(strDate);
+
+ OPCPackage pkg = new ZipPackage();
+ PackagePropertiesPart props = (PackagePropertiesPart)pkg.getPackageProperties();
+
+ // created
+ assertEquals("", props.getCreatedPropertyString());
+ assertNull(props.getCreatedProperty().getValue());
+ props.setCreatedProperty((String)null);
+ assertEquals("", props.getCreatedPropertyString());
+ assertNull(props.getCreatedProperty().getValue());
+ props.setCreatedProperty(new Nullable<Date>());
+ assertEquals("", props.getCreatedPropertyString());
+ assertNull(props.getCreatedProperty().getValue());
+ props.setCreatedProperty(new Nullable<Date>(date));
+ assertEquals(strDate, props.getCreatedPropertyString());
+ assertEquals(date, props.getCreatedProperty().getValue());
+ props.setCreatedProperty(strDate);
+ assertEquals(strDate, props.getCreatedPropertyString());
+ assertEquals(date, props.getCreatedProperty().getValue());
+
+ // lastPrinted
+ assertEquals("", props.getLastPrintedPropertyString());
+ assertNull(props.getLastPrintedProperty().getValue());
+ props.setLastPrintedProperty((String)null);
+ assertEquals("", props.getLastPrintedPropertyString());
+ assertNull(props.getLastPrintedProperty().getValue());
+ props.setLastPrintedProperty(new Nullable<Date>());
+ assertEquals("", props.getLastPrintedPropertyString());
+ assertNull(props.getLastPrintedProperty().getValue());
+ props.setLastPrintedProperty(new Nullable<Date>(date));
+ assertEquals(strDate, props.getLastPrintedPropertyString());
+ assertEquals(date, props.getLastPrintedProperty().getValue());
+ props.setLastPrintedProperty(strDate);
+ assertEquals(strDate, props.getLastPrintedPropertyString());
+ assertEquals(date, props.getLastPrintedProperty().getValue());
+
+ // modified
+ assertNull(props.getModifiedProperty().getValue());
+ props.setModifiedProperty((String)null);
+ assertNull(props.getModifiedProperty().getValue());
+ props.setModifiedProperty(new Nullable<Date>());
+ assertNull(props.getModifiedProperty().getValue());
+ props.setModifiedProperty(new Nullable<Date>(date));
+ assertEquals(strDate, props.getModifiedPropertyString());
+ assertEquals(date, props.getModifiedProperty().getValue());
+ props.setModifiedProperty(strDate);
+ assertEquals(strDate, props.getModifiedPropertyString());
+ assertEquals(date, props.getModifiedProperty().getValue());
+ }
+
}