Clean up uses of Any::getValue() in chart2
Change-Id: I53224053ea05c715f5e359a4c68e1ae5efbfe792
This commit is contained in:
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user