diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-17 16:44:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-19 06:37:52 +0000 |
commit | 7c55f9e327ddcede8ebb8235c97a83436a87b5be (patch) | |
tree | df3d7c7d09028df792d2e55a2cabf5273878abbc | |
parent | cf734427550f1a42f8ac669378719a1cad617bbb (diff) |
XUnoTunnel->dynamic_cast in OTextCursorHelper
Change-Id: I9b0101b4f0b96c59ddbde01c7cf7f286aac2a8e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145703
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
28 files changed, 71 insertions, 216 deletions
diff --git a/sw/inc/TextCursorHelper.hxx b/sw/inc/TextCursorHelper.hxx index f14d68ab2c41..3eff663c3d08 100644 --- a/sw/inc/TextCursorHelper.hxx +++ b/sw/inc/TextCursorHelper.hxx @@ -17,29 +17,22 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #pragma once -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <cppuhelper/implbase1.hxx> class SwDoc; class SwPaM; -class OTextCursorHelper : public ::cppu::ImplHelper1< css::lang::XUnoTunnel> +class SAL_LOPLUGIN_ANNOTATE("crosscast") OTextCursorHelper { public: - OTextCursorHelper(){} - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - virtual const SwPaM* GetPaM() const = 0; virtual SwPaM* GetPaM() = 0; virtual const SwDoc* GetDoc() const = 0; virtual SwDoc* GetDoc() = 0; protected: - ~OTextCursorHelper() {} + ~OTextCursorHelper(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index fb02bfb9f9d1..160d29290d8d 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -199,7 +199,7 @@ class SW_DLLPUBLIC SwXTextTableCursor final public: SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox const* pBox); SwXTextTableCursor(SwFrameFormat& rTableFormat, const SwTableCursor* pTableSelection); - DECLARE_XINTERFACE() + virtual void SAL_CALL release() noexcept override; //XTextTableCursor virtual OUString SAL_CALL getRangeName() override; diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index 0d3ce0e5e60c..b45cc0899540 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -110,14 +110,6 @@ public: virtual const SwDoc* GetDoc() const override; virtual SwDoc* GetDoc() override; - DECLARE_XINTERFACE() - - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( - const css::uno::Sequence< sal_Int8 >& rIdentifier) override; - // XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService( diff --git a/sw/source/core/unocore/TextCursorHelper.cxx b/sw/source/core/unocore/TextCursorHelper.cxx index 7c2e10be0189..fad4ebe0ab48 100644 --- a/sw/source/core/unocore/TextCursorHelper.cxx +++ b/sw/source/core/unocore/TextCursorHelper.cxx @@ -20,19 +20,6 @@ #include <TextCursorHelper.hxx> #include <comphelper/servicehelper.hxx> -using namespace ::com::sun::star; - -const uno::Sequence< sal_Int8 > & OTextCursorHelper::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theOTextCursorHelperUnoTunnelId; - return theOTextCursorHelperUnoTunnelId.getSeq(); -} - -//XUnoTunnel -sal_Int64 SAL_CALL OTextCursorHelper::getSomething( - const uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} +OTextCursorHelper::~OTextCursorHelper() {} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 2e5e1f697c0f..6faab283f787 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -217,8 +217,7 @@ void SwXBookmark::attachToRangeEx( const uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc *const pDoc = pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr); diff --git a/sw/source/core/unocore/unocontentcontrol.cxx b/sw/source/core/unocore/unocontentcontrol.cxx index b8546a0a6e28..6d07645df66a 100644 --- a/sw/source/core/unocore/unocontentcontrol.cxx +++ b/sw/source/core/unocore/unocontentcontrol.cxx @@ -438,15 +438,9 @@ void SwXContentControl::AttachImpl(const uno::Reference<text::XTextRange>& xText } uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY); - if (!xRangeTunnel.is()) - { - throw lang::IllegalArgumentException( - "SwXContentControl::AttachImpl(): argument is no XUnoTunnel", - static_cast<::cppu::OWeakObject*>(this), 0); - } SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); OTextCursorHelper* pCursor - = pRange ? nullptr : comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + = pRange ? nullptr : dynamic_cast<OTextCursorHelper*>(xTextRange.get()); if (!pRange && !pCursor) { throw lang::IllegalArgumentException( diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 3596e21cf00a..db63dfb52848 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -144,10 +144,6 @@ void GetSelectableFromAny(uno::Reference<uno::XInterface> const& xIfc, } uno::Reference<lang::XUnoTunnel> const xTunnel(xIfc, UNO_QUERY); - if (!xTunnel.is()) // everything below needs tunnel - { - return; - } SwXShape *const pShape(comphelper::getFromUnoTunnel<SwXShape>(xTunnel)); if (pShape) @@ -171,7 +167,7 @@ void GetSelectableFromAny(uno::Reference<uno::XInterface> const& xIfc, } OTextCursorHelper *const pCursor( - comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel)); + dynamic_cast<OTextCursorHelper*>(xIfc.get())); if (pCursor) { if (pCursor->GetDoc() == &rTargetDoc) diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 517dd5aaa8cd..068f18fd08ae 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -2003,21 +2003,17 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) // (see also SwXTextRange::XTextRangeToSwPaM) const SwDoc* pDoc = nullptr; uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - if(xRangeTunnel.is()) - { - if (auto pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel)) - pDoc = &pRange->GetDoc(); - else if (auto pText = comphelper::getFromUnoTunnel<SwXText>(xRangeTunnel)) - pDoc = pText->GetDoc(); - else if (auto pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel)) - pDoc = pCursor->GetDoc(); - else if (auto pPortion = comphelper::getFromUnoTunnel<SwXTextPortion>(xRangeTunnel)) - pDoc = &pPortion->GetCursor().GetDoc(); - else if (auto pParagraph = comphelper::getFromUnoTunnel<SwXParagraph>(xRangeTunnel); - pParagraph && pParagraph->GetTextNode()) - pDoc = &pParagraph->GetTextNode()->GetDoc(); - - } + if (auto pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel)) + pDoc = &pRange->GetDoc(); + else if (auto pText = comphelper::getFromUnoTunnel<SwXText>(xRangeTunnel)) + pDoc = pText->GetDoc(); + else if (auto pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get())) + pDoc = pCursor->GetDoc(); + else if (auto pPortion = comphelper::getFromUnoTunnel<SwXTextPortion>(xRangeTunnel)) + pDoc = &pPortion->GetCursor().GetDoc(); + else if (auto pParagraph = comphelper::getFromUnoTunnel<SwXParagraph>(xRangeTunnel); + pParagraph && pParagraph->GetTextNode()) + pDoc = &pParagraph->GetTextNode()->GetDoc(); if(!pDoc) throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index d5126bfaaf81..abbde27a3d69 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1352,7 +1352,7 @@ void SAL_CALL SwXTextField::attach( { uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr; // if a FieldMaster was attached, then the document is already fixed! diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index d81ed0ff6b63..e8a884623663 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2738,7 +2738,7 @@ void SwXFrame::attachToRange(uno::Reference<text::XTextRange> const& xTextRange, throw uno::RuntimeException(); uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr; if(!pDoc) diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 054119216f65..484db986d2ff 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -296,7 +296,7 @@ SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) SwXTextRange *const pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc *const pNewDoc = pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr); if (!pNewDoc) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index b2b4f1618068..c03227062e69 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1291,8 +1291,7 @@ SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) const uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange *const pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper *const pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc *const pDoc = pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr); @@ -1761,7 +1760,7 @@ SwXDocumentIndexMark::attach( SwXTextRange *const pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc *const pDoc = pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr); if (!pDoc) diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 51ef4da39402..3ec3f1d7012b 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1004,19 +1004,6 @@ SwXTextCursor::getSupportedServiceNames() }; } -const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theSwXTextCursorUnoTunnelId; - return theSwXTextCursorUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL -SwXTextCursor::getSomething(const uno::Sequence< sal_Int8 >& rId) -{ - const sal_Int64 nRet( comphelper::getSomethingImpl<SwXTextCursor>(rId, this) ); - return nRet ? nRet : OTextCursorHelper::getSomething(rId); -} - void SAL_CALL SwXTextCursor::collapseToStart() { SolarMutexGuard aGuard; @@ -1207,7 +1194,7 @@ SwXTextCursor::gotoRange( uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xRange.get()); if (!pRange && !pCursor) { @@ -3131,14 +3118,4 @@ SwXTextCursor::getAvailableServiceNames() return aRet; } -IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) - -uno::Any SAL_CALL -SwXTextCursor::queryInterface(const uno::Type& rType) -{ - return (rType == cppu::UnoType<lang::XUnoTunnel>::get()) - ? OTextCursorHelper::queryInterface(rType) - : SwXTextCursor_Base::queryInterface(rType); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e5fefbc0e376..e85df86d26c8 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1108,7 +1108,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwXTextPortion* pPortion = comphelper::getFromUnoTunnel<SwXTextPortion>(xRangeTunnel); SwXText* pText = comphelper::getFromUnoTunnel<SwXText>(xRangeTunnel); SwXParagraph* pPara = comphelper::getFromUnoTunnel<SwXParagraph>(xRangeTunnel); @@ -1126,8 +1126,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, // if it is started with a table then set into the table xTextCursor.set(pHeadText->CreateTextCursor(true)); xTextCursor->gotoEnd(true); - pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xTextCursor); + pCursor = dynamic_cast<OTextCursorHelper*>(xTextCursor.get()); pCursor->GetPaM()->Normalize(); } else @@ -1135,8 +1134,7 @@ bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, { xTextCursor.set( pText->CreateCursor() ); xTextCursor->gotoEnd(true); - pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xTextCursor); + pCursor = dynamic_cast<OTextCursorHelper*>(xTextCursor.get()); } if(pRange && &pRange->GetDoc() == &rToFill.GetDoc()) { diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index d7c91d1501c7..623710f3e374 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -272,7 +272,7 @@ SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) } uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc *const pDocument = pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr); if (!pDocument) @@ -937,16 +937,9 @@ SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange, } uno::Reference<lang::XUnoTunnel> xRangeTunnel(i_xTextRange, uno::UNO_QUERY); - if (!xRangeTunnel.is()) - { - throw lang::IllegalArgumentException( - "SwXMeta::attach(): argument is no XUnoTunnel", - static_cast< ::cppu::OWeakObject* >(this), 0); - } SwXTextRange *const pRange( comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel)); - OTextCursorHelper *const pCursor( pRange ? nullptr : - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel)); + OTextCursorHelper *const pCursor(dynamic_cast<OTextCursorHelper*>(i_xTextRange.get())); if (!pRange && !pCursor) { throw lang::IllegalArgumentException( diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 25aa3804a66f..990c561800ef 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -281,7 +281,7 @@ SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwDoc *const pDoc = pRange ? &pRange->GetDoc() : (pCursor ? pCursor->GetDoc() : nullptr); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index f1d697a36c81..5858975d6cf5 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1423,26 +1423,12 @@ OUString SwXTextTableCursor::getImplementationName() sal_Bool SwXTextTableCursor::supportsService(const OUString& rServiceName) { return cppu::supportsService(this, rServiceName); } -void SwXTextTableCursor::acquire() noexcept -{ - SwXTextTableCursor_Base::acquire(); -} - void SwXTextTableCursor::release() noexcept { SolarMutexGuard aGuard; SwXTextTableCursor_Base::release(); } -css::uno::Any SAL_CALL -SwXTextTableCursor::queryInterface( const css::uno::Type& _rType ) -{ - css::uno::Any aReturn = SwXTextTableCursor_Base::queryInterface( _rType ); - if ( !aReturn.hasValue() ) - aReturn = OTextCursorHelper::queryInterface( _rType ); - return aReturn; -} - const SwPaM* SwXTextTableCursor::GetPaM() const { return &GetCursor(); } SwPaM* SwXTextTableCursor::GetPaM() { return &GetCursor(); } const SwDoc* SwXTextTableCursor::GetDoc() const { return GetFrameFormat()->GetDoc(); } @@ -2099,7 +2085,7 @@ SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange) uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY); SwXTextRange* pRange(comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel)); - OTextCursorHelper* pCursor(comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel)); + OTextCursorHelper* pCursor(dynamic_cast<OTextCursorHelper*>(xTextRange.get())); SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr; if (!pDoc || !m_pImpl->m_nRows || !m_pImpl->m_nColumns) throw lang::IllegalArgumentException(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 2f16de793d35..c14829af6261 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -301,8 +301,7 @@ SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, uno::UNO_QUERY); SwXTextRange *const pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper *const pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); if ((!pRange || &pRange ->GetDoc() != GetDoc()) && (!pCursor || pCursor->GetDoc() != GetDoc())) { @@ -442,8 +441,7 @@ SwXText::insertControlCharacter( SwXTextRange *const pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>( - xRangeTunnel); + dynamic_cast<OTextCursorHelper*>(xTextRange.get()); if (pRange) { pRange->SetPositions(aPam); @@ -475,7 +473,7 @@ SwXText::insertControlCharacter( SwXTextRange *const pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + dynamic_cast<OTextCursorHelper*>(xTextRange.get()); SwCursor aCursor(*aPam.GetPoint(), nullptr); SwUnoCursorHelper::SelectPam(aCursor, true); @@ -614,7 +612,7 @@ SwXText::insertTextContent( pRange->DeleteAndInsert(u"", ::sw::DeleteAndInsertMode::ForceReplace | (bForceExpandHints ? ::sw::DeleteAndInsertMode::ForceExpandHints : ::sw::DeleteAndInsertMode::Default)); } - else if (SwXTextCursor *const pCursor = dynamic_cast<SwXTextCursor*>(comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel))) + else if (SwXTextCursor *const pCursor = dynamic_cast<SwXTextCursor*>(dynamic_cast<OTextCursorHelper*>(xRange.get()))) { pCursor->DeleteAndInsert(u"", ::sw::DeleteAndInsertMode::ForceReplace | (bForceExpandHints ? ::sw::DeleteAndInsertMode::ForceExpandHints : ::sw::DeleteAndInsertMode::Default)); @@ -996,7 +994,7 @@ bool SwXText::Impl::CheckForOwnMember( const uno::Reference<text::XTextCursor> xOwnCursor(m_rThis.CreateCursor()); OTextCursorHelper *const pOwnCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xOwnCursor); + dynamic_cast<OTextCursorHelper*>(xOwnCursor.get()); OSL_ENSURE(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? "); const SwStartNode* pOwnStartNode = pOwnCursor->GetPaM()->GetPointNode().StartOfSectionNode(); @@ -1373,11 +1371,7 @@ SwXText::insertTextPortion( } uno::Reference< text::XTextRange > xRet; const uno::Reference<text::XTextCursor> xTextCursor = createTextCursorByRange(xInsertPosition); - - const uno::Reference< lang::XUnoTunnel > xRangeTunnel( - xTextCursor, uno::UNO_QUERY_THROW ); - SwXTextCursor *const pTextCursor = - comphelper::getFromUnoTunnel<SwXTextCursor>(xRangeTunnel); + SwXTextCursor *const pTextCursor = dynamic_cast<SwXTextCursor*>(xTextCursor.get()); bool bIllegalException = false; bool bRuntimeException = false; @@ -1827,7 +1821,7 @@ SwXText::convertToTextFrame( const uno::Reference<text::XTextCursor> xFrameTextCursor = rNewFrame.createTextCursor(); SwXTextCursor *const pFrameCursor = - comphelper::getFromUnoTunnel<SwXTextCursor>(xFrameTextCursor); + dynamic_cast<SwXTextCursor*>(xFrameTextCursor.get()); if (bParaBeforeInserted) { // todo: remove paragraph before frame @@ -2372,11 +2366,7 @@ SwXText::copyText( xText->createTextCursor(); xCursor->gotoEnd( true ); - uno::Reference< lang::XUnoTunnel > const xCursorTunnel(xCursor, - uno::UNO_QUERY_THROW); - - OTextCursorHelper *const pCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); + OTextCursorHelper *const pCursor = dynamic_cast<OTextCursorHelper*>(xCursor.get()); if (!pCursor) { throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx index eb31601dd64a..2aa8aef7322f 100644 --- a/sw/source/core/unocore/unotextmarkup.cxx +++ b/sw/source/core/unocore/unotextmarkup.cxx @@ -101,8 +101,6 @@ void SAL_CALL SwXTextMarkup::commitTextRangeMarkup(::sal_Int32 nType, const OUSt uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); - if(!xRangeTunnel.is()) return; - if (auto pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel)) { SwDoc& rDoc = pRange->GetDoc(); @@ -115,7 +113,7 @@ void SAL_CALL SwXTextMarkup::commitTextRangeMarkup(::sal_Int32 nType, const OUSt commitStringMarkup (nType, aIdentifier, startPos->GetContentIndex(), endPos->GetContentIndex() - startPos->GetContentIndex(), xMarkupInfoContainer); } - else if (auto pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel)) + else if (auto pCursor = dynamic_cast<OTextCursorHelper*>(xRange.get())) { SwPaM & rPam(*pCursor->GetPaM()); diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 6d3bb6007ae6..d5848ea4e65a 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -60,10 +60,8 @@ using ::com::sun::star::beans::XPropertySetInfo; // a few helper functions static SwDoc* lcl_GetDocViaTunnel( Reference<XTextCursor> const & rCursor ) { - Reference<XUnoTunnel> xTunnel( rCursor, UNO_QUERY); - OSL_ENSURE(xTunnel.is(), "missing XUnoTunnel for XTextCursor"); OTextCursorHelper *const pXCursor = - comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel); + dynamic_cast<OTextCursorHelper*>(rCursor.get()); OSL_ENSURE( pXCursor, "OTextCursorHelper missing" ); return pXCursor ? pXCursor->GetDoc() : nullptr; } diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 03c30542efa3..9233886fe0b8 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -363,7 +363,7 @@ void SwXMLImport::setStyleInsertMode( SfxStyleFamily nFamilies, static OTextCursorHelper *lcl_xml_GetSwXTextCursor( const Reference < XTextCursor >& rTextCursor ) { - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(rTextCursor); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(rTextCursor.get()); OSL_ENSURE( pTextCursor, "SwXTextCursor missing" ); return pTextCursor; } @@ -629,10 +629,10 @@ void SwXMLImport::endDocument() SwDoc *pDoc = nullptr; if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() ) { - Reference<XUnoTunnel> xCursorTunnel( GetTextImport()->GetCursor(), + Reference<XInterface> xCursorTunnel( GetTextImport()->GetCursor(), UNO_QUERY); assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(xCursorTunnel.get()); assert(pTextCursor && "SwXTextCursor missing"); SwPaM *pPaM = pTextCursor->GetPaM(); if( IsInsertMode() && m_oSttNdIdx->GetIndex() ) diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 44ae125d30b0..cb369afc08a5 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -595,9 +595,7 @@ void SwXMLTableCellContext_Impl::endFastElement(sal_Int32 ) xSrcTextCursor->gotoEnd( true ); // Until we have an API for copying we have to use the core. - Reference<XUnoTunnel> xSrcCursorTunnel( xSrcTextCursor, UNO_QUERY); - assert(xSrcCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper *pSrcTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xSrcTextCursor); + OTextCursorHelper *pSrcTextCursor = dynamic_cast<OTextCursorHelper*>(xSrcTextCursor.get()); assert(pSrcTextCursor && "SwXTextCursor missing"); SwDoc *pDoc = pSrcTextCursor->GetDoc(); const SwPaM *pSrcPaM = pSrcTextCursor->GetPaM(); @@ -606,10 +604,7 @@ void SwXMLTableCellContext_Impl::endFastElement(sal_Int32 ) { InsertContent_(); - Reference<XUnoTunnel> xDstCursorTunnel( - GetImport().GetTextImport()->GetCursor(), UNO_QUERY); - assert(xDstCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper *pDstTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(GetImport().GetTextImport()->GetCursor()); + OTextCursorHelper *pDstTextCursor = dynamic_cast<OTextCursorHelper*>(GetImport().GetTextImport()->GetCursor().get()); assert(pDstTextCursor && "SwXTextCursor missing"); SwPaM aSrcPaM(*pSrcPaM->GetMark(), *pSrcPaM->GetPoint()); SwPosition aDstPos( *pDstTextCursor->GetPaM()->GetPoint() ); @@ -2672,10 +2667,10 @@ const SwStartNode *SwXMLTableContext::InsertTableSection( ->InsertTableSection(pPrevSttNd, pStringValueStyleName); const SwStartNode *pStNd; - Reference<XUnoTunnel> xCursorTunnel( GetImport().GetTextImport()->GetCursor(), + Reference<XInterface> xCursorTunnel( GetImport().GetTextImport()->GetCursor(), UNO_QUERY); OSL_ENSURE( xCursorTunnel.is(), "missing XUnoTunnel for Cursor" ); - OTextCursorHelper *pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); + OTextCursorHelper *pTextCursor = dynamic_cast<OTextCursorHelper*>(xCursorTunnel.get()); OSL_ENSURE( pTextCursor, "SwXTextCursor missing" ); if( m_bFirstSection ) diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 7ec4616f76dd..0464c0f26a83 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -172,10 +172,7 @@ SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext( bool SwXMLTextImportHelper::IsInHeaderFooter() const { - uno::Reference<XUnoTunnel> xCursorTunnel( - const_cast<SwXMLTextImportHelper *>(this)->GetCursor(), UNO_QUERY ); - assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(const_cast<SwXMLTextImportHelper *>(this)->GetCursor().get()); SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing"); SwDoc *pDoc = pTextCursor ? pTextCursor->GetDoc() : nullptr; @@ -216,9 +213,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject( if( aObjName.isEmpty() ) return xPropSet; - uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY ); - assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get()); SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing"); SwDoc *pDoc = static_cast<SwXMLImport&>(rImport).getDoc(); @@ -518,10 +513,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink( uno::Reference < XPropertySet > xPropSet; - uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY ); - assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); - OSL_ENSURE( pTextCursor, "SwXTextCursor missing" ); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get()); + assert( pTextCursor && "SwXTextCursor missing" ); SwDoc *pDoc = static_cast<SwXMLImport&>(rImport).getDoc(); SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() ); @@ -609,10 +602,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet( SolarMutexGuard aGuard; uno::Reference < XPropertySet > xPropSet; - uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY ); - assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); - OSL_ENSURE( pTextCursor, "SwXTextCursor missing" ); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get()); + assert( pTextCursor && "SwXTextCursor missing" ); SwDoc *pDoc = pTextCursor->GetDoc(); SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() ); @@ -653,10 +644,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin( sal_Int32 nWidth, sal_Int32 nHeight ) { uno::Reference < XPropertySet > xPropSet; - uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY ); - assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); - OSL_ENSURE( pTextCursor, "SwXTextCursor missing" ); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get()); + assert( pTextCursor && "SwXTextCursor missing" ); SwDoc *pDoc = pTextCursor->GetDoc(); SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() ); @@ -732,10 +721,8 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra SolarMutexGuard aGuard; uno::Reference < XPropertySet > xPropSet; - uno::Reference<XUnoTunnel> xCursorTunnel( GetCursor(), UNO_QUERY ); - assert(xCursorTunnel.is() && "missing XUnoTunnel for Cursor"); - OTextCursorHelper* pTextCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); - OSL_ENSURE( pTextCursor, "SwXTextCursor missing" ); + OTextCursorHelper* pTextCursor = dynamic_cast<OTextCursorHelper*>(GetCursor().get()); + assert( pTextCursor && "SwXTextCursor missing" ); SwDoc *pDoc = pTextCursor->GetDoc(); SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() ); diff --git a/sw/source/uibase/inc/unotxvw.hxx b/sw/source/uibase/inc/unotxvw.hxx index cfffa3169b4b..2ceb49215704 100644 --- a/sw/source/uibase/inc/unotxvw.hxx +++ b/sw/source/uibase/inc/unotxvw.hxx @@ -163,8 +163,6 @@ class SwXTextViewCursor final: public SwXTextViewCursor_Base, public OTextCursor public: SwXTextViewCursor(SwView* pVw); - DECLARE_XINTERFACE() - //XTextViewCursor virtual sal_Bool SAL_CALL isVisible() override; virtual void SAL_CALL setVisible(sal_Bool bVisible) override; @@ -231,11 +229,6 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; - void Invalidate(){m_pView = nullptr;} // ITextCursorHelper diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index 5e037b4d679a..651ecf173cbe 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -331,7 +331,7 @@ uno::Reference< text::XAutoTextEntry > SwXAutoTextGroup::insertNewByName(const { uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pxRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); - OTextCursorHelper* pxCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pxCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get()); OUString sOnlyText; OUString* pOnlyText = nullptr; @@ -848,11 +848,12 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR // This means that we would reflect any changes which were done to the AutoText by foreign instances // in the meantime - // The reference to the tunnel is needed during the whole call, likely because it could be a + // The reference to xTmp is needed during the whole call, likely because it could be a // different object, not xTextRange itself, and the reference guards it from preliminary death + uno::Reference<text::XTextRange> xKeepAlive( xTextRange ); uno::Reference<lang::XUnoTunnel> xTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xKeepAlive.get()); SwXText *pText = comphelper::getFromUnoTunnel<SwXText>(xTunnel); SwDoc* pDoc = nullptr; @@ -862,8 +863,8 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR pDoc = pCursor->GetDoc(); else if ( pText && pText->GetDoc() ) { - xTunnel.set(pText->getStart(), uno::UNO_QUERY); - pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel); + xKeepAlive = pText->getStart(); + pCursor = dynamic_cast<OTextCursorHelper*>(xKeepAlive.get()); if (pCursor) pDoc = pText->GetDoc(); } diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 35ff90d58865..6b5b52d105dd 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -779,8 +779,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > bool bParentInExtra = false; if(xLastResult.is()) { - Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY); - OTextCursorHelper* pPosCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xCursorTunnel); + OTextCursorHelper* pPosCursor = dynamic_cast<OTextCursorHelper*>(xLastResult.get()); SwPaM* pCursor = pPosCursor ? pPosCursor->GetPaM() : nullptr; if(pCursor) { @@ -789,6 +788,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > } else { + Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xCursorTunnel); if(!pRange) return nullptr; diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index 09862245167e..7232e98136a6 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -991,7 +991,7 @@ void SwXTextViewCursor::gotoRange( uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel); SwXParagraph* pPara = comphelper::getFromUnoTunnel<SwXParagraph>(xRangeTunnel); - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xRange.get()); const FrameTypeFlags nFrameType = rSh.GetFrameType(nullptr,true); @@ -1599,21 +1599,6 @@ Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames() "com.sun.star.style.ParagraphPropertiesComplex" }; } -const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theSwXTextViewCursorUnoTunnelId; - return theSwXTextViewCursorUnoTunnelId.getSeq(); -} - -//XUnoTunnel -sal_Int64 SAL_CALL SwXTextViewCursor::getSomething( - const uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this, - comphelper::FallbackToGetSomethingOf<OTextCursorHelper>{}); -} - -IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper) const SwDoc* SwXTextViewCursor::GetDoc() const { SwWrtShell& rSh = m_pView->GetWrtShell(); diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index 9ba9e642f3b6..fba4437f4a54 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -151,7 +151,7 @@ void SwOneExampleFrame::Paint(vcl::RenderContext& rRenderContext, const tools::R Color aBgColor = SW_MOD()->GetColorConfig().GetColorValue(::svtools::DOCCOLOR).nColor; m_xVirDev->DrawWallpaper(tools::Rectangle(Point(), aSize), aBgColor); - auto pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(m_xCursor); + auto pCursor = dynamic_cast<OTextCursorHelper*>(m_xCursor.get()); if (pCursor) { uno::Reference<view::XViewSettingsSupplier> xSettings(m_xController, uno::UNO_QUERY); @@ -298,7 +298,7 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, void ) //From here, a cursor is defined, which goes through the template, //and overwrites the template words where it is necessary. - auto pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(m_xCursor); + auto pCursor = dynamic_cast<OTextCursorHelper*>(m_xCursor.get()); SwDoc *pDoc = pCursor ? pCursor->GetDoc() : nullptr; if (pDoc && (m_nStyleFlags & EX_LOCALIZE_TOC_STRINGS)) @@ -434,11 +434,9 @@ IMPL_LINK( SwOneExampleFrame, TimeoutHdl, Timer*, pTimer, void ) void SwOneExampleFrame::ClearDocument() { - uno::Reference< lang::XUnoTunnel> xTunnel( m_xCursor, uno::UNO_QUERY); - if( !xTunnel.is() ) + if( !m_xCursor ) return; - - OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(m_xCursor.get()); if( pCursor ) { SwDoc* pDoc = pCursor->GetDoc(); |