Kaydet (Commit) f35b1397 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up uses of Any::getValue() in chart2

Change-Id: I53224053ea05c715f5e359a4c68e1ae5efbfe792
üst e6c004dd
...@@ -19,6 +19,10 @@ $(eval $(call gb_CppunitTest_add_defs,chart2_common_functors,\ ...@@ -19,6 +19,10 @@ $(eval $(call gb_CppunitTest_add_defs,chart2_common_functors,\
-DOOO_DLLIMPLEMENTATION_CHARTTOOLS \ -DOOO_DLLIMPLEMENTATION_CHARTTOOLS \
)) ))
$(eval $(call gb_CppunitTest_use_externals,chart2_common_functors, \
boost_headers \
))
$(eval $(call gb_CppunitTest_use_libraries,chart2_common_functors, \ $(eval $(call gb_CppunitTest_use_libraries,chart2_common_functors, \
cppu \ cppu \
cppuhelper \ cppuhelper \
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <com/sun/star/chart2/AxisOrientation.hpp> #include <com/sun/star/chart2/AxisOrientation.hpp>
#include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/AxisType.hpp>
#include <o3tl/any.hxx>
#include <svl/eitem.hxx> #include <svl/eitem.hxx>
#include <svx/chrtitem.hxx> #include <svx/chrtitem.hxx>
#include <svl/intitem.hxx> #include <svl/intitem.hxx>
...@@ -286,10 +287,9 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI ...@@ -286,10 +287,9 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI
{ {
if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue()) if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue())
{ {
OSL_ASSERT( rSubIncrements[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG );
rOutItemSet.Put( SfxInt32Item( nWhichId, rOutItemSet.Put( SfxInt32Item( nWhichId,
*static_cast< const sal_Int32 * >( *o3tl::doAccess<sal_Int32>(
rSubIncrements[0].IntervalCount.getValue()) )); rSubIncrements[0].IntervalCount) ));
} }
else else
{ {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <editeng/postitem.hxx> #include <editeng/postitem.hxx>
#include <editeng/wghtitem.hxx> #include <editeng/wghtitem.hxx>
#include <editeng/fhgtitem.hxx> #include <editeng/fhgtitem.hxx>
#include <o3tl/any.hxx>
#include <svl/stritem.hxx> #include <svl/stritem.hxx>
#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertyState.hpp>
...@@ -150,8 +151,7 @@ void CharacterPropertyItemConverter::FillSpecialItem( ...@@ -150,8 +151,7 @@ void CharacterPropertyItemConverter::FillSpecialItem(
} }
aValue = GetPropertySet()->getPropertyValue( "CharUnderlineHasColor" ); aValue = GetPropertySet()->getPropertyValue( "CharUnderlineHasColor" );
if( aValue.hasValue() && if( aValue.hasValue() && *o3tl::doAccess<bool>(aValue) )
*static_cast< const sal_Bool * >( aValue.getValue()) )
{ {
aItem.PutValue( aValue, MID_TL_HASCOLOR ); aItem.PutValue( aValue, MID_TL_HASCOLOR );
bModified = true; bModified = true;
...@@ -182,8 +182,7 @@ void CharacterPropertyItemConverter::FillSpecialItem( ...@@ -182,8 +182,7 @@ void CharacterPropertyItemConverter::FillSpecialItem(
} }
aValue = GetPropertySet()->getPropertyValue( "CharOverlineHasColor" ); aValue = GetPropertySet()->getPropertyValue( "CharOverlineHasColor" );
if ( aValue.hasValue() && if ( aValue.hasValue() && *o3tl::doAccess<bool>(aValue) )
*static_cast< const sal_Bool* >( aValue.getValue() ) )
{ {
aItem.PutValue( aValue, MID_TL_HASCOLOR ); aItem.PutValue( aValue, MID_TL_HASCOLOR );
bModified = true; bModified = true;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <o3tl/any.hxx>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Any.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
...@@ -56,13 +57,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble : public ::std::unary_function< css: ...@@ -56,13 +57,7 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble : public ::std::unary_function< css:
{ {
double fResult; double fResult;
::rtl::math::setNan( & fResult ); ::rtl::math::setNan( & fResult );
rAny >>= fResult;
css::uno::TypeClass eClass( rAny.getValueType().getTypeClass() );
if( eClass == css::uno::TypeClass_DOUBLE )
{
fResult = * static_cast< const double * >( rAny.getValue() );
}
return fResult; return fResult;
} }
}; };
...@@ -74,10 +69,8 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public ::std::unary_function< css: ...@@ -74,10 +69,8 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public ::std::unary_function< css:
{ {
OUString operator() ( const css::uno::Any & rAny ) OUString operator() ( const css::uno::Any & rAny )
{ {
css::uno::TypeClass eClass( rAny.getValueType().getTypeClass() ); if( auto pDouble = o3tl::tryAccess<double>(rAny) )
if( eClass == css::uno::TypeClass_DOUBLE )
{ {
const double* pDouble = static_cast< const double * >( rAny.getValue() );
if( ::rtl::math::isNan(*pDouble) ) if( ::rtl::math::isNan(*pDouble) )
return OUString(); return OUString();
return ::rtl::math::doubleToUString( return ::rtl::math::doubleToUString(
...@@ -88,9 +81,9 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public ::std::unary_function< css: ...@@ -88,9 +81,9 @@ struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString : public ::std::unary_function< css:
true // remove trailing zeros 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(); return OUString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment