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:14 +0200 |
commit | 3f65724ec5fc92d5a0078a99932358ef7091435c (patch) | |
tree | 94dd9bf1d0ecd42dbf7f94db45bc7e1bf29b83ce /sd | |
parent | 6444b026b4039458d01ada5fee58eae98166585b (diff) |
Use <comphelper/servicehelper.hxx> implementing XUnoTunnel part 4
- Change implementations of getSomething to use getSomethingImpl
Or where that's impossible, use getSomething_cast to unify this and
reduce number of places where we reinterpret_cast.
All static methods getting tunnel ids were renamed to getUnoTunnelId,
to comply with the convention used in <comphelper/servicehelper.hxx>.
TODO (in separate commits):
- Revise uses of getSomething to use getFromUnoTunnel
Change-Id: Ifde9e214b52e5df678de71fcc32d2199c82e85cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122100
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/app/sdxfer.cxx | 13 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/framework/factories/Pane.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/framework/factories/ViewShellWrapper.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/inc/sdxfer.hxx | 5 | ||||
-rw-r--r-- | sd/source/ui/unoidl/DrawController.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/view/ViewTabBar.cxx | 9 |
9 files changed, 16 insertions, 70 deletions
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index ea67e78c6adc..eb8bef68b8dd 100644 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -710,18 +710,7 @@ void SdTransferable::SetPageBookmarks( const std::vector<OUString> &rPageBookmar sal_Int64 SAL_CALL SdTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) { - sal_Int64 nRet; - - if( comphelper::isUnoTunnelId<SdTransferable>(rId) ) - { - nRet = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); - } - else - { - nRet = 0; - } - - return nRet; + return comphelper::getSomethingImpl(rId, this); } void SdTransferable::AddUserData (const std::shared_ptr<UserData>& rpData) diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index e4ce13798207..2b8a6142ef0b 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -114,16 +114,8 @@ void SdPageObjsTLV::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction ) sal_Int64 SAL_CALL SdPageObjsTLV::SdPageObjsTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) { - sal_Int64 nRet; - - if (comphelper::isUnoTunnelId<SdPageObjsTLV::SdPageObjsTransferable>(rId)) - { - nRet = static_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); - } - else - nRet = SdTransferable::getSomething(rId); - - return nRet; + return comphelper::getSomethingImpl(rId, this, + comphelper::FallbackToGetSomethingOf<SdTransferable>{}); } const css::uno::Sequence<sal_Int8>& SdPageObjsTLV::SdPageObjsTransferable::getUnoTunnelId() diff --git a/sd/source/ui/framework/factories/Pane.cxx b/sd/source/ui/framework/factories/Pane.cxx index bbf081c85c16..ffbb5e001d4e 100644 --- a/sd/source/ui/framework/factories/Pane.cxx +++ b/sd/source/ui/framework/factories/Pane.cxx @@ -146,14 +146,7 @@ const Sequence<sal_Int8>& Pane::getUnoTunnelId() sal_Int64 SAL_CALL Pane::getSomething (const Sequence<sal_Int8>& rId) { - sal_Int64 nResult = 0; - - if (comphelper::isUnoTunnelId<Pane>(rId)) - { - nResult = reinterpret_cast<sal_Int64>(this); - } - - return nResult; + return comphelper::getSomethingImpl(rId, this); } Reference<rendering::XCanvas> Pane::CreateCanvas() diff --git a/sd/source/ui/framework/factories/ViewShellWrapper.cxx b/sd/source/ui/framework/factories/ViewShellWrapper.cxx index a689f8882842..d5604e79d5cb 100644 --- a/sd/source/ui/framework/factories/ViewShellWrapper.cxx +++ b/sd/source/ui/framework/factories/ViewShellWrapper.cxx @@ -219,14 +219,7 @@ const Sequence<sal_Int8>& ViewShellWrapper::getUnoTunnelId() sal_Int64 SAL_CALL ViewShellWrapper::getSomething (const Sequence<sal_Int8>& rId) { - sal_Int64 nResult = 0; - - if (comphelper::isUnoTunnelId<ViewShellWrapper>(rId)) - { - nResult = reinterpret_cast<sal_Int64>(this); - } - - return nResult; + return comphelper::getSomethingImpl(rId, this); } //===== awt::XWindowListener ================================================== diff --git a/sd/source/ui/inc/sdxfer.hxx b/sd/source/ui/inc/sdxfer.hxx index 1c95efb35646..65b67839958e 100644 --- a/sd/source/ui/inc/sdxfer.hxx +++ b/sd/source/ui/inc/sdxfer.hxx @@ -101,6 +101,9 @@ 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; @@ -108,8 +111,6 @@ protected: virtual bool WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override; virtual void ObjectReleased() override final; - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; - private: SfxObjectShellRef maDocShellRef; diff --git a/sd/source/ui/unoidl/DrawController.cxx b/sd/source/ui/unoidl/DrawController.cxx index 39a763ec8c45..66e1fd142f27 100644 --- a/sd/source/ui/unoidl/DrawController.cxx +++ b/sd/source/ui/unoidl/DrawController.cxx @@ -561,14 +561,7 @@ const Sequence<sal_Int8>& DrawController::getUnoTunnelId() sal_Int64 SAL_CALL DrawController::getSomething (const Sequence<sal_Int8>& rId) { - sal_Int64 nResult = 0; - - if (comphelper::isUnoTunnelId<DrawController>(rId)) - { - nResult = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); - } - - return nResult; + return comphelper::getSomethingImpl(rId, this); } //===== Properties ============================================================ diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 55d1ff923d92..632be3183bef 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -344,13 +344,11 @@ const css::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() noex sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) { - if( comphelper::isUnoTunnelId<SdXImpressDocument>(rIdentifier) ) - return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); + if (comphelper::isUnoTunnelId<SdrModel>(rIdentifier)) + return comphelper::getSomething_cast(mpDoc); - if( comphelper::isUnoTunnelId<SdrModel>(rIdentifier) ) - return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(mpDoc)); - - return SfxBaseModel::getSomething( rIdentifier ); + return comphelper::getSomethingImpl(rIdentifier, this, + comphelper::FallbackToGetSomethingOf<SfxBaseModel>{}); } // XTypeProvider diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 9010a31f448d..e9ff103f34e0 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -330,14 +330,8 @@ const css::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() noexc sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) { - if( comphelper::isUnoTunnelId<SdGenericDrawPage>(rId) ) - { - return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); - } - else - { - return SvxFmDrawPage::getSomething( rId ); - } + return comphelper::getSomethingImpl(rId, this, + comphelper::FallbackToGetSomethingOf<SvxFmDrawPage>{}); } SdGenericDrawPage::SdGenericDrawPage(SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet) diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx index 92bfd880ad55..da624e6094ba 100644 --- a/sd/source/ui/view/ViewTabBar.cxx +++ b/sd/source/ui/view/ViewTabBar.cxx @@ -281,14 +281,7 @@ const Sequence<sal_Int8>& ViewTabBar::getUnoTunnelId() sal_Int64 SAL_CALL ViewTabBar::getSomething (const Sequence<sal_Int8>& rId) { - sal_Int64 nResult = 0; - - if (comphelper::isUnoTunnelId<ViewTabBar>(rId)) - { - nResult = reinterpret_cast<sal_Int64>(this); - } - - return nResult; + return comphelper::getSomethingImpl(rId, this); } bool ViewTabBar::ActivatePage(size_t nIndex) |