summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-10-28 02:59:43 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-10-28 07:56:24 +0100
commitc026807d8d4654090bccefc6d70ceb1819c2092a (patch)
tree6ce539e935ca3ac096b8435c71231a924ecf8853
parent5f0ddb2d2068a4388a7df12cd0e11f628b91e4c0 (diff)
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.kaganski@collabora.com>
-rw-r--r--embeddedobj/source/msole/olepersist.cxx103
1 files changed, 49 insertions, 54 deletions
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
}