unotools/source/ucbhelper/XTempFile.hxx | 4 +- unotools/source/ucbhelper/xtempfile.cxx | 61 ++++++++++++++++---------------- unoxml/inc/event.hxx | 3 + unoxml/source/events/event.cxx | 18 ++++----- unoxml/source/events/mouseevent.cxx | 21 +++++------ unoxml/source/events/mutationevent.cxx | 15 ++++--- unoxml/source/events/uievent.cxx | 7 +-- 7 files changed, 66 insertions(+), 63 deletions(-)
New commits: commit 870a3b5bc34d5d4082b46940822d871106cac2d9 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Dec 23 21:38:41 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Dec 25 07:15:33 2021 +0100 osl::Mutex->std::mutex in CEvent Change-Id: I644ebf86803448e824818f571d6612741408d02c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127402 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/unoxml/inc/event.hxx b/unoxml/inc/event.hxx index c33d8f9d3b3c..216bf2775ed4 100644 --- a/unoxml/inc/event.hxx +++ b/unoxml/inc/event.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/util/Time.hpp> #include <cppuhelper/implbase.hxx> +#include <mutex> namespace DOM::events { @@ -35,7 +36,7 @@ class CEvent : public cppu::WeakImplHelper< css::xml::dom::events::XEvent > friend class CEventDispatcher; protected: - ::osl::Mutex m_Mutex; + std::mutex m_Mutex; bool m_canceled; OUString m_eventType; css::uno::Reference< css::xml::dom::events::XEventTarget > m_target; diff --git a/unoxml/source/events/event.cxx b/unoxml/source/events/event.cxx index bc12bb5f83c1..e3b092ff3831 100644 --- a/unoxml/source/events/event.cxx +++ b/unoxml/source/events/event.cxx @@ -39,52 +39,52 @@ namespace DOM::events OUString SAL_CALL CEvent::getType() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_eventType; } Reference< XEventTarget > SAL_CALL CEvent::getTarget() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_target; } Reference< XEventTarget > SAL_CALL CEvent::getCurrentTarget() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_currentTarget; } PhaseType SAL_CALL CEvent::getEventPhase() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_phase; } sal_Bool SAL_CALL CEvent::getBubbles() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_bubbles; } sal_Bool SAL_CALL CEvent::getCancelable() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_cancelable; } css::util::Time SAL_CALL CEvent::getTimeStamp() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_time; } void SAL_CALL CEvent::stopPropagation() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); if (m_cancelable) { m_canceled = true; } } @@ -96,7 +96,7 @@ namespace DOM::events CEvent::initEvent(OUString const& eventTypeArg, sal_Bool canBubbleArg, sal_Bool cancelableArg) { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); m_eventType = eventTypeArg; m_bubbles = canBubbleArg; diff --git a/unoxml/source/events/mouseevent.cxx b/unoxml/source/events/mouseevent.cxx index ee22b8905c70..4ae8a1b55741 100644 --- a/unoxml/source/events/mouseevent.cxx +++ b/unoxml/source/events/mouseevent.cxx @@ -40,47 +40,47 @@ namespace DOM::events sal_Int32 SAL_CALL CMouseEvent::getScreenX() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_screenX; } sal_Int32 SAL_CALL CMouseEvent::getScreenY() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_screenY; } sal_Int32 SAL_CALL CMouseEvent::getClientX() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_clientX; } sal_Int32 SAL_CALL CMouseEvent::getClientY() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_clientY; } sal_Bool SAL_CALL CMouseEvent::getCtrlKey() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_ctrlKey; } sal_Bool SAL_CALL CMouseEvent::getShiftKey() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_shiftKey; } sal_Bool SAL_CALL CMouseEvent::getAltKey() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_altKey; } sal_Bool SAL_CALL CMouseEvent::getMetaKey() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_metaKey; } sal_Int16 SAL_CALL CMouseEvent::getButton() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_button; } Reference< XEventTarget > SAL_CALL CMouseEvent::getRelatedTarget() @@ -105,9 +105,8 @@ namespace DOM::events sal_Int16 buttonArg, const Reference< XEventTarget >& /*relatedTargetArg*/) { - ::osl::MutexGuard const g(m_Mutex); - CUIEvent::initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); + std::unique_lock const g(m_Mutex); m_screenX = screenXArg; m_screenY = screenYArg; m_clientX = clientXArg; diff --git a/unoxml/source/events/mutationevent.cxx b/unoxml/source/events/mutationevent.cxx index 216c2b164022..8ef91f0e317e 100644 --- a/unoxml/source/events/mutationevent.cxx +++ b/unoxml/source/events/mutationevent.cxx @@ -36,31 +36,31 @@ namespace DOM::events Reference< XNode > SAL_CALL CMutationEvent::getRelatedNode() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_relatedNode; } OUString SAL_CALL CMutationEvent::getPrevValue() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_prevValue; } OUString SAL_CALL CMutationEvent::getNewValue() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_newValue; } OUString SAL_CALL CMutationEvent::getAttrName() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_attrName; } AttrChangeType SAL_CALL CMutationEvent::getAttrChange() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_attrChangeType; } @@ -70,9 +70,10 @@ namespace DOM::events const OUString& newValueArg, const OUString& attrNameArg, AttrChangeType attrChangeArg) { - ::osl::MutexGuard const g(m_Mutex); - CEvent::initEvent(typeArg, canBubbleArg, cancelableArg); + + std::unique_lock const g(m_Mutex); + m_relatedNode = relatedNodeArg; m_prevValue = prevValueArg; m_newValue = newValueArg; diff --git a/unoxml/source/events/uievent.cxx b/unoxml/source/events/uievent.cxx index 6d4092fc6b24..be61ca5cf391 100644 --- a/unoxml/source/events/uievent.cxx +++ b/unoxml/source/events/uievent.cxx @@ -33,13 +33,13 @@ namespace DOM::events Reference< XAbstractView > SAL_CALL CUIEvent::getView() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_view; } sal_Int32 SAL_CALL CUIEvent::getDetail() { - ::osl::MutexGuard const g(m_Mutex); + std::unique_lock const g(m_Mutex); return m_detail; } @@ -49,9 +49,8 @@ namespace DOM::events const Reference< XAbstractView >& viewArg, sal_Int32 detailArg) { - ::osl::MutexGuard const g(m_Mutex); - CEvent::initEvent(typeArg, canBubbleArg, cancelableArg); + std::unique_lock const g(m_Mutex); m_view = viewArg; m_detail = detailArg; } commit 8d17c555ad913b787927ab327586965c04048505 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Dec 23 19:45:46 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Dec 25 07:15:19 2021 +0100 osl::Mutex->std::mutex in OTempFileService Change-Id: If841031faf5b214a1978422b93b59cfa32fcd299 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127400 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/unotools/source/ucbhelper/XTempFile.hxx b/unotools/source/ucbhelper/XTempFile.hxx index a59abd5ae622..7fcaefb7be1f 100644 --- a/unotools/source/ucbhelper/XTempFile.hxx +++ b/unotools/source/ucbhelper/XTempFile.hxx @@ -28,7 +28,7 @@ #include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase.hxx> -#include <osl/mutex.hxx> +#include <mutex> #include <unotools/tempfile.hxx> namespace com::sun::star::uno { class XComponentContext; } @@ -50,7 +50,7 @@ class OTempFileService : public OTempFileBase { protected: std::optional<utl::TempFile> mpTempFile; - ::osl::Mutex maMutex; + std::mutex maMutex; SvStream* mpStream; bool mbRemoveFile; bool mbInClosed; diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx index d0f566c9e26c..a8ace5da6725 100644 --- a/unotools/source/ucbhelper/xtempfile.cxx +++ b/unotools/source/ucbhelper/xtempfile.cxx @@ -56,7 +56,7 @@ css::uno::Sequence< css::uno::Type > SAL_CALL OTempFileService::getTypes( ) sal_Bool SAL_CALL OTempFileService::getRemoveFile() { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( !mpTempFile ) { @@ -68,7 +68,7 @@ sal_Bool SAL_CALL OTempFileService::getRemoveFile() }; void SAL_CALL OTempFileService::setRemoveFile( sal_Bool _removefile ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( !mpTempFile ) { @@ -81,7 +81,7 @@ void SAL_CALL OTempFileService::setRemoveFile( sal_Bool _removefile ) }; OUString SAL_CALL OTempFileService::getUri() { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( !mpTempFile ) { @@ -93,7 +93,7 @@ OUString SAL_CALL OTempFileService::getUri() }; OUString SAL_CALL OTempFileService::getResourceName() { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( !mpTempFile ) { @@ -107,7 +107,7 @@ OUString SAL_CALL OTempFileService::getResourceName() sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbInClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -128,27 +128,28 @@ sal_Int32 SAL_CALL OTempFileService::readBytes( css::uno::Sequence< sal_Int8 >& } sal_Int32 SAL_CALL OTempFileService::readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) { - ::osl::MutexGuard aGuard( maMutex ); - if ( mbInClosed ) - throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); + { + std::unique_lock aGuard( maMutex ); + if ( mbInClosed ) + throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); - checkConnected(); - checkError(); + checkConnected(); + checkError(); - if (nMaxBytesToRead < 0) - throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) ); + if (nMaxBytesToRead < 0) + throw css::io::BufferSizeExceededException( OUString(), static_cast < css::uno::XWeak * >( this ) ); - if (mpStream->eof()) - { - aData.realloc(0); - return 0; + if (mpStream->eof()) + { + aData.realloc(0); + return 0; + } } - else - return readBytes(aData, nMaxBytesToRead); + return readBytes(aData, nMaxBytesToRead); } void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbInClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -159,7 +160,7 @@ void SAL_CALL OTempFileService::skipBytes( sal_Int32 nBytesToSkip ) } sal_Int32 SAL_CALL OTempFileService::available( ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbInClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -172,7 +173,7 @@ sal_Int32 SAL_CALL OTempFileService::available( ) } void SAL_CALL OTempFileService::closeInput( ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbInClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -190,7 +191,7 @@ void SAL_CALL OTempFileService::closeInput( ) void SAL_CALL OTempFileService::writeBytes( const css::uno::Sequence< sal_Int8 >& aData ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -202,7 +203,7 @@ void SAL_CALL OTempFileService::writeBytes( const css::uno::Sequence< sal_Int8 > } void SAL_CALL OTempFileService::flush( ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -212,7 +213,7 @@ void SAL_CALL OTempFileService::flush( ) } void SAL_CALL OTempFileService::closeOutput( ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); if ( mbOutClosed ) throw css::io::NotConnectedException ( OUString(), static_cast < css::uno::XWeak * > (this ) ); @@ -249,9 +250,11 @@ void OTempFileService::checkConnected () void SAL_CALL OTempFileService::seek( sal_Int64 nLocation ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); checkConnected(); - if ( nLocation < 0 || nLocation > getLength() ) + checkError(); + sal_Int64 nEndPos = mpStream->TellEnd(); + if ( nLocation < 0 || nLocation > nEndPos ) throw css::lang::IllegalArgumentException(); mpStream->Seek(static_cast<sal_uInt32>(nLocation) ); @@ -259,7 +262,7 @@ void SAL_CALL OTempFileService::seek( sal_Int64 nLocation ) } sal_Int64 SAL_CALL OTempFileService::getPosition( ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); checkConnected(); sal_uInt32 nPos = mpStream->Tell(); @@ -268,7 +271,7 @@ sal_Int64 SAL_CALL OTempFileService::getPosition( ) } sal_Int64 SAL_CALL OTempFileService::getLength( ) { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); checkConnected(); checkError(); @@ -294,7 +297,7 @@ css::uno::Reference< css::io::XOutputStream > SAL_CALL OTempFileService::getOutp void SAL_CALL OTempFileService::truncate() { - ::osl::MutexGuard aGuard( maMutex ); + std::unique_lock aGuard( maMutex ); checkConnected(); // SetStreamSize() call does not change the position mpStream->Seek( 0 );