diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx index 28fe88b02b38..d193ad8c9def 100644 --- a/embeddedobj/source/inc/oleembobj.hxx +++ b/embeddedobj/source/inc/oleembobj.hxx @@ -258,7 +258,8 @@ protected: /// @throws css::uno::Exception void InsertVisualCache_Impl( const css::uno::Reference< css::io::XStream >& xTargetStream, - const css::uno::Reference< css::io::XStream >& xCachedVisualRepresentation ); + const css::uno::Reference< css::io::XStream >& xCachedVisualRepresentation, + osl::ResettableMutexGuard& rGuard); /// @throws css::uno::Exception void RemoveVisualCache_Impl( const css::uno::Reference< css::io::XStream >& xTargetStream ); @@ -453,6 +454,9 @@ public: OUString SAL_CALL getImplementationName() override; sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + +private: + css::awt::Size getVisualAreaSize_impl(sal_Int64 nAspect, osl::ResettableMutexGuard& guard); }; namespace diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index 1ddc02b27c8b..9a9a54a7eb8b 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -353,7 +353,8 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToGetAcceptableFormat_Impl( void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStream >& xTargetStream, - const uno::Reference< io::XStream >& xCachedVisualRepresentation ) + const uno::Reference< io::XStream >& xCachedVisualRepresentation, + osl::ResettableMutexGuard& rGuard ) { OSL_ENSURE( xTargetStream.is() && xCachedVisualRepresentation.is(), "Invalid arguments!" ); @@ -433,7 +434,7 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea xTempOutStream->writeBytes( aData ); // get the size - awt::Size aSize = getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); + awt::Size aSize = getVisualAreaSize_impl(embed::Aspects::MSOLE_CONTENT, rGuard); sal_Int32 nIndex = 0; // write width @@ -1223,7 +1224,7 @@ void OleEmbeddedObject::StoreToLocation_Impl( } } - InsertVisualCache_Impl( xTargetStream, xCachedVisualRepresentation ); + InsertVisualCache_Impl(xTargetStream, xCachedVisualRepresentation, rGuard); } else { @@ -1600,7 +1601,7 @@ void SAL_CALL OleEmbeddedObject::saveCompleted( sal_Bool bUseNew ) { // the call will cache the size in case of success // probably it might need to be done earlier, while the object is in active state - getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); + getVisualAreaSize_impl(embed::Aspects::MSOLE_CONTENT, aGuard); } catch( const uno::Exception& ) {} @@ -1750,7 +1751,7 @@ void SAL_CALL OleEmbeddedObject::storeOwn() { // the m_xCachedVisualRepresentation must be set or it should be already stored if ( m_xCachedVisualRepresentation.is() ) - InsertVisualCache_Impl( m_xObjectStream, m_xCachedVisualRepresentation ); + InsertVisualCache_Impl(m_xObjectStream, m_xCachedVisualRepresentation, aGuard); else { m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream, aGuard ); @@ -1775,7 +1776,7 @@ void SAL_CALL OleEmbeddedObject::storeOwn() { // the call will cache the size in case of success // probably it might need to be done earlier, while the object is in active state - getVisualAreaSize( embed::Aspects::MSOLE_CONTENT ); + getVisualAreaSize_impl(embed::Aspects::MSOLE_CONTENT, aGuard); } catch( const uno::Exception& ) {} diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx index 539933278e45..bcee997c189e 100644 --- a/embeddedobj/source/msole/olevisual.cxx +++ b/embeddedobj/source/msole/olevisual.cxx @@ -155,18 +155,19 @@ void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt m_nCachedAspect = nAspect; } -awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) +awt::Size OleEmbeddedObject::getVisualAreaSize_impl(sal_Int64 nAspect, + osl::ResettableMutexGuard& guard) { // begin wrapping related part ==================== uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject; if ( xWrappedObject.is() ) { + osl::ResettableMutexGuardScopedReleaser area(guard); // the object was converted to OOo embedded object, the current implementation is now only a wrapper return xWrappedObject->getVisualAreaSize( nAspect ); } // end wrapping related part ==================== - ::osl::ResettableMutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -197,7 +198,9 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) { // there is no internal cache awt::Size aSize; - aGuard.clear(); + + { // => unguarded + osl::ResettableMutexGuardScopedReleaser area(guard); bool bBackToLoaded = false; @@ -277,7 +280,7 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) "No size available!", static_cast< ::cppu::OWeakObject* >(this) ); - aGuard.reset(); + } // <= unguarded m_aCachedSize = aSize; m_nCachedAspect = nAspect; @@ -314,6 +317,12 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) return aResult; } +awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) +{ + osl::ResettableMutexGuard aGuard(m_aMutex); + return getVisualAreaSize_impl(nAspect, aGuard); +} + embed::VisualRepresentation SAL_CALL OleEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect ) { // begin wrapping related part ====================