sd/source/ui/inc/DrawController.hxx | 2 + sd/source/ui/tools/EventMultiplexer.cxx | 24 ++++++--------- sd/source/ui/unoidl/DrawController.cxx | 8 +++++ sd/source/ui/unoidl/unolayer.cxx | 50 +++++--------------------------- sd/source/ui/unoidl/unolayer.hxx | 2 - sd/source/ui/unoidl/unowcntr.cxx | 25 ++++++++-------- sd/source/ui/unoidl/unowcntr.hxx | 14 ++++---- 7 files changed, 49 insertions(+), 76 deletions(-)
New commits: commit 77a58b5f7c85e8036606791ee6fe2fb763eaab0d Author: Noel Grandin <[email protected]> AuthorDate: Wed Sep 18 11:08:14 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Sep 18 21:33:11 2024 +0200 use more concrete UNO types in sd Change-Id: I07e1db5a771c0a2391afbd715c91ea5919e19ac0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173606 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sd/source/ui/inc/DrawController.hxx b/sd/source/ui/inc/DrawController.hxx index c935888fa92c..f856df0d00b2 100644 --- a/sd/source/ui/inc/DrawController.hxx +++ b/sd/source/ui/inc/DrawController.hxx @@ -223,6 +223,8 @@ public: virtual css::uno::Reference<css::drawing::framework::XModuleController> SAL_CALL getModuleController() override; + rtl::Reference<sd::framework::ConfigurationController> getConfigurationControllerImpl(); + private: /** This method must return the name to index table. This table contains all property names and types of this object. diff --git a/sd/source/ui/tools/EventMultiplexer.cxx b/sd/source/ui/tools/EventMultiplexer.cxx index 5e20b9cc1f33..20f3b6e5e518 100644 --- a/sd/source/ui/tools/EventMultiplexer.cxx +++ b/sd/source/ui/tools/EventMultiplexer.cxx @@ -24,6 +24,7 @@ #include <DrawController.hxx> #include <SlideSorterViewShell.hxx> #include <framework/FrameworkHelper.hxx> +#include <framework/ConfigurationController.hxx> #include <sal/log.hxx> #include <tools/debug.hxx> @@ -122,7 +123,7 @@ private: css::uno::WeakReference<css::frame::XController> mxControllerWeak; css::uno::WeakReference<css::frame::XFrame> mxFrameWeak; SdDrawDocument* mpDocument; - css::uno::WeakReference<css::drawing::framework::XConfigurationController> + unotools::WeakReference<sd::framework::ConfigurationController> mxConfigurationControllerWeak; void ReleaseListeners(); @@ -214,15 +215,13 @@ EventMultiplexer::Implementation::Implementation (ViewShellBase& rBase) // Listen for configuration changes. DrawController& rDrawController = *mrBase.GetDrawController(); - Reference<XConfigurationController> xConfigurationController ( - rDrawController.getConfigurationController()); - mxConfigurationControllerWeak = xConfigurationController; + rtl::Reference<sd::framework::ConfigurationController> xConfigurationController ( + rDrawController.getConfigurationControllerImpl()); + mxConfigurationControllerWeak = xConfigurationController.get(); if (!xConfigurationController.is()) return; - Reference<XComponent> xComponent (xConfigurationController, UNO_QUERY); - if (xComponent.is()) - xComponent->addEventListener(static_cast<beans::XPropertyChangeListener*>(this)); + xConfigurationController->addEventListener(static_cast<beans::XPropertyChangeListener*>(this)); xConfigurationController->addConfigurationChangeListener( this, @@ -268,13 +267,10 @@ void EventMultiplexer::Implementation::ReleaseListeners() } // Stop listening for configuration changes. - Reference<XConfigurationController> xConfigurationController (mxConfigurationControllerWeak); + rtl::Reference<sd::framework::ConfigurationController> xConfigurationController (mxConfigurationControllerWeak.get()); if (xConfigurationController.is()) { - Reference<XComponent> xComponent (xConfigurationController, UNO_QUERY); - if (xComponent.is()) - xComponent->removeEventListener(static_cast<beans::XPropertyChangeListener*>(this)); - + xConfigurationController->removeEventListener(static_cast<beans::XPropertyChangeListener*>(this)); xConfigurationController->removeConfigurationChangeListener(this); } } @@ -418,10 +414,10 @@ void SAL_CALL EventMultiplexer::Implementation::disposing ( } } - Reference<XConfigurationController> xConfigurationController ( + rtl::Reference<sd::framework::ConfigurationController> xConfigurationController ( mxConfigurationControllerWeak); if (xConfigurationController.is() - && rEventObject.Source == xConfigurationController) + && rEventObject.Source == cppu::getXWeak(xConfigurationController.get())) { mxConfigurationControllerWeak.clear(); } diff --git a/sd/source/ui/unoidl/DrawController.cxx b/sd/source/ui/unoidl/DrawController.cxx index 813b07477076..d35578616777 100644 --- a/sd/source/ui/unoidl/DrawController.cxx +++ b/sd/source/ui/unoidl/DrawController.cxx @@ -561,6 +561,14 @@ Reference<XConfigurationController> SAL_CALL return mxConfigurationController; } +rtl::Reference<sd::framework::ConfigurationController> + DrawController::getConfigurationControllerImpl() +{ + ThrowIfDisposed(); + + return mxConfigurationController; +} + Reference<XModuleController> SAL_CALL DrawController::getModuleController() { commit 20c7dd09f2485838a0d230efe0a1c36d5b22723f Author: Noel Grandin <[email protected]> AuthorDate: Wed Sep 18 11:01:11 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Sep 18 21:33:03 2024 +0200 use more concrete UNO types in sd Change-Id: I01e30ca54b909da84c3bf535842d2c2283c31451 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173605 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx index f6bfcb9265cd..abc5bf309052 100644 --- a/sd/source/ui/unoidl/unolayer.cxx +++ b/sd/source/ui/unoidl/unolayer.cxx @@ -561,7 +561,7 @@ uno::Any SAL_CALL SdLayerManager::getByName( const OUString& aName ) if( pLayer == nullptr ) throw container::NoSuchElementException(); - return uno::Any( GetLayer (pLayer) ); + return uno::Any( css::uno::Reference< css::drawing::XLayer>(GetLayer(pLayer)) ); } uno::Sequence< OUString > SAL_CALL SdLayerManager::getElementNames() @@ -644,57 +644,23 @@ void SdLayerManager::UpdateLayerView() const noexcept return nullptr; } -namespace -{ -/** Compare two pointers to <type>SdrLayer</type> objects. - @param xRef - The implementing SdLayer class provides the first pointer by the - <member>SdLayer::GetSdrLayer</member> method. - @param pSearchData - This void pointer is the second pointer to an <type>SdrLayer</type> - object. - @return - Return </True> if both pointers point to the same object. -*/ -bool compare_layers (const uno::WeakReference<uno::XInterface>& xRef, void const * pSearchData) -{ - uno::Reference<uno::XInterface> xLayer (xRef); - if (xLayer.is()) - { - SdLayer* pSdLayer = dynamic_cast<SdLayer*> (xLayer.get()); - if (pSdLayer != nullptr) - { - SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer (); - if (pSdrLayer == static_cast<SdrLayer const *>(pSearchData)) - return true; - } - } - return false; -} -} - /** Use the <member>mpLayers</member> container of weak references to either retrieve and return a previously created <type>XLayer</type> object for the given <type>SdrLayer</type> object or create and remember a new one. */ -uno::Reference<drawing::XLayer> SdLayerManager::GetLayer (SdrLayer* pLayer) +rtl::Reference<SdLayer> SdLayerManager::GetLayer (SdrLayer* pLayer) { - uno::WeakReference<uno::XInterface> xRef; - uno::Reference<drawing::XLayer> xLayer; + rtl::Reference<SdLayer> xLayer; // Search existing xLayer for the given pLayer. - if (mpLayers->findRef (xRef, static_cast<void*>(pLayer), compare_layers)) - xLayer.set(xRef, uno::UNO_QUERY); + if (mpLayers->findRef(xLayer, pLayer)) + return xLayer; // Create the xLayer if necessary. - if ( ! xLayer.is()) - { - xLayer = new SdLayer (this, pLayer); + xLayer = new SdLayer (this, pLayer); - // Remember the new xLayer for future calls. - uno::WeakReference<uno::XInterface> wRef(xLayer); - mpLayers->insert(wRef); - } + // Remember the new xLayer for future calls. + mpLayers->insert(xLayer); return xLayer; } diff --git a/sd/source/ui/unoidl/unolayer.hxx b/sd/source/ui/unoidl/unolayer.hxx index 42f9b868341f..f96634f536ff 100644 --- a/sd/source/ui/unoidl/unolayer.hxx +++ b/sd/source/ui/unoidl/unolayer.hxx @@ -142,7 +142,7 @@ public: associated with the specified argument. If no layer can be created for the argument than an empty reference is returned. */ - css::uno::Reference< css::drawing::XLayer> GetLayer (SdrLayer* pLayer); + rtl::Reference<SdLayer> GetLayer (SdrLayer* pLayer); // XComponent virtual void SAL_CALL dispose( ) override; diff --git a/sd/source/ui/unoidl/unowcntr.cxx b/sd/source/ui/unoidl/unowcntr.cxx index 1079477ef379..b7522e6560af 100644 --- a/sd/source/ui/unoidl/unowcntr.cxx +++ b/sd/source/ui/unoidl/unowcntr.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include "unowcntr.hxx" +#include "unolayer.hxx" using namespace ::com::sun::star; @@ -32,19 +33,19 @@ SvUnoWeakContainer::~SvUnoWeakContainer() noexcept } /** inserts the given ref into this container */ -void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xRef ) noexcept +void SvUnoWeakContainer::insert( const rtl::Reference< SdLayer >& xRef ) noexcept { for ( auto it = maVector.begin(); it != maVector.end(); ) { - uno::WeakReference< uno::XInterface > & rWeakRef = *it; - uno::Reference< uno::XInterface > xTestRef( rWeakRef ); + unotools::WeakReference< SdLayer > & rWeakRef = *it; + rtl::Reference< SdLayer > xTestRef( rWeakRef ); if ( !xTestRef.is() ) { it = maVector.erase( it ); } else { - if ( rWeakRef == xRef ) + if ( xTestRef == xRef ) return; ++it; } @@ -56,24 +57,24 @@ void SvUnoWeakContainer::insert( const uno::WeakReference< uno::XInterface >& xR search function */ bool SvUnoWeakContainer::findRef( - uno::WeakReference< uno::XInterface >& rRef, - void const * pSearchData, - weakref_searchfunc pSearchFunc + rtl::Reference< SdLayer >& rRef, + SdrLayer const * pSearchData ) { for ( auto it = maVector.begin(); it != maVector.end(); ) { - uno::WeakReference< uno::XInterface > & itRef = *it; - uno::Reference< uno::XInterface > xTestRef( itRef ); - if ( !xTestRef.is() ) + unotools::WeakReference< SdLayer > & itRef = *it; + rtl::Reference< SdLayer > pSdLayer( itRef ); + if ( !pSdLayer.is() ) { it = maVector.erase( it ); } else { - if( (*pSearchFunc)( itRef, pSearchData ) ) + SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer (); + if (pSdrLayer == pSearchData) { - rRef = itRef; + rRef = pSdLayer; return true; } ++it; diff --git a/sd/source/ui/unoidl/unowcntr.hxx b/sd/source/ui/unoidl/unowcntr.hxx index a863f09291eb..4e0141fe7e60 100644 --- a/sd/source/ui/unoidl/unowcntr.hxx +++ b/sd/source/ui/unoidl/unowcntr.hxx @@ -19,27 +19,27 @@ #pragma once -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> #include <vector> -typedef bool (*weakref_searchfunc)( const css::uno::WeakReference< css::uno::XInterface >& xRef, void const * pSearchData ); +class SdLayer; +class SdrLayer; class SvUnoWeakContainer { private: - std::vector< css::uno::WeakReference< css::uno::XInterface > > maVector; + std::vector< unotools::WeakReference< SdLayer > > maVector; public: SvUnoWeakContainer() noexcept; ~SvUnoWeakContainer() noexcept; /** inserts the given ref into this container */ - void insert( const css::uno::WeakReference< css::uno::XInterface >& xRef ) noexcept; + void insert( const rtl::Reference< SdLayer >& xRef ) noexcept; - /** searches the container for a ref that returns true on the given - search function + /** searches the container for a matching SdrLayer */ - bool findRef( css::uno::WeakReference< css::uno::XInterface >& rRef, void const * pSearchData, weakref_searchfunc pSearchFunc ); + bool findRef( rtl::Reference< SdLayer >& rRef, const SdrLayer * pSearchData ); void dispose(); };
