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/source/commonembedding | |
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/source/commonembedding')
-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 |
3 files changed, 147 insertions, 147 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() |