sw/qa/extras/ooxmlexport/data/tdf148380_modifiedField.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx                 |   17 +++++++++++++
 sw/source/filter/ww8/ww8atr.cxx                            |    4 +--
 3 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit d9b33ed6644203141fdb0776c291425c2bc9f5ac
Author:     Justin Luth <justin_l...@sil.org>
AuthorDate: Wed Apr 6 18:54:02 2022 +0200
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Sat Apr 16 05:47:06 2022 +0200

    tdf#148380 docx export: support CHANGEDATE/PRINTDATE without format
    
    This is the same idea as the earlier patch for CREATEDATE.
    However, it isn't safe to import these as fields,
    so a round-trip test can only test the string itself.
    
    The unit test here really doesn't test any of the code changes,
    but is just pre-emptive to ensure that if DI_CHANGE
    is imported as a field that it will have the right
    output.
    (P.S. Expected date output matches MS Word 2003
     even after an F9 refresh.)
    
    Change-Id: I30a8b1fc851246898a67e6241a35e927f85dfbb9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132664
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf148380_modifiedField.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148380_modifiedField.docx
new file mode 100644
index 000000000000..14f6e319e298
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148380_modifiedField.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 960bb3f16d8b..5d5bdb22471a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -83,6 +83,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148380_createField, 
"tdf148380_createField.docx"
     CPPUNIT_ASSERT_EQUAL(OUString("yesterday at noon"), 
xField->getPresentation(false));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148380_modifiedField, 
"tdf148380_modifiedField.docx")
+{
+    getParagraph(2, "4/5/2022 4:29:00 PM"); // default (unspecified) date 
format
+
+    // Verify that these are fields, and not just plain text
+    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);
+    // unspecified SAVEDATE gets default US formatting because style.xml has 
w:lang w:val="en-US"
+    //CPPUNIT_ASSERT_EQUAL(OUString("4/5/2022 4:29:00 PM"), 
xField->getPresentation(false));
+    //xField.set(xFields->nextElement(), uno::UNO_QUERY);
+    // FIXME: This was hand-modified and really should be Charlie Brown
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Did you fix me? I really should be Charlie 
Brown (or a date)",
+                                 OUString("Charles Brown"), 
xField->getPresentation(false));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf135906)
 {
     loadAndReload("tdf135906.docx");
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index b9c71e4433ae..a5e650eb8e6c 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2948,13 +2948,13 @@ void AttributeOutputBase::TextField( const 
SwFormatField& rField )
                 case DI_CHANGE:
                     if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
                         eField = ww::eLASTSAVEDBY;
-                    else if (GetExport().GetNumberFormat(*pField, sStr))
+                    else if (GetExport().GetNumberFormat(*pField, sStr) || 
sStr.isEmpty())
                         eField = ww::eSAVEDATE;
                     break;
 
                 case DI_PRINT:
                     if (DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK) &&
-                        GetExport().GetNumberFormat(*pField, sStr))
+                        (GetExport().GetNumberFormat(*pField, sStr) || 
sStr.isEmpty()))
                         eField = ww::ePRINTDATE;
                     break;
                 case DI_CUSTOM:

Reply via email to