[Libreoffice-commits] core.git: embeddedobj/source emfio/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 14 18:39:51 UTC 2020


 embeddedobj/source/commonembedding/embedobj.cxx    |   54 +-
 embeddedobj/source/commonembedding/miscobj.cxx     |  124 +++---
 embeddedobj/source/commonembedding/persistence.cxx |  116 ++---
 embeddedobj/source/general/docholder.cxx           |   70 +--
 embeddedobj/source/general/dummyobject.cxx         |   52 +-
 embeddedobj/source/general/intercept.cxx           |   99 ++--
 embeddedobj/source/msole/oleembed.cxx              |   96 ++--
 embeddedobj/source/msole/olemisc.cxx               |   34 -
 embeddedobj/source/msole/ownview.cxx               |   34 -
 emfio/source/reader/emfreader.cxx                  |   32 -
 emfio/source/reader/mtftools.cxx                   |  422 ++++++++++-----------
 emfio/source/reader/wmfreader.cxx                  |   64 +--
 12 files changed, 599 insertions(+), 598 deletions(-)

New commits:
commit 1c3929a0a1645e802ee18f9c3d3d380375500c72
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Apr 14 15:48:35 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Apr 14 20:39:00 2020 +0200

    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 at collabora.co.uk>

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& )
+    {}
 }
 
 
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index e29ec1b39132..35a5f020d0fa 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -624,26 +624,26 @@ namespace emfio
             return;
 
         // taking the amount of points of each polygon, retrieving the total number of points
-        if ( mpInputStream->good() &&
+        if ( !(mpInputStream->good() &&
              ( nNumberOfPolylines < SAL_MAX_UINT32 / sizeof( sal_uInt16 ) ) &&
-             ( nNumberOfPolylines * sizeof( sal_uInt16 ) ) <= ( nEndPos - mpInputStream->Tell() )
+             ( nNumberOfPolylines * sizeof( sal_uInt16 ) ) <= ( nEndPos - mpInputStream->Tell() ))
            )
+            return;
+
+        std::unique_ptr< sal_uInt32[] > pnPolylinePointCount( new sal_uInt32[ nNumberOfPolylines ] );
+        for ( sal_uInt32 i = 0; i < nNumberOfPolylines && mpInputStream->good(); i++ )
         {
-            std::unique_ptr< sal_uInt32[] > pnPolylinePointCount( new sal_uInt32[ nNumberOfPolylines ] );
-            for ( sal_uInt32 i = 0; i < nNumberOfPolylines && mpInputStream->good(); i++ )
-            {
-                sal_uInt32 nPoints;
-                mpInputStream->ReadUInt32( nPoints );
-                SAL_INFO("emfio", "\t\t\tPoint " << i << " of " << nNumberOfPolylines << ": " << nPoints);
-                pnPolylinePointCount[ i ] = nPoints;
-            }
+            sal_uInt32 nPoints;
+            mpInputStream->ReadUInt32( nPoints );
+            SAL_INFO("emfio", "\t\t\tPoint " << i << " of " << nNumberOfPolylines << ": " << nPoints);
+            pnPolylinePointCount[ i ] = nPoints;
+        }
 
-            // Get polyline points:
-            for ( sal_uInt32 i = 0; ( i < nNumberOfPolylines ) && mpInputStream->good(); i++ )
-            {
-                tools::Polygon aPolygon = ReadPolygon<T>(0, pnPolylinePointCount[i], nNextPos);
-                DrawPolyLine(aPolygon, false, mbRecordPath);
-            }
+        // Get polyline points:
+        for ( sal_uInt32 i = 0; ( i < nNumberOfPolylines ) && mpInputStream->good(); i++ )
+        {
+            tools::Polygon aPolygon = ReadPolygon<T>(0, pnPolylinePointCount[i], nNextPos);
+            DrawPolyLine(aPolygon, false, mbRecordPath);
         }
     }
 
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 15ede2bf6d40..cc2fddcf4796 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -675,31 +675,31 @@ namespace emfio
 
     void MtfTools::ImplDrawClippedPolyPolygon( const tools::PolyPolygon& rPolyPoly )
     {
-        if ( rPolyPoly.Count() )
+        if ( !rPolyPoly.Count() )
+            return;
+
+        ImplSetNonPersistentLineColorTransparenz();
+        if ( rPolyPoly.Count() == 1 )
         {
-            ImplSetNonPersistentLineColorTransparenz();
-            if ( rPolyPoly.Count() == 1 )
+            if ( rPolyPoly.IsRect() )
+                mpGDIMetaFile->AddAction( new MetaRectAction( rPolyPoly.GetBoundRect() ) );
+            else
             {
-                if ( rPolyPoly.IsRect() )
-                    mpGDIMetaFile->AddAction( new MetaRectAction( rPolyPoly.GetBoundRect() ) );
-                else
+                tools::Polygon aPoly( rPolyPoly[ 0 ] );
+                sal_uInt16 nCount = aPoly.GetSize();
+                if ( nCount )
                 {
-                    tools::Polygon aPoly( rPolyPoly[ 0 ] );
-                    sal_uInt16 nCount = aPoly.GetSize();
-                    if ( nCount )
+                    if ( aPoly[ nCount - 1 ] != aPoly[ 0 ] )
                     {
-                        if ( aPoly[ nCount - 1 ] != aPoly[ 0 ] )
-                        {
-                            Point aPoint( aPoly[ 0 ] );
-                            aPoly.Insert( nCount, aPoint );
-                        }
-                        mpGDIMetaFile->AddAction( new MetaPolygonAction( aPoly ) );
+                        Point aPoint( aPoly[ 0 ] );
+                        aPoly.Insert( nCount, aPoint );
                     }
+                    mpGDIMetaFile->AddAction( new MetaPolygonAction( aPoly ) );
                 }
             }
-            else
-                mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( rPolyPoly ) );
         }
