summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-10 18:54:57 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-10 18:54:57 +0200
commitc97c898f65196292e7084bcad696c666adb9149f (patch)
treedf8624d61118aab1ffcd9c59a076ac31556f9b96 /sc
parenta7ce813f4898d99084f2b2929823acc9a2747ad4 (diff)
Clean up uses of Any::getValue() in sc
Change-Id: Ic272f616533021ee2148adaf28eed68301aa4602
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/dptabsrc.cxx6
-rw-r--r--sc/source/ui/unoobj/docuno.cxx15
-rw-r--r--sc/source/ui/unoobj/miscuno.cxx15
-rw-r--r--sc/source/ui/vba/vbarange.cxx3
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx2
5 files changed, 17 insertions, 24 deletions
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index eb6052cfb003..498c11c3434c 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -24,6 +24,7 @@
#include <unordered_set>
#include <vector>
+#include <o3tl/any.hxx>
#include <rtl/math.hxx>
#include <svl/itemprop.hxx>
#include <svl/intitem.hxx>
@@ -85,9 +86,8 @@ SC_SIMPLE_SERVICE_INFO( ScDPMember, "ScDPMember", "com.sun.star.sheet.
//TODO: move to a header?
static bool lcl_GetBoolFromAny( const uno::Any& aAny )
{
- if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN )
- return *static_cast<sal_Bool const *>(aAny.getValue());
- return false;
+ auto b = o3tl::tryAccess<bool>(aAny);
+ return b && *b;
}
ScDPSource::ScDPSource( ScDPTableData* pD ) :
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 1d9d4624a697..912a4fde0a85 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -22,6 +22,7 @@
#include "scitems.hxx"
#include <editeng/editview.hxx>
#include <editeng/outliner.hxx>
+#include <o3tl/any.hxx>
#include <svx/fmdpage.hxx>
#include <svx/fmview.hxx>
#include <svx/svditer.hxx>
@@ -1035,11 +1036,10 @@ uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeExcep
{
const uno::Type& rProvType = cppu::UnoType<lang::XTypeProvider>::get();
uno::Any aNumProv(xNumberAgg->queryAggregation(rProvType));
- if(aNumProv.getValueType() == rProvType)
+ if(auto xNumProv
+ = o3tl::tryAccess<uno::Reference<lang::XTypeProvider>>(aNumProv))
{
- uno::Reference<lang::XTypeProvider> xNumProv(
- *static_cast<uno::Reference<lang::XTypeProvider> const *>(aNumProv.getValue()));
- aAggTypes = xNumProv->getTypes();
+ aAggTypes = (*xNumProv)->getTypes();
}
}
long nAggLen = aAggTypes.getLength();
@@ -2626,11 +2626,10 @@ sal_Int64 SAL_CALL ScModelObj::getSomething(
{
const uno::Type& rTunnelType = cppu::UnoType<lang::XUnoTunnel>::get();
uno::Any aNumTunnel(xNumberAgg->queryAggregation(rTunnelType));
- if(aNumTunnel.getValueType() == rTunnelType)
+ if(auto xTunnelAgg = o3tl::tryAccess<uno::Reference<lang::XUnoTunnel>>(
+ aNumTunnel))
{
- uno::Reference<lang::XUnoTunnel> xTunnelAgg(
- *static_cast<uno::Reference<lang::XUnoTunnel> const *>(aNumTunnel.getValue()));
- return xTunnelAgg->getSomething( rId );
+ return (*xTunnelAgg)->getSomething( rId );
}
}
diff --git a/sc/source/ui/unoobj/miscuno.cxx b/sc/source/ui/unoobj/miscuno.cxx
index a6256fcf54fb..fb870d5cdc8f 100644
--- a/sc/source/ui/unoobj/miscuno.cxx
+++ b/sc/source/ui/unoobj/miscuno.cxx
@@ -18,6 +18,7 @@
*/
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/any.hxx>
#include <vcl/svapp.hxx>
#include "miscuno.hxx"
@@ -45,14 +46,7 @@ bool ScUnoHelpFunctions::GetBoolProperty( const uno::Reference<beans::XPropertyS
{
try
{
- uno::Any aAny(xProp->getPropertyValue( rName ));
- //! type conversion???
- // operator >>= shouldn't be used for bool (?)
- if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN )
- {
- //! safe way to get bool value from any???
- bRet = *static_cast<sal_Bool const *>(aAny.getValue());
- }
+ xProp->getPropertyValue( rName ) >>= bRet;
}
catch(uno::Exception&)
{
@@ -131,9 +125,8 @@ OUString ScUnoHelpFunctions::GetStringProperty(
bool ScUnoHelpFunctions::GetBoolFromAny( const uno::Any& aAny )
{
- if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN )
- return *static_cast<sal_Bool const *>(aAny.getValue());
- return false;
+ auto b = o3tl::tryAccess<bool>(aAny);
+ return b && *b;
}
sal_Int16 ScUnoHelpFunctions::GetInt16FromAny( const uno::Any& aAny )
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index c7ad99222ee2..40921ee5c382 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -23,6 +23,7 @@
#include <comphelper/unwrapargs.hxx>
#include <comphelper/processfactory.hxx>
+#include <o3tl/any.hxx>
#include <sfx2/objsh.hxx>
#include <com/sun/star/script/ArrayWrapper.hpp>
@@ -950,7 +951,7 @@ protected:
ValueGetter& mValueGetter;
void processValue( sal_Int32 x, sal_Int32 y, const uno::Any& aValue )
{
- uno::Sequence< uno::Sequence< uno::Any > >& aMatrix = *const_cast<css::uno::Sequence<css::uno::Sequence<css::uno::Any>> *>(static_cast<uno::Sequence< uno::Sequence< uno::Any > > const *>(maValue.getValue()));
+ uno::Sequence< uno::Sequence< uno::Any > >& aMatrix = const_cast<css::uno::Sequence<css::uno::Sequence<css::uno::Any>> &>(*o3tl::doAccess<uno::Sequence<uno::Sequence<uno::Any>>>(maValue));
aMatrix[x][y] = aValue;
}
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index ba6c992c6fcf..6b97d3b7bb90 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -82,7 +82,7 @@ ScVbaWorkbook::ResetColors( ) throw (::script::BasicErrorException, ::uno::Runt
ScVbaWorkbook::Colors( const ::uno::Any& Index ) throw (::script::BasicErrorException, ::uno::RuntimeException, std::exception)
{
uno::Any aRet;
- if ( Index.getValue() )
+ if ( Index.hasValue() )
{
sal_Int32 nIndex = 0;
Index >>= nIndex;