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:27 +0200 |
commit | 96bd77de5ad7b7a13f7e48e0f95c05ef49255aa0 (patch) | |
tree | 4c79c57712124a8589c9e6579b6ec7fec9200c3b /vbahelper/source | |
parent | 3f65724ec5fc92d5a0078a99932358ef7091435c (diff) |
Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 5
- Revise uses of getSomething to use getFromUnoTunnel
Where that is impossible, use getSomething_cast to unify casting,
and minimize number of places doing low-level transformations.
The change keeps the existing tunnel references that last for the
duration of the pointers' life, because sometimes destroying such
reference may destroy the pointed object, and result in use after
free.
Change-Id: I291c33223582c34cd2c763aa8aacf0ae899ca4c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122101
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vbahelper/source')
-rw-r--r-- | vbahelper/source/vbahelper/vbahelper.cxx | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 28591b233092..389a13352e6a 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -43,6 +43,7 @@ #include <comphelper/automationinvokedzone.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> #include <sfx2/objsh.hxx> #include <sfx2/viewfrm.hxx> @@ -1100,12 +1101,7 @@ uno::Reference< XHelperInterface > getUnoDocModule( std::u16string_view aModName SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) { - SfxObjectShell* pFoundShell = nullptr; - if ( xModel.is() ) - { - uno::Reference< lang::XUnoTunnel > xObjShellTunnel( xModel, uno::UNO_QUERY_THROW ); - pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); - } + SfxObjectShell* pFoundShell = comphelper::getFromUnoTunnel<SfxObjectShell>(xModel); if ( !pFoundShell ) throw uno::RuntimeException(); return pFoundShell; |