+        else
+            mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( rPolyPoly ) );
     }
 
     void MtfTools::CreateObject( std::unique_ptr<GDIObj> pObject )
@@ -736,39 +736,39 @@ namespace emfio
 
     void MtfTools::CreateObjectIndexed( sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject )
     {
-        if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
+        if ( ( nIndex & ENHMETA_STOCK_OBJECT ) != 0 )
+            return;
+
+        nIndex &= 0xffff;       // safety check: do not allow index to be > 65535
+        if ( pObject )
         {
-            nIndex &= 0xffff;       // safety check: do not allow index to be > 65535
-            if ( pObject )
+            const auto pLineStyle = dynamic_cast<WinMtfLineStyle*>(pObject.get());
+            const auto pFontStyle = dynamic_cast<WinMtfFontStyle*>(pObject.get());
+            if ( pFontStyle )
             {
-                const auto pLineStyle = dynamic_cast<WinMtfLineStyle*>(pObject.get());
-                const auto pFontStyle = dynamic_cast<WinMtfFontStyle*>(pObject.get());
-                if ( pFontStyle )
-                {
-                    if (pFontStyle->aFont.GetFontHeight() == 0)
-                        pFontStyle->aFont.SetFontHeight(423);
-                    ImplMap(pFontStyle->aFont);
-                }
-                else if ( pLineStyle )
-                {
-                    Size aSize(pLineStyle->aLineInfo.GetWidth(), 0);
-                    pLineStyle->aLineInfo.SetWidth( ImplMap(aSize).Width() );
+                if (pFontStyle->aFont.GetFontHeight() == 0)
+                    pFontStyle->aFont.SetFontHeight(423);
+                ImplMap(pFontStyle->aFont);
+            }
+            else if ( pLineStyle )
+            {
+                Size aSize(pLineStyle->aLineInfo.GetWidth(), 0);
+                pLineStyle->aLineInfo.SetWidth( ImplMap(aSize).Width() );
 
-                    if ( pLineStyle->aLineInfo.GetStyle() == LineStyle::Dash )
-                    {
-                        aSize.AdjustWidth(1 );
-                        long nDotLen = ImplMap( aSize ).Width();
-                        pLineStyle->aLineInfo.SetDistance( nDotLen );
-                        pLineStyle->aLineInfo.SetDotLen( nDotLen );
-                        pLineStyle->aLineInfo.SetDashLen( nDotLen * 3 );
-                    }
+                if ( pLineStyle->aLineInfo.GetStyle() == LineStyle::Dash )
+                {
+                    aSize.AdjustWidth(1 );
+                    long nDotLen = ImplMap( aSize ).Width();
+                    pLineStyle->aLineInfo.SetDistance( nDotLen );
+                    pLineStyle->aLineInfo.SetDotLen( nDotLen );
+                    pLineStyle->aLineInfo.SetDashLen( nDotLen * 3 );
                 }
             }
-            if ( o3tl::make_unsigned(nIndex) >= mvGDIObj.size() )
-                ImplResizeObjectArry( nIndex + 16 );
-
-            mvGDIObj[ nIndex ] = std::move(pObject);
         }
+        if ( o3tl::make_unsigned(nIndex) >= mvGDIObj.size() )
+            ImplResizeObjectArry( nIndex + 16 );
+
+        mvGDIObj[ nIndex ] = std::move(pObject);
     }
 
     void MtfTools::CreateObject()
@@ -933,54 +933,54 @@ namespace emfio
 
     void MtfTools::UpdateClipRegion()
     {
-        if (mbClipNeedsUpdate)
-        {
-            mbClipNeedsUpdate = false;
-            mbComplexClip = false;
+        if (!mbClipNeedsUpdate)
+            return;
 
-            mpGDIMetaFile->AddAction( new MetaPopAction() );                    // taking the original clipregion
-            mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::CLIPREGION ) );
+        mbClipNeedsUpdate = false;
+        mbComplexClip = false;
 
-            // skip for 'no clipping at all' case
-            if( !maClipPath.isEmpty() )
-            {
-                const basegfx::B2DPolyPolygon& rClipPoly( maClipPath.getClipPath() );
+        mpGDIMetaFile->AddAction( new MetaPopAction() );                    // taking the original clipregion
+        mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::CLIPREGION ) );
 
