embeddedobj/source/msole/olepersist.cxx |  103 +++++++++++++++-----------------
 1 file changed, 49 insertions(+), 54 deletions(-)

New commits:
commit c026807d8d4654090bccefc6d70ceb1819c2092a
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Oct 28 02:59:43 2018 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Oct 28 07:56:24 2018 +0100

    tdf#120703 PVS: V547 Expression is always true/false
    
    Fixed the logic broken since commit 5d64757c7a5df2d3cb9b36d18f44932df15e5b3f
    with what seems to be the original idea.
    
    Change-Id: I1a25cfb27d7d9a1af4e024c2989ea4959014455f
    Reviewed-on: https://gerrit.libreoffice.org/62462
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/embeddedobj/source/msole/olepersist.cxx 
b/embeddedobj/source/msole/olepersist.cxx
index 286f24b709fc..eedc8c4fe63b 100644
--- a/embeddedobj/source/msole/olepersist.cxx
+++ b/embeddedobj/source/msole/olepersist.cxx
@@ -1878,72 +1878,67 @@ void SAL_CALL OleEmbeddedObject::breakLink( const 
uno::Reference< embed::XStorag
 
 
 #ifdef _WIN32
-    if ( m_pOleComponent )
-    {
-        // TODO: create an object based on the link
-
-        // disconnect the old temporary URL
-        OUString aOldTempURL = m_aTempURL;
-        m_aTempURL.clear();
+    // TODO: create an object based on the link
 
-        OleComponent* pNewOleComponent = new OleComponent( m_xFactory, this );
-        try {
-            pNewOleComponent->InitEmbeddedCopyOfLink( m_pOleComponent );
-        }
-        catch ( const uno::Exception& )
-        {
-            delete pNewOleComponent;
-            if ( !m_aTempURL.isEmpty() )
-                   KillFile_Impl( m_aTempURL, m_xFactory );
-            m_aTempURL = aOldTempURL;
-            throw;
-        }
+    // disconnect the old temporary URL
+    OUString aOldTempURL = m_aTempURL;
+    m_aTempURL.clear();
 
-        try {
-            GetRidOfComponent();
-        }
-        catch( const uno::Exception& )
-        {
-            delete pNewOleComponent;
-            if ( !m_aTempURL.isEmpty() )
-                   KillFile_Impl( m_aTempURL, m_xFactory );
-            m_aTempURL = aOldTempURL;
-            throw;
-        }
+    OleComponent* pNewOleComponent = new OleComponent(m_xFactory, this);
+    try {
+        pNewOleComponent->InitEmbeddedCopyOfLink(m_pOleComponent);
+    }
+    catch (const uno::Exception&)
+    {
+        delete pNewOleComponent;
+        if (!m_aTempURL.isEmpty())
+            KillFile_Impl(m_aTempURL, m_xFactory);
+        m_aTempURL = aOldTempURL;
+        throw;
+    }
 
-           KillFile_Impl( aOldTempURL, m_xFactory );
+    try {
+        GetRidOfComponent();
+    }
+    catch (const uno::Exception&)
+    {
+        delete pNewOleComponent;
+        if (!m_aTempURL.isEmpty())
+            KillFile_Impl(m_aTempURL, m_xFactory);
+        m_aTempURL = aOldTempURL;
+        throw;
+    }
 
-        CreateOleComponent_Impl( pNewOleComponent );
+    KillFile_Impl(aOldTempURL, m_xFactory);
 
-        if ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) )
-            SwitchOwnPersistence( xStorage, sEntName );
+    CreateOleComponent_Impl(pNewOleComponent);
 
-        if ( m_nObjectState != embed::EmbedStates::LOADED )
-        {
-            // TODO: should we activate the new object if the link was 
activated?
+    if (m_xParentStorage != xStorage || !m_aEntryName.equals(sEntName))
+        SwitchOwnPersistence(xStorage, sEntName);
 
-            sal_Int32 nTargetState = m_nObjectState;
-            m_nObjectState = embed::EmbedStates::LOADED;
+    if (m_nObjectState != embed::EmbedStates::LOADED)
+    {
+        // TODO: should we activate the new object if the link was activated?
 
-            if ( m_nObjectState == embed::EmbedStates::RUNNING )
-                m_pOleComponent->RunObject(); // the object already was in 
running state, the server must be installed
-            else // m_nObjectState == embed::EmbedStates::ACTIVE
-            {
-                m_pOleComponent->RunObject(); // the object already was in 
running state, the server must be installed
-                m_pOleComponent->ExecuteVerb( 
embed::EmbedVerbs::MS_OLEVERB_OPEN );
-            }
+        const sal_Int32 nTargetState = m_nObjectState;
+        m_nObjectState = embed::EmbedStates::LOADED;
 
-            m_nObjectState = nTargetState;
+        if (nTargetState == embed::EmbedStates::RUNNING)
+            m_pOleComponent->RunObject(); // the object already was in running 
state, the server must be installed
+        else // nTargetState == embed::EmbedStates::ACTIVE
+        {
+            m_pOleComponent->RunObject(); // the object already was in running 
state, the server must be installed
+            m_pOleComponent->ExecuteVerb(embed::EmbedVerbs::MS_OLEVERB_OPEN);
         }
 
-        m_bIsLink = false;
-        m_aLinkURL.clear();
-    }
-    else
-#endif
-    {
-        throw io::IOException(); //TODO:
+        m_nObjectState = nTargetState;
     }
+
+    m_bIsLink = false;
+    m_aLinkURL.clear();
+#else // ! _WIN32
+    throw io::IOException(); //TODO:
+#endif // _WIN32
 }
 
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to