[Libreoffice-commits] core.git: chart2/CppunitTest_chart2_common_functors.mk chart2/source
Stephan Bergmann
sbergman at redhat.com
Fri Jun 17 06:46:02 UTC 2016
chart2/CppunitTest_chart2_common_functors.mk | 4 ++
chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx | 6 +--
chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx | 7 +---
chart2/source/inc/CommonFunctors.hxx | 17 ++--------
4 files changed, 15 insertions(+), 19 deletions(-)
New commits:
commit f35b1397ae3e7e975ea1c423df5c7a8ee711d335
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jun 17 08:45:28 2016 +0200
Clean up uses of Any::getValue() in chart2
Change-Id: I53224053ea05c715f5e359a4c68e1ae5efbfe792
diff --git a/chart2/CppunitTest_chart2_common_functors.mk b/chart2/CppunitTest_chart2_common_functors.mk
index 203de1d..55a64b2 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 8c99140..2ad5d63 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 aa44d3a..ed16e0a 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 f912f50..bbdc27a 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();
More information about the Libreoffice-commits
mailing list