diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 10:35:44 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-05-02 16:07:32 +0200 |
commit | c489dff8e376692fa1d079b92be4c12aae32f8dc (patch) | |
tree | 19c1947882547ecb38f9595acacd568759423dcf | |
parent | 41c6389a177b651d46459c1837a401e4e0425dc6 (diff) |
loplugin:flatten in sw/core/ole..sw/core/table [sw/source/core/ole/ndole.cxx]
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99886
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit c9edb99bdc74715e7d952b2b95a4d75a73300207)
Change-Id: If74f1cfca114d52566164656c34a0764cfbaad43
-rw-r--r-- | sw/source/core/ole/ndole.cxx | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 9000d6ef1b9e..cfade1209469 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -572,22 +572,22 @@ void SwOLENode::BreakFileLink_Impl() { SfxObjectShell* pPers = GetDoc()->GetPersist(); - if ( pPers ) + if ( !pPers ) + return; + + uno::Reference< embed::XStorage > xStorage = pPers->GetStorage(); + if ( !xStorage.is() ) + return; + + try + { + uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW ); + xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() ); + DisconnectFileLink_Impl(); + maLinkURL.clear(); + } + catch( uno::Exception& ) { - uno::Reference< embed::XStorage > xStorage = pPers->GetStorage(); - if ( xStorage.is() ) - { - try - { - uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW ); - xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() ); - DisconnectFileLink_Impl(); - maLinkURL.clear(); - } - catch( uno::Exception& ) - { - } - } } } @@ -602,27 +602,27 @@ void SwOLENode::DisconnectFileLink_Impl() void SwOLENode::CheckFileLink_Impl() { - if ( maOLEObj.m_xOLERef.GetObject().is() && !mpObjectLink ) + if ( !(maOLEObj.m_xOLERef.GetObject().is() && !mpObjectLink) ) + return; + + try { - try + uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW ); + if ( xLinkSupport->isLink() ) { - uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW ); - if ( xLinkSupport->isLink() ) + const OUString aLinkURL = xLinkSupport->getLinkURL(); + if ( !aLinkURL.isEmpty() ) { - const OUString aLinkURL = xLinkSupport->getLinkURL(); - if ( !aLinkURL.isEmpty() ) - { - // this is a file link so the model link manager should handle it - mpObjectLink = new SwEmbedObjectLink( this ); - maLinkURL = aLinkURL; - GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL ); - mpObjectLink->Connect(); - } + // this is a file link so the model link manager should handle it + mpObjectLink = new SwEmbedObjectLink( this ); + maLinkURL = aLinkURL; + GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL ); + mpObjectLink->Connect(); } } - catch( uno::Exception& ) - { - } + } + catch( uno::Exception& ) + { } } @@ -862,39 +862,39 @@ SwOLEObj::~SwOLEObj() COVERITY_NOEXCEPT_FALSE void SwOLEObj::SetNode( SwOLENode* pNode ) { m_pOLENode = pNode; - if ( m_aName.isEmpty() ) - { - SwDoc* pDoc = pNode->GetDoc(); - - // If there's already a SvPersist instance, we use it - SfxObjectShell* p = pDoc->GetPersist(); - if( !p ) - { - // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here? - // What happens to the document? - OSL_ENSURE( false, "Why are we creating a DocShell here??" ); - p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL ); - p->DoInitNew(); - } + if ( !m_aName.isEmpty() ) + return; - OUString aObjName; - uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY ); - if ( xChild.is() && xChild->getParent() != p->GetModel() ) - // it is possible that the parent was set already - xChild->setParent( p->GetModel() ); - if (!p->GetEmbeddedObjectContainer().InsertEmbeddedObject( m_xOLERef.GetObject(), aObjName ) ) - { - OSL_FAIL( "InsertObject failed" ); - if ( xChild.is() ) - xChild->setParent( nullptr ); - } - else - m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName ); + SwDoc* pDoc = pNode->GetDoc(); - const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required + // If there's already a SvPersist instance, we use it + SfxObjectShell* p = pDoc->GetPersist(); + if( !p ) + { + // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here? + // What happens to the document? + OSL_ENSURE( false, "Why are we creating a DocShell here??" ); + p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL ); + p->DoInitNew(); + } - m_aName = aObjName; + OUString aObjName; + uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY ); + if ( xChild.is() && xChild->getParent() != p->GetModel() ) + // it is possible that the parent was set already + xChild->setParent( p->GetModel() ); + if (!p->GetEmbeddedObjectContainer().InsertEmbeddedObject( m_xOLERef.GetObject(), aObjName ) ) + { + OSL_FAIL( "InsertObject failed" ); + if ( xChild.is() ) + xChild->setParent( nullptr ); } + else + m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName ); + + const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required + + m_aName = aObjName; } OUString SwOLEObj::GetStyleString() @@ -1167,7 +1167,7 @@ void SwOLELRUCache::Load() if (nVal < m_nLRU_InitSize) { - std::shared_ptr<SwOLELRUCache> tmp(g_pOLELRU_Cache); // prevent delete this + std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this // size of cache has been changed sal_Int32 nCount = m_OleObjects.size(); sal_Int32 nPos = nCount; @@ -1197,20 +1197,20 @@ void SwOLELRUCache::InsertObj( SwOLEObj& rObj ) m_OleObjects.erase(it); it = m_OleObjects.end(); } - if (it == m_OleObjects.end()) + if (it != m_OleObjects.end()) + return; + + std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this + // try to remove objects if necessary + sal_Int32 nCount = m_OleObjects.size(); + sal_Int32 nPos = nCount-1; + while (nPos >= 0 && nCount >= m_nLRU_InitSize) { - std::shared_ptr<SwOLELRUCache> tmp(g_pOLELRU_Cache); // prevent delete this - // try to remove objects if necessary - sal_Int32 nCount = m_OleObjects.size(); - sal_Int32 nPos = nCount-1; - while (nPos >= 0 && nCount >= m_nLRU_InitSize) - { - pObj = m_OleObjects[ nPos-- ]; - if ( pObj->UnloadObject() ) - nCount--; - } - m_OleObjects.push_front(&rObj); + pObj = m_OleObjects[ nPos-- ]; + if ( pObj->UnloadObject() ) + nCount--; } + m_OleObjects.push_front(&rObj); } void SwOLELRUCache::RemoveObj( SwOLEObj& rObj ) |