aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-05-28 15:01:48 +0000
committerPJ Fanning <fanningpj@apache.org>2022-05-28 15:01:48 +0000
commit30bca4da834c69051eb7d85f60c76b9daa3e4dfa (patch)
treeec85934e7040c350207fba4d522a4d7f1fc95778
parent772c938f4cc7e0487ce1c63909313445b86a33b5 (diff)
downloadpoi-30bca4da834c69051eb7d85f60c76b9daa3e4dfa.tar.gz
poi-30bca4da834c69051eb7d85f60c76b9daa3e4dfa.zip
[bug-56155] support version property in CoreProperties
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901356 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java19
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java3
2 files changed, 22 insertions, 0 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java
index 14779374fe..af423bf157 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java
@@ -345,6 +345,25 @@ public class POIXMLProperties {
public String getTitle() {
return part.getTitleProperty().orElse(null);
}
+
+ /**
+ * Sets the version property.
+ * @param version property value
+ * @since POI 5.2.3
+ */
+ public void setVersion(String version) {
+ part.setVersionProperty(version);
+ }
+
+ /**
+ * Returns the version property value.
+ * @return version property (can be null)
+ * @since POI 5.2.3
+ */
+ public String getVersion() {
+ return part.getVersionProperty().orElse(null);
+ }
+
public String getRevision() {
return part.getRevisionProperty().orElse(null);
}
diff --git a/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java b/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
index fae10b0c0d..4144372623 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java
@@ -219,6 +219,9 @@ public final class TestPOIXMLProperties {
assertEquals("Greetings", subject);
String title = _coreProperties.getTitle();
assertEquals("Hello World", title);
+ assertNull(_coreProperties.getVersion());
+ _coreProperties.setVersion("1.2.3");
+ assertEquals("1.2.3", _coreProperties.getVersion());
}
@Test