diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-23 09:43:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-23 13:01:58 +0000 |
commit | bddc275d1e25b4d528e884179bac1b712f6c45a2 (patch) | |
tree | 4fb4a697c0f687e072e77dca4a1bf76c625720e5 /sc | |
parent | 29d795b772cb75ee1d12cc6bcd4d905f1c520a79 (diff) |
osl::Mutex->std::mutex in OleNameOverrideContainer
Change-Id: Ieeeb8f51f4970cbe1214aea493409739a64ac561
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147502
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/excimp8.cxx | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index d5db209a119a..3996e18337b1 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -73,39 +73,41 @@ class OleNameOverrideContainer : public ::cppu::WeakImplHelper< container::XName private: typedef std::unordered_map< OUString, uno::Reference< container::XIndexContainer > > NamedIndexToOleName; NamedIndexToOleName IdToOleNameHash; - ::osl::Mutex m_aMutex; + std::mutex m_aMutex; public: // XElementAccess virtual uno::Type SAL_CALL getElementType( ) override { return cppu::UnoType<container::XIndexContainer>::get(); } virtual sal_Bool SAL_CALL hasElements( ) override { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); return ( !IdToOleNameHash.empty() ); } // XNameAccess virtual uno::Any SAL_CALL getByName( const OUString& aName ) override { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( !hasByName(aName) ) + std::unique_lock aGuard( m_aMutex ); + auto it = IdToOleNameHash.find( aName ); + if ( it == IdToOleNameHash.end() ) throw container::NoSuchElementException(); - return uno::Any( IdToOleNameHash[ aName ] ); + return uno::Any( it->second ); } virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); return comphelper::mapKeysToSequence( IdToOleNameHash); } virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); return ( IdToOleNameHash.find( aName ) != IdToOleNameHash.end() ); } // XNameContainer virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) override { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( hasByName( aName ) ) + std::unique_lock aGuard( m_aMutex ); + auto it = IdToOleNameHash.find( aName ); + if ( it != IdToOleNameHash.end() ) throw container::ElementExistException(); uno::Reference< container::XIndexContainer > xElement; if ( ! ( aElement >>= xElement ) ) @@ -114,19 +116,20 @@ public: } virtual void SAL_CALL removeByName( const OUString& aName ) override { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( IdToOleNameHash.erase( aName ) == 0 ) throw container::NoSuchElementException(); } virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) override { - ::osl::MutexGuard aGuard( m_aMutex ); - if ( !hasByName( aName ) ) + std::unique_lock aGuard( m_aMutex ); + auto it = IdToOleNameHash.find( aName ); + if ( it == IdToOleNameHash.end() ) throw container::NoSuchElementException(); uno::Reference< container::XIndexContainer > xElement; if ( ! ( aElement >>= xElement ) ) throw lang::IllegalArgumentException(); - IdToOleNameHash[ aName ] = xElement; + it->second = xElement; } }; |