]> source.dussan.org Git - poi.git/commitdiff
[github-157] add setters for ExtendedProperties. Thanks to Thibaut Cuvelier. This...
authorPJ Fanning <fanningpj@apache.org>
Fri, 19 Jul 2019 19:48:14 +0000 (19:48 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 19 Jul 2019 19:48:14 +0000 (19:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1863432 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java
src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java

index 361fa75fed0df0dc20b2cb475d96c2c4cb47d004..a816e93fda845fda23563d00865ac2daa230fbc8 100644 (file)
@@ -376,36 +376,60 @@ public class POIXMLProperties {
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setTemplate(String template) {
+            props.getProperties().setTemplate(template);
+        }
         public String getManager() {
             if (props.getProperties().isSetManager()) {
                 return props.getProperties().getManager();
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setManager(String manager) {
+            props.getProperties().setManager(manager);
+        }
         public String getCompany() {
             if (props.getProperties().isSetCompany()) {
                 return props.getProperties().getCompany();
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setCompany(String company) {
+            props.getProperties().setCompany(company);
+        }
         public String getPresentationFormat() {
             if (props.getProperties().isSetPresentationFormat()) {
                 return props.getProperties().getPresentationFormat();
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setPresentationFormat(String presentationFormat) {
+            props.getProperties().setPresentationFormat(presentationFormat);
+        }
         public String getApplication() {
             if (props.getProperties().isSetApplication()) {
                 return props.getProperties().getApplication();
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setApplication(String application) {
+            props.getProperties().setApplication(application);
+        }
         public String getAppVersion() {
             if (props.getProperties().isSetAppVersion()) {
                 return props.getProperties().getAppVersion();
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setAppVersion(String appVersion) {
+            props.getProperties().setAppVersion(appVersion);
+        }
 
         public int getPages() {
             if (props.getProperties().isSetPages()) {
@@ -413,66 +437,110 @@ public class POIXMLProperties {
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setPages(int pages) {
+            props.getProperties().setPages(pages);
+        }
         public int getWords() {
             if (props.getProperties().isSetWords()) {
                 return props.getProperties().getWords();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setWords(int words) {
+            props.getProperties().setWords(words);
+        }
         public int getCharacters() {
             if (props.getProperties().isSetCharacters()) {
                 return props.getProperties().getCharacters();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setCharacters(int characters) {
+            props.getProperties().setCharacters(characters);
+        }
         public int getCharactersWithSpaces() {
             if (props.getProperties().isSetCharactersWithSpaces()) {
                 return props.getProperties().getCharactersWithSpaces();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setCharactersWithSpaces(int charactersWithSpaces) {
+            props.getProperties().setCharactersWithSpaces(charactersWithSpaces);
+        }
         public int getLines() {
             if (props.getProperties().isSetLines()) {
                 return props.getProperties().getLines();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setLines(int lines) {
+            props.getProperties().setLines(lines);
+        }
         public int getParagraphs() {
             if (props.getProperties().isSetParagraphs()) {
                 return props.getProperties().getParagraphs();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setParagraphs(int paragraphs) {
+            props.getProperties().setParagraphs(paragraphs);
+        }
         public int getSlides() {
             if (props.getProperties().isSetSlides()) {
                 return props.getProperties().getSlides();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setSlides(int slides) {
+            props.getProperties().setSlides(slides);
+        }
         public int getNotes() {
             if (props.getProperties().isSetNotes()) {
                 return props.getProperties().getNotes();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setNotes(int notes) {
+            props.getProperties().setNotes(notes);
+        }
         public int getTotalTime()  {
             if (props.getProperties().isSetTotalTime()) {
                 return props.getProperties().getTotalTime();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setTotalTime(int totalTime) {
+            props.getProperties().setTotalTime(totalTime);
+        }
         public int getHiddenSlides()  {
             if (props.getProperties().isSetHiddenSlides()) {
                 return props.getProperties().getHiddenSlides();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setHiddenSlides(int hiddenSlides) {
+            props.getProperties().setHiddenSlides(hiddenSlides);
+        }
         public int getMMClips() {
             if (props.getProperties().isSetMMClips()) {
                 return props.getProperties().getMMClips();
             }
             return -1;
         }
+        /** @since POI 4.1.1 */
+        public void setMMClips(int mmClips) {
+            props.getProperties().setMMClips(mmClips);
+        }
 
         public String getHyperlinkBase() {
             if (props.getProperties().isSetHyperlinkBase()) {
@@ -480,6 +548,10 @@ public class POIXMLProperties {
             }
             return null;
         }
+        /** @since POI 4.1.1 */
+        public void setHyperlinkBase(String hyperlinkBase) {
+            props.getProperties().setHyperlinkBase(hyperlinkBase);
+        }
     }
 
     /**
index 4bd9de3a6ce7293d48882e731f66b464ede50e79..d5270fe2c4627455ae0dc481cd0d9e5b0fc74abd 100644 (file)
@@ -116,6 +116,42 @@ public final class TestPOIXMLProperties {
         newWorkbook.close();
     }
 
+    @Test
+    public void testWorkbookExtendedPropertiesGettersSetters() throws Exception {
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        POIXMLProperties props = workbook.getProperties();
+        assertNotNull(props);
+
+        POIXMLProperties.ExtendedProperties properties =
+                props.getExtendedProperties();
+
+        String appVersion = "3.5 beta";
+        String application = "POI Modified";
+
+        assertEquals("Apache POI", properties.getApplication());
+        properties.setApplication(application);
+        assertEquals(properties.getApplication(), application);
+
+        assertNull(properties.getAppVersion());
+        properties.setAppVersion(appVersion);
+        assertEquals(properties.getAppVersion(), appVersion);
+
+        XSSFWorkbook newWorkbook =
+                XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        workbook.close();
+        assertNotSame(workbook, newWorkbook);
+
+        POIXMLProperties newProps = newWorkbook.getProperties();
+        assertNotNull(newProps);
+        POIXMLProperties.ExtendedProperties newProperties =
+                newProps.getExtendedProperties();
+
+        assertEquals(application, newProperties.getApplication());
+        assertEquals(appVersion, newProperties.getAppVersion());
+
+        newWorkbook.close();
+    }
+
 
     /**
      * Test usermodel API for setting custom properties