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 <jluth@mail.com>
This commit is contained in:
parent
4659fc2f0a
commit
d9b33ed664
BIN
sw/qa/extras/ooxmlexport/data/tdf148380_modifiedField.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/tdf148380_modifiedField.docx
Normal file
Binary file not shown.
@ -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");
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user