]> source.dussan.org Git - poi.git/commitdiff
[bug-56155] support version property in CoreProperties
authorPJ Fanning <fanningpj@apache.org>
Sat, 28 May 2022 15:01:48 +0000 (15:01 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 28 May 2022 15:01:48 +0000 (15:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901356 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java
poi-ooxml/src/test/java/org/apache/poi/ooxml/TestPOIXMLProperties.java

index 14779374fe4bb60ea705c06a1625fc854efa1177..af423bf15704c07bdff74efdca9b944f73473c7e 100644 (file)
@@ -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);
         }
index fae10b0c0d093e854c2f17c653f0322113fe8009..4144372623d9989d884d953f41bdf9137a205fe1 100644 (file)
@@ -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