[Libreoffice-commits] core.git: pyuno/source
Arkadiy Illarionov (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 18 12:42:02 UTC 2019
pyuno/source/module/pyuno.cxx | 13 +++++--------
pyuno/source/module/pyuno_adapter.cxx | 2 +-
pyuno/source/module/pyuno_impl.hxx | 2 +-
pyuno/source/module/pyuno_runtime.cxx | 7 ++-----
4 files changed, 9 insertions(+), 15 deletions(-)
New commits:
commit 8e53efa926bc05d73c48579f63c3d662a96bd35e
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Wed Sep 18 00:18:33 2019 +0300
Commit: Arkadiy Illarionov <qarkai at gmail.com>
CommitDate: Wed Sep 18 14:40:48 2019 +0200
tdf#39593 use getUnoTunnelImplementation in pyuno
Change-Id: I2cbbaad921b0a3d2ea6def4da2a2527dc4d94549
Reviewed-on: https://gerrit.libreoffice.org/79075
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai at gmail.com>
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() );
More information about the Libreoffice-commits
mailing list