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 /editeng | |
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 'editeng')
-rw-r--r-- | editeng/source/items/xmlcnitm.cxx | 9 | ||||
-rw-r--r-- | editeng/source/uno/unotext.cxx | 4 |
2 files changed, 4 insertions, 9 deletions
diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx index 1e88121ee576..7bcfe11f9a55 100644 --- a/editeng/source/items/xmlcnitm.cxx +++ b/editeng/source/items/xmlcnitm.cxx @@ -18,6 +18,8 @@ */ #include <memory> + +#include <comphelper/servicehelper.hxx> #include <com/sun/star/xml/AttributeData.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <o3tl/any.hxx> @@ -75,13 +77,8 @@ bool SvXMLAttrContainerItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMembe bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) { - SvUnoAttributeContainer* pContainer = nullptr; - Reference<XUnoTunnel> xTunnel(rVal, UNO_QUERY); - if( xTunnel.is() ) - pContainer = reinterpret_cast<SvUnoAttributeContainer*>(static_cast<sal_uLong>(xTunnel->getSomething(SvUnoAttributeContainer::getUnoTunnelId()))); - - if( pContainer ) + if (auto pContainer = comphelper::getFromUnoTunnel<SvUnoAttributeContainer>(xTunnel)) { maContainerData = *pContainer->GetContainerImpl(); } diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 3ad90c4709c3..92620d1951d3 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -2093,10 +2093,8 @@ void SvxUnoTextBase::copyText( SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr; if( !pTextForwarder ) return; - if( xUT.is() ) + if (auto pSource = comphelper::getFromUnoTunnel<SvxUnoTextBase>(xUT)) { - SvxUnoTextBase* pSource = reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>( - xUT->getSomething( SvxUnoTextBase::getUnoTunnelId()))); SvxEditSource *pSourceEditSource = pSource->GetEditSource(); SvxTextForwarder *pSourceTextForwarder = pSourceEditSource ? pSourceEditSource->GetTextForwarder() : nullptr; if( pSourceTextForwarder ) |