summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/source/core/xmlfilterbase.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/data/custom-properties.docxbin0 -> 12892 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport2.cxx47
-rw-r--r--sw/qa/unit/swmodeltestbase.cxx10
4 files changed, 60 insertions, 1 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index dbc419c28a3e..43f4e573229a 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -826,11 +826,13 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie
util::DateTime aDateTime;
if ( rProp.Value >>= num )
{
+ // i4 - 4-byte signed integer
+ // r8 - 8-byte real number
writeElement( pAppProps, FSNS( XML_vt, XML_i4 ), num );
}
else if ( rProp.Value >>= aDate )
{
- aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Year, aDate.Month, aDate.Day, true );
+ aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Day, aDate.Month, aDate.Year, true );
writeElement( pAppProps, FSNS( XML_vt, XML_filetime ), aDateTime);
}
else if ( rProp.Value >>= aDuration )
diff --git a/sw/qa/extras/ooxmlexport/data/custom-properties.docx b/sw/qa/extras/ooxmlexport/data/custom-properties.docx
new file mode 100644
index 000000000000..33cce91f7ec4
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/custom-properties.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index f05f6251ed48..a77d41b64094 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -85,6 +85,53 @@ DECLARE_OOXMLEXPORT_TEST(testPageGraphicBackground, "page-graphic-background.odt
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPageStyle, "BackColor"));
}
+
+DECLARE_OOXMLEXPORT_TEST(testCustomProperties, "custom-properties.docx")
+{
+ // tdf#133377 FILESAVE XLSX: Make sure the custom/core/application file properties
+ // are stored correctly after roundtrip to .docx
+
+ // Extended file properties - specific to Office package,
+ // eg. docx - Number of Pages, pptx - Number of Slides
+ xmlDocUniquePtr pXmlDoc = parseExport("docProps/app.xml");
+ if (!pXmlDoc)
+ return;
+
+ assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", "1");
+ //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Lines", "1");
+ assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Pages", "1");
+ assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Words", "3");
+ assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Characters", "21");
+ assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:CharactersWithSpaces", "23");
+ assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Company", "hhhhkompany");
+
+ // Custom file properties - defined by user
+ xmlDocUniquePtr pCustomXml = parseExport("docProps/custom.xml");
+ assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[12]",
+ "name", "testDateProperty");
+ assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[12]/vt:filetime",
+ "1982-04-19T10:00:00Z");
+ assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[14]",
+ "name", "testNegativeNumberProperty");
+ assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[14]/vt:i4",
+ "-100");
+ assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[17]",
+ "name", "testTextProperty");
+ assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[17]/vt:lpwstr",
+ "testPropertyValue");
+ assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[18]",
+ "name", "testYesNoProperty");
+ assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[18]/vt:bool",
+ "1");
+
+ // Core file properties - common for all packages (eg. creation date, modify date)
+ pXmlDoc = parseExport("docProps/core.xml");
+ assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:creator", "Bartosz Kosiorek");
+ assertXPathContent(pXmlDoc, "/cp:coreProperties/dc:description", "cccckomentarzglowny");
+ assertXPathContent(pXmlDoc, "/cp:coreProperties/cp:lastPrinted", "2020-10-15T07:42:00Z");
+ assertXPathContent(pXmlDoc, "/cp:coreProperties/dcterms:created", "2020-10-14T16:23:00Z");
+}
+
DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx
index 306e03476cef..b520967b21f4 100644
--- a/sw/qa/unit/swmodeltestbase.cxx
+++ b/sw/qa/unit/swmodeltestbase.cxx
@@ -729,8 +729,18 @@ void SwModelTestBase::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx)
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"),
BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"));
xmlXPathRegisterNs(
+ pXmlXpathCtx, BAD_CAST("cp"),
+ BAD_CAST("http://schemas.openxmlformats.org/package/2006/metadata/core-properties"));
+ xmlXPathRegisterNs(
pXmlXpathCtx, BAD_CAST("extended-properties"),
BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"));
+ xmlXPathRegisterNs(
+ pXmlXpathCtx, BAD_CAST("custom-properties"),
+ BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"));
+ xmlXPathRegisterNs(
+ pXmlXpathCtx, BAD_CAST("vt"),
+ BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"));
+ xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dcterms"), BAD_CAST("http://purl.org/dc/terms/"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a14"),
BAD_CAST("http://schemas.microsoft.com/office/drawing/2010/main"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"),