diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-13 11:29:37 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-15 06:08:14 +0200 |
commit | 3f65724ec5fc92d5a0078a99932358ef7091435c (patch) | |
tree | 94dd9bf1d0ecd42dbf7f94db45bc7e1bf29b83ce /framework | |
parent | 6444b026b4039458d01ada5fee58eae98166585b (diff) |
Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 4
- Change implementations of getSomething to use getSomethingImpl
Or where that's impossible, use getSomething_cast to unify this and
reduce number of places where we reinterpret_cast.
All static methods getting tunnel ids were renamed to getUnoTunnelId,
to comply with the convention used in <comphelper/servicehelper.hxx>.
TODO (in separate commits):
- Revise uses of getSomething to use getFromUnoTunnel
Change-Id: Ifde9e214b52e5df678de71fcc32d2199c82e85cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122100
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'framework')
7 files changed, 11 insertions, 23 deletions
diff --git a/framework/inc/classes/imagewrapper.hxx b/framework/inc/classes/imagewrapper.hxx index 54b2ee404fcc..eea43c4e0394 100644 --- a/framework/inc/classes/imagewrapper.hxx +++ b/framework/inc/classes/imagewrapper.hxx @@ -39,7 +39,7 @@ class ImageWrapper final : public ::cppu::WeakImplHelper< css::awt::XBitmap, return m_aImage; } - static css::uno::Sequence< sal_Int8 > const & GetUnoTunnelId(); + static css::uno::Sequence<sal_Int8> const& getUnoTunnelId(); // XBitmap virtual css::awt::Size SAL_CALL getSize() override; diff --git a/framework/inc/classes/rootactiontriggercontainer.hxx b/framework/inc/classes/rootactiontriggercontainer.hxx index 601d7c6bcc09..151a7c7338d4 100644 --- a/framework/inc/classes/rootactiontriggercontainer.hxx +++ b/framework/inc/classes/rootactiontriggercontainer.hxx @@ -78,6 +78,7 @@ class RootActionTriggerContainer final : public PropertySetContainer, // XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() noexcept; // XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; diff --git a/framework/source/fwe/classes/imagewrapper.cxx b/framework/source/fwe/classes/imagewrapper.cxx index b95bbbc34e01..978ef77a474f 100644 --- a/framework/source/fwe/classes/imagewrapper.cxx +++ b/framework/source/fwe/classes/imagewrapper.cxx @@ -18,6 +18,7 @@ */ #include <classes/imagewrapper.hxx> +#include <comphelper/servicehelper.hxx> #include <vcl/svapp.hxx> #include <vcl/bitmapex.hxx> #include <vcl/BitmapTools.hxx> @@ -45,10 +46,7 @@ ImageWrapper::~ImageWrapper() { } -Sequence< sal_Int8 > const & ImageWrapper::GetUnoTunnelId() -{ - return impl_getStaticIdentifier(); -} +Sequence<sal_Int8> const& ImageWrapper::getUnoTunnelId() { return impl_getStaticIdentifier(); } // XBitmap css::awt::Size SAL_CALL ImageWrapper::getSize() @@ -80,10 +78,7 @@ Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() // XUnoTunnel sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) { - if ( aIdentifier == impl_getStaticIdentifier() ) - return reinterpret_cast< sal_Int64 >( this ); - else - return 0; + return comphelper::getSomethingImpl(aIdentifier, this); } } diff --git a/framework/source/fwe/classes/rootactiontriggercontainer.cxx b/framework/source/fwe/classes/rootactiontriggercontainer.cxx index 0732959d1a80..f49cf9c70c5e 100644 --- a/framework/source/fwe/classes/rootactiontriggercontainer.cxx +++ b/framework/source/fwe/classes/rootactiontriggercontainer.cxx @@ -21,6 +21,7 @@ #include <classes/actiontriggercontainer.hxx> #include <classes/actiontriggerpropertyset.hxx> #include <classes/actiontriggerseparatorpropertyset.hxx> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> @@ -36,7 +37,7 @@ using namespace com::sun::star::beans; namespace framework { -static Sequence< sal_Int8 > const & impl_getStaticIdentifier() +const css::uno::Sequence<sal_Int8>& RootActionTriggerContainer::getUnoTunnelId() noexcept { static const sal_uInt8 pGUID[16] = { 0x17, 0x0F, 0xA2, 0xC9, 0xCA, 0x50, 0x4A, 0xD3, 0xA6, 0x3B, 0x39, 0x99, 0xC5, 0x96, 0x43, 0x27 }; static css::uno::Sequence< sal_Int8 > seqID(reinterpret_cast<const sal_Int8*>(pGUID), 16); @@ -211,10 +212,7 @@ Sequence< OUString > SAL_CALL RootActionTriggerContainer::getSupportedServiceNam // XUnoTunnel sal_Int64 SAL_CALL RootActionTriggerContainer::getSomething( const Sequence< sal_Int8 >& aIdentifier ) { - if ( aIdentifier == impl_getStaticIdentifier() ) - return reinterpret_cast< sal_Int64 >( this ); - else - return 0; + return comphelper::getSomethingImpl(aIdentifier, this); } // XTypeProvider diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx index ac9f9c41a3ff..9cff941e23c3 100644 --- a/framework/source/fwe/helper/actiontriggerhelper.cxx +++ b/framework/source/fwe/helper/actiontriggerhelper.cxx @@ -155,7 +155,7 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer if ( xUnoTunnel.is() ) { // Try to get implementation pointer through XUnoTunnel - sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::GetUnoTunnelId() ); + sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::getUnoTunnelId() ); if ( nPointer ) { // This is our own optimized implementation of menu images! diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx index 8c39d7ee763d..ef76a51e5cc0 100644 --- a/framework/source/fwi/uielement/constitemcontainer.cxx +++ b/framework/source/fwi/uielement/constitemcontainer.cxx @@ -162,11 +162,7 @@ Reference< XIndexAccess > ConstItemContainer::deepCopyContainer( const Reference // XUnoTunnel sal_Int64 ConstItemContainer::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) { - if( comphelper::isUnoTunnelId<ConstItemContainer>(rIdentifier) ) - { - return reinterpret_cast< sal_Int64 >( this ); - } - return 0; + return comphelper::getSomethingImpl(rIdentifier, this); } const Sequence< sal_Int8 >& ConstItemContainer::getUnoTunnelId() noexcept diff --git a/framework/source/fwi/uielement/rootitemcontainer.cxx b/framework/source/fwi/uielement/rootitemcontainer.cxx index 2dacda65fe3b..480c5b23d7b9 100644 --- a/framework/source/fwi/uielement/rootitemcontainer.cxx +++ b/framework/source/fwi/uielement/rootitemcontainer.cxx @@ -141,9 +141,7 @@ Reference< XIndexAccess > RootItemContainer::deepCopyContainer( const Reference< // XUnoTunnel sal_Int64 RootItemContainer::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) { - if( comphelper::isUnoTunnelId<RootItemContainer>(rIdentifier) ) - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); - return 0; + return comphelper::getSomethingImpl(rIdentifier, this); } const Sequence< sal_Int8 >& RootItemContainer::getUnoTunnelId() noexcept |