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 xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + auto xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference xFields(xFieldsAccess->createEnumeration()); + uno::Reference 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: