summaryrefslogtreecommitdiff
path: root/chart2/source/tools/NumberFormatterWrapper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/tools/NumberFormatterWrapper.cxx')
-rw-r--r--chart2/source/tools/NumberFormatterWrapper.cxx28
1 files changed, 23 insertions, 5 deletions
diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx
index f5bef49d19de..9687fd60e161 100644
--- a/chart2/source/tools/NumberFormatterWrapper.cxx
+++ b/chart2/source/tools/NumberFormatterWrapper.cxx
@@ -20,7 +20,6 @@
#include <NumberFormatterWrapper.hxx>
#include <svl/numformat.hxx>
#include <svl/numuno.hxx>
-#include <svl/zforlist.hxx>
#include <tools/color.hxx>
#include <com/sun/star/util/Date.hpp>
#include <osl/diagnose.h>
@@ -54,7 +53,7 @@ NumberFormatterWrapper::NumberFormatterWrapper( const uno::Reference< util::XNum
{
uno::Reference<beans::XPropertySet> xProp(m_xNumberFormatsSupplier,uno::UNO_QUERY);
- OUString sNullDate( "NullDate" );
+ OUString sNullDate( u"NullDate"_ustr );
if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(sNullDate) )
m_aNullDate = xProp->getPropertyValue(sNullDate);
SvNumberFormatsSupplierObj* pSupplierObj = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>( xSupplier );
@@ -67,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);
}
@@ -103,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 )