sw/qa/extras/ooxmlexport/ooxmlexport14.cxx |    7 +++++++
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |    2 --
 sw/source/filter/ww8/ww8atr.cxx            |    6 +++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 5453721050f1cad2951410cc8d5ebca19ea38294
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Tue Apr 5 11:43:43 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Apr 12 11:46:44 2022 +0200

    tdf#148380 docx export: support CREATEDATE without format
    
    When CREATEDATE is given as a field command without the optional
    format string, then export was treating it as bWriteExpand
    (aka ww::eUNKNOWN) and just dumped out the field name.
    
    Instead, accept an empty string as a valid number format
    in order to maintain it as a field.
    
    In order to do this, we have to also turn off write-expand
    for fixed fields, since import always treats CREATEDATE as FIXED.
    
    The other existing example is
    writerfilter/qa/cppunittests/dmapper/data/create-date-preserve.docx
    
    DOC: not yet importing as FIXED
    RTF: seems to just ignore bWriteExpand and does the right thing anyway.
    
    Change-Id: If0aef38f6730f55b5fa1be6a62e0b6a0b4871658
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132662
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index fa0199ede9dd..ebc1cbfd02ab 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -737,6 +737,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf83309, "tdf83309.docx")
     // behave same way)
     OUString sNodeType = parseDump("/root/page[1]/body/txt[1]/Text[1]", 
"nType");
     CPPUNIT_ASSERT_EQUAL(OUString("PortionType::Text"), sNodeType);
+
+    // tdf148380: creation-date field in header.xml was unsupported on export
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+    uno::Reference<text::XTextField> xField(xFields->nextElement(), 
uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("8/31/14 10:26 AM"), 
xField->getPresentation(false));
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testTdf121661)
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 0c357607be22..3df56e2489ce 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -75,8 +75,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148380_createField, 
"tdf148380_createField.docx"
     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
     auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
     uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
-    if (mbExported)
-        return;
     uno::Reference<text::XTextField> xField(xFields->nextElement(), 
uno::UNO_QUERY);
     // This should NOT be "Lorenzo Chavez", or a real date since the user 
hand-modified the result.
     CPPUNIT_ASSERT_EQUAL(OUString("Myself - that's who"), 
xField->getPresentation(false));
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index d038bac90953..44063c816d9e 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2935,8 +2935,12 @@ void AttributeOutputBase::TextField( const 
SwFormatField& rField )
                 case DI_CREATE:
                     if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
                         eField = ww::eAUTHOR;
-                    else if (GetExport().GetNumberFormat(*pField, sStr))
+                    else if (GetExport().GetNumberFormat(*pField, sStr) || 
sStr.isEmpty())
                         eField = ww::eCREATEDATE;
+
+                    // Create author/time are always imported as fixed. Safe 
to ignore on export
+                    if (GetExport().GetExportFormat() != MSWordExportBase::DOC)
+                        bWriteExpand = false;
                     break;
 
                 case DI_CHANGE:

Reply via email to