From d60722e29a0dde6282915188e5ff7e24890a14d3 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 Jan 2023 16:25:40 +0200 Subject: XUnoTunnel->dynamic_cast in TransferableHelper which leads us to find that we can skip all the dynamic_cast'ing altogether in SwView_Impl Change-Id: I8914f78df6bfdd743df370c0017d5b8521863594 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145483 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/uibase/dochdl/swdtflvr.cxx | 14 +------------- sw/source/uibase/inc/swdtflvr.hxx | 3 --- sw/source/uibase/inc/uivwimp.hxx | 3 ++- sw/source/uibase/uiview/uivwimp.cxx | 7 +++---- 4 files changed, 6 insertions(+), 21 deletions(-) (limited to 'sw') diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index d9a6db5c1bb5..43308154fcb1 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -4351,21 +4351,9 @@ void SwTransferable::ClearSelection( const SwWrtShell& rSh, } } -const Sequence< sal_Int8 >& SwTransferable::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theSwTransferableUnoTunnelId; - return theSwTransferableUnoTunnelId.getSeq(); -} - -sal_Int64 SwTransferable::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this, - comphelper::FallbackToGetSomethingOf{}); -} - SwTransferable* SwTransferable::GetSwTransferable( const TransferableDataHelper& rData ) { - return comphelper::getFromUnoTunnel(rData.GetTransferable()); + return dynamic_cast(rData.GetTransferable().get()); } SwTransferDdeLink::SwTransferDdeLink( SwTransferable& rTrans, SwWrtShell& rSh ) diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx index df16e3a8bd56..375ca33a128d 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -237,9 +237,6 @@ public: // the related SwView is being closed and the SwTransferable is invalid now void Invalidate() {m_pWrtShell = nullptr;} - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; static void SelectPasteFormat(TransferableDataHelper& rData, sal_uInt8& nAction, SotClipboardFormatId& nFormat); diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx index 1cb5fd6590ed..352469f33401 100644 --- a/sw/source/uibase/inc/uivwimp.hxx +++ b/sw/source/uibase/inc/uivwimp.hxx @@ -26,6 +26,7 @@ #include #include #include +#include class SwXTextView; class SfxRequest; @@ -86,7 +87,7 @@ class SwView_Impl { css::uno::Reference< css::frame::XDispatchProviderInterceptor > m_xDispatchProviderInterceptor; css::uno::Reference< css::view::XSelectionSupplier > mxXTextView; // UNO object - std::vector< css::uno::WeakReference< css::lang::XUnoTunnel > > mxTransferables; + std::vector< unotools::WeakReference< SwTransferable > > mxTransferables; // temporary document for printing text of selection / multi selection // in PDF export. diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index cea09ed3b5ba..efe2a713d635 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -212,7 +212,7 @@ void SwView_Impl::Invalidate() GetUNOObject_Impl()->Invalidate(); for (const auto& xTransferable: mxTransferables) { - auto pTransferable = comphelper::getFromUnoTunnel(xTransferable.get()); + auto pTransferable = xTransferable.get().get(); if(pTransferable) pTransferable->Invalidate(); } @@ -225,9 +225,8 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable) { // Remove previously added, but no longer existing weak references. mxTransferables.erase(std::remove_if(mxTransferables.begin(), mxTransferables.end(), - [](const css::uno::WeakReference& rTunnel) { - uno::Reference xTunnel(rTunnel.get(), uno::UNO_QUERY); - return !xTunnel.is(); + [](const unotools::WeakReference& rTunnel) { + return !rTunnel.get(); }), mxTransferables.end()); mxTransferables.emplace_back(&rTransferable); -- cgit