aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2019-07-19 19:48:14 +0000
committerPJ Fanning <fanningpj@apache.org>2019-07-19 19:48:14 +0000
commit10b5a462dcf52ea6e047cd0ccdb6a6dbce45123d (patch)
tree8fe5ebab21fef6347a8933147b2fcaa219f2e137 /src
parent65c4aafe3eab8ddb886d965f59ae6c135dd3d782 (diff)
downloadpoi-10b5a462dcf52ea6e047cd0ccdb6a6dbce45123d.tar.gz
poi-10b5a462dcf52ea6e047cd0ccdb6a6dbce45123d.zip
[github-157] add setters for ExtendedProperties. Thanks to Thibaut Cuvelier. This closes #157
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1863432 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java72
-rw-r--r--src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java36
2 files changed, 108 insertions, 0 deletions
diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java
index 361fa75fed..a816e93fda 100644
--- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java
+++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java
@@ -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);
+ }
}
/**
diff --git a/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java b/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java
index 4bd9de3a6c..d5270fe2c4 100644
--- a/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java
+++ b/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLProperties.java
@@ -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