diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-12 16:25:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-13 18:13:51 +0000 |
commit | d60722e29a0dde6282915188e5ff7e24890a14d3 (patch) | |
tree | f69b4c7e4b4abb44cbbfd3235a3136dff833a386 | |
parent | d4d046bb9c5d17cdd432b362c38914cc7b0a75f1 (diff) |
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 <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/vcl/transfer.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/app/drwtrans.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/inc/drwtrans.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/inc/transobj.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/app/sdxfer.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/inc/sdtreelb.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/inc/sdxfer.hxx | 3 | ||||
-rw-r--r-- | starmath/source/view.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/inc/swdtflvr.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/inc/uivwimp.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uiview/uivwimp.cxx | 7 | ||||
-rw-r--r-- | vcl/source/treelist/transfer.cxx | 12 |
16 files changed, 12 insertions, 101 deletions
diff --git a/include/vcl/transfer.hxx b/include/vcl/transfer.hxx index bd5999a82234..e460e9f9c155 100644 --- a/include/vcl/transfer.hxx +++ b/include/vcl/transfer.hxx @@ -29,7 +29,6 @@ #include <cppuhelper/implbase.hxx> #include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/datatransfer/XTransferable2.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> @@ -130,8 +129,7 @@ struct ExecuteDropEvent class VCL_DLLPUBLIC TransferableHelper : public cppu::WeakImplHelper< css::datatransfer::XTransferable2, css::datatransfer::clipboard::XClipboardOwner, - css::datatransfer::dnd::XDragSourceListener, - css::lang::XUnoTunnel > + css::datatransfer::dnd::XDragSourceListener> { private: @@ -265,12 +263,6 @@ public: void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions ); static void ClearPrimarySelection(); - - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - -public: - - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; }; struct TransferableDataHelper_Impl; diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index ed83dc893ae5..2ec8c57354b6 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -231,7 +231,7 @@ ScDrawTransferObj::~ScDrawTransferObj() ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard(const uno::Reference<datatransfer::XTransferable2>& xTransferable) { - return comphelper::getFromUnoTunnel<ScDrawTransferObj>(xTransferable); + return dynamic_cast<ScDrawTransferObj*>(xTransferable.get()); } static bool lcl_HasOnlyControls( SdrModel* pModel ) @@ -719,16 +719,4 @@ void ScDrawTransferObj::InitDocShell() pDocSh->UpdateOle(aViewData, true); } -const css::uno::Sequence< sal_Int8 >& ScDrawTransferObj::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theScDrawTransferObjUnoTunnelId; - return theScDrawTransferObjUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL ScDrawTransferObj::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl( - rId, this, comphelper::FallbackToGetSomethingOf<TransferDataContainer>{}); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index a81e4149956e..3bba033d28e7 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -198,7 +198,7 @@ ScTransferObj::~ScTransferObj() ScTransferObj* ScTransferObj::GetOwnClipboard(const uno::Reference<datatransfer::XTransferable2>& xTransferable) { - return comphelper::getFromUnoTunnel<ScTransferObj>(xTransferable); + return dynamic_cast<ScTransferObj*>(xTransferable.get()); } void ScTransferObj::AddSupportedFormats() @@ -903,16 +903,4 @@ void ScTransferObj::StripRefs( ScDocument& rDoc, } } -const css::uno::Sequence< sal_Int8 >& ScTransferObj::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theScTransferUnoTunnelId; - return theScTransferUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL ScTransferObj::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl( - rId, this, comphelper::FallbackToGetSomethingOf<TransferDataContainer>{}); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx index 34e4af7063fc..49ec9e1e34d3 100644 --- a/sc/source/ui/inc/drwtrans.hxx +++ b/sc/source/ui/inc/drwtrans.hxx @@ -90,9 +90,6 @@ public: static ScDrawTransferObj* GetOwnClipboard(const css::uno::Reference<css::datatransfer::XTransferable2>&); - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - const ScRangeListVector& GetProtectedChartRangesVector() const { return m_aProtectedChartRangesVector; } }; diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx index 8429b6e6c257..3a597669e8b1 100644 --- a/sc/source/ui/inc/transobj.hxx +++ b/sc/source/ui/inc/transobj.hxx @@ -105,8 +105,6 @@ public: static SC_DLLPUBLIC ScTransferObj* GetOwnClipboard(const css::uno::Reference<css::datatransfer::XTransferable2>&); static SfxObjectShell* SetDrawClipDoc(bool bAnyOle, const std::shared_ptr<ScDocument>& = {} ); // update ScGlobal::xDrawClipDocShellRef - virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) override; - static const com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index a19484aa9007..b2f05416a6bd 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -621,15 +621,13 @@ void ScViewFunc::PasteFromSystem() void ScViewFunc::PasteFromTransferable( const uno::Reference<datatransfer::XTransferable>& rxTransferable ) { - uno::Reference<lang::XUnoTunnel> xTunnel( rxTransferable, uno::UNO_QUERY ); - - if (auto pOwnClip = comphelper::getFromUnoTunnel<ScTransferObj>(xTunnel)) + if (auto pOwnClip = dynamic_cast<ScTransferObj*>(rxTransferable.get())) { PasteFromClip( InsertDeleteFlags::ALL, pOwnClip->GetDocument(), ScPasteFunc::NONE, false, false, false, INS_NONE, InsertDeleteFlags::NONE, true ); // allow warning dialog } - else if (auto pDrawClip = comphelper::getFromUnoTunnel<ScDrawTransferObj>(xTunnel)) + else if (auto pDrawClip = dynamic_cast<ScDrawTransferObj*>(rxTransferable.get())) { ScViewData& rViewData = GetViewData(); SCCOL nPosX = rViewData.GetCurX(); diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index e87fd1a016b3..7e7d42dacd92 100644 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -704,11 +704,6 @@ void SdTransferable::SetPageBookmarks( std::vector<OUString> && rPageBookmarks, mbPageTransferablePersistent = bPersistent; } -sal_Int64 SAL_CALL SdTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - void SdTransferable::AddUserData (const std::shared_ptr<UserData>& rpData) { maUserData.push_back(rpData); diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index da6a7182ef2a..5b2d092cb105 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -115,18 +115,6 @@ void SdPageObjsTLV::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction ) SdTransferable::DragFinished(nDropAction); } -sal_Int64 SAL_CALL SdPageObjsTLV::SdPageObjsTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this, - comphelper::FallbackToGetSomethingOf<SdTransferable>{}); -} - -const css::uno::Sequence<sal_Int8>& SdPageObjsTLV::SdPageObjsTransferable::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theSdPageObjsTLBUnoTunnelId; - return theSdPageObjsTLBUnoTunnelId.getSeq(); -} - SdPageObjsTLV::SdPageObjsTransferable* SdPageObjsTLV::SdPageObjsTransferable::getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) noexcept { diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index d937f9e310c0..81a535c19a05 100644 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -416,7 +416,6 @@ public: ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;} NavigatorDragType GetDragType() const { return meDragType;} - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); static SdPageObjsTransferable* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) noexcept; /** Return a temporary transferable data flavor that is used internally in the navigator for reordering entries. Its @@ -438,8 +437,6 @@ public: virtual void AddSupportedFormats() override; virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; virtual void DragFinished( sal_Int8 nDropAction ) override; - - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; }; friend class SdPageObjsTLV::SdPageObjsTransferable; diff --git a/sd/source/ui/inc/sdxfer.hxx b/sd/source/ui/inc/sdxfer.hxx index 8393e8f7aea0..fd949aef5400 100644 --- a/sd/source/ui/inc/sdxfer.hxx +++ b/sd/source/ui/inc/sdxfer.hxx @@ -102,9 +102,6 @@ public: */ std::shared_ptr<UserData> GetUserData (const sal_Int32 nIndex) const; - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 >& rId) override; - protected: virtual void AddSupportedFormats() override; diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index bdc8b0729335..45059c9816b9 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1717,7 +1717,7 @@ void SmViewShell::Execute(SfxRequest& rReq) Reference< datatransfer::XTransferable > xTrans( GetDoc()->GetModel(), uno::UNO_QUERY ); if( xTrans.is() ) { - auto pTrans = comphelper::getFromUnoTunnel<TransferableHelper>(xTrans); + auto pTrans = dynamic_cast<TransferableHelper*>(xTrans.get()); if (pTrans) { SmEditWindow *pEditWin = GetEditWindow(); 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<TransferableHelper>{}); -} - SwTransferable* SwTransferable::GetSwTransferable( const TransferableDataHelper& rData ) { - return comphelper::getFromUnoTunnel<SwTransferable>(rData.GetTransferable()); + return dynamic_cast<SwTransferable*>(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 <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> #include <cppuhelper/implbase.hxx> #include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> 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<SwTransferable>(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<css::lang::XUnoTunnel>& rTunnel) { - uno::Reference<lang::XUnoTunnel> xTunnel(rTunnel.get(), uno::UNO_QUERY); - return !xTunnel.is(); + [](const unotools::WeakReference<SwTransferable>& rTunnel) { + return !rTunnel.get(); }), mxTransferables.end()); mxTransferables.emplace_back(&rTransferable); diff --git a/vcl/source/treelist/transfer.cxx b/vcl/source/treelist/transfer.cxx index f2c453792a6f..bef49272b7c1 100644 --- a/vcl/source/treelist/transfer.cxx +++ b/vcl/source/treelist/transfer.cxx @@ -506,12 +506,6 @@ void SAL_CALL TransferableHelper::dropActionChanged( const DragSourceDragEvent& } -sal_Int64 SAL_CALL TransferableHelper::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - - void TransferableHelper::ImplFlush() { if( !mxClipboard.is() ) @@ -998,12 +992,6 @@ void TransferableHelper::ClearPrimarySelection() xSelection->setContents( nullptr, nullptr ); } -const Sequence< sal_Int8 >& TransferableHelper::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theTransferableHelperUnoTunnelId; - return theTransferableHelperUnoTunnelId.getSeq(); -} - namespace { class TransferableClipboardNotifier : public ::cppu::WeakImplHelper< XClipboardListener > |