diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-14 15:48:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-14 20:39:00 +0200 |
commit | 1c3929a0a1645e802ee18f9c3d3d380375500c72 (patch) | |
tree | 842d6867a8c67837b15d2ff666e1ad1dd694b401 /embeddedobj | |
parent | 9693b491295336955f7ce8359284b67a82ecf28f (diff) |
loplugin:flatten in embeddedobj,emfio
Change-Id: Ibaf5e1a4db1088322cf8c5e127d328b140406197
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92196
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/commonembedding/embedobj.cxx | 54 | ||||
-rw-r--r-- | embeddedobj/source/commonembedding/miscobj.cxx | 124 | ||||
-rw-r--r-- | embeddedobj/source/commonembedding/persistence.cxx | 116 | ||||
-rw-r--r-- | embeddedobj/source/general/docholder.cxx | 70 | ||||
-rw-r--r-- | embeddedobj/source/general/dummyobject.cxx | 52 | ||||
-rw-r--r-- | embeddedobj/source/general/intercept.cxx | 99 | ||||
-rw-r--r-- | embeddedobj/source/msole/oleembed.cxx | 96 | ||||
-rw-r--r-- | embeddedobj/source/msole/olemisc.cxx | 34 | ||||
-rw-r--r-- | embeddedobj/source/msole/ownview.cxx | 34 |
9 files changed, 340 insertions, 339 deletions
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index e6e5bec2a316..6250555e05ec 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -120,39 +120,39 @@ void OCommonEmbeddedObject::Deactivate() void OCommonEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard ) { - if ( m_pInterfaceContainer ) - { - ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( - cppu::UnoType<embed::XStateChangeListener>::get()); - if ( pContainer != nullptr ) - { - lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); - ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + if ( !m_pInterfaceContainer ) + return; - // should be locked after the method is finished successfully - rGuard.clear(); + ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer( + cppu::UnoType<embed::XStateChangeListener>::get()); + if ( pContainer == nullptr ) + return; - while (pIterator.hasMoreElements()) - { - try - { - if ( bBeforeChange ) - static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState ); - else - static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState ); - } - catch( const uno::Exception& ) - { - // even if the listener complains ignore it for now - } + lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); - if ( m_bDisposed ) - return; - } + // should be locked after the method is finished successfully + rGuard.clear(); - rGuard.reset(); + while (pIterator.hasMoreElements()) + { + try + { + if ( bBeforeChange ) + static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState ); + else + static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState ); } + catch( const uno::Exception& ) + { + // even if the listener complains ignore it for now + } + + if ( m_bDisposed ) + return; } + + rGuard.reset(); } diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx index 5947fef7aca0..71f79fabd96d 100644 --- a/embeddedobj/source/commonembedding/miscobj.cxx +++ b/embeddedobj/source/commonembedding/miscobj.cxx @@ -256,34 +256,34 @@ void OCommonEmbeddedObject::LinkInit_Impl( OCommonEmbeddedObject::~OCommonEmbeddedObject() { - if ( m_pInterfaceContainer || m_xDocHolder.is() ) - { - osl_atomic_increment(&m_refCount); - try { - lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); + if ( !(m_pInterfaceContainer || m_xDocHolder.is()) ) + return; - if ( m_pInterfaceContainer ) - { - m_pInterfaceContainer->disposeAndClear( aSource ); + osl_atomic_increment(&m_refCount); + try { + lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) ); - delete m_pInterfaceContainer; - m_pInterfaceContainer = nullptr; - } - } catch( const uno::Exception& ) {} + if ( m_pInterfaceContainer ) + { + m_pInterfaceContainer->disposeAndClear( aSource ); - try { - if ( m_xDocHolder.is() ) - { - m_xDocHolder->CloseFrame(); - try { - m_xDocHolder->CloseDocument( true, true ); - } catch ( const uno::Exception& ) {} - m_xDocHolder->FreeOffice(); + delete m_pInterfaceContainer; + m_pInterfaceContainer = nullptr; + } + } catch( const uno::Exception& ) {} - m_xDocHolder.clear(); - } - } catch( const uno::Exception& ) {} - } + try { + if ( m_xDocHolder.is() ) + { + m_xDocHolder->CloseFrame(); + try { + m_xDocHolder->CloseDocument( true, true ); + } catch ( const uno::Exception& ) {} + m_xDocHolder->FreeOffice(); + + m_xDocHolder.clear(); + } + } catch( const uno::Exception& ) {} } @@ -292,20 +292,20 @@ void OCommonEmbeddedObject::requestPositioning( const awt::Rectangle& aRect ) // the method is called in case object is inplace active and the object window was resized OSL_ENSURE( m_xClientSite.is(), "The client site must be set for inplace active object!" ); - if ( m_xClientSite.is() ) - { - uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); + if ( !m_xClientSite.is() ) + return; + + uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY ); - OSL_ENSURE( xInplaceClient.is(), "The client site must support XInplaceClient to allow inplace activation!" ); - if ( xInplaceClient.is() ) + OSL_ENSURE( xInplaceClient.is(), "The client site must support XInplaceClient to allow inplace activation!" ); + if ( xInplaceClient.is() ) + { + try { + xInplaceClient->changedPlacement( aRect ); + } + catch( const uno::Exception& ) { - try { - xInplaceClient->changedPlacement( aRect ); - } - catch( const uno::Exception& ) - { - OSL_FAIL( "Exception on request to resize!" ); - } + OSL_FAIL( "Exception on request to resize!" ); } } } @@ -313,35 +313,35 @@ void OCommonEmbeddedObject::requestPositioning( const awt::Rectangle& aRect ) void OCommonEmbeddedObject::PostEvent_Impl( const OUString& aEventName ) { - if ( m_pInterfaceContainer ) + if ( !m_pInterfaceContainer ) + return; + + ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer( + cppu::UnoType<document::XEventListener>::get()); + if( !pIC ) + return; + + document::EventObject aEvent; + aEvent.EventName = aEventName; + aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); + // For now all the events are sent as object events + // aEvent.Source = ( xSource.is() ? xSource + // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); + ::cppu::OInterfaceIteratorHelper aIt( *pIC ); + while( aIt.hasMoreElements() ) { - ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer( - cppu::UnoType<document::XEventListener>::get()); - if( pIC ) + try { - document::EventObject aEvent; - aEvent.EventName = aEventName; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - // For now all the events are sent as object events - // aEvent.Source = ( xSource.is() ? xSource - // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - try - { - static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent ); - } - catch( const uno::RuntimeException& ) - { - aIt.remove(); - } - - // the listener could dispose the object. - if ( m_bDisposed ) - return; - } + static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent ); + } + catch( const uno::RuntimeException& ) + { + aIt.remove(); } + + // the listener could dispose the object. + if ( m_bDisposed ) + return; } } diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index f162dfef5f31..7b63ca58118f 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -217,23 +217,23 @@ static uno::Reference< util::XCloseable > CreateDocument( const uno::Reference< static void SetDocToEmbedded( const uno::Reference< frame::XModel >& rDocument, const OUString& aModuleName ) { - if (rDocument.is()) - { - uno::Sequence< beans::PropertyValue > aSeq( 1 ); - aSeq[0].Name = "SetEmbedded"; - aSeq[0].Value <<= true; - rDocument->attachResource( OUString(), aSeq ); + if (!rDocument.is()) + return; - if ( !aModuleName.isEmpty() ) + uno::Sequence< beans::PropertyValue > aSeq( 1 ); + aSeq[0].Name = "SetEmbedded"; + aSeq[0].Value <<= true; + rDocument->attachResource( OUString(), aSeq ); + + if ( !aModuleName.isEmpty() ) + { + try { - try - { - uno::Reference< frame::XModule > xModule( rDocument, uno::UNO_QUERY_THROW ); - xModule->setIdentifier( aModuleName ); - } - catch( const uno::Exception& ) - {} + uno::Reference< frame::XModule > xModule( rDocument, uno::UNO_QUERY_THROW ); + xModule->setIdentifier( aModuleName ); } + catch( const uno::Exception& ) + {} } } @@ -612,26 +612,26 @@ uno::Reference< io::XInputStream > OCommonEmbeddedObject::StoreDocumentToTempStr void OCommonEmbeddedObject::SaveObject_Impl() { - if ( m_xClientSite.is() ) + if ( !m_xClientSite.is() ) + return; + + try { - try - { - // check whether the component is modified, - // if not there is no need for storing - uno::Reference< util::XModifiable > xModifiable( m_xDocHolder->GetComponent(), uno::UNO_QUERY ); - if ( xModifiable.is() && !xModifiable->isModified() ) - return; - } - catch( const uno::Exception& ) - {} + // check whether the component is modified, + // if not there is no need for storing + uno::Reference< util::XModifiable > xModifiable( m_xDocHolder->GetComponent(), uno::UNO_QUERY ); + if ( xModifiable.is() && !xModifiable->isModified() ) + return; + } + catch( const uno::Exception& ) + {} - try { - m_xClientSite->saveObject(); - } - catch( const uno::Exception& ) - { - SAL_WARN( "embeddedobj.common", "The object was not stored!" ); - } + try { + m_xClientSite->saveObject(); + } + catch( const uno::Exception& ) + { + SAL_WARN( "embeddedobj.common", "The object was not stored!" ); } } @@ -1232,23 +1232,23 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const uno::Reference< embed:: } } - if ( m_nObjectState != embed::EmbedStates::LOADED ) - { - uno::Reference< embed::XStorage > xSubStorage = - xStorage->openStorageElement( sEntName, embed::ElementModes::READWRITE ); + if ( m_nObjectState == embed::EmbedStates::LOADED ) + return; - if ( !xSubStorage.is() ) - throw uno::RuntimeException(); //TODO + uno::Reference< embed::XStorage > xSubStorage = + xStorage->openStorageElement( sEntName, embed::ElementModes::READWRITE ); - aGuard.clear(); - // TODO/LATER: support hierarchical name for embedded objects in embedded objects - StoreDocToStorage_Impl( - xSubStorage, lArguments, lObjArgs, nTargetStorageFormat, sEntName, false ); - aGuard.reset(); + if ( !xSubStorage.is() ) + throw uno::RuntimeException(); //TODO - if ( bSwitchBackToLoaded ) - changeState( embed::EmbedStates::LOADED ); - } + aGuard.clear(); + // TODO/LATER: support hierarchical name for embedded objects in embedded objects + StoreDocToStorage_Impl( + xSubStorage, lArguments, lObjArgs, nTargetStorageFormat, sEntName, false ); + aGuard.reset(); + + if ( bSwitchBackToLoaded ) + changeState( embed::EmbedStates::LOADED ); // TODO: should the listener notification be done? } @@ -1723,20 +1723,20 @@ void SAL_CALL OCommonEmbeddedObject::reload( if ( lArguments[nInd].Name == "ReadOnly" ) lArguments[nInd].Value >>= m_bReadOnly; - if ( bOldReadOnlyValue != m_bReadOnly && !m_bIsLink ) - { - // close own storage - try { - if ( m_xObjectStorage.is() ) - m_xObjectStorage->dispose(); - } - catch ( const uno::Exception& ) - { - } + if ( bOldReadOnlyValue == m_bReadOnly || m_bIsLink ) + return; - sal_Int32 nStorageMode = m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE; - m_xObjectStorage = m_xParentStorage->openStorageElement( m_aEntryName, nStorageMode ); + // close own storage + try { + if ( m_xObjectStorage.is() ) + m_xObjectStorage->dispose(); } + catch ( const uno::Exception& ) + { + } + + sal_Int32 nStorageMode = m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE; + m_xObjectStorage = m_xParentStorage->openStorageElement( m_aEntryName, nStorageMode ); } sal_Bool SAL_CALL OCommonEmbeddedObject::isStored() diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx index 4c35ffc156e6..cfc7afcf81a9 100644 --- a/embeddedobj/source/general/docholder.cxx +++ b/embeddedobj/source/general/docholder.cxx @@ -294,27 +294,27 @@ void DocumentHolder::PlaceFrame( const awt::Rectangle& aNewRect ) "The object does not have windows required for inplace mode!" ); //TODO: may need mutex locking??? - if ( m_xFrame.is() && m_xOwnWindow.is() ) - { - // the frame can be replaced only in inplace mode - frame::BorderWidths aOldWidths; - IntCounterGuard aGuard( m_nNoBorderResizeReact ); + if ( !(m_xFrame.is() && m_xOwnWindow.is()) ) + return; - do - { - aOldWidths = m_aBorderWidths; + // the frame can be replaced only in inplace mode + frame::BorderWidths aOldWidths; + IntCounterGuard aGuard( m_nNoBorderResizeReact ); - awt::Rectangle aHatchRect = AddBorderToArea( aNewRect ); + do + { + aOldWidths = m_aBorderWidths; - ResizeWindows_Impl( aHatchRect ); + awt::Rectangle aHatchRect = AddBorderToArea( aNewRect ); - } while ( aOldWidths.Left != m_aBorderWidths.Left - || aOldWidths.Top != m_aBorderWidths.Top - || aOldWidths.Right != m_aBorderWidths.Right - || aOldWidths.Bottom != m_aBorderWidths.Bottom ); + ResizeWindows_Impl( aHatchRect ); - m_aObjRect = aNewRect; - } + } while ( aOldWidths.Left != m_aBorderWidths.Left + || aOldWidths.Top != m_aBorderWidths.Top + || aOldWidths.Right != m_aBorderWidths.Right + || aOldWidths.Bottom != m_aBorderWidths.Bottom ); + + m_aObjRect = aNewRect; } @@ -1244,30 +1244,30 @@ awt::Rectangle SAL_CALL DocumentHolder::calcAdjustedRectangle( const awt::Rectan void SAL_CALL DocumentHolder::activated( ) { - if ( m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) + if ( !(m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE) ) + return; + + if ( m_pEmbedObj->getCurrentState() != embed::EmbedStates::UI_ACTIVE && + !(m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) ) { - if ( m_pEmbedObj->getCurrentState() != embed::EmbedStates::UI_ACTIVE && - !(m_pEmbedObj->getStatus(embed::Aspects::MSOLE_CONTENT)&embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) ) + try { - try - { - m_pEmbedObj->changeState( embed::EmbedStates::UI_ACTIVE ); - } - catch ( const css::embed::StateChangeInProgressException& ) - { - // must catch this exception because focus is grabbed while UI activation in doVerb() - } - catch ( const css::uno::Exception& ) - { - // no outgoing exceptions specified here - } + m_pEmbedObj->changeState( embed::EmbedStates::UI_ACTIVE ); } - else + catch ( const css::embed::StateChangeInProgressException& ) { - uno::Reference< frame::XFramesSupplier > xSupp = m_xFrame->getCreator(); - if ( xSupp.is() ) - xSupp->setActiveFrame( m_xFrame ); + // must catch this exception because focus is grabbed while UI activation in doVerb() } + catch ( const css::uno::Exception& ) + { + // no outgoing exceptions specified here + } + } + else + { + uno::Reference< frame::XFramesSupplier > xSupp = m_xFrame->getCreator(); + if ( xSupp.is() ) + xSupp->setActiveFrame( m_xFrame ); } } diff --git a/embeddedobj/source/general/dummyobject.cxx b/embeddedobj/source/general/dummyobject.cxx index b83b9ec29183..e37aca939b9b 100644 --- a/embeddedobj/source/general/dummyobject.cxx +++ b/embeddedobj/source/general/dummyobject.cxx @@ -57,35 +57,35 @@ void ODummyEmbeddedObject::CheckInit_Runtime() } void ODummyEmbeddedObject::PostEvent_Impl( const OUString& aEventName ) { - if ( m_pInterfaceContainer ) + if ( !m_pInterfaceContainer ) + return; + + ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer( + cppu::UnoType<document::XEventListener>::get()); + if( !pIC ) + return; + + document::EventObject aEvent; + aEvent.EventName = aEventName; + aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); + // For now all the events are sent as object events + // aEvent.Source = ( xSource.is() ? xSource + // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); + ::cppu::OInterfaceIteratorHelper aIt( *pIC ); + while( aIt.hasMoreElements() ) { - ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer( - cppu::UnoType<document::XEventListener>::get()); - if( pIC ) + try { - document::EventObject aEvent; - aEvent.EventName = aEventName; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - // For now all the events are sent as object events - // aEvent.Source = ( xSource.is() ? xSource - // : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - try - { - static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent ); - } - catch( const uno::RuntimeException& ) - { - aIt.remove(); - } - - // the listener could dispose the object. - if ( m_bDisposed ) - return; - } + static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent ); + } + catch( const uno::RuntimeException& ) + { + aIt.remove(); } + + // the listener could dispose the object. + if ( m_bDisposed ) + return; } } diff --git a/embeddedobj/source/general/intercept.cxx b/embeddedobj/source/general/intercept.cxx index 238f39704a33..9b1449cd9518 100644 --- a/embeddedobj/source/general/intercept.cxx +++ b/embeddedobj/source/general/intercept.cxx @@ -69,48 +69,48 @@ Interceptor::dispatch( beans::PropertyValue >& Arguments ) { osl::MutexGuard aGuard(m_aMutex); - if( m_pDocHolder ) + if( !m_pDocHolder ) + return; + + if(URL.Complete == m_aInterceptedURL[0]) + m_pDocHolder->GetEmbedObject()->SaveObject_Impl(); + else if(URL.Complete == m_aInterceptedURL[2] || + URL.Complete == m_aInterceptedURL[3] || + URL.Complete == m_aInterceptedURL[4]) { - if(URL.Complete == m_aInterceptedURL[0]) - m_pDocHolder->GetEmbedObject()->SaveObject_Impl(); - else if(URL.Complete == m_aInterceptedURL[2] || - URL.Complete == m_aInterceptedURL[3] || - URL.Complete == m_aInterceptedURL[4]) - { - try { - m_pDocHolder->GetEmbedObject()->changeState( embed::EmbedStates::RUNNING ); - } - catch( const uno::Exception& ) - { - } + try { + m_pDocHolder->GetEmbedObject()->changeState( embed::EmbedStates::RUNNING ); } - else if ( URL.Complete == m_aInterceptedURL[5] ) + catch( const uno::Exception& ) { - uno::Sequence< beans::PropertyValue > aNewArgs = Arguments; - sal_Int32 nInd = 0; - - while( nInd < aNewArgs.getLength() ) - { - if ( aNewArgs[nInd].Name == "SaveTo" ) - { - aNewArgs[nInd].Value <<= true; - break; - } - nInd++; - } + } + } + else if ( URL.Complete == m_aInterceptedURL[5] ) + { + uno::Sequence< beans::PropertyValue > aNewArgs = Arguments; + sal_Int32 nInd = 0; - if ( nInd == aNewArgs.getLength() ) + while( nInd < aNewArgs.getLength() ) + { + if ( aNewArgs[nInd].Name == "SaveTo" ) { - aNewArgs.realloc( nInd + 1 ); - aNewArgs[nInd].Name = "SaveTo"; aNewArgs[nInd].Value <<= true; + break; } + nInd++; + } - uno::Reference< frame::XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch( - URL, "_self", 0 ); - if ( xDispatch.is() ) - xDispatch->dispatch( URL, aNewArgs ); + if ( nInd == aNewArgs.getLength() ) + { + aNewArgs.realloc( nInd + 1 ); + aNewArgs[nInd].Name = "SaveTo"; + aNewArgs[nInd].Value <<= true; } + + uno::Reference< frame::XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch( + URL, "_self", 0 ); + if ( xDispatch.is() ) + xDispatch->dispatch( URL, aNewArgs ); } } @@ -167,26 +167,27 @@ Interceptor::addStatusListener( return; } - if(URL.Complete == m_aInterceptedURL[5]) - { // SaveAs - frame::FeatureStateEvent aStateEvent; - aStateEvent.FeatureURL.Complete = m_aInterceptedURL[5]; - aStateEvent.FeatureDescriptor = "SaveCopyTo"; - aStateEvent.IsEnabled = true; - aStateEvent.Requery = false; - aStateEvent.State <<= OUString("($3)"); - Control->statusChanged(aStateEvent); + if(URL.Complete != m_aInterceptedURL[5]) + return; - { - osl::MutexGuard aGuard(m_aMutex); - if(!m_pStatCL) - m_pStatCL.reset(new StatusChangeListenerContainer(m_aMutex)); - } +// SaveAs + frame::FeatureStateEvent aStateEvent; + aStateEvent.FeatureURL.Complete = m_aInterceptedURL[5]; + aStateEvent.FeatureDescriptor = "SaveCopyTo"; + aStateEvent.IsEnabled = true; + aStateEvent.Requery = false; + aStateEvent.State <<= OUString("($3)"); + Control->statusChanged(aStateEvent); - m_pStatCL->addInterface(URL.Complete,Control); - return; + { + osl::MutexGuard aGuard(m_aMutex); + if(!m_pStatCL) + m_pStatCL.reset(new StatusChangeListenerContainer(m_aMutex)); } + m_pStatCL->addInterface(URL.Complete,Control); + return; + } diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx index c84b0e72d073..faf23cf585c9 100644 --- a/embeddedobj/source/msole/oleembed.cxx +++ b/embeddedobj/source/msole/oleembed.cxx @@ -119,82 +119,82 @@ uno::Sequence< sal_Int32 > OleEmbeddedObject::GetIntermediateVerbsSequence_Impl( void OleEmbeddedObject::MoveListeners() { - if ( m_pInterfaceContainer ) + if ( !m_pInterfaceContainer ) + return; + + // move state change listeners { - // move state change listeners + ::cppu::OInterfaceContainerHelper* pStateChangeContainer = + m_pInterfaceContainer->getContainer( cppu::UnoType<embed::XStateChangeListener>::get()); + if ( pStateChangeContainer != nullptr ) { - ::cppu::OInterfaceContainerHelper* pStateChangeContainer = - m_pInterfaceContainer->getContainer( cppu::UnoType<embed::XStateChangeListener>::get()); - if ( pStateChangeContainer != nullptr ) + if ( m_xWrappedObject.is() ) { - if ( m_xWrappedObject.is() ) + ::cppu::OInterfaceIteratorHelper pIterator( *pStateChangeContainer ); + while ( pIterator.hasMoreElements() ) { - ::cppu::OInterfaceIteratorHelper pIterator( *pStateChangeContainer ); - while ( pIterator.hasMoreElements() ) + try { - try - { - m_xWrappedObject->addStateChangeListener( static_cast<embed::XStateChangeListener*>(pIterator.next()) ); - } - catch( const uno::RuntimeException& ) - { - pIterator.remove(); - } + m_xWrappedObject->addStateChangeListener( static_cast<embed::XStateChangeListener*>(pIterator.next()) ); + } + catch( const uno::RuntimeException& ) + { + pIterator.remove(); } } } } + } - // move event listeners + // move event listeners + { + ::cppu::OInterfaceContainerHelper* pEventContainer = + m_pInterfaceContainer->getContainer( cppu::UnoType<document::XEventListener>::get()); + if ( pEventContainer != nullptr ) { - ::cppu::OInterfaceContainerHelper* pEventContainer = - m_pInterfaceContainer->getContainer( cppu::UnoType<document::XEventListener>::get()); - if ( pEventContainer != nullptr ) + if ( m_xWrappedObject.is() ) { - if ( m_xWrappedObject.is() ) + ::cppu::OInterfaceIteratorHelper pIterator( *pEventContainer ); + while ( pIterator.hasMoreElements() ) { - ::cppu::OInterfaceIteratorHelper pIterator( *pEventContainer ); - while ( pIterator.hasMoreElements() ) + try { - try - { - m_xWrappedObject->addEventListener( static_cast<document::XEventListener*>(pIterator.next()) ); - } - catch( const uno::RuntimeException& ) - { - pIterator.remove(); - } + m_xWrappedObject->addEventListener( static_cast<document::XEventListener*>(pIterator.next()) ); + } + catch( const uno::RuntimeException& ) + { + pIterator.remove(); } } } } + } - // move close listeners + // move close listeners + { + ::cppu::OInterfaceContainerHelper* pCloseContainer = + m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get()); + if ( pCloseContainer != nullptr ) { - ::cppu::OInterfaceContainerHelper* pCloseContainer = - m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get()); - if ( pCloseContainer != nullptr ) + if ( m_xWrappedObject.is() ) { - if ( m_xWrappedObject.is() ) + ::cppu::OInterfaceIteratorHelper pIterator( *pCloseContainer ); + while ( pIterator.hasMoreElements() ) { - ::cppu::OInterfaceIteratorHelper pIterator( *pCloseContainer ); - while ( pIterator.hasMoreElements() ) + try { - try - { - m_xWrappedObject->addCloseListener( static_cast<util::XCloseListener*>(pIterator.next()) ); - } - catch( const uno::RuntimeException& ) - { - pIterator.remove(); - } + m_xWrappedObject->addCloseListener( static_cast<util::XCloseListener*>(pIterator.next()) ); + } + catch( const uno::RuntimeException& ) + { + pIterator.remove(); } } } } - - m_pInterfaceContainer.reset(); } + + m_pInterfaceContainer.reset(); } diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx index 66572c40be4d..6de6a9cdca75 100644 --- a/embeddedobj/source/msole/olemisc.cxx +++ b/embeddedobj/source/msole/olemisc.cxx @@ -158,25 +158,25 @@ OleEmbeddedObject::~OleEmbeddedObject() void OleEmbeddedObject::MakeEventListenerNotification_Impl( const OUString& aEventName ) { - if ( m_pInterfaceContainer ) + if ( !m_pInterfaceContainer ) + return; + + ::cppu::OInterfaceContainerHelper* pContainer = + m_pInterfaceContainer->getContainer( + cppu::UnoType<document::XEventListener>::get()); + if ( pContainer == nullptr ) + return; + + document::EventObject aEvent( static_cast< ::cppu::OWeakObject* >( this ), aEventName ); + ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); + while (pIterator.hasMoreElements()) { - ::cppu::OInterfaceContainerHelper* pContainer = - m_pInterfaceContainer->getContainer( - cppu::UnoType<document::XEventListener>::get()); - if ( pContainer != nullptr ) + try + { + static_cast<document::XEventListener*>(pIterator.next())->notifyEvent( aEvent ); + } + catch( const uno::RuntimeException& ) { - document::EventObject aEvent( static_cast< ::cppu::OWeakObject* >( this ), aEventName ); - ::cppu::OInterfaceIteratorHelper pIterator(*pContainer); - while (pIterator.hasMoreElements()) - { - try - { - static_cast<document::XEventListener*>(pIterator.next())->notifyEvent( aEvent ); - } - catch( const uno::RuntimeException& ) - { - } - } } } } diff --git a/embeddedobj/source/msole/ownview.cxx b/embeddedobj/source/msole/ownview.cxx index 3344bc6804ed..9750798c6388 100644 --- a/embeddedobj/source/msole/ownview.cxx +++ b/embeddedobj/source/msole/ownview.cxx @@ -580,24 +580,24 @@ void SAL_CALL OwnView_Impl::notifyEvent( const document::EventObject& aEvent ) } } - if ( xModel.is() ) - { - try { - uno::Reference< document::XEventBroadcaster > xBroadCaster( xModel, uno::UNO_QUERY ); - if ( xBroadCaster.is() ) - xBroadCaster->removeEventListener( uno::Reference< document::XEventListener >( - static_cast< ::cppu::OWeakObject* >( this ), - uno::UNO_QUERY ) ); - - uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); - if ( xCloseable.is() ) - xCloseable->removeCloseListener( uno::Reference< util::XCloseListener >( - static_cast< ::cppu::OWeakObject* >( this ), - uno::UNO_QUERY ) ); - } - catch( uno::Exception& ) - {} + if ( !xModel.is() ) + return; + + try { + uno::Reference< document::XEventBroadcaster > xBroadCaster( xModel, uno::UNO_QUERY ); + if ( xBroadCaster.is() ) + xBroadCaster->removeEventListener( uno::Reference< document::XEventListener >( + static_cast< ::cppu::OWeakObject* >( this ), + uno::UNO_QUERY ) ); + + uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY ); + if ( xCloseable.is() ) + xCloseable->removeCloseListener( uno::Reference< util::XCloseListener >( + static_cast< ::cppu::OWeakObject* >( this ), + uno::UNO_QUERY ) ); } + catch( uno::Exception& ) + {} } |