oox/source/core/xmlfilterbase.cxx                    |    4 +
 sw/qa/extras/ooxmlexport/data/custom-properties.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx            |   47 +++++++++++++++++++
 sw/qa/inc/swmodeltestbase.hxx                        |    4 +
 4 files changed, 54 insertions(+), 1 deletion(-)

New commits:
commit 5dda71e33e8d7e5b6433b7c3b48115c6738a177f
Author:     Bartosz Kosiorek <gan...@poczta.onet.pl>
AuthorDate: Fri Oct 16 16:46:52 2020 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Sat Oct 17 17:06:12 2020 +0200

    tdf#133377 OOXML Fix storage of date in Custom Properties
    
    During exporting documents into OOXML formats (docx, xlsx, pptx),
    if custom properties have Date format, the day and year were switched.
    
    This commit fixes that.
    
    Change-Id: Id497602eb3354de78bfd52bf5ef61d32aafd957d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104450
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104463

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index e0e1933a39a1..3521a521ee81 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
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/custom-properties.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index fa75e2d6af85..9640fb73764a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -78,6 +78,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/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx
index 8769e38992c2..090044e1cd23 100644
--- a/sw/qa/inc/swmodeltestbase.hxx
+++ b/sw/qa/inc/swmodeltestbase.hxx
@@ -985,7 +985,11 @@ protected:
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), 
BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math";));
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ContentType"), 
BAD_CAST("http://schemas.openxmlformats.org/package/2006/content-types";));
         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"), 
BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart";));
         xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("o"), 
BAD_CAST("urn:schemas-microsoft-com:office:office"));
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to