-                mbComplexClip = rClipPoly.count() > 1
-                    || !basegfx::utils::isRectangle(rClipPoly);
+        // skip for 'no clipping at all' case
+        if( maClipPath.isEmpty() )
+            return;
 
-                static bool bEnableComplexClipViaRegion = getenv("SAL_WMF_COMPLEXCLIP_VIA_REGION") != nullptr;
+        const basegfx::B2DPolyPolygon& rClipPoly( maClipPath.getClipPath() );
 
-                if (bEnableComplexClipViaRegion)
-                {
-                    //this makes cases like tdf#45820 work in reasonable time, and I feel in theory should
-                    //be just fine. In practice I see the output is different so needs work before its the
-                    //default, but for file fuzzing it should be good enough
-                    if (mbComplexClip)
-                    {
-                        mpGDIMetaFile->AddAction(
-                            new MetaISectRegionClipRegionAction(
-                                vcl::Region(rClipPoly)));
-                        mbComplexClip = false;
-                    }
-                    else
-                    {
-                        mpGDIMetaFile->AddAction(
-                            new MetaISectRectClipRegionAction(
-                                vcl::unotools::rectangleFromB2DRectangle(
-                                    rClipPoly.getB2DRange())));
-                    }
-                }
-                else
-                {
-                    //normal case
-                    mpGDIMetaFile->AddAction(
-                        new MetaISectRectClipRegionAction(
-                            vcl::unotools::rectangleFromB2DRectangle(
-                                rClipPoly.getB2DRange())));
-                }
+        mbComplexClip = rClipPoly.count() > 1
+            || !basegfx::utils::isRectangle(rClipPoly);
+
+        static bool bEnableComplexClipViaRegion = getenv("SAL_WMF_COMPLEXCLIP_VIA_REGION") != nullptr;
+
+        if (bEnableComplexClipViaRegion)
+        {
+            //this makes cases like tdf#45820 work in reasonable time, and I feel in theory should
+            //be just fine. In practice I see the output is different so needs work before its the
+            //default, but for file fuzzing it should be good enough
+            if (mbComplexClip)
+            {
+                mpGDIMetaFile->AddAction(
+                    new MetaISectRegionClipRegionAction(
+                        vcl::Region(rClipPoly)));
+                mbComplexClip = false;
+            }
+            else
+            {
+                mpGDIMetaFile->AddAction(
+                    new MetaISectRectClipRegionAction(
+                        vcl::unotools::rectangleFromB2DRectangle(
+                            rClipPoly.getB2DRange())));
             }
         }
+        else
+        {
+            //normal case
+            mpGDIMetaFile->AddAction(
+                new MetaISectRectClipRegionAction(
+                    vcl::unotools::rectangleFromB2DRectangle(
+                        rClipPoly.getB2DRange())));
+        }
     }
 
     void MtfTools::ImplSetNonPersistentLineColorTransparenz()
