tdf#120703 PVS: V547 Expression is always true/false

Fixed the logic broken since commit 5d64757c7a
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>
This commit is contained in:
Mike Kaganski
2018-10-28 02:59:43 +03:00
parent 5f0ddb2d20
commit c026807d8d

View File

@@ -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
// TODO: create an object based on the link
// disconnect the old temporary URL
OUString aOldTempURL = m_aTempURL;
m_aTempURL.clear();
// disconnect the old temporary URL
OUString aOldTempURL = m_aTempURL;
m_aTempURL.clear();
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;
}
try {
GetRidOfComponent();
}
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 );
CreateOleComponent_Impl( pNewOleComponent );
if ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) )
SwitchOwnPersistence( xStorage, sEntName );
if ( m_nObjectState != embed::EmbedStates::LOADED )
{
// TODO: should we activate the new object if the link was activated?
sal_Int32 nTargetState = m_nObjectState;
m_nObjectState = embed::EmbedStates::LOADED;
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 );
}
m_nObjectState = nTargetState;
}
m_bIsLink = false;
m_aLinkURL.clear();
OleComponent* pNewOleComponent = new OleComponent(m_xFactory, this);
try {
pNewOleComponent->InitEmbeddedCopyOfLink(m_pOleComponent);
}
else
#endif
catch (const uno::Exception&)
{
throw io::IOException(); //TODO:
delete pNewOleComponent;
if (!m_aTempURL.isEmpty())
KillFile_Impl(m_aTempURL, m_xFactory);
m_aTempURL = aOldTempURL;
throw;
}
try {
GetRidOfComponent();
}
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);
CreateOleComponent_Impl(pNewOleComponent);
if (m_xParentStorage != xStorage || !m_aEntryName.equals(sEntName))
SwitchOwnPersistence(xStorage, sEntName);
if (m_nObjectState != embed::EmbedStates::LOADED)
{
// TODO: should we activate the new object if the link was activated?
const sal_Int32 nTargetState = m_nObjectState;
m_nObjectState = embed::EmbedStates::LOADED;
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_nObjectState = nTargetState;
}
m_bIsLink = false;
m_aLinkURL.clear();
#else // ! _WIN32
throw io::IOException(); //TODO:
#endif // _WIN32
}