sw/source/core/doc/CntntIdxStore.cxx | 11 + sw/source/core/doc/DocumentChartDataProviderManager.cxx | 3 sw/source/core/doc/DocumentFieldsManager.cxx | 21 +-- sw/source/core/doc/DocumentLinksAdministrationManager.cxx | 87 ++++++++------ sw/source/core/doc/DocumentRedlineManager.cxx | 79 +++++++----- sw/source/core/doc/DocumentStylePoolManager.cxx | 18 +- sw/source/core/doc/doc.cxx | 44 +++---- sw/source/core/doc/docbasic.cxx | 20 +-- sw/source/core/doc/docbm.cxx | 8 - sw/source/core/doc/docchart.cxx | 23 +-- sw/source/core/doc/doccomp.cxx | 28 ++-- sw/source/core/doc/doccorr.cxx | 22 ++- sw/source/core/doc/docfld.cxx | 6 13 files changed, 218 insertions(+), 152 deletions(-)
New commits: commit 0f097b4d05881af59e9f106831080476c7b61093 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sun Apr 19 13:30:27 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Apr 19 15:19:08 2020 +0200 loplugin:buriedassign in sw(3) Change-Id: Iabeb4c7f9bb224c7eacc9a102a66f70bdca70dd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92497 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx index 98fbca5c98a7..1fe119f2e877 100644 --- a/sw/source/core/doc/CntntIdxStore.cxx +++ b/sw/source/core/doc/CntntIdxStore.cxx @@ -442,10 +442,15 @@ void ContentIdxStoreImpl::SaveShellCursors(SwDoc* pDoc, sal_uLong nNode, sal_Int { SwPaM *_pStackCursor = static_cast<SwCursorShell*>(&rCurShell)->GetStackCursor(); if( _pStackCursor ) - do { + for (;;) + { lcl_ChkPaMBoth( m_aShellCursorEntries, nNode, nContent, *_pStackCursor); - } while ( (_pStackCursor != nullptr ) && - ((_pStackCursor = _pStackCursor->GetNext()) != static_cast<SwCursorShell*>(&rCurShell)->GetStackCursor()) ); + if (!_pStackCursor) + break; + _pStackCursor = _pStackCursor->GetNext(); + if (_pStackCursor == static_cast<SwCursorShell*>(&rCurShell)->GetStackCursor()) + break; + } for(SwPaM& rPaM : static_cast<SwCursorShell*>(&rCurShell)->GetCursor_()->GetRingContainer()) { diff --git a/sw/source/core/doc/DocumentChartDataProviderManager.cxx b/sw/source/core/doc/DocumentChartDataProviderManager.cxx index 674c43c8471f..90785725e2dd 100644 --- a/sw/source/core/doc/DocumentChartDataProviderManager.cxx +++ b/sw/source/core/doc/DocumentChartDataProviderManager.cxx @@ -64,7 +64,8 @@ void DocumentChartDataProviderManager::CreateChartInternalDataProviders( const S while (nullptr != (pStNd = aIdx.GetNode().GetStartNode())) { ++aIdx; - if( nullptr != ( pONd = aIdx.GetNode().GetOLENode() ) && + pONd = aIdx.GetNode().GetOLENode(); + if( pONd && aName == pONd->GetChartTableName() /* OLE node is chart? */ && nullptr != (pONd->getLayoutFrame( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ ) { diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index 88e0c6b7f018..800c9096722f 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -816,16 +816,19 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt ) if( !pCNd ) pCNd = m_rDoc.GetNodes().GoNext( &aCNdIdx ); - std::pair<Point, bool> const tmp(aPt, true); - if (pCNd && nullptr != (pFrame = pCNd->getLayoutFrame( - pLayout, nullptr, &tmp))) + if (pCNd) { - SwPosition aPos( *pCNd ); - if( GetBodyTextNode( m_rDoc, aPos, *pFrame ) ) - FieldsToCalc(*pCalc, SetGetExpField(aPos.nNode), - pLayout); - else - pFrame = nullptr; + std::pair<Point, bool> const tmp(aPt, true); + pFrame = pCNd->getLayoutFrame(pLayout, nullptr, &tmp); + if( pFrame ) + { + SwPosition aPos( *pCNd ); + if( GetBodyTextNode( m_rDoc, aPos, *pFrame ) ) + FieldsToCalc(*pCalc, SetGetExpField(aPos.nNode), + pLayout); + else + pFrame = nullptr; + } } } if( !pFrame ) diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index 83a1e8f81f8d..c5ca5b11eae6 100644 --- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -122,9 +122,8 @@ namespace if( sNm == sCompare ) { // found, so get the data - const SwNodeIndex* pIdx; - if( nullptr != (pIdx = pSectFormat->GetContent().GetContentIdx() ) && - &pSectFormat->GetDoc()->GetNodes() == &pIdx->GetNodes() ) + const SwNodeIndex* pIdx = pSectFormat->GetContent().GetContentIdx(); + if( pIdx && &pSectFormat->GetDoc()->GetNodes() == &pIdx->GetNodes() ) { // a table in the normal NodesArr pItem->pSectNd = pIdx->GetNode().GetSectionNode(); @@ -142,17 +141,18 @@ namespace OUString sNm( GetAppCharClass().lowercase( pTableFormat->GetName() )); if ( sNm == pItem->m_Item ) { - SwTable* pTmpTable; - SwTableBox* pFBox; - if( nullptr != ( pTmpTable = SwTable::FindTable( pTableFormat ) ) && - nullptr != ( pFBox = pTmpTable->GetTabSortBoxes()[0] ) && - pFBox->GetSttNd() && - &pTableFormat->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) + SwTable* pTmpTable = SwTable::FindTable( pTableFormat ); + if( pTmpTable ) { - // a table in the normal NodesArr - pItem->pTableNd = const_cast<SwTableNode*>( - pFBox->GetSttNd()->FindTableNode()); - return false; + SwTableBox* pFBox = pTmpTable->GetTabSortBoxes()[0]; + if( pFBox && pFBox->GetSttNd() && + &pTableFormat->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) + { + // a table in the normal NodesArr + pItem->pTableNd = const_cast<SwTableNode*>( + pFBox->GetSttNd()->FindTableNode()); + return false; + } } // If the name is already correct, but not the rest then we don't have them. // The names are always unique. @@ -337,13 +337,16 @@ void DocumentLinksAdministrationManager::SetData( const OUString& rItem ) { // bookmarks ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*m_rDoc.getIDocumentMarkAccess(), rItem, bCaseSensitive); - if(pBkmk && pBkmk->IsExpanded() - && (nullptr == (pObj = pBkmk->GetRefObject()))) + if(pBkmk && pBkmk->IsExpanded()) { - // mark found, but no link yet -> create hotlink - pObj = new SwServerObject(*pBkmk); - pBkmk->SetRefObject(pObj); - GetLinkManager().InsertServer(pObj); + pObj = pBkmk->GetRefObject(); + if( !pObj ) + { + // mark found, but no link yet -> create hotlink + pObj = new SwServerObject(*pBkmk); + pBkmk->SetRefObject(pObj); + GetLinkManager().InsertServer(pObj); + } } if(pObj) return pObj; @@ -356,13 +359,16 @@ void DocumentLinksAdministrationManager::SetData( const OUString& rItem ) break; } - if(aPara.pSectNd - && (nullptr == (pObj = aPara.pSectNd->GetSection().GetObject()))) + if(aPara.pSectNd) { - // section found, but no link yet -> create hotlink - pObj = new SwServerObject( *aPara.pSectNd ); - aPara.pSectNd->GetSection().SetRefObject( pObj ); - GetLinkManager().InsertServer(pObj); + pObj = aPara.pSectNd->GetSection().GetObject(); + if( !pObj ) + { + // section found, but no link yet -> create hotlink + pObj = new SwServerObject( *aPara.pSectNd ); + aPara.pSectNd->GetSection().SetRefObject( pObj ); + GetLinkManager().InsertServer(pObj); + } } if(pObj) return pObj; @@ -378,13 +384,16 @@ void DocumentLinksAdministrationManager::SetData( const OUString& rItem ) if (!(lcl_FindTable(pFormat, &aPara))) break; } - if(aPara.pTableNd - && (nullptr == (pObj = aPara.pTableNd->GetTable().GetObject()))) + if(aPara.pTableNd) { - // table found, but no link yet -> create hotlink - pObj = new SwServerObject(*aPara.pTableNd); - aPara.pTableNd->GetTable().SetRefObject(pObj); - GetLinkManager().InsertServer(pObj); + pObj = aPara.pTableNd->GetTable().GetObject(); + if( !pObj ) + { + // table found, but no link yet -> create hotlink + pObj = new SwServerObject(*aPara.pTableNd); + aPara.pTableNd->GetTable().SetRefObject(pObj); + GetLinkManager().InsertServer(pObj); + } } return pObj; } @@ -477,12 +486,18 @@ bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, SwNodeIndex* pIdx; SwNode* pNd; const SwFlyFrameFormat* pFlyFormat = m_rDoc.FindFlyByName( sName ); - if( pFlyFormat && - nullptr != ( pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx()) ) && - !( pNd = &pIdx->GetNode())->IsNoTextNode() ) + if( pFlyFormat ) { - rpRange.reset(new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() )); - return true; + pIdx = const_cast<SwNodeIndex*>(pFlyFormat->GetContent().GetContentIdx()); + if( pIdx ) + { + pNd = &pIdx->GetNode(); + if( !pNd->IsNoTextNode() ) + { + rpRange.reset(new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() )); + return true; + } + } } } else if( sCmp == "region" ) diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 759a0633eb84..3d8435efd262 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -283,10 +283,12 @@ namespace bool IsPrevPos( const SwPosition & rPos1, const SwPosition & rPos2 ) { const SwContentNode* pCNd; - return 0 == rPos2.nContent.GetIndex() && - rPos2.nNode.GetIndex() - 1 == rPos1.nNode.GetIndex() && - nullptr != ( pCNd = rPos1.nNode.GetNode().GetContentNode() ) && - rPos1.nContent.GetIndex() == pCNd->Len(); + if( 0 != rPos2.nContent.GetIndex() ) + return false; + if( rPos2.nNode.GetIndex() - 1 != rPos1.nNode.GetIndex() ) + return false; + pCNd = rPos1.nNode.GetNode().GetContentNode(); + return pCNd && rPos1.nContent.GetIndex() == pCNd->Len(); } // copy style or return with SwRedlineExtra_FormatColl with reject data of the upcoming copy @@ -2847,10 +2849,11 @@ const SwRangeRedline* DocumentRedlineManager::SelNextRedline( SwPaM& rPam ) cons if( pTmp->HasMark() && pTmp->IsVisible() ) { const SwPosition *pRStt; - if( pFnd->GetType() == pTmp->GetType() && - pFnd->GetAuthor() == pTmp->GetAuthor() && - ( *pPrevEnd == *( pRStt = pTmp->Start() ) || - IsPrevPos( *pPrevEnd, *pRStt )) ) + if( pFnd->GetType() != pTmp->GetType() || + pFnd->GetAuthor() != pTmp->GetAuthor() ) + break; + pRStt = pTmp->Start(); + if( *pPrevEnd == *pRStt || IsPrevPos( *pPrevEnd, *pRStt ) ) { pPrevEnd = pTmp->End(); rSttPos = *pPrevEnd; @@ -2867,25 +2870,31 @@ const SwRangeRedline* DocumentRedlineManager::SelNextRedline( SwPaM& rPam ) cons SwContentNode* pCNd; SwNodeIndex* pIdx = &rPam.GetMark()->nNode; - if( !pIdx->GetNode().IsContentNode() && - nullptr != ( pCNd = m_rDoc.GetNodes().GoNextSection( pIdx )) ) + if( !pIdx->GetNode().IsContentNode() ) { - if( *pIdx <= rPam.GetPoint()->nNode ) - rPam.GetMark()->nContent.Assign( pCNd, 0 ); - else - pFnd = nullptr; + pCNd = m_rDoc.GetNodes().GoNextSection( pIdx ); + if( pCNd ) + { + if( *pIdx <= rPam.GetPoint()->nNode ) + rPam.GetMark()->nContent.Assign( pCNd, 0 ); + else + pFnd = nullptr; + } } if( pFnd ) { pIdx = &rPam.GetPoint()->nNode; - if( !pIdx->GetNode().IsContentNode() && - nullptr != ( pCNd = SwNodes::GoPrevSection( pIdx )) ) + if( !pIdx->GetNode().IsContentNode() ) { - if( *pIdx >= rPam.GetMark()->nNode ) - rPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - else - pFnd = nullptr; + pCNd = SwNodes::GoPrevSection( pIdx ); + if( pCNd ) + { + if( *pIdx >= rPam.GetMark()->nNode ) + rPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + else + pFnd = nullptr; + } } } @@ -2988,25 +2997,31 @@ const SwRangeRedline* DocumentRedlineManager::SelPrevRedline( SwPaM& rPam ) cons SwContentNode* pCNd; SwNodeIndex* pIdx = &rPam.GetMark()->nNode; - if( !pIdx->GetNode().IsContentNode() && - nullptr != ( pCNd = SwNodes::GoPrevSection( pIdx )) ) + if( !pIdx->GetNode().IsContentNode() ) { - if( *pIdx >= rPam.GetPoint()->nNode ) - rPam.GetMark()->nContent.Assign( pCNd, pCNd->Len() ); - else - pFnd = nullptr; + pCNd = SwNodes::GoPrevSection( pIdx ); + if( pCNd ) + { + if( *pIdx >= rPam.GetPoint()->nNode ) + rPam.GetMark()->nContent.Assign( pCNd, pCNd->Len() ); + else + pFnd = nullptr; + } } if( pFnd ) { pIdx = &rPam.GetPoint()->nNode; - if( !pIdx->GetNode().IsContentNode() && - nullptr != ( pCNd = m_rDoc.GetNodes().GoNextSection( pIdx )) ) + if( !pIdx->GetNode().IsContentNode() ) { - if( *pIdx <= rPam.GetMark()->nNode ) - rPam.GetPoint()->nContent.Assign( pCNd, 0 ); - else - pFnd = nullptr; + pCNd = m_rDoc.GetNodes().GoNextSection( pIdx ); + if( pCNd ) + { + if( *pIdx <= rPam.GetMark()->nNode ) + rPam.GetPoint()->nContent.Assign( pCNd, 0 ); + else + pFnd = nullptr; + } } } diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 1dc4c4e9ea9d..41b44ec276f9 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -585,7 +585,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, sal_uInt16 nOutLvlBits = 0; for (size_t n = 0, nSize = m_rDoc.GetTextFormatColls()->size(); n < nSize; ++n) { - if( nId == ( pNewColl = (*m_rDoc.GetTextFormatColls())[ n ] )->GetPoolFormatId() ) + pNewColl = (*m_rDoc.GetTextFormatColls())[ n ]; + if( nId == pNewColl->GetPoolFormatId() ) { return pNewColl; } @@ -1467,11 +1468,13 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) while( nArrCnt-- ) for( size_t n = 0; n < (*pArray[nArrCnt]).GetFormatCount(); ++n ) - if( nId == ( pNewFormat = (*pArray[ nArrCnt ] ).GetFormat( n ) )-> - GetPoolFormatId() ) + { + pNewFormat = (*pArray[ nArrCnt ] ).GetFormat( n ); + if( nId == pNewFormat->GetPoolFormatId() ) { return pNewFormat; } + } OUString aNm(SwResId(pRCId)); SwAttrSet aSet( m_rDoc.GetAttrPool(), pWhichRange ); @@ -1873,7 +1876,8 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId ) for (size_t n = 0; n < m_rDoc.GetNumRuleTable().size(); ++n ) { - if (nId == ( pNewRule = m_rDoc.GetNumRuleTable()[ n ] )->GetPoolFormatId()) + pNewRule = m_rDoc.GetNumRuleTable()[ n ]; + if (nId == pNewRule->GetPoolFormatId()) { return pNewRule; } @@ -2497,9 +2501,11 @@ bool DocumentStylePoolManager::IsPoolFormatUsed( sal_uInt16 nId ) const bFnd = false; while( nArrCnt-- && !bFnd ) for( size_t n = 0; !bFnd && n < (*pArray[nArrCnt]).GetFormatCount(); ++n ) - if( nId == ( pNewFormat = (*pArray[ nArrCnt ] ).GetFormat( n ) )-> - GetPoolFormatId() ) + { + pNewFormat = (*pArray[ nArrCnt ] ).GetFormat( n ); + if( nId == pNewFormat->GetPoolFormatId() ) bFnd = true; + } } // Not found or no dependencies? diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 2a8511a676b0..6ed9811d6c3e 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1064,17 +1064,16 @@ const SwFormatRefMark* SwDoc::GetRefMark( const OUString& rName ) const /// @return the RefMark per index - for Uno const SwFormatRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const { - const SwTextRefMark* pTextRef; const SwFormatRefMark* pRet = nullptr; sal_uInt32 nCount = 0; for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK)) { auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem); - - if( pRefMark && - nullptr != (pTextRef = pRefMark->GetTextRefMark()) && - &pTextRef->GetTextNode().GetNodes() == &GetNodes() ) + if( !pRefMark ) + continue; + const SwTextRefMark* pTextRef = pRefMark->GetTextRefMark(); + if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() ) { if(nCount == nIndex) { @@ -1092,16 +1091,14 @@ const SwFormatRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const // OS 25.06.96: From now on we always return the reference count sal_uInt16 SwDoc::GetRefMarks( std::vector<OUString>* pNames ) const { - const SwTextRefMark* pTextRef; - sal_uInt16 nCount = 0; for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK)) { auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem); - - if( pRefMark && - nullptr != (pTextRef = pRefMark->GetTextRefMark()) && - &pTextRef->GetTextNode().GetNodes() == &GetNodes() ) + if( !pRefMark ) + continue; + const SwTextRefMark* pTextRef = pRefMark->GetTextRefMark(); + if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() ) { if( pNames ) { @@ -1207,16 +1204,16 @@ void SwDoc::InvalidateAutoCompleteFlag() const SwFormatINetFormat* SwDoc::FindINetAttr( const OUString& rName ) const { - const SwTextINetFormat* pTextAttr; - const SwTextNode* pTextNd; for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT)) { auto pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem); - if( pFormatItem && - pFormatItem->GetName() == rName && - nullptr != ( pTextAttr = pFormatItem->GetTextINetFormat()) && - nullptr != ( pTextNd = pTextAttr->GetpTextNode() ) && - &pTextNd->GetNodes() == &GetNodes() ) + if( !pFormatItem || pFormatItem->GetName() != rName ) + continue; + const SwTextINetFormat* pTextAttr = pFormatItem->GetTextINetFormat(); + if( !pTextAttr ) + continue; + const SwTextNode* pTextNd = pTextAttr->GetpTextNode(); + if( pTextNd && &pTextNd->GetNodes() == &GetNodes() ) { return pFormatItem; } @@ -1264,9 +1261,9 @@ void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bIm ++aEndOfDoc; while( aIndx < aEndOfDoc ) { - SwNode *pNode; bool bDelete = false; - if( (pNode = &aIndx.GetNode())->IsTextNode() ) + SwNode *pNode = &aIndx.GetNode(); + if( pNode->IsTextNode() ) { SwTextNode *pNd = pNode->GetTextNode(); if( pNd->HasSwAttrSet() ) @@ -1323,9 +1320,10 @@ void RemoveOrDeleteContents(SwTextNode* pTextNd, IDocumentContentOperations& xOp bool HandleHidingField(SwFormatField& rFormatField, const SwNodes& rNodes, IDocumentContentOperations& xOperations) { - SwTextNode* pTextNd; - if (rFormatField.GetTextField() - && nullptr != (pTextNd = rFormatField.GetTextField()->GetpTextNode()) + if( !rFormatField.GetTextField() ) + return false; + SwTextNode* pTextNd = rFormatField.GetTextField()->GetpTextNode(); + if( pTextNd && pTextNd->GetpSwpHints() && pTextNd->IsHiddenByParaField() && &pTextNd->GetNodes() == &rNodes) { diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index e72ee5ad76a3..4fb0db9641c5 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -179,16 +179,18 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall if( bCheckPtr ) { const SwFrameFormat* pFormat = rCallEvent.PTR.IMAP.pFormat; - const ImageMap* pIMap; - if (GetSpzFrameFormats()->IsAlive(pFormat) && - nullptr != (pIMap = pFormat->GetURL().GetMap()) ) + if (GetSpzFrameFormats()->IsAlive(pFormat)) { - for( size_t nPos = pIMap->GetIMapObjectCount(); nPos; ) - if( pIMapObj == pIMap->GetIMapObject( --nPos )) - { - bCheckPtr = false; // misuse as a flag - break; - } + const ImageMap* pIMap = pFormat->GetURL().GetMap(); + if (pIMap) + { + for( size_t nPos = pIMap->GetIMapObjectCount(); nPos; ) + if( pIMapObj == pIMap->GetIMapObject( --nPos )) + { + bCheckPtr = false; // misuse as a flag + break; + } + } } } if( !bCheckPtr ) diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 423aeedae79b..2f7e48ce02f3 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1818,7 +1818,9 @@ void DelBookmarks( { bool bStt = true; SwContentNode* pCNd = pRStt->nNode.GetNode().GetContentNode(); - if( !pCNd && nullptr == ( pCNd = pDoc->GetNodes().GoNext( &pRStt->nNode )) ) + if( !pCNd ) + pCNd = pDoc->GetNodes().GoNext( &pRStt->nNode ); + if (!pCNd) { bStt = false; pRStt->nNode = rStt; @@ -1840,7 +1842,9 @@ void DelBookmarks( { bool bStt = false; SwContentNode* pCNd = pREnd->nNode.GetNode().GetContentNode(); - if( !pCNd && nullptr == ( pCNd = SwNodes::GoPrevious( &pREnd->nNode )) ) + if( !pCNd ) + pCNd = SwNodes::GoPrevious( &pREnd->nNode ); + if( !pCNd ) { bStt = true; pREnd->nNode = rEnd; diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx index d0601e454a40..4acfb511949a 100644 --- a/sw/source/core/doc/docchart.cxx +++ b/sw/source/core/doc/docchart.cxx @@ -83,16 +83,13 @@ void SwDoc::DoUpdateAllCharts() const SwFrameFormats& rTableFormats = *GetTableFrameFormats(); for( size_t n = 0; n < rTableFormats.size(); ++n ) { - SwTable* pTmpTable; - const SwTableNode* pTableNd; const SwFrameFormat* pFormat = rTableFormats[ n ]; - - if( nullptr != ( pTmpTable = SwTable::FindTable( pFormat ) ) && - nullptr != ( pTableNd = pTmpTable->GetTableNode() ) && - pTableNd->GetNodes().IsDocNodes() ) - { - UpdateCharts_( *pTmpTable, *pVSh ); - } + if( SwTable* pTmpTable = SwTable::FindTable( pFormat ) ) + if( const SwTableNode* pTableNd = pTmpTable->GetTableNode() ) + if( pTableNd->GetNodes().IsDocNodes() ) + { + UpdateCharts_( *pTmpTable, *pVSh ); + } } } } @@ -105,8 +102,8 @@ void SwDoc::UpdateCharts_( const SwTable& rTable, SwViewShell const & rVSh ) con while( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) ) { ++aIdx; - SwOLENode *pONd; - if( nullptr != ( pONd = aIdx.GetNode().GetOLENode() ) && + SwOLENode *pONd = aIdx.GetNode().GetOLENode(); + if( pONd && aName == pONd->GetChartTableName() && pONd->getLayoutFrame( rVSh.GetLayout() ) ) { @@ -142,8 +139,8 @@ void SwDoc::SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName const SwFrameFormats& rTable = *GetTableFrameFormats(); for( size_t i = rTable.size(); i; ) { - const SwFrameFormat* pFormat; - if( !( pFormat = rTable[ --i ] )->IsDefault() && + const SwFrameFormat* pFormat = rTable[ --i ]; + if( !pFormat->IsDefault() && pFormat->GetName() == rNewName && IsUsed( *pFormat ) ) { bNameFound = true; diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 21a79453985e..0b0448b73562 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1410,12 +1410,16 @@ sal_uLong CompareData::NextIdx( const SwNode* pNd ) { if( pNd->IsStartNode() ) { - const SwSectionNode* pSNd; - if( pNd->IsTableNode() || - ( nullptr != (pSNd = pNd->GetSectionNode() ) && - ( SectionType::Content != pSNd->GetSection().GetType() || - pSNd->GetSection().IsProtect() ) ) ) + if( pNd->IsTableNode() ) pNd = pNd->EndOfSectionNode(); + else + { + const SwSectionNode* pSNd = pNd->GetSectionNode(); + if( pSNd && + ( SectionType::Content != pSNd->GetSection().GetType() || + pSNd->GetSection().IsProtect() ) ) + pNd = pNd->EndOfSectionNode(); + } } return pNd->GetIndex() + 1; } @@ -1424,12 +1428,16 @@ sal_uLong CompareData::PrevIdx( const SwNode* pNd ) { if( pNd->IsEndNode() ) { - const SwSectionNode* pSNd; - if( pNd->StartOfSectionNode()->IsTableNode() || - ( nullptr != (pSNd = pNd->StartOfSectionNode()->GetSectionNode() ) && - ( SectionType::Content != pSNd->GetSection().GetType() || - pSNd->GetSection().IsProtect() ) ) ) + if( pNd->StartOfSectionNode()->IsTableNode() ) pNd = pNd->StartOfSectionNode(); + else + { + const SwSectionNode* pSNd = pNd->StartOfSectionNode()->GetSectionNode(); + if( pSNd && + ( SectionType::Content != pSNd->GetSection().GetType() || + pSNd->GetSection().IsProtect() ) ) + pNd = pNd->StartOfSectionNode(); + } } return pNd->GetIndex() - 1; } diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index 8e2769b353e5..41f7b673d2fc 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -100,10 +100,15 @@ void PaMCorrAbs( const SwPaM& rRange, const SwCursorShell* pCursorShell = static_cast<const SwCursorShell*>(&rShell); SwPaM *_pStackCursor = pCursorShell->GetStackCursor(); if( _pStackCursor ) - do { + for (;;) + { lcl_PaMCorrAbs( *_pStackCursor, aStart, aEnd, aNewPos ); - } while ( (_pStackCursor != nullptr ) && - ((_pStackCursor = _pStackCursor->GetNext()) != pCursorShell->GetStackCursor()) ); + if( !_pStackCursor ) + break; + _pStackCursor = _pStackCursor->GetNext(); + if( _pStackCursor == pCursorShell->GetStackCursor() ) + break; + } for(SwPaM& rPaM : const_cast<SwShellCursor*>(pCursorShell->GetCursor_())->GetRingContainer()) { @@ -252,10 +257,15 @@ void PaMCorrRel( const SwNodeIndex &rOldNode, SwCursorShell* pCursorShell = const_cast<SwCursorShell*>(static_cast<const SwCursorShell*>(&rShell)); SwPaM *_pStackCursor = pCursorShell->GetStackCursor(); if( _pStackCursor ) - do { + for (;;) + { lcl_PaMCorrRel1( _pStackCursor, pOldNode, aNewPos, nCntIdx ); - } while ( (_pStackCursor != nullptr ) && - ((_pStackCursor = _pStackCursor->GetNext()) != pCursorShell->GetStackCursor()) ); + if( !_pStackCursor ) + break; + _pStackCursor = _pStackCursor->GetNext(); + if( _pStackCursor == pCursorShell->GetStackCursor() ) + break; + } SwPaM* pStartPaM = pCursorShell->GetCursor_(); for(SwPaM& rPaM : pStartPaM->GetRingContainer()) diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 36d7f5118def..7ea93bb4a649 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -831,8 +831,10 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode ) for (SwSectionFormats::size_type n = rArr.size(); n; ) { SwSection* pSect = rArr[ --n ]->GetSection(); - if( pSect && pSect->IsHidden() && !pSect->GetCondition().isEmpty() && - nullptr != ( pSectNd = pSect->GetFormat()->GetSectionNode() )) + if( !pSect || !pSect->IsHidden() || pSect->GetCondition().isEmpty() ) + continue; + pSectNd = pSect->GetFormat()->GetSectionNode(); + if( pSectNd ) { sal_uLong nIdx = pSectNd->GetIndex(); aTmpArr.push_back( nIdx ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits