summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-20 11:43:37 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-20 11:43:37 +0200
commit50a0473e821081c1db2646dd4c3fcc24f5c11bf3 (patch)
tree2d339c30171dcc9271619da46f91acfaa9a684cf
parent4833ed2f7fed76cba5fa40b0490da14c6838e8b6 (diff)
Clean up uses of Any::getValue() in comphelper
Change-Id: I433cca20fb29c6b6ede934edcb2e200f15b060f2
-rw-r--r--comphelper/source/container/container.cxx5
-rw-r--r--comphelper/source/eventattachermgr/eventattachermgr.cxx21
-rw-r--r--comphelper/source/misc/types.cxx5
-rw-r--r--include/comphelper/uno3.hxx8
4 files changed, 21 insertions, 18 deletions
diff --git a/comphelper/source/container/container.cxx b/comphelper/source/container/container.cxx
index df7c75f7e693..00e3b77a40af 100644
--- a/comphelper/source/container/container.cxx
+++ b/comphelper/source/container/container.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <comphelper/container.hxx>
+#include <o3tl/any.hxx>
#include <osl/diagnose.h>
@@ -65,7 +66,7 @@ css::uno::Reference< css::uno::XInterface> IndexAccessIterator::Next()
if (xContainerAccess.is() && xContainerAccess->getCount() && ShouldStepInto(xContainerAccess))
{
css::uno::Any aElement(xContainerAccess->getByIndex(0));
- xSearchLoop = *static_cast<css::uno::Reference< css::uno::XInterface> const *>(aElement.getValue());
+ xSearchLoop = *o3tl::doAccess<css::uno::Reference<css::uno::XInterface>>(aElement);
bCheckingStartingPoint = false;
m_arrChildIndizies.push_back((sal_Int32)0);
@@ -90,7 +91,7 @@ css::uno::Reference< css::uno::XInterface> IndexAccessIterator::Next()
++nOldSearchChildIndex;
// and check the next child
css::uno::Any aElement(xContainerAccess->getByIndex(nOldSearchChildIndex));
- xSearchLoop = *static_cast<css::uno::Reference< css::uno::XInterface> const *>(aElement.getValue());
+ xSearchLoop = *o3tl::doAccess<css::uno::Reference<css::uno::XInterface>>(aElement);
bCheckingStartingPoint = false;
// and update its position in the list.
m_arrChildIndizies.push_back((sal_Int32)nOldSearchChildIndex);
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index e4f0698509ce..cf3232b99eb1 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/any.hxx>
#include <osl/mutex.hxx>
#include <osl/diagnose.h>
#include <comphelper/eventattachermgr.hxx>
@@ -284,24 +287,24 @@ Any SAL_CALL AttacherAllListener_Impl::approveFiring( const AllEventObject& Even
case TypeClass_BOOLEAN:
// FALSE -> Return
- if( !(*static_cast<sal_Bool const *>(aRet.getValue())) )
+ if( !(*o3tl::forceAccess<bool>(aRet)) )
return aRet;
break;
case TypeClass_STRING:
// none empty string -> return
- if( !(static_cast<OUString const *>(aRet.getValue()))->isEmpty() )
+ if( !o3tl::forceAccess<OUString>(aRet)->isEmpty() )
return aRet;
break;
// none zero number -> return
- case TypeClass_FLOAT: if( *static_cast<float const *>(aRet.getValue()) ) return aRet; break;
- case TypeClass_DOUBLE: if( *static_cast<double const *>(aRet.getValue()) ) return aRet; break;
- case TypeClass_BYTE: if( *static_cast<sal_uInt8 const *>(aRet.getValue()) ) return aRet; break;
- case TypeClass_SHORT: if( *static_cast<sal_Int16 const *>(aRet.getValue()) ) return aRet; break;
- case TypeClass_LONG: if( *static_cast<sal_Int32 const *>(aRet.getValue()) ) return aRet; break;
- case TypeClass_UNSIGNED_SHORT: if( *static_cast<sal_uInt16 const *>(aRet.getValue()) ) return aRet; break;
- case TypeClass_UNSIGNED_LONG: if( *static_cast<sal_uInt32 const *>(aRet.getValue()) ) return aRet; break;
+ case TypeClass_FLOAT: if( *o3tl::forceAccess<float>(aRet) ) return aRet; break;
+ case TypeClass_DOUBLE: if( *o3tl::forceAccess<double>(aRet) ) return aRet; break;
+ case TypeClass_BYTE: if( *o3tl::forceAccess<sal_Int8>(aRet) ) return aRet; break;
+ case TypeClass_SHORT: if( *o3tl::forceAccess<sal_Int16>(aRet) ) return aRet; break;
+ case TypeClass_LONG: if( *o3tl::forceAccess<sal_Int32>(aRet) ) return aRet; break;
+ case TypeClass_UNSIGNED_SHORT: if( *o3tl::forceAccess<sal_uInt16>(aRet) ) return aRet; break;
+ case TypeClass_UNSIGNED_LONG: if( *o3tl::forceAccess<sal_uInt32>(aRet) ) return aRet; break;
default:
OSL_ASSERT(false);
diff --git a/comphelper/source/misc/types.cxx b/comphelper/source/misc/types.cxx
index e70e19e1419b..e8ccfedbac18 100644
--- a/comphelper/source/misc/types.cxx
+++ b/comphelper/source/misc/types.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/awt/FontStrikeout.hpp>
#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <o3tl/any.hxx>
#include <osl/diagnose.h>
#include <typelib/typedescription.hxx>
@@ -91,8 +92,8 @@ OUString getString(const Any& _rAny)
bool getBOOL(const Any& _rAny)
{
bool bReturn = false;
- if (_rAny.getValueType() == cppu::UnoType<bool>::get())
- bReturn = *static_cast<sal_Bool const *>(_rAny.getValue());
+ if (auto b = o3tl::tryAccess<bool>(_rAny))
+ bReturn = *b;
else
OSL_FAIL("comphelper::getBOOL : invalid argument !");
return bReturn;
diff --git a/include/comphelper/uno3.hxx b/include/comphelper/uno3.hxx
index 427deb394186..5b4cb63a3542 100644
--- a/include/comphelper/uno3.hxx
+++ b/include/comphelper/uno3.hxx
@@ -169,13 +169,11 @@ namespace comphelper
template <class iface>
bool query_aggregation(const css::uno::Reference< css::uno::XAggregation >& _rxAggregate, css::uno::Reference<iface>& _rxOut)
{
- _rxOut = static_cast<iface*>(nullptr);
+ _rxOut.clear();
if (_rxAggregate.is())
{
- css::uno::Any aCheck = _rxAggregate->queryAggregation(
- cppu::UnoType<iface>::get());
- if (aCheck.hasValue())
- _rxOut = *static_cast<const css::uno::Reference<iface>*>(aCheck.getValue());
+ _rxAggregate->queryAggregation(cppu::UnoType<iface>::get())
+ >>= _rxOut;
}
return _rxOut.is();
}