diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-07-03 21:52:53 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-07-04 00:12:37 +0200 |
commit | 79d31d08146afa0861ceb1705262411449e71ec7 (patch) | |
tree | a029051df5d9c931c99e45e0734d0ee2aef84542 /sw/source/filter/ww8/ww8par5.cxx | |
parent | 57bd9a60757a5a5d222d6e992e7f38cb3cea4bf6 (diff) |
tdf100961: import fixed date/time field attribute from DOC
Change-Id: Ic67e1cb2fbdb0e7efdeca67ba5cf72ff30856e80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118357
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source/filter/ww8/ww8par5.cxx')
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 0a583ca80f90..9096889a9c60 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -1822,31 +1822,22 @@ 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) + if (nDT & SvNumFormatType::DATE || nDT == SvNumFormatType::TIME) { SwDateTimeField aField(static_cast<SwDateTimeFieldType*>( 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 | nDoNotRecalculate), - nFormat); + nDT & SvNumFormatType::DATE ? DATEFLD : TIMEFLD, nFormat); + if (pF->nOpt & 0x10) // Fixed field + { + double fSerial; + if (!m_rDoc.GetNumberFormatter()->IsNumberFormat(GetFieldResult(pF), nFormat, fSerial, + SvNumInputOptions::LAX_TIME)) + return eF_ResT::TEXT; // just drop the field and insert the plain text. + aField.SetSubType(aField.GetSubType() | FIXEDFLD); + DateTime aSetDateTime(m_rDoc.GetNumberFormatter()->GetNullDate()); + aSetDateTime.AddTime(fSerial); + aField.SetDateTime(aSetDateTime); + } ForceFieldLanguage(aField, nLang); m_rDoc.getIDocumentContentOperations().InsertPoolItem( *m_pPaM, SwFormatField( aField ) ); } |