diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-08-06 20:55:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-07 11:23:03 +0200 |
commit | 6f954f50266f671f9fba25006131f635b00b6e22 (patch) | |
tree | f6b1182d2191e3a38558dc06ae73fe56e7915c06 /chart2 | |
parent | 2808c8a0941f0fc7ab8db4a109cb8dfa0d7c41f1 (diff) |
crashtesting: null date assert seen on loading forum-fr-25994.ods
presumably part of this problem is since:
commit 22c7da0ca5438b69165609db2a1ef219aa167dc2
Date: Wed Mar 19 04:50:20 2014 +0100
the type in the Any is a util::Date and not a DateTime, fdo#74549
and we also have...
rOutProperties.emplace_back( "NullDate",
PROP_DOCUMENT_NULL_DATE,
::cppu::UnoType<css::util::DateTime>::get(),
beans::PropertyAttribute::MAYBEVOID );
which has DateTime and not Date, but we can get this set as either Date and
DateTime, so just accept both.
Change-Id: If77af5bb74755d2196527112665facf27a4d1403
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137911
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/tools/NumberFormatterWrapper.cxx | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx index d6e704d145d6..e00df1fae04e 100644 --- a/chart2/source/tools/NumberFormatterWrapper.cxx +++ b/chart2/source/tools/NumberFormatterWrapper.cxx @@ -66,12 +66,31 @@ NumberFormatterWrapper::~NumberFormatterWrapper() { } +namespace +{ + bool getDate(const css::uno::Any& rAny, util::Date& rDate) + { + if (rAny >>= rDate) + return true; + util::DateTime aUtilDateTime; + if (rAny >>= aUtilDateTime) + { + rDate.Day = aUtilDateTime.Day; + rDate.Month = aUtilDateTime.Month; + rDate.Year = aUtilDateTime.Year; + return true; + } + SAL_WARN("chart2.tools", "neither a util::Date nor a util::DateTime"); + return false; + } +} + Date NumberFormatterWrapper::getNullDate() const { Date aRet(30,12,1899); util::Date aUtilDate; - if( m_aNullDate.hasValue() && (m_aNullDate >>= aUtilDate) ) + if (m_aNullDate.hasValue() && getDate(m_aNullDate, aUtilDate)) { aRet = Date(aUtilDate.Day,aUtilDate.Month,aUtilDate.Year); } @@ -102,8 +121,8 @@ OUString NumberFormatterWrapper::getFormattedString( sal_Int32 nNumberFormatKey, nMonth = rDate.GetMonth(); nDay = rDate.GetDay(); util::Date aNewNullDate; - m_aNullDate >>= aNewNullDate; - m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year); + if (getDate(m_aNullDate, aNewNullDate)) + m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year); } // tdf#130969: use UNLIMITED_PRECISION in case of GENERAL Number Format if( m_pNumberFormatter->GetStandardPrec() != SvNumberFormatter::UNLIMITED_PRECISION ) |