summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-09-18 00:18:33 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-09-18 14:40:48 +0200
commit8e53efa926bc05d73c48579f63c3d662a96bd35e (patch)
tree1390a88298fe70cc0e9c3b16a97e5476f07b73d4 /pyuno
parenteef2795aa105ae52607cc158504c455da87dfd2a (diff)
tdf#39593 use getUnoTunnelImplementation in pyuno
Change-Id: I2cbbaad921b0a3d2ea6def4da2a2527dc4d94549 Reviewed-on: https://gerrit.libreoffice.org/79075 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/module/pyuno.cxx13
-rw-r--r--pyuno/source/module/pyuno_adapter.cxx2
-rw-r--r--pyuno/source/module/pyuno_impl.hxx2
-rw-r--r--pyuno/source/module/pyuno_runtime.cxx7
4 files changed, 9 insertions, 15 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index a4d0ddc4e314..d9c9dacbb3fd 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/script/XInvocation2.hpp>
#include <com/sun/star/script/XTypeConverter.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <comphelper/servicehelper.hxx>
#include "pyuno_impl.hxx"
@@ -1711,14 +1712,10 @@ PyRef PyUNO_new (
xInvocation.set(
ssf->createInstanceWithArguments( Sequence<Any>( &targetInterface, 1 ) ), css::uno::UNO_QUERY_THROW );
- Reference<XUnoTunnel> xUnoTunnel (
- xInvocation->getIntrospection()->queryAdapter(cppu::UnoType<XUnoTunnel>::get()), UNO_QUERY );
- if( xUnoTunnel.is() )
- {
- sal_Int64 that = xUnoTunnel->getSomething( ::pyuno::Adapter::getUnoTunnelImplementationId() );
- if( that )
- return reinterpret_cast<Adapter*>(that)->getWrappedObject();
- }
+ auto that = comphelper::getUnoTunnelImplementation<Adapter>(
+ xInvocation->getIntrospection()->queryAdapter(cppu::UnoType<XUnoTunnel>::get()));
+ if( that )
+ return that->getWrappedObject();
}
if( !Py_IsInitialized() )
throw RuntimeException();
diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx
index 1c392989d744..a8efd4153831 100644
--- a/pyuno/source/module/pyuno_adapter.cxx
+++ b/pyuno/source/module/pyuno_adapter.cxx
@@ -68,7 +68,7 @@ Adapter::~Adapter()
static cppu::OImplementationId g_id( false );
-Sequence<sal_Int8> Adapter::getUnoTunnelImplementationId()
+Sequence<sal_Int8> Adapter::getUnoTunnelId()
{
return g_id.getImplementationId();
}
diff --git a/pyuno/source/module/pyuno_impl.hxx b/pyuno/source/module/pyuno_impl.hxx
index 000f2660469d..91c24b4e7a88 100644
--- a/pyuno/source/module/pyuno_impl.hxx
+++ b/pyuno/source/module/pyuno_impl.hxx
@@ -347,7 +347,7 @@ public:
Adapter( const PyRef &obj,
const css::uno::Sequence< css::uno::Type > & types );
- static css::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+ static css::uno::Sequence< sal_Int8 > getUnoTunnelId();
const PyRef& getWrappedObject() const { return mWrappedObject; }
const css::uno::Sequence< css::uno::Type >& getWrappedTypes() const { return mTypes; }
virtual ~Adapter() override;
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index d307f9af363c..62b3861288c3 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <comphelper/sequence.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <vector>
@@ -832,11 +833,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con
if( adapterObject.is() )
{
// object got already bridged !
- Reference< css::lang::XUnoTunnel > tunnel( adapterObject, UNO_QUERY );
-
- Adapter *pAdapter = reinterpret_cast<Adapter*>(
- tunnel->getSomething(
- ::pyuno::Adapter::getUnoTunnelImplementationId() ) );
+ auto pAdapter = comphelper::getUnoTunnelImplementation<Adapter>(adapterObject);
mappedObject = impl->cargo->xAdapterFactory->createAdapter(
adapterObject, pAdapter->getWrappedTypes() );