@@ -1063,34 +1063,34 @@ namespace emfio
 
     void MtfTools::StrokeAndFillPath( bool bStroke, bool bFill )
     {
-        if ( maPathObj.Count() )
+        if ( !maPathObj.Count() )
+            return;
+
+        UpdateClipRegion();
+        UpdateLineStyle();
+        UpdateFillStyle();
+        if ( bFill )
         {
-            UpdateClipRegion();
-            UpdateLineStyle();
-            UpdateFillStyle();
-            if ( bFill )
+            if ( !bStroke )
             {
-                if ( !bStroke )
-                {
-                    mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
-                    mpGDIMetaFile->AddAction( new MetaLineColorAction( Color(), false ) );
-                }
-                if ( maPathObj.Count() == 1 )
-                    mpGDIMetaFile->AddAction( new MetaPolygonAction( maPathObj.GetObject( 0 ) ) );
-                else
-                    mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( maPathObj ) );
-
-                if ( !bStroke )
-                    mpGDIMetaFile->AddAction( new MetaPopAction() );
+                mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
+                mpGDIMetaFile->AddAction( new MetaLineColorAction( Color(), false ) );
             }
+            if ( maPathObj.Count() == 1 )
+                mpGDIMetaFile->AddAction( new MetaPolygonAction( maPathObj.GetObject( 0 ) ) );
             else
-            {
-                sal_uInt16 i, nCount = maPathObj.Count();
-                for ( i = 0; i < nCount; i++ )
-                    mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) );
-            }
-            ClearPath();
+                mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( maPathObj ) );
+
+            if ( !bStroke )
+                mpGDIMetaFile->AddAction( new MetaPopAction() );
         }
+        else
+        {
+            sal_uInt16 i, nCount = maPathObj.Count();
+            for ( i = 0; i < nCount; i++ )
+                mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) );
+        }
+        ClearPath();
     }
 
     void MtfTools::DrawPixel( const Point& rSource, const Color& rColor )
@@ -1380,51 +1380,51 @@ namespace emfio
         UpdateClipRegion();
 
         sal_uInt16 nPoints = rPolygon.GetSize();
-        if (nPoints >= 1)
+        if (nPoints < 1)
+            return;
+
+        ImplMap( rPolygon );
+        if ( bTo )
         {
-            ImplMap( rPolygon );
-            if ( bTo )
-            {
-                rPolygon[ 0 ] = maActPos;
-                maActPos = rPolygon[ rPolygon.GetSize() - 1 ];
-            }
-            if ( bRecordPath )
-                maPathObj.AddPolyLine( rPolygon );
-            else
-            {
-                UpdateLineStyle();
-                mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
-            }
+            rPolygon[ 0 ] = maActPos;
+            maActPos = rPolygon[ rPolygon.GetSize() - 1 ];
+        }
+        if ( bRecordPath )
+            maPathObj.AddPolyLine( rPolygon );
+        else
+        {
+            UpdateLineStyle();
+            mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
         }
     }
 
     void MtfTools::DrawPolyBezier( tools::Polygon rPolygon, bool bTo, bool bRecordPath )
     {
         sal_uInt16 nPoints = rPolygon.GetSize();
-        if ( ( nPoints >= 4 ) && ( ( ( nPoints - 4 ) % 3 ) == 0 ) )
-        {
-            UpdateClipRegion();
+        if ( !(( nPoints >= 4 ) && ( ( ( nPoints - 4 ) % 3 ) == 0 )) )
+            return;
 
-            ImplMap( rPolygon );
-            if ( bTo )
-            {
-                rPolygon[ 0 ] = maActPos;
-                maActPos = rPolygon[ nPoints - 1 ];
-            }
-            sal_uInt16 i;
-            for ( i = 0; ( i + 2 ) < nPoints; )
-            {
-                rPolygon.SetFlags( i++, PolyFlags::Normal );
-                rPolygon.SetFlags( i++, PolyFlags::Control );
-                rPolygon.SetFlags( i++, PolyFlags::Control );
-            }
-            if ( bRecordPath )
-                maPathObj.AddPolyLine( rPolygon );
-            else
-            {
-                UpdateLineStyle();
-                mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
-            }
+        UpdateClipRegion();
+
+        ImplMap( rPolygon );
+        if ( bTo )
+        {
+            rPolygon[ 0 ] = maActPos;
+            maActPos = rPolygon[ nPoints - 1 ];
+        }
+        sal_uInt16 i;
+        for ( i = 0; ( i + 2 ) < nPoints; )
+        {
+            rPolygon.SetFlags( i++, PolyFlags::Normal );
+            rPolygon.SetFlags( i++, PolyFlags::Control );
+            rPolygon.SetFlags( i++, PolyFlags::Control );
+        }
+        if ( bRecordPath )
+            maPathObj.AddPolyLine( rPolygon );
+        else
+        {
+            UpdateLineStyle();
+            mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) );
         }
     }
 
