summaryrefslogtreecommitdiffstats
path: root/chart2
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-17 08:45:28 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-17 08:45:28 +0200
commitf35b1397ae3e7e975ea1c423df5c7a8ee711d335 (patch)
tree19e56e5698718acc0622225c146ca27dce29d5ea /chart2
parentconvert DBG_ASSERT in xmloff (diff)
downloadcore-f35b1397ae3e7e975ea1c423df5c7a8ee711d335.tar.gz
core-f35b1397ae3e7e975ea1c423df5c7a8ee711d335.zip
Clean up uses of Any::getValue() in chart2
Change-Id: I53224053ea05c715f5e359a4c68e1ae5efbfe792
Diffstat (limited to 'chart2')
-rw-r--r--chart2/CppunitTest_chart2_common_functors.mk4
-rw-r--r--chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx6
-rw-r--r--chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx7
-rw-r--r--chart2/source/inc/CommonFunctors.hxx17
4 files changed, 15 insertions, 19 deletions
diff --git a/chart2/CppunitTest_chart2_common_functors.mk b/chart2/CppunitTest_chart2_common_functors.mk
index 203de1d17b64..55a64b257643 100644
--- a/chart2/CppunitTest_chart2_common_functors.mk
+++ b/chart2/CppunitTest_chart2_common_functors.mk
@@ -19,6 +19,10 @@ $(eval $(call gb_CppunitTest_add_defs,chart2_common_functors,\
-DOOO_DLLIMPLEMENTATION_CHARTTOOLS \
))
+$(eval $(call gb_CppunitTest_use_externals,chart2_common_functors, \
+ boost_headers \
+))
+
$(eval $(call gb_CppunitTest_use_libraries,chart2_common_functors, \
cppu \
cppuhelper \
diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
index 8c99140704b8..2ad5d630d917 100644
--- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
@@ -39,6 +39,7 @@
#include <com/sun/star/chart2/AxisOrientation.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
+#include <o3tl/any.hxx>
#include <svl/eitem.hxx>
#include <svx/chrtitem.hxx>
#include <svl/intitem.hxx>
@@ -286,10 +287,9 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI
{
if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue())
{
- OSL_ASSERT( rSubIncrements[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG );
rOutItemSet.Put( SfxInt32Item( nWhichId,
- *static_cast< const sal_Int32 * >(
- rSubIncrements[0].IntervalCount.getValue()) ));
+ *o3tl::doAccess<sal_Int32>(
+ rSubIncrements[0].IntervalCount) ));
}
else
{
diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx
index aa44d3aa17ec..ed16e0a501fa 100644
--- a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx
@@ -30,6 +30,7 @@
#include <editeng/postitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/fhgtitem.hxx>
+#include <o3tl/any.hxx>
#include <svl/stritem.hxx>
#include <com/sun/star/beans/XPropertyState.hpp>
@@ -150,8 +151,7 @@ void CharacterPropertyItemConverter::FillSpecialItem(
}
aValue = GetPropertySet()->getPropertyValue( "CharUnderlineHasColor" );
- if( aValue.hasValue() &&
- *static_cast< const sal_Bool * >( aValue.getValue()) )
+ if( aValue.hasValue() && *o3tl::doAccess<bool>(aValue) )
{
aItem.PutValue( aValue, MID_TL_HASCOLOR );
bModified = true;
@@ -182,8 +182,7 @@ void CharacterPropertyItemConverter::FillSpecialItem(
}
aValue = GetPropertySet()->getPropertyValue( "CharOverlineHasColor" );
- if ( aValue.hasValue() &&
- *static_cast< const sal_Bool* >( aValue.getValue() ) )
+ if ( aValue.hasValue() && *o3tl::doAccess<bool>(aValue) )
{
aItem.PutValue( aValue, MID_TL_HASCOLOR );
bModified = true;
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();