sfx2/source/doc/printhelper.cxx | 29 ++++++++++++++--------------- sfx2/source/doc/printhelper.hxx | 2 -- 2 files changed, 14 insertions(+), 17 deletions(-)
New commits: commit 20b41d29f1b66a73179e66413123d7a6752d16ef Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Dec 20 20:14:19 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jan 3 20:55:22 2022 +0100 osl::Mutex->std::mutex in SfxPrintHelper Change-Id: I8a88af7e177f6737e683d398531c914d1766266c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127902 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index 2f0874ea976e..5cbd8e258c72 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -39,7 +39,7 @@ #include <tools/urlobj.hxx> #include <tools/diagnose_ex.h> #include <ucbhelper/content.hxx> -#include <comphelper/multicontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <osl/mutex.hxx> #include <cppuhelper/implbase.hxx> #include <vcl/settings.hxx> @@ -59,12 +59,12 @@ using namespace ::com::sun::star::uno; struct IMPL_PrintListener_DataContainer : public SfxListener { SfxObjectShellRef m_pObjectShell; - comphelper::OMultiTypeInterfaceContainerHelper2 m_aInterfaceContainer; + std::mutex m_aMutex; + comphelper::OInterfaceContainerHelper4<view::XPrintJobListener> m_aJobListeners; uno::Reference< css::view::XPrintJob> m_xPrintJob; css::uno::Sequence< css::beans::PropertyValue > m_aPrintOptions; - explicit IMPL_PrintListener_DataContainer( ::osl::Mutex& aMutex) - : m_aInterfaceContainer ( aMutex ) + explicit IMPL_PrintListener_DataContainer() { } @@ -144,7 +144,7 @@ void SAL_CALL SfxPrintJob_Impl::cancelJob() SfxPrintHelper::SfxPrintHelper() { - m_pData.reset(new IMPL_PrintListener_DataContainer(m_aMutex)); + m_pData.reset(new IMPL_PrintListener_DataContainer()); } void SAL_CALL SfxPrintHelper::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) @@ -781,30 +781,29 @@ void IMPL_PrintListener_DataContainer::Notify( SfxBroadcaster& rBC, const SfxHin m_aPrintOptions = pPrintHint->GetOptions(); } - comphelper::OInterfaceContainerHelper2* pContainer = m_aInterfaceContainer.getContainer( - cppu::UnoType<view::XPrintJobListener>::get()); - if ( !pContainer ) + std::unique_lock aGuard(m_aMutex); + if (!m_aJobListeners.getLength()) return; - view::PrintJobEvent aEvent; aEvent.Source = m_xPrintJob; aEvent.State = pPrintHint->GetWhich(); - comphelper::OInterfaceIteratorHelper2 pIterator(*pContainer); + comphelper::OInterfaceIteratorHelper4 pIterator(m_aJobListeners); + aGuard.unlock(); while (pIterator.hasMoreElements()) - static_cast<view::XPrintJobListener*>(pIterator.next())->printJobEvent( aEvent ); + pIterator.next()->printJobEvent( aEvent ); } void SAL_CALL SfxPrintHelper::addPrintJobListener( const css::uno::Reference< css::view::XPrintJobListener >& xListener ) { - SolarMutexGuard aGuard; - m_pData->m_aInterfaceContainer.addInterface( cppu::UnoType<view::XPrintJobListener>::get(), xListener ); + std::unique_lock aGuard(m_pData->m_aMutex); + m_pData->m_aJobListeners.addInterface( xListener ); } void SAL_CALL SfxPrintHelper::removePrintJobListener( const css::uno::Reference< css::view::XPrintJobListener >& xListener ) { - SolarMutexGuard aGuard; - m_pData->m_aInterfaceContainer.removeInterface( cppu::UnoType<view::XPrintJobListener>::get(), xListener ); + std::unique_lock aGuard(m_pData->m_aMutex); + m_pData->m_aJobListeners.removeInterface( xListener ); } diff --git a/sfx2/source/doc/printhelper.hxx b/sfx2/source/doc/printhelper.hxx index b1f12c90ee53..a38e3d7a4981 100644 --- a/sfx2/source/doc/printhelper.hxx +++ b/sfx2/source/doc/printhelper.hxx @@ -31,7 +31,6 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/lang/XInitialization.hpp> -#include <osl/mutex.hxx> #include <cppuhelper/implbase.hxx> struct IMPL_PrintListener_DataContainer; @@ -57,7 +56,6 @@ public: private: - osl::Mutex m_aMutex; std::unique_ptr<IMPL_PrintListener_DataContainer> m_pData ; void impl_setPrinter(const css::uno::Sequence< css::beans::PropertyValue >& rPrinter, VclPtr<SfxPrinter>& pPrinter,