sw/qa/extras/ww8export/data/tdf100961_fixedDateTime.doc |binary sw/qa/extras/ww8export/ww8export3.cxx | 6 +++++ sw/source/filter/ww8/ww8par5.cxx | 18 ++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)
New commits: commit 74a8bda42d443c8fbcfab7619a929ccf53a00918 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Mon Apr 12 14:52:13 2021 +0200 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Thu Apr 15 17:53:53 2021 +0200 partial fix tdf100961 doc import: E_Locked field as plain text The date/time fields should be a const time, not the current, updateable time. This patch throws away the field and just imports the plain text (and paves the way for locking the field as well). A better fix requires a better programmer, one who can take that plain text string and use the formatting information to set the DateTime field to that time. But at least this plain-text date will be better than a completely wrong field date. Change-Id: I8a57ecde64aa670b2205fcf99ed9ae226579c4ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113986 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ww8export/data/tdf100961_fixedDateTime.doc b/sw/qa/extras/ww8export/data/tdf100961_fixedDateTime.doc new file mode 100644 index 000000000000..86f0e478d469 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf100961_fixedDateTime.doc differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 05211e47f0f3..e525927579e3 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -69,6 +69,12 @@ DECLARE_WW8EXPORT_TEST(testTdf37778_readonlySection, "tdf37778_readonlySection.d CPPUNIT_ASSERT_EQUAL_MESSAGE("Last printed date", sal_Int16(2009), xDPS->getDocumentProperties()->getPrintDate().Year); } +DECLARE_WW8EXPORT_TEST(testTdf100961_fixedDateTime, "tdf100961_fixedDateTime.doc") +{ + // This should be a fixed date/time field, not the current time. + getParagraph(1, "05.01.19 04:06:08"); +} + DECLARE_WW8EXPORT_TEST(testTdf138345_paraCharHighlight, "tdf138345_paraCharHighlight.doc") { uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(9), 1, "A side benefit is that "), uno::UNO_QUERY_THROW); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 4ffd00a5ebee..ad20690464ef 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1819,17 +1819,31 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, OUString& rStr ) } } + sal_uInt16 nDoNotRecalculate = (pF->nOpt & 0x10) ? FIXEDFLD : 0; + if (nDoNotRecalculate) + { + // TODO: Doing this properly would require setting the field to the original date/time. + // Unfortunately, none of the plumbing to do this exists AFAICS + //SAL_WARN("DEBUG","Need to aField.SetDateTime() to ["<<GetFieldResult(pF)<<"] based on format string["<<aReadParam.GetResult()<<"]"); + // So instead, just drop the field and insert the plain text. + // That is at least better than having the current date/time. + return eF_ResT::TEXT; + } if (nDT & SvNumFormatType::DATE) { SwDateTimeField aField(static_cast<SwDateTimeFieldType*>( - m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime )), DATEFLD, nFormat); + m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime)), + (DATEFLD | nDoNotRecalculate), + nFormat); ForceFieldLanguage(aField, nLang); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); } else if (nDT == SvNumFormatType::TIME) { SwDateTimeField aField(static_cast<SwDateTimeFieldType*>( - m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime)), TIMEFLD, nFormat); + m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DateTime)), + (TIMEFLD | nDoNotRecalculate), + nFormat); ForceFieldLanguage(aField, nLang); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits