canvas/source/vcl/canvasfont.cxx | 15 +++--- canvas/source/vcl/canvasfont.hxx | 10 +--- framework/source/fwe/helper/titlehelper.cxx | 65 ++++++++++++++-------------- include/framework/titlehelper.hxx | 11 ++-- 4 files changed, 52 insertions(+), 49 deletions(-)
New commits: commit 6e4ba9b13d81a9d2f7476bf4fbf21a9eb8dc2371 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 27 16:32:16 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Mar 30 18:01:46 2024 +0100 convert TitleHelper to comphelper::WeakImplHelper Change-Id: I81571a0786a4d13e049dba82ba6e4f3509887fa4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165572 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx index c5e0255a2a41..58c28f8f8ef9 100644 --- a/framework/source/fwe/helper/titlehelper.cxx +++ b/framework/source/fwe/helper/titlehelper.cxx @@ -50,13 +50,12 @@ namespace framework{ TitleHelper::TitleHelper(css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::uno::XInterface >& xOwner, const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers) - : ::cppu::BaseMutex () - , m_xContext (std::move(xContext)) + : + m_xContext (std::move(xContext)) , m_xOwner (xOwner) , m_xUntitledNumbers(xNumbers) , m_bExternalTitle (false) , m_nLeasedNumber (css::frame::UntitledNumbersConst::INVALID_NUMBER) - , m_aListener (m_aMutex) { if (css::uno::Reference<css::frame::XModel> xModel{ xOwner, css::uno::UNO_QUERY }) { @@ -80,7 +79,7 @@ TitleHelper::~TitleHelper() OUString SAL_CALL TitleHelper::getTitle() { // SYNCHRONIZED -> - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // An external title will win always and disable all internal logic about // creating/using a title value. @@ -93,7 +92,9 @@ OUString SAL_CALL TitleHelper::getTitle() return m_sTitle; // Title seems to be unused till now ... do bootstrapping + aLock.unlock(); impl_updateTitle (true); + aLock.lock(); return m_sTitle; // <- SYNCHRONIZED @@ -103,7 +104,7 @@ void SAL_CALL TitleHelper::setTitle(const OUString& sTitle) { // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); m_bExternalTitle = true; m_sTitle = sTitle; @@ -115,14 +116,14 @@ void SAL_CALL TitleHelper::setTitle(const OUString& sTitle) void SAL_CALL TitleHelper::addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) { - // container is threadsafe by himself - m_aListener.addInterface( cppu::UnoType<css::frame::XTitleChangeListener>::get(), xListener ); + std::unique_lock aLock(m_aMutex); + m_aTitleChangeListeners.addInterface( aLock, xListener ); } void SAL_CALL TitleHelper::removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) { - // container is threadsafe by himself - m_aListener.removeInterface( cppu::UnoType<css::frame::XTitleChangeListener>::get(), xListener ); + std::unique_lock aLock(m_aMutex); + m_aTitleChangeListeners.removeInterface( aLock, xListener ); } void SAL_CALL TitleHelper::titleChanged(const css::frame::TitleChangedEvent& aEvent) @@ -130,7 +131,7 @@ void SAL_CALL TitleHelper::titleChanged(const css::frame::TitleChangedEvent& aEv css::uno::Reference< css::frame::XTitle > xSubTitle; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xSubTitle = m_xSubTitle; } @@ -152,7 +153,7 @@ void SAL_CALL TitleHelper::documentEventOccured(const css::document::DocumentEve css::uno::Reference< css::frame::XModel > xOwner; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xOwner.set(m_xOwner, css::uno::UNO_QUERY); } @@ -174,7 +175,7 @@ void SAL_CALL TitleHelper::frameAction(const css::frame::FrameActionEvent& aEven css::uno::Reference< css::frame::XFrame > xOwner; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xOwner.set(m_xOwner, css::uno::UNO_QUERY); } @@ -203,7 +204,7 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent) ::sal_Int32 nLeasedNumber; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xOwner = m_xOwner; xNumbers = m_xUntitledNumbers; @@ -229,7 +230,7 @@ void SAL_CALL TitleHelper::disposing(const css::lang::EventObject& aEvent) // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); m_xOwner.clear(); m_sTitle.clear(); @@ -243,7 +244,7 @@ void TitleHelper::impl_sendTitleChangedEvent () css::uno::Reference<css::uno::XInterface> xOwner; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xOwner = m_xOwner; } @@ -254,21 +255,23 @@ void TitleHelper::impl_sendTitleChangedEvent () if( ! aEvent.Source.is() ) return; - comphelper::OInterfaceContainerHelper2* pContainer = m_aListener.getContainer( cppu::UnoType<css::frame::XTitleChangeListener>::get()); - if ( ! pContainer) - return; - - comphelper::OInterfaceIteratorHelper2 pIt( *pContainer ); + std::unique_lock aLock(m_aMutex); + comphelper::OInterfaceIteratorHelper4 pIt( aLock, m_aTitleChangeListeners ); while ( pIt.hasMoreElements() ) { + aLock.unlock(); try { - static_cast<css::frame::XTitleChangeListener*>(pIt.next())->titleChanged( aEvent ); + uno::Reference<css::frame::XTitleChangeListener> i = pIt.next(); + i->titleChanged( aEvent ); } catch(const css::uno::Exception&) { - pIt.remove(); + aLock.lock(); + pIt.remove(aLock); + aLock.unlock(); } + aLock.lock(); } } @@ -278,7 +281,7 @@ void TitleHelper::impl_updateTitle (bool init) // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xOwner = m_xOwner; } @@ -313,7 +316,7 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram ::sal_Int32 nLeasedNumber; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // external title won't be updated internally! // It has to be set from outside new. @@ -373,7 +376,7 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram bool bChanged; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // WORKAROUND: the notification is currently sent always, // can be changed after shared mode is supported per UNO API @@ -395,7 +398,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css: ::sal_Int32 nLeasedNumber; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // external title won't be updated internally! // It has to be set from outside new. @@ -454,7 +457,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css: bool bChanged; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); OUString sNewTitle = sTitle.makeStringAndClear (); bChanged = !init && m_sTitle != sNewTitle; @@ -474,7 +477,7 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // external title won't be updated internally! // It has to be set from outside new. @@ -505,7 +508,7 @@ void TitleHelper::impl_updateTitleForFrame (const css::uno::Reference< css::fram bool bChanged; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); OUString sNewTitle = sTitle.makeStringAndClear (); bChanged = !init && m_sTitle != sNewTitle; @@ -549,7 +552,7 @@ void TitleHelper::impl_appendModuleName (OUStringBuffer& sTitle) css::uno::Reference< css::uno::XComponentContext > xContext; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); xOwner = m_xOwner; xContext = m_xContext; @@ -635,7 +638,7 @@ void TitleHelper::impl_setSubTitle (const css::uno::Reference< css::frame::XTitl css::uno::Reference< css::frame::XTitle > xOldSubTitle; // SYNCHRONIZED -> { - osl::MutexGuard aLock(m_aMutex); + std::unique_lock aLock(m_aMutex); // ignore duplicate calls. Makes outside using of this helper more easy :-) xOldSubTitle = m_xSubTitle; diff --git a/include/framework/titlehelper.hxx b/include/framework/titlehelper.hxx index 064bfe8cc7b7..c87111064f0d 100644 --- a/include/framework/titlehelper.hxx +++ b/include/framework/titlehelper.hxx @@ -27,10 +27,9 @@ #include <com/sun/star/frame/XFrameActionListener.hpp> #include <com/sun/star/document/XDocumentEventListener.hpp> -#include <cppuhelper/basemutex.hxx> #include <cppuhelper/weakref.hxx> -#include <cppuhelper/implbase.hxx> -#include <comphelper/multicontainer2.hxx> +#include <comphelper/compbase.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <rtl/ustrbuf.hxx> @@ -51,8 +50,8 @@ namespace framework{ @threadsafe */ -class UNLESS_MERGELIBS_MORE(FWK_DLLPUBLIC) TitleHelper final : private ::cppu::BaseMutex - , public ::cppu::WeakImplHelper< css::frame::XTitle , +class UNLESS_MERGELIBS_MORE(FWK_DLLPUBLIC) TitleHelper final : + public ::comphelper::WeakImplHelper< css::frame::XTitle , css::frame::XTitleChangeBroadcaster, css::frame::XTitleChangeListener , css::frame::XFrameActionListener , @@ -172,7 +171,7 @@ class UNLESS_MERGELIBS_MORE(FWK_DLLPUBLIC) TitleHelper final : private ::cppu::B ::sal_Int32 m_nLeasedNumber; /** contains all title change listener */ - comphelper::OMultiTypeInterfaceContainerHelper2 m_aListener; + comphelper::OInterfaceContainerHelper4<css::frame::XTitleChangeListener> m_aTitleChangeListeners; }; } // namespace framework commit 62d5b1ae8db0292d03ee2747aab42bac8c0d3379 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 27 16:35:35 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Mar 30 18:01:34 2024 +0100 convert CanvasFont to comphelper::WeakComponentImplHelper Change-Id: I91aab0365aa57670d484228797f97a2675894cd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165573 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/canvas/source/vcl/canvasfont.cxx b/canvas/source/vcl/canvasfont.cxx index d827368969ba..b587a5b64167 100644 --- a/canvas/source/vcl/canvasfont.cxx +++ b/canvas/source/vcl/canvasfont.cxx @@ -41,7 +41,6 @@ namespace vclcanvas const geometry::Matrix2D& rFontMatrix, rendering::XGraphicDevice& rDevice, const OutDevProviderSharedPtr& rOutDevProvider ) : - CanvasFont_Base( m_aMutex ), maFont( vcl::Font( rFontRequest.FontDescription.FamilyName, rFontRequest.FontDescription.StyleName, Size( 0, ::basegfx::fround(rFontRequest.CellSize) ) ) ), @@ -74,12 +73,16 @@ namespace vclcanvas maFont->SetEmphasisMark(FontEmphasisMark(nEmphasisMark)); } - void SAL_CALL CanvasFont::disposing() + void CanvasFont::disposing(std::unique_lock<std::mutex>& rGuard) { - SolarMutexGuard aGuard; - - mpOutDevProvider.reset(); - mpRefDevice.clear(); + rGuard.unlock(); + { + SolarMutexGuard aGuard; + + mpOutDevProvider.reset(); + mpRefDevice.clear(); + } + rGuard.lock(); } uno::Reference< rendering::XTextLayout > SAL_CALL CanvasFont::createTextLayout( const rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 ) diff --git a/canvas/source/vcl/canvasfont.hxx b/canvas/source/vcl/canvasfont.hxx index 834df756e0b7..3e64d3d9f60d 100644 --- a/canvas/source/vcl/canvasfont.hxx +++ b/canvas/source/vcl/canvasfont.hxx @@ -19,8 +19,7 @@ #pragma once -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/compbase.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/geometry/Matrix2D.hpp> @@ -39,11 +38,10 @@ namespace vclcanvas { - typedef ::cppu::WeakComponentImplHelper< css::rendering::XCanvasFont, + typedef ::comphelper::WeakComponentImplHelper< css::rendering::XCanvasFont, css::lang::XServiceInfo > CanvasFont_Base; - class CanvasFont : public ::cppu::BaseMutex, - public CanvasFont_Base + class CanvasFont : public CanvasFont_Base { public: typedef rtl::Reference<CanvasFont> Reference; @@ -59,7 +57,7 @@ namespace vclcanvas const OutDevProviderSharedPtr& rOutDevProvider ); /// Dispose all internal references - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; // XCanvasFont virtual css::uno::Reference< css::rendering::XTextLayout > SAL_CALL createTextLayout( const css::rendering::StringContext& aText, sal_Int8 nDirection, sal_Int64 nRandomSeed ) override;