From 8c3825be73d3b5aa20a7931ec3536c649e2c0d2f Mon Sep 17 00:00:00 2001 From: Paolo Mottadelli Date: Mon, 20 Jul 2009 17:10:43 +0000 Subject: [PATCH] POIXMLproperties: core properties improvement + test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@795923 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/POIXMLProperties.java | 12 ++++++++ .../org/apache/poi/TestPOIXMLProperties.java | 29 ++++++++++++++++-- .../poi/hwpf/data/documentProperties.docx | Bin 0 -> 23514 bytes 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/scratchpad/testcases/org/apache/poi/hwpf/data/documentProperties.docx diff --git a/src/ooxml/java/org/apache/poi/POIXMLProperties.java b/src/ooxml/java/org/apache/poi/POIXMLProperties.java index 6966149668..ca2ca808b9 100644 --- a/src/ooxml/java/org/apache/poi/POIXMLProperties.java +++ b/src/ooxml/java/org/apache/poi/POIXMLProperties.java @@ -165,6 +165,18 @@ public class POIXMLProperties { public String getTitle() { return part.getTitleProperty().getValue(); } + public String getCreator() { + return part.getCreatorProperty().getValue(); + } + public void setCreator(String creator) { + part.setCreatorProperty(creator); + } + public String getSubject() { + return part.getSubjectProperty().getValue(); + } + public void setSubjectProperty(String subject) { + part.setSubjectProperty(subject); + } public PackagePropertiesPart getUnderlyingProperties() { return part; diff --git a/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java b/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java index 4349600ad6..c27619cec0 100755 --- a/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java +++ b/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java @@ -18,15 +18,20 @@ package org.apache.poi; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xssf.XSSFTestDataSamples; +import java.io.File; import junit.framework.TestCase; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.xssf.XSSFTestDataSamples; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.xwpf.usermodel.XWPFDocument; + /** * Test setting extended and custom OOXML properties */ public class TestPOIXMLProperties extends TestCase { + public void testWorkbookExtendedProperties() throws Exception { XSSFWorkbook workbook = new XSSFWorkbook(); POIXMLProperties props = workbook.getProperties(); @@ -131,4 +136,24 @@ public class TestPOIXMLProperties extends TestCase { } + + public void testDocumentProperties() throws Exception { + File sampleFile = new File( + System.getProperty("HWPF.testdata.path") + + File.separator + "documentProperties.docx" + ); + assertTrue(sampleFile.exists()); + XWPFDocument sampleDoc; + sampleDoc = new XWPFDocument( + POIXMLDocument.openPackage(sampleFile.toString()) + ); + POIXMLProperties props = sampleDoc.getProperties(); + assertNotNull(props); + String title = props.getCoreProperties().getTitle(); + assertEquals("Hello World", title); + String creator = props.getCoreProperties().getCreator(); + assertEquals("Paolo Mottadelli", creator); + String subject = props.getCoreProperties().getSubject(); + assertEquals("Greetings", subject); + } } \ No newline at end of file diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/data/documentProperties.docx b/src/scratchpad/testcases/org/apache/poi/hwpf/data/documentProperties.docx new file mode 100644 index 0000000000000000000000000000000000000000..d18b31e2ce53c24cb5bddd2d974a0decbb471296 GIT binary patch literal 23514 zcmeHvWmr{P*XV*xhjc3~At@jo(jZ88h{UF0(_PXaNP_~3AOg}If^?@yNlFMJf|Me? z@7j9K(c^dC``zb#?~nW3kIA#v8hg$$#++l!9?Ut^lprX?02+V+0014ZL-VlE9|-`o zPyv7lz(6*XhB>-H9o&M@f9%U|-Mj)mO}lk%Jg{#rHBdY2&BA9NSjD6~e&O$%s#a#(ci_rZw%Ues3`( zge&Z8y6oxKtL`y@RfOwX)^73*HwcuK&BG+~k_3nsp9fhC`}sjBz1O>aB&FwAF(}Lu z-dC^|dbze|Y9>}i7Ji(Gq&By`FXe)tTE@3$L6W+kDvj|rO-Db(S99qN(lM@IvviD} zD-v!?YeeW>B3GF4%`wr;&z%e3iVIanA?V__Fr;H*_sKqqY$h0Ds;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