@@ -1892,22 +1892,22 @@ namespace emfio
 
     void MtfTools::SetDevExt( const Size& rSize ,bool regular)
     {
-        if ( rSize.Width() && rSize.Height() )
+        if ( !(rSize.Width() && rSize.Height()) )
+            return;
+
+        switch( mnMapMode )
         {
-            switch( mnMapMode )
+            case MM_ISOTROPIC :
+            case MM_ANISOTROPIC :
             {
-                case MM_ISOTROPIC :
-                case MM_ANISOTROPIC :
-                {
-                    mnDevWidth = rSize.Width();
-                    mnDevHeight = rSize.Height();
-                }
-            }
-            if (regular)
-            {
-                mbIsMapDevSet=true;
+                mnDevWidth = rSize.Width();
+                mnDevHeight = rSize.Height();
             }
         }
+        if (regular)
+        {
+            mbIsMapDevSet=true;
+        }
     }
 
     void MtfTools::ScaleDevExt(double fX, double fY)
@@ -1950,21 +1950,21 @@ namespace emfio
 
     void MtfTools::SetWinExt(const Size& rSize, bool bIsEMF)
     {
-        if (rSize.Width() && rSize.Height())
+        if (!(rSize.Width() && rSize.Height()))
+            return;
+
+        switch( mnMapMode )
         {
-            switch( mnMapMode )
+            case MM_ISOTROPIC :
+            case MM_ANISOTROPIC :
             {
-                case MM_ISOTROPIC :
-                case MM_ANISOTROPIC :
+                mnWinExtX = rSize.Width();
+                mnWinExtY = rSize.Height();
+                if (bIsEMF)
                 {
-                    mnWinExtX = rSize.Width();
-                    mnWinExtY = rSize.Height();
-                    if (bIsEMF)
-                    {
-                        SetDevByWin();
-                    }
-                    mbIsMapWinSet = true;
+                    SetDevByWin();
                 }
+                mbIsMapWinSet = true;
             }
         }
     }
@@ -2146,50 +2146,50 @@ namespace emfio
     void MtfTools::Pop()
     {
         // Get the latest data from the stack
-        if( !mvSaveStack.empty() )
-        {
-            // Backup the current data on the stack
-            std::shared_ptr<SaveStruct>& pSave( mvSaveStack.back() );
-
-            maLineStyle = pSave->aLineStyle;
-            maFillStyle = pSave->aFillStyle;
-
-            maFont = pSave->aFont;
-            maTextColor = pSave->aTextColor;
-            mnTextAlign = pSave->nTextAlign;
-            mnTextLayoutMode = pSave->nTextLayoutMode;
-            mnBkMode = pSave->nBkMode;
-            mnGfxMode = pSave->nGfxMode;
-            mnMapMode = pSave->nMapMode;
-            maBkColor = pSave->aBkColor;
-            mbFillStyleSelected = pSave->bFillStyleSelected;
-
-            maActPos = pSave->aActPos;
-            maXForm = pSave->aXForm;
-            meRasterOp = pSave->eRasterOp;
-
-            mnWinOrgX = pSave->nWinOrgX;
-            mnWinOrgY = pSave->nWinOrgY;
-            mnWinExtX = pSave->nWinExtX;
-            mnWinExtY = pSave->nWinExtY;
-            mnDevOrgX = pSave->nDevOrgX;
-            mnDevOrgY = pSave->nDevOrgY;
-            mnDevWidth = pSave->nDevWidth;
-            mnDevHeight = pSave->nDevHeight;
-
-            maPathObj = pSave->maPathObj;
-            if ( ! ( maClipPath == pSave->maClipPath ) )
-            {
-                maClipPath = pSave->maClipPath;
-                mbClipNeedsUpdate = true;
-            }
-            if ( meLatestRasterOp != meRasterOp )
-            {
-                mpGDIMetaFile->AddAction( new MetaRasterOpAction( meRasterOp ) );
-                meLatestRasterOp = meRasterOp;
-            }
-            mvSaveStack.pop_back();
+        if( mvSaveStack.empty() )
+            return;
+
+        // Backup the current data on the stack
+        std::shared_ptr<SaveStruct>& pSave( mvSaveStack.back() );
+
+        maLineStyle = pSave->aLineStyle;
+        maFillStyle = pSave->aFillStyle;
+
+        maFont = pSave->aFont;
+        maTextColor = pSave->aTextColor;
+        mnTextAlign = pSave->nTextAlign;
+        mnTextLayoutMode = pSave->nTextLayoutMode;
+        mnBkMode = pSave->nBkMode;
+        mnGfxMode = pSave->nGfxMode;
+        mnMapMode = pSave->nMapMode;
+        maBkColor = pSave->aBkColor;
+        mbFillStyleSelected = pSave->bFillStyleSelected;
+
+        maActPos = pSave->aActPos;
+        maXForm = pSave->aXForm;
+        meRasterOp = pSave->eRasterOp;
+
+        mnWinOrgX = pSave->nWinOrgX;
+        mnWinOrgY = pSave->nWinOrgY;
+        mnWinExtX = pSave->nWinExtX;
+        mnWinExtY = pSave->nWinExtY;
+        mnDevOrgX = pSave->nDevOrgX;
+        mnDevOrgY = pSave->nDevOrgY;
+        mnDevWidth = pSave->nDevWidth;
+        mnDevHeight = pSave->nDevHeight;
+
+        maPathObj = pSave->maPathObj;
+        if ( ! ( maClipPath == pSave->maClipPath ) )
+        {
+            maClipPath = pSave->maClipPath;
+            mbClipNeedsUpdate = true;
+        }
+        if ( meLatestRasterOp != meRasterOp )
+        {
+            mpGDIMetaFile->AddAction( new MetaRasterOpAction( meRasterOp ) );
+            meLatestRasterOp = meRasterOp;
         }
+        mvSaveStack.pop_back();
     }
 
     void MtfTools::AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile )
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index e09061185541..1d67f5c52e98 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -1813,39 +1813,39 @@ namespace emfio
             bRet = false;
         }
 
