diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-06-17 08:45:28 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-06-17 08:45:28 +0200 |
commit | f35b1397ae3e7e975ea1c423df5c7a8ee711d335 (patch) | |
tree | 19e56e5698718acc0622225c146ca27dce29d5ea /chart2/source/inc | |
parent | e6c004dd9f24c32f5e7468182a5e8d42293ec7b6 (diff) |
Clean up uses of Any::getValue() in chart2
Change-Id: I53224053ea05c715f5e359a4c68e1ae5efbfe792
Diffstat (limited to 'chart2/source/inc')
-rw-r--r-- | chart2/source/inc/CommonFunctors.hxx | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/chart2/source/inc/CommonFunctors.hxx b/chart2/source/inc/CommonFunctors.hxx index f912f50fb572..bbdc27a851c1 100644 --- a/chart2/source/inc/CommonFunctors.hxx +++ b/chart2/source/inc/CommonFunctors.hxx @@ -21,6 +21,7 @@ #include <algorithm> #include <functional> +#include <o3tl/any.hxx> #include <rtl/math.hxx> #include <com/sun/star/uno/Any.hxx> #include <rtl/ustring.hxx> @@ -56,13 +57,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble : public ::std::unary_function< css: { double fResult; ::rtl::math::setNan( & fResult ); - - css::uno::TypeClass eClass( rAny.getValueType().getTypeClass() ); - if( eClass == css::uno::TypeClass_DOUBLE ) - { - fResult = * static_cast< const double * >( rAny.getValue() ); - } - + rAny >>= fResult; return fResult; } }; @@ -74,10 +69,8 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public ::std::unary_function< css: { OUString operator() ( const css::uno::Any & rAny ) { - css::uno::TypeClass eClass( rAny.getValueType().getTypeClass() ); - if( eClass == css::uno::TypeClass_DOUBLE ) + if( auto pDouble = o3tl::tryAccess<double>(rAny) ) { - const double* pDouble = static_cast< const double * >( rAny.getValue() ); if( ::rtl::math::isNan(*pDouble) ) return OUString(); return ::rtl::math::doubleToUString( @@ -88,9 +81,9 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public ::std::unary_function< css: true // remove trailing zeros ); } - else if( eClass == css::uno::TypeClass_STRING ) + else if( auto s = o3tl::tryAccess<OUString>(rAny) ) { - return * static_cast< const OUString * >( rAny.getValue() ); + return *s; } return OUString(); |