summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-09-13 11:29:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-09-15 06:08:27 +0200
commit96bd77de5ad7b7a13f7e48e0f95c05ef49255aa0 (patch)
tree4c79c57712124a8589c9e6579b6ec7fec9200c3b /filter
parent3f65724ec5fc92d5a0078a99932358ef7091435c (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 'filter')
-rw-r--r--filter/source/msfilter/msvbahelper.cxx7
1 files changed, 3 insertions, 4 deletions
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index 254d31e0550a..4eec9e4e696e 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <tools/urlobj.hxx>
#include <osl/file.hxx>
@@ -538,8 +539,7 @@ void SAL_CALL VBAMacroResolver::initialize( const uno::Sequence< uno::Any >& rAr
// first argument: document model
mxModel.set( rArgs[ 0 ], uno::UNO_QUERY_THROW );
- uno::Reference< lang::XUnoTunnel > xUnoTunnel( mxModel, uno::UNO_QUERY_THROW );
- mpObjShell = reinterpret_cast< SfxObjectShell* >( xUnoTunnel->getSomething( SfxObjectShell::getUnoTunnelId() ) );
+ mpObjShell = comphelper::getFromUnoTunnel<SfxObjectShell>(mxModel);
if( !mpObjShell )
throw uno::RuntimeException();
@@ -734,8 +734,7 @@ void applyShortCutKeyBinding ( const uno::Reference< frame::XModel >& rxModel, c
SfxObjectShell* pShell = nullptr;
if ( rxModel.is() )
{
- uno::Reference< lang::XUnoTunnel > xObjShellTunnel( rxModel, uno::UNO_QUERY_THROW );
- pShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId()));
+ pShell = comphelper::getFromUnoTunnel<SfxObjectShell>(rxModel);
if ( !pShell )
throw uno::RuntimeException();
}