summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-04-12 14:52:13 +0200
committerJustin Luth <justin_luth@sil.org>2021-04-15 17:53:53 +0200
commit74a8bda42d443c8fbcfab7619a929ccf53a00918 (patch)
tree8b26585e00ed4760512d4b9c72d7af31a36570f6 /sw
parenta93ed3aaab465056f345bba09206865ae7e2a609 (diff)
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.kaganski@collabora.com> Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ww8export/data/tdf100961_fixedDateTime.docbin0 -> 19968 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx18
3 files changed, 22 insertions, 2 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf100961_fixedDateTime.doc
Binary files 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 ) );
}