-        if (bRet)
+        if (!bRet)
+            return;
+
+        if (aWinExt)
         {
-            if (aWinExt)
-            {
-                rPlaceableBound = tools::Rectangle(aWinOrg, *aWinExt);
-                SAL_INFO("vcl.wmf", "Window dimension "
-                           " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
-                        << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
-            }
-            else if (aViewportExt)
-            {
-                rPlaceableBound = tools::Rectangle(aViewportOrg, *aViewportExt);
-                SAL_INFO("vcl.wmf", "Viewport dimension "
-                           " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
-                        << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
-            }
-            else if (bBoundsDetermined)
-            {
-                rPlaceableBound = aBound;
-                SAL_INFO("vcl.wmf", "Determined dimension "
-                           " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
-                        << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
-            }
-            else
-            {
-                rPlaceableBound.SetLeft( 0 );
-                rPlaceableBound.SetTop( 0 );
-                rPlaceableBound.SetRight( aMaxWidth );
-                rPlaceableBound.SetBottom( aMaxWidth );
-                SAL_INFO("vcl.wmf", "Default dimension "
-                           " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
-                        << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
-            }
+            rPlaceableBound = tools::Rectangle(aWinOrg, *aWinExt);
+            SAL_INFO("vcl.wmf", "Window dimension "
+                       " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
+                    << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
+        }
+        else if (aViewportExt)
+        {
+            rPlaceableBound = tools::Rectangle(aViewportOrg, *aViewportExt);
+            SAL_INFO("vcl.wmf", "Viewport dimension "
+                       " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
+                    << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
+        }
+        else if (bBoundsDetermined)
+        {
+            rPlaceableBound = aBound;
+            SAL_INFO("vcl.wmf", "Determined dimension "
+                       " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
+                    << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
+        }
+        else
+        {
+            rPlaceableBound.SetLeft( 0 );
+            rPlaceableBound.SetTop( 0 );
+            rPlaceableBound.SetRight( aMaxWidth );
+            rPlaceableBound.SetBottom( aMaxWidth );
+            SAL_INFO("vcl.wmf", "Default dimension "
+                       " t: " << rPlaceableBound.Left()  << " l: " << rPlaceableBound.Top()
+                    << " b: " << rPlaceableBound.Right() << " r: " << rPlaceableBound.Bottom());
         }
     }
 


More information about the Libreoffice-commits mailing list