diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-10 10:02:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-10 20:43:38 +0200 |
commit | 474a9171e7e996116037bb9ca6c985d0a3d6c0c3 (patch) | |
tree | 7ca10ffc1a6514817ff173e41d1ac04251b69c9a | |
parent | Update git submodules (diff) | |
download | core-474a9171e7e996116037bb9ca6c985d0a3d6c0c3.tar.gz core-474a9171e7e996116037bb9ca6c985d0a3d6c0c3.zip |
loplugin:buriedassign in sw
limited this only fixing assignments inside "if" statements, since other
things are harder to change
Change-Id: If3188a3e3d5fcd94123211c97fee097ece5e2797
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95990
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
78 files changed, 491 insertions, 222 deletions
diff --git a/compilerplugins/clang/buriedassign.cxx b/compilerplugins/clang/buriedassign.cxx index 9155efc85ab5..1758a4fcbca8 100644 --- a/compilerplugins/clang/buriedassign.cxx +++ b/compilerplugins/clang/buriedassign.cxx @@ -182,8 +182,25 @@ public: return; if (fn == SRCDIR "/sw/source/core/doc/notxtfrm.cxx") return; - // the point at which I gave up on sw/ because it just does it EVERYWHERE - if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sw/")) + if (fn == SRCDIR "/sw/source/core/docnode/node.cxx") + return; + if (fn == SRCDIR "/sw/source/core/layout/ftnfrm.cxx") + return; + if (fn == SRCDIR "/sw/source/core/table/swtable.cxx") + return; + if (fn == SRCDIR "/sw/source/core/unocore/unoframe.cxx") + return; + if (fn == SRCDIR "/sw/source/filter/xml/xmlimp.cxx") + return; + if (fn == SRCDIR "/sw/source/uibase/docvw/edtwin.cxx") + return; + if (fn == SRCDIR "/sw/source/uibase/shells/langhelper.cxx") + return; + if (fn == SRCDIR "/sw/source/uibase/shells/tabsh.cxx") + return; + if (fn == SRCDIR "/sw/source/uibase/shells/textsh1.cxx") + return; + if (fn == SRCDIR "/sw/source/uibase/uiview/view2.cxx") return; if (fn == SRCDIR "/starmath/source/mathtype.cxx") return; @@ -212,6 +229,7 @@ public: private: void MarkIfAssignment(Stmt const*); + void MarkAll(Stmt const*); void MarkConditionForControlLoops(Expr const*); std::unordered_set<const Stmt*> m_handled; @@ -297,7 +315,7 @@ bool BuriedAssign::VisitBinaryOperator(BinaryOperator const* binaryOp) report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line", compat::getBeginLoc(binaryOp)) << binaryOp->getSourceRange(); - //getParentStmt(getParentStmt(getParentStmt(binaryOp)))->dump(); + //getParentStmt(getParentStmt(getParentStmt(getParentStmt(getParentStmt(getParentStmt(binaryOp))))))->dump(); return true; } @@ -392,13 +410,84 @@ void BuriedAssign::MarkIfAssignment(Stmt const* stmt) } } +void BuriedAssign::MarkAll(Stmt const* stmt) +{ + m_handled.insert(stmt); + for (auto it = stmt->child_begin(); it != stmt->child_end(); ++it) + MarkAll(*it); +} + +/** + * Restrict this to cases where the buried assignment is part of the first + * condition inside the if condition. Other cases tend to be too hard + * too extract (notably in sw/) + */ bool BuriedAssign::VisitIfStmt(IfStmt const* ifStmt) { if (ignoreLocation(ifStmt)) return true; - MarkConditionForControlLoops(ifStmt->getCond()); MarkIfAssignment(ifStmt->getThen()); MarkIfAssignment(ifStmt->getElse()); + + auto expr = ifStmt->getCond(); + expr = IgnoreImplicitAndConversionOperator(expr); + expr = expr->IgnoreParens(); + expr = IgnoreImplicitAndConversionOperator(expr); + MarkAll(expr); + + if (auto binaryOp = dyn_cast<BinaryOperator>(expr)) + { + if (isAssignmentOp(binaryOp->getOpcode())) + { + report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line", + compat::getBeginLoc(expr)) + << expr->getSourceRange(); + } + else if (binaryOp->isComparisonOp()) + { + if (auto binaryOp2 + = dyn_cast<BinaryOperator>(binaryOp->getLHS()->IgnoreParenImpCasts())) + { + if (binaryOp->getRHS()->isCXX11ConstantExpr(compiler.getASTContext()) + && isAssignmentOp(binaryOp2->getOpcode())) + report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line", + compat::getBeginLoc(expr)) + << expr->getSourceRange(); + } + if (auto binaryOp2 + = dyn_cast<BinaryOperator>(binaryOp->getRHS()->IgnoreParenImpCasts())) + { + if (binaryOp->getLHS()->isCXX11ConstantExpr(compiler.getASTContext()) + && isAssignmentOp(binaryOp2->getOpcode())) + report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line", + compat::getBeginLoc(expr)) + << expr->getSourceRange(); + } + } + else if (binaryOp->isLogicalOp()) + { + if (auto binaryOp2 + = dyn_cast<BinaryOperator>(binaryOp->getLHS()->IgnoreParenImpCasts())) + { + if (isAssignmentOp(binaryOp2->getOpcode())) + report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line", + compat::getBeginLoc(expr)) + << expr->getSourceRange(); + } + } + } + else if (auto operCall = dyn_cast<CXXOperatorCallExpr>(expr)) + { + // Ignore chained assignment. + // TODO limit this to only ordinary assignment + if (isAssignmentOp(operCall->getOperator())) + { + report(DiagnosticsEngine::Warning, "buried assignment, rather put on own line", + compat::getBeginLoc(expr)) + << expr->getSourceRange(); + } + } + return true; } diff --git a/compilerplugins/clang/test/buriedassign.cxx b/compilerplugins/clang/test/buriedassign.cxx index b44a7cce6039..9cbdbfc49df9 100644 --- a/compilerplugins/clang/test/buriedassign.cxx +++ b/compilerplugins/clang/test/buriedassign.cxx @@ -96,4 +96,36 @@ void foo() pTask->exec(); } } + +namespace test5 +{ +void main(OUString sUserAutoCorrFile, int* p2) +{ + OUString sRet; + int* p1; + if (sUserAutoCorrFile == "yyy" && (p1 = p2)) + sRet = sUserAutoCorrFile; + if (sUserAutoCorrFile == "yyy" && nullptr != (p1 = p2)) + sRet = sUserAutoCorrFile; + // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}} + if (nullptr != (p1 = p2)) + sRet = sUserAutoCorrFile; + // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}} + if ((p1 = p2) != nullptr) + sRet = sUserAutoCorrFile; + // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}} + if ((p1 = p2)) + sRet = sUserAutoCorrFile; + // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}} + if ((p1 = p2) && sUserAutoCorrFile == "yyy") + sRet = sUserAutoCorrFile; + // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}} + if ((p1 = p2) || sUserAutoCorrFile == "yyy") + sRet = sUserAutoCorrFile; + // expected-error@+1 {{buried assignment, rather put on own line [loplugin:buriedassign]}} + if ((p1 = p2) && sUserAutoCorrFile == "yyy") + sRet = sUserAutoCorrFile; +} +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index ffe3d9d9c92b..8d0bc3f5fa34 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -759,8 +759,8 @@ SwCalcOper SwCalc::GetToken() nSttPos = nFndPos; do { - if( -1 != ( nFndPos = - m_sCommand.indexOf( ']', nFndPos )) ) + nFndPos = m_sCommand.indexOf( ']', nFndPos ); + if( -1 != nFndPos ) { // ignore the ] if ('\\' == m_sCommand[nFndPos-1]) diff --git a/sw/source/core/bastyp/swcache.cxx b/sw/source/core/bastyp/swcache.cxx index 2227000051a5..fee19de3e583 100644 --- a/sw/source/core/bastyp/swcache.cxx +++ b/sw/source/core/bastyp/swcache.cxx @@ -230,8 +230,8 @@ void SwCache::ToTop( SwCacheObj *pObj ) SwCacheObj *SwCache::Get( const void *pOwner, const sal_uInt16 nIndex, const bool bToTop ) { - SwCacheObj *pRet; - if ( nullptr != (pRet = (nIndex < m_aCacheObjects.size()) ? m_aCacheObjects[ nIndex ].get() : nullptr) ) + SwCacheObj *pRet = (nIndex < m_aCacheObjects.size()) ? m_aCacheObjects[ nIndex ].get() : nullptr; + if ( pRet ) { if ( !pRet->IsOwner( pOwner ) ) pRet = nullptr; @@ -335,8 +335,8 @@ void SwCache::Delete(void const*const pOwner, sal_uInt16 const nIndex) void SwCache::Delete( const void *pOwner ) { INCREMENT( m_nDelete ); - SwCacheObj *pObj; - if ( nullptr != (pObj = Get( pOwner, false )) ) + SwCacheObj *pObj = Get( pOwner, false ); + if ( pObj ) DeleteObj( pObj ); } diff --git a/sw/source/core/bastyp/swregion.cxx b/sw/source/core/bastyp/swregion.cxx index e67dac264082..f2fb006d9006 100644 --- a/sw/source/core/bastyp/swregion.cxx +++ b/sw/source/core/bastyp/swregion.cxx @@ -74,8 +74,8 @@ void SwRegionRects::operator-=( const SwRect &rRect ) // now split; only those rectangles should be left over that are in // the "old" but not in the "new" area; hence, not in intersection. - long nTmp; - if ( 0 < (nTmp = aInter.Top() - aTmp.Top()) ) + long nTmp = aInter.Top() - aTmp.Top(); + if ( 0 < nTmp ) { const long nOldVal = aTmp.Height(); aTmp.Height(nTmp); @@ -89,7 +89,8 @@ void SwRegionRects::operator-=( const SwRect &rRect ) aTmp.Top( aInter.Top() ); aTmp.Bottom( aInter.Bottom() ); - if ( 0 < (nTmp = aInter.Left() - aTmp.Left()) ) + nTmp = aInter.Left() - aTmp.Left(); + if ( 0 < nTmp ) { const long nOldVal = aTmp.Width(); aTmp.Width( nTmp ); diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index b9f92982129a..40d536de3083 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -290,7 +290,8 @@ void SwAttrCheckArr::SetNewSet( const SwTextNode& rTextNd, const SwPaM& rPam ) } else { - if( RES_TXTATR_END <= (nWhich = pItem->Which() )) + nWhich = pItem->Which(); + if( RES_TXTATR_END <= nWhich ) break; // end of text attributes if( CmpAttr( rSet.Get( nWhich, !m_bNoColls ), *pItem ) ) @@ -761,7 +762,9 @@ static bool lcl_SearchForward( const SwTextNode& rTextNd, SwAttrCheckArr& rCmpAr continue; // then we have our search area - if( (nSttPos = rCmpArr.Start()) > (nEndPos = rCmpArr.End()) ) + nSttPos = rCmpArr.Start(); + nEndPos = rCmpArr.End(); + if( nSttPos > nEndPos ) return false; lcl_SetAttrPam( rPam, nSttPos, &nEndPos, true ); @@ -850,7 +853,9 @@ static bool lcl_SearchBackward( const SwTextNode& rTextNd, SwAttrCheckArr& rCmpA continue; // then we have our search area - if( (nSttPos = rCmpArr.Start()) > (nEndPos = rCmpArr.End()) ) + nSttPos = rCmpArr.Start(); + nEndPos = rCmpArr.End(); + if( nSttPos > nEndPos ) return false; lcl_SetAttrPam( rPam, nSttPos, &nEndPos, false ); diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 9756c57dee3f..017885da5e25 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -71,7 +71,8 @@ struct PercentHdl PercentHdl( sal_uLong nStt, sal_uLong nEnd, SwDocShell* pSh ) : pDSh(pSh), nActPos(nStt), bBack(false), bNodeIdx(false) { - if( ( bBack = (nStt > nEnd )) ) + bBack = (nStt > nEnd); + if( bBack ) { sal_uLong n = nStt; nStt = nEnd; nEnd = n; } @@ -95,7 +96,8 @@ struct PercentHdl nEnd = rPam.GetPoint()->nNode.GetIndex(); } nActPos = nStt; - if( ( bBack = (nStt > nEnd )) ) + bBack = (nStt > nEnd ); + if( bBack ) { sal_uLong n = nStt; nStt = nEnd; nEnd = n; } @@ -269,12 +271,14 @@ bool SwCursor::IsSelOvr( SwCursorSelOverFlags eFlags ) if( !bValidNodesRange ) { rPtIdx = m_vSavePos.back().nNode; - if( nullptr == ( pCNd = rPtIdx.GetNode().GetContentNode() ) ) + pCNd = rPtIdx.GetNode().GetContentNode(); + if( !pCNd ) { bIsValidPos = false; nContentPos = 0; rPtIdx = aIdx; - if( nullptr == ( pCNd = rPtIdx.GetNode().GetContentNode() ) ) + pCNd = rPtIdx.GetNode().GetContentNode(); + if( !pCNd ) { // then to the beginning of the document rPtIdx = rNds.GetEndOfExtras(); @@ -519,7 +523,8 @@ bool SwCursor::IsSelOvr( SwCursorSelOverFlags eFlags ) if ( nullptr == pMyNd) break; - if( nullptr != ( pPtNd = pMyNd->FindTableNode() )) + pPtNd = pMyNd->FindTableNode(); + if( pPtNd ) continue; } @@ -616,7 +621,8 @@ GoNextCell: if( !aCellStt.GetNode().IsStartNode() ) break; ++aCellStt; - if( nullptr == ( pCNd = aCellStt.GetNode().GetContentNode() )) + pCNd = aCellStt.GetNode().GetContentNode(); + if( !pCNd ) pCNd = aCellStt.GetNodes().GoNext( &aCellStt ); bProt = pCNd->IsProtect(); if( !bProt ) @@ -667,7 +673,8 @@ GoPrevCell: if( !pNd->IsEndNode() ) break; aCellStt.Assign( *pNd->StartOfSectionNode(), +1 ); - if( nullptr == ( pCNd = aCellStt.GetNode().GetContentNode() )) + pCNd = aCellStt.GetNode().GetContentNode(); + if( !pCNd ) pCNd = pNd->GetNodes().GoNext( &aCellStt ); bProt = pCNd->IsProtect(); if( !bProt ) @@ -963,9 +970,10 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, { // if string was not found in region then get all sections (cursors // stays unchanged) - if( 0 == ( nFound = lcl_FindSelection( rParas, this, fnMove, - pFndRing, aRegion, eFndRngs, - bInReadOnly, bCancel ) )) + nFound = lcl_FindSelection( rParas, this, fnMove, + pFndRing, aRegion, eFndRngs, + bInReadOnly, bCancel ); + if( 0 == nFound ) return nFound; // found string at least once; it's all in new Cursor ring thus delete old one diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index cdee8e9c54d4..6cb3488f68bc 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -820,10 +820,11 @@ bool SwCursorShell::CheckTableBoxContent( const SwPosition* pPos ) GetTableBox( m_pBoxIdx->GetIndex() ) ) pChkBox = m_pBoxPtr; } - else if( nullptr != ( pSttNd = pPos->nNode.GetNode(). - FindSttNodeByType( SwTableBoxStartNode )) ) + else { - pChkBox = pSttNd->FindTableNode()->GetTable().GetTableBox( pSttNd->GetIndex() ); + pSttNd = pPos->nNode.GetNode().FindSttNodeByType( SwTableBoxStartNode ); + if( pSttNd) + pChkBox = pSttNd->FindTableNode()->GetTable().GetTableBox( pSttNd->GetIndex() ); } // box has more than one paragraph diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index c76e4417c020..d18d020e8c88 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1823,7 +1823,8 @@ void DelBookmarks( { bStt = false; pRStt->nNode = rStt; - if( nullptr == ( pCNd = SwNodes::GoPrevious( &pRStt->nNode )) ) + pCNd = SwNodes::GoPrevious( &pRStt->nNode ); + if( !pCNd ) { pRStt->nNode = pREnd->nNode; pCNd = pRStt->nNode.GetNode().GetContentNode(); @@ -1847,7 +1848,8 @@ void DelBookmarks( { bStt = true; pREnd->nNode = rEnd; - if( nullptr == ( pCNd = pDoc->GetNodes().GoNext( &pREnd->nNode )) ) + pCNd = pDoc->GetNodes().GoNext( &pREnd->nNode ); + if( !pCNd ) { pREnd->nNode = pRStt->nNode; pCNd = pREnd->nNode.GetNode().GetContentNode(); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 7ea93bb4a649..7d4691a3422c 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -222,7 +222,8 @@ bool SetGetExpField::operator<( const SetGetExpField& rField ) const else pFirstStt = pFirst->StartOfSectionNode(); - if( nullptr != ( pTableNd = pNext->FindTableNode() ) ) + pTableNd = pNext->FindTableNode(); + if( pTableNd ) pNextStt = pTableNd->StartOfSectionNode(); else pNextStt = pNext->StartOfSectionNode(); diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 9929ec8ae599..af02d317d284 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1451,7 +1451,8 @@ void SwDoc::SetAllUniqueFlyNames() const OUString sGrfNm(SwResId(STR_GRAPHIC_DEFNAME)); const OUString sOLENm(SwResId(STR_OBJECT_DEFNAME)); - if( 255 < ( n = GetSpzFrameFormats()->size() )) + n = GetSpzFrameFormats()->size(); + if( 255 < n ) n = 255; SwFrameFormatsV aArr; aArr.reserve( n ); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 15222f091f25..13b6136ef89a 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -2566,7 +2566,9 @@ OUString SwDoc::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) c // All Numbers have been flagged accordingly, so identify the right Number nNum = mpNumRuleTable->size(); for( sal_uInt16 n = 0; n < nFlagSize; ++n ) - if( 0xff != ( nTmp = pSetFlags[ n ] )) + { + nTmp = pSetFlags[ n ]; + if( 0xff != nTmp ) { // identify the Number nNum = n * 8; @@ -2577,6 +2579,7 @@ OUString SwDoc::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) c } break; } + } } if( pChkStr && !pChkStr->isEmpty() ) return *pChkStr; diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 21ff81b7b1d6..3a5f982f72e8 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -200,11 +200,14 @@ OUString SwSortTextElement::GetKey(sal_uInt16 nId) const // Find the delimiter while( nStart != -1 && i < nDCount) - if( -1 != ( nStart = rStr.indexOf( nDeli, nStart ) ) ) + { + nStart = rStr.indexOf( nDeli, nStart ); + if( -1 != nStart ) { nStart++; i++; } + } // Found next delimiter or end of String // and copy diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 164a33ae54cd..cdb75e14755b 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -747,11 +747,13 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwNodeIndex& rSttBox, // Do not create empty Sections, otherwise they will be deleted! lcl_CpyBox( rCpyTable, pCpyBox, *this, pMyBox, bDelContent, pUndo ); - if( nullptr == (pTmp = pCpyBox->FindNextBox( rCpyTable, pCpyBox, false ))) + pTmp = pCpyBox->FindNextBox( rCpyTable, pCpyBox, false ); + if( !pTmp ) break; // no more Boxes pCpyBox = pTmp; - if( nullptr == ( pTmp = pMyBox->FindNextBox( *this, pMyBox, false ))) + pTmp = pMyBox->FindNextBox( *this, pMyBox, false ); + if( !pTmp ) bDelContent = false; // No space left? else pMyBox = const_cast<SwTableBox*>(pTmp); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 5eb2ff9994b0..9fabc3e00a99 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -1362,7 +1362,8 @@ static void lcl_Merge_MoveBox(FndBox_ & rFndBox, InsULPara *const pULPara) if( pULPara->bUL ) // Left ? { // if there are Boxes before it, move them - if( 0 != ( nPos = pFndTableBox->GetUpper()->GetBoxPos( pFndTableBox ) ) ) + nPos = pFndTableBox->GetUpper()->GetBoxPos( pFndTableBox ); + if( 0 != nPos ) lcl_CpyBoxes( 0, nPos, *pBoxes, pULPara->pInsLine ); } else // Right diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 4d12c2d2e812..a4a907b4fc9a 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -339,7 +339,8 @@ void SwTextNode::CopyCollFormat( SwTextNode& rDestNd ) SwAttrSet aPgBrkSet( pDestDoc->GetAttrPool(), aBreakSetRange ); const SwAttrSet* pSet; - if( nullptr != ( pSet = rDestNd.GetpSwAttrSet() ) ) + pSet = rDestNd.GetpSwAttrSet(); + if( nullptr != pSet ) { // Special cases for Break-Attributes const SfxPoolItem* pAttr; @@ -351,7 +352,8 @@ void SwTextNode::CopyCollFormat( SwTextNode& rDestNd ) } rDestNd.ChgFormatColl( pDestDoc->CopyTextColl( *GetTextColl() )); - if( nullptr != ( pSet = GetpSwAttrSet() ) ) + pSet = GetpSwAttrSet(); + if( nullptr != pSet ) pSet->CopyToModify( rDestNd ); if( aPgBrkSet.Count() ) diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index f59db1e8533e..845e3156c765 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -1320,12 +1320,15 @@ void SwSectionNode::NodesArrChgd() // Set the right StartNode for all in this Area sal_uLong nStart = GetIndex()+1, nEnd = EndOfSectionIndex(); for( sal_uLong n = nStart; n < nEnd; ++n ) + { // Make up the Format's nesting - if( nullptr != ( pSectNd = rNds[ n ]->GetSectionNode() ) ) + pSectNd = rNds[ n ]->GetSectionNode(); + if( nullptr != pSectNd ) { pSectNd->GetSection().GetFormat()->SetDerivedFrom( pFormat ); n = pSectNd->EndOfSectionIndex(); } + } // Moving Nodes to the UndoNodes array? if( rNds.IsDocNodes() ) diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 4d5469e8fdac..3e36cfcabc81 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -215,7 +215,8 @@ SwTableNode* SwDoc::IsIdxInTable(const SwNodeIndex& rIdx) sal_uLong nIndex = rIdx.GetIndex(); do { SwNode* pNd = GetNodes()[ nIndex ]->StartOfSectionNode(); - if( nullptr != ( pTableNd = pNd->GetTableNode() ) ) + pTableNd = pNd->GetTableNode(); + if( nullptr != pTableNd ) break; nIndex = pNd->GetIndex(); @@ -245,19 +246,25 @@ bool SwNodes::InsBoxen( SwTableNode* pTableNd, { if( nInsPos < pLine->GetTabBoxes().size() ) { - if( nullptr == (pPrvBox = pLine->FindPreviousBox( pTableNd->GetTable(), - pLine->GetTabBoxes()[ nInsPos ] ))) + pPrvBox = pLine->FindPreviousBox( pTableNd->GetTable(), + pLine->GetTabBoxes()[ nInsPos ] ); + if( nullptr == pPrvBox ) pPrvBox = pLine->FindPreviousBox( pTableNd->GetTable() ); } else { - if( nullptr == (pNxtBox = pLine->FindNextBox( pTableNd->GetTable(), - pLine->GetTabBoxes().back() ))) + pNxtBox = pLine->FindNextBox( pTableNd->GetTable(), + pLine->GetTabBoxes().back() ); + if( nullptr == pNxtBox ) pNxtBox = pLine->FindNextBox( pTableNd->GetTable() ); } } - else if( nullptr == ( pNxtBox = pLine->FindNextBox( pTableNd->GetTable() ))) - pPrvBox = pLine->FindPreviousBox( pTableNd->GetTable() ); + else + { + pNxtBox = pLine->FindNextBox( pTableNd->GetTable() ); + if( nullptr == pNxtBox ) + pPrvBox = pLine->FindPreviousBox( pTableNd->GetTable() ); + } if( !pPrvBox && !pNxtBox ) { @@ -1650,7 +1657,8 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, SwSectionNode *pSNd; while( aDelRg.aStart.GetIndex() < nEnd ) { - if( nullptr != ( pCNd = aDelRg.aStart.GetNode().GetContentNode())) + pCNd = aDelRg.aStart.GetNode().GetContentNode(); + if( nullptr != pCNd ) { if( pFrameNd->IsContentNode() ) static_cast<SwContentNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(*pCNd); @@ -1660,14 +1668,18 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, static_cast<SwSectionNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aDelRg.aStart); pFrameNd = pCNd; } - else if( nullptr != ( pSNd = aDelRg.aStart.GetNode().GetSectionNode())) + else { - if( !pSNd->GetSection().IsHidden() && !pSNd->IsContentHidden() ) + pSNd = aDelRg.aStart.GetNode().GetSectionNode(); + if( pSNd ) { - pSNd->MakeOwnFrames(&aFrameIdx, &aDelRg.aEnd); - break; + if( !pSNd->GetSection().IsHidden() && !pSNd->IsContentHidden() ) + { + pSNd->MakeOwnFrames(&aFrameIdx, &aDelRg.aEnd); + break; + } + aDelRg.aStart = *pSNd->EndOfSectionNode(); } - aDelRg.aStart = *pSNd->EndOfSectionNode(); } ++aDelRg.aStart; } diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 6dc3814db244..798d20bf98fa 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -278,8 +278,8 @@ static void lcl_CollectLines( std::vector<SwTableLine*> &rArr, const SwCursor& r static void lcl_ProcessRowAttr(std::vector<std::unique_ptr<SwTableFormatCmp>>& rFormatCmp, SwTableLine* pLine, const SfxPoolItem& rNew) { - SwFrameFormat *pNewFormat; - if ( nullptr != (pNewFormat = SwTableFormatCmp::FindNewFormat( rFormatCmp, pLine->GetFrameFormat(), 0 ))) + SwFrameFormat *pNewFormat = SwTableFormatCmp::FindNewFormat( rFormatCmp, pLine->GetFrameFormat(), 0 ); + if ( nullptr != pNewFormat ) pLine->ChgFrameFormat( static_cast<SwTableLineFormat*>(pNewFormat) ); else { @@ -800,8 +800,8 @@ void SwDoc::SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet ) } SwTableBox *pBox = const_cast<SwTableBox*>(pCell->GetTabBox()); - SwFrameFormat *pNewFormat; - if ( nullptr != (pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), nType ))) + SwFrameFormat *pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), nType ); + if ( nullptr != pNewFormat ) pBox->ChgFrameFormat( static_cast<SwTableBoxFormat*>(pNewFormat) ); else { @@ -1163,8 +1163,8 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew ) { SwTableBox *pBox = aBoxes[i]; - SwFrameFormat *pNewFormat; - if ( nullptr != (pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), 0 ))) + SwFrameFormat *pNewFormat = SwTableFormatCmp::FindNewFormat( aFormatCmp, pBox->GetFrameFormat(), 0 ); + if ( nullptr != pNewFormat ) pBox->ChgFrameFormat( static_cast<SwTableBoxFormat*>(pNewFormat) ); else { diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index e5b0a4061d64..171aa8454744 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -296,7 +296,8 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const SwNodeType nNdType ) SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes()); SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ]; rNodes.InsertNode( this, rWhere ); - if( nullptr == ( m_pStartOfSection = pNd->GetStartNode()) ) + m_pStartOfSection = pNd->GetStartNode(); + if( nullptr == m_pStartOfSection ) { m_pStartOfSection = pNd->m_pStartOfSection; if( pNd->GetEndNode() ) // Skip EndNode ? Section @@ -328,7 +329,8 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType ) { SwNode* pNd = rNodes[ nPos - 1 ]; rNodes.InsertNode( this, nPos ); - if( nullptr == ( m_pStartOfSection = pNd->GetStartNode()) ) + m_pStartOfSection = pNd->GetStartNode(); + if( nullptr == m_pStartOfSection ) { m_pStartOfSection = pNd->m_pStartOfSection; if( pNd->GetEndNode() ) // Skip EndNode ? Section! @@ -423,7 +425,8 @@ bool SwNode::IsProtect() const if( pSttNd && static_cast<const SwSectionNode*>(pSttNd)->GetSection().IsProtectFlag() ) return true; - if( nullptr != ( pSttNd = FindTableBoxStartNode() ) ) + pSttNd = FindTableBoxStartNode(); + if( nullptr != pSttNd ) { SwContentFrame* pCFrame; if( IsContentNode() && nullptr != (pCFrame = static_cast<const SwContentNode*>(this)->getLayoutFrame( GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout() ) )) @@ -449,7 +452,8 @@ bool SwNode::IsProtect() const return &rAnchorNd != this && rAnchorNd.IsProtect(); } - if( nullptr != ( pSttNd = FindFootnoteStartNode() ) ) + pSttNd = FindFootnoteStartNode(); + if( nullptr != pSttNd ) { const SwTextFootnote* pTFootnote = GetDoc()->GetFootnoteIdxs().SeekEntry( SwNodeIndex( *pSttNd ) ); @@ -682,7 +686,8 @@ const SwPageDesc* SwNode::FindPageDesc( size_t* pPgDescNdIdx ) const } } - if( nullptr != ( pNd = aInfo.GetFoundNode() )) + pNd = aInfo.GetFoundNode(); + if( nullptr != pNd ) { if( pNd->IsContentNode() ) pPgDesc = static_cast<const SwFormatPageDesc&>(pNd->GetContentNode()-> diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 4d077fe401b4..54e931ac3821 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -181,10 +181,11 @@ SwContact* GetUserCall( const SdrObject* pObj ) /// Returns true if the SrdObject is a Marquee-Object (scrolling text) bool IsMarqueeTextObj( const SdrObject& rObj ) { - SdrTextAniKind eTKind; - return SdrInventor::Default == rObj.GetObjInventor() && - OBJ_TEXT == rObj.GetObjIdentifier() && - ( SdrTextAniKind::Scroll == ( eTKind = static_cast<const SdrTextObj&>(rObj).GetTextAniKind()) + if (SdrInventor::Default != rObj.GetObjInventor() || + OBJ_TEXT != rObj.GetObjIdentifier()) + return false; + SdrTextAniKind eTKind = static_cast<const SdrTextObj&>(rObj).GetTextAniKind(); + return ( SdrTextAniKind::Scroll == eTKind || SdrTextAniKind::Alternate == eTKind || SdrTextAniKind::Slide == eTKind ); } @@ -518,8 +519,8 @@ SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFor // order to transport the z-order. // After creating the first Reference the Masters are removed from the // List and are not important anymore. - SdrPage* pPg(nullptr); - if(nullptr != (pPg = pContact->GetMaster()->getSdrPageFromSdrObject())) + SdrPage* pPg = pContact->GetMaster()->getSdrPageFromSdrObject(); + if(nullptr != pPg) { const size_t nOrdNum = pContact->GetMaster()->GetOrdNum(); pPg->ReplaceObject(pDrawObj, nOrdNum); @@ -2222,9 +2223,9 @@ void SwDrawVirtObj::AddToDrawingPage() SdrObject* pOrgMasterSdrObj = mrDrawContact.GetMaster(); // insert 'virtual' drawing object into page, set layer and user call. - SdrPage* pDrawPg; + SdrPage* pDrawPg = pOrgMasterSdrObj->getSdrPageFromSdrObject(); // #i27030# - apply order number of referenced object - if ( nullptr != ( pDrawPg = pOrgMasterSdrObj->getSdrPageFromSdrObject() ) ) + if ( nullptr != pDrawPg ) { // #i27030# - apply order number of referenced object pDrawPg->InsertObject( this, GetReferencedObj().GetOrdNum() ); diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index fd69be2ca96a..155339cbcc5d 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -224,8 +224,8 @@ void SwDrawView::AddCustomHdl() if (RndStdIds::FLY_AS_CHAR == rAnchor.GetAnchorId()) return; - const SwFrame* pAnch; - if(nullptr == (pAnch = CalcAnchor())) + const SwFrame* pAnch = CalcAnchor(); + if(nullptr == pAnch) return; Point aPos(m_aAnchorPoint); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 20abffc64ea4..fb982cd8552c 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -517,7 +517,9 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const SwContentNode* pCNd; for( sal_uLong n = nSttNd; bRet && n <= nEndNd; ++n ) - if( nullptr != ( pCNd = GetDoc()->GetNodes()[ n ]->GetTextNode() )) + { + pCNd = GetDoc()->GetNodes()[ n ]->GetTextNode(); + if( nullptr != pCNd ) { pCNd = sw::GetParaPropsNode(*GetLayout(), *pCNd); const SvxLRSpaceItem& rLS = static_cast<const SvxLRSpaceItem&>( @@ -539,6 +541,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const bRet = false; } } + } if( !bRet ) break; diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 816c4cf727e1..ed67d98f01a0 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -2231,7 +2231,8 @@ SwTextFormatColl* SwEditShell::MakeTextFormatColl(const OUString& rFormatCollNam SwTextFormatColl *pColl; if ( pParent == nullptr ) pParent = &GetTextFormatColl(0); - if ( (pColl=GetDoc()->MakeTextFormatColl(rFormatCollName, pParent)) == nullptr ) + pColl = GetDoc()->MakeTextFormatColl(rFormatCollName, pParent); + if ( pColl == nullptr ) { OSL_FAIL( "MakeTextFormatColl failed" ); } diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index dd05535e4e9f..ce60edf34ec9 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -264,7 +264,8 @@ void SwEditShell::UpdateOneField(SwField &rField) if( aPam.Start()->nContent != pCurStt->nContent ) bOkay = false; - if( nullptr != (pTextField = GetTextFieldAtPos( pCurStt, true )) ) + pTextField = GetTextFieldAtPos( pCurStt, true ); + if( nullptr != pTextField ) { pFormatField = const_cast<SwFormatField*>(&pTextField->GetFormatField()); SwField *pCurField = pFormatField->GetField(); diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 0b932fba1652..9e53670badfa 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -780,7 +780,8 @@ void SwEditShell::SetNumberingRestart() switch( pNd->GetNodeType() ) { case SwNodeType::Text: - if( nullptr != ( pContentFrame = static_cast<SwTextNode*>(pNd)->getLayoutFrame( GetLayout() )) ) + pContentFrame = static_cast<SwTextNode*>(pNd)->getLayoutFrame( GetLayout() ); + if( nullptr != pContentFrame ) { // skip hidden frames - ignore protection! if( !static_cast<SwTextFrame*>(pContentFrame)->IsHiddenNow() ) diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index db2cdc3bfe5a..166bf24282d3 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1236,7 +1236,8 @@ SwTextNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark if( pIdx ) { SwNodeIndex aIdx( *pIdx, 1 ); - if( nullptr == ( pTextNd = aIdx.GetNode().GetTextNode())) + pTextNd = aIdx.GetNode().GetTextNode(); + if( nullptr == pTextNd ) pTextNd = static_cast<SwTextNode*>(pDoc->GetNodes().GoNext( &aIdx )); } *pStt = 0; diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index ac98cefd0c63..98c017108e7f 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1227,8 +1227,8 @@ void SwFEShell::EndTextEdit() StartAllAction(); SdrView *pView = Imp()->GetDrawView(); SdrObject *pObj = pView->GetTextEditObject(); - SdrObjUserCall* pUserCall; - if( nullptr != ( pUserCall = GetUserCall(pObj) ) ) + SdrObjUserCall* pUserCall = GetUserCall(pObj); + if( nullptr != pUserCall ) { SdrObject *pTmp = static_cast<SwContact*>(pUserCall)->GetMaster(); if( !pTmp ) diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 242c148f89b0..ef52d5a43e0d 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1017,7 +1017,8 @@ static sal_uInt16 lcl_GetRowNumber( const SwPosition& rPos ) const SwContentFrame *pFrame; std::pair<Point, bool> const tmp(aTmpPt, false); - if( nullptr != ( pNd = rPos.nNode.GetNode().GetContentNode() )) + pNd = rPos.nNode.GetNode().GetContentNode(); + if( nullptr != pNd ) pFrame = pNd->getLayoutFrame(pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), &rPos, &tmp); else pFrame = nullptr; diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index e9840644667d..ee19c4b383b0 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -168,7 +168,8 @@ const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt, break; case CurRectType::HeaderFooter: - if( nullptr == (pFrame = pFrame->FindFooterOrHeader()) ) + pFrame = pFrame->FindFooterOrHeader(); + if( nullptr == pFrame ) return GetLayout()->getFrameArea(); break; @@ -702,7 +703,8 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, if( _opRef ) { pFrame = GetCurrFrame(); - if( nullptr != ( pFly = pFrame->FindFlyFrame() ) ) + pFly = pFrame->FindFlyFrame(); + if( nullptr != pFly ) pFrame = pFly->GetAnchorFrame(); } else diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index cdcb4451bf7e..33bc25fc896f 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -405,7 +405,8 @@ void GetTableSel( const SwLayoutFrame* pStart, const SwLayoutFrame* pEnd, pTable->Calc(pTable->getRootFrame()->GetCurrShell()->GetOut()); pTable->SetCompletePaint(); - if( nullptr == (pTable = pTable->GetFollow()) ) + pTable = pTable->GetFollow(); + if( nullptr == pTable ) break; } @@ -654,7 +655,8 @@ bool ChkChartSel( const SwNode& rSttNd, const SwNode& rEndNd ) pTable->Calc(pTable->getRootFrame()->GetCurrShell()->GetOut()); pTable->SetCompletePaint(); - if( nullptr == (pTable = pTable->GetFollow()) ) + pTable = pTable->GetFollow(); + if( nullptr == pTable ) break; } --nLoopMax; @@ -737,9 +739,11 @@ bool GetAutoSumSel( const SwCursorShell& rShell, SwCellFrames& rBoxes ) { sal_uInt16 nWhichId = 0; for( size_t n = rBoxes.size(); n; ) - if( USHRT_MAX != ( nWhichId = rBoxes[ --n ] - ->GetTabBox()->IsFormulaOrValueBox() )) + { + nWhichId = rBoxes[ --n ]->GetTabBox()->IsFormulaOrValueBox(); + if( USHRT_MAX != nWhichId ) break; + } // all boxes together, do not check the // row, if a formula or value was found @@ -805,9 +809,12 @@ bool GetAutoSumSel( const SwCursorShell& rShell, SwCellFrames& rBoxes ) { sal_uInt16 nWhichId = 0; for( size_t n = rBoxes.size(); n; ) - if( USHRT_MAX != ( nWhichId = rBoxes[ --n ] - ->GetTabBox()->IsFormulaOrValueBox() )) + { + nWhichId = rBoxes[ --n ] + ->GetTabBox()->IsFormulaOrValueBox(); + if( USHRT_MAX != nWhichId ) break; + } // all boxes together, do not check the // row if a formula or value was found diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index 548399e40478..a2d6508e459c 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -1229,8 +1229,8 @@ SwFrame *SwFrame::FindPrev_() void SwFrame::ImplInvalidateNextPos( bool bNoFootnote ) { - SwFrame *pFrame; - if ( nullptr != (pFrame = FindNext_()) ) + SwFrame *pFrame = FindNext_(); + if ( nullptr != pFrame ) { if( pFrame->IsSctFrame() ) { diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index e33cb736ce19..b67fdc5a07bd 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -474,7 +474,8 @@ bool SwFlowFrame::PasteTree( SwFrame *pStart, SwLayoutFrame *pParent, SwFrame *p // On the way there, we invalidate as required. if ( pSibling ) { - if ( nullptr != (pStart->mpPrev = pSibling->GetPrev()) ) + pStart->mpPrev = pSibling->GetPrev(); + if ( nullptr != pStart->mpPrev ) pStart->GetPrev()->mpNext = pStart; else pParent->m_pLower = pStart; @@ -483,7 +484,8 @@ bool SwFlowFrame::PasteTree( SwFrame *pStart, SwLayoutFrame *pParent, SwFrame *p } else { - if ( nullptr == (pStart->mpPrev = pParent->Lower()) ) + pStart->mpPrev = pParent->Lower(); + if ( nullptr == pStart->mpPrev ) pParent->m_pLower = pStart; else //i#100782 diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index ddd7d41e3bc7..c41e61b98b65 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2718,8 +2718,8 @@ SwFrame *SaveContent( SwLayoutFrame *pLay, SwFrame *pStart ) if( pLay->IsSctFrame() && pLay->Lower() && pLay->Lower()->IsColumnFrame() ) sw_RemoveFootnotes( static_cast<SwColumnFrame*>(pLay->Lower()), true, true ); - SwFrame *pSav; - if ( nullptr == (pSav = pLay->ContainsAny()) ) + SwFrame *pSav = pLay->ContainsAny(); + if ( nullptr == pSav ) return nullptr; if( pSav->IsInFootnote() && !pLay->IsInFootnote() ) diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 7f913c8a02ff..f84d33eccb3f 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -862,8 +862,8 @@ static const SwFrame *lcl_FindFirstInvaLay( const SwFrame *pFrame, long nBottom { if (lcl_IsInvaLay(pFrame, nBottom)) return pFrame; - const SwFrame *pTmp; - if ( nullptr != (pTmp = lcl_FindFirstInvaLay( pFrame, nBottom )) ) + const SwFrame *pTmp = lcl_FindFirstInvaLay( pFrame, nBottom ); + if ( nullptr != pTmp ) return pTmp; } pFrame = pFrame->GetNext(); diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index a77960ee3e98..9a343e793a51 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3796,9 +3796,9 @@ bool SwFlyFrame::IsBackgroundTransparent() const bool SwFlyFrame::IsPaint( SdrObject *pObj, const SwViewShell *pSh ) { - SdrObjUserCall *pUserCall; + SdrObjUserCall *pUserCall = GetUserCall(pObj); - if ( nullptr == ( pUserCall = GetUserCall(pObj) ) ) + if ( nullptr == pUserCall ) return true; //Attribute dependent, don't paint for printer or Preview diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index de9a62430822..807780612bdc 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -281,8 +281,10 @@ void SwSectionFrame::Cut_( bool bRemove ) { InvalidateNextPos(); // Someone has to take over the retouching: predecessor or Upper - if ( nullptr != (pFrame = GetPrev()) ) - { pFrame->SetRetouche(); + pFrame = GetPrev(); + if ( nullptr != pFrame ) + { + pFrame->SetRetouche(); pFrame->Prepare( PrepareHint::WidowsOrphans ); if ( pFrame->IsContentFrame() ) pFrame->InvalidatePage( pPage ); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index f4aed1ed650d..0a3e5f997357 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -3236,8 +3236,8 @@ void SwTabFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew ) InvalidatePrt_(); if ( nInvFlags & 0x40 ) InvalidatePos_(); - SwFrame *pTmp; - if ( nullptr != (pTmp = GetIndNext()) ) + SwFrame *pTmp = GetIndNext(); + if ( nullptr != pTmp ) { if ( nInvFlags & 0x04 ) { @@ -3599,8 +3599,10 @@ void SwTabFrame::Cut() { InvalidateNextPos(); //Someone has to do the retouch: predecessor or upper - if ( nullptr != (pFrame = GetPrev()) ) - { pFrame->SetRetouche(); + pFrame = GetPrev(); + if ( nullptr != pFrame ) + { + pFrame->SetRetouche(); pFrame->Prepare( PrepareHint::WidowsOrphans ); pFrame->InvalidatePos_(); if ( pFrame->IsContentFrame() ) diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index c7de73e4e0e7..8ea9580f9eb4 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1099,7 +1099,8 @@ bool GetFrameInPage( const SwContentFrame *pCnt, SwWhichPage fnWhichPage, return false; //Now the desired ContentFrame below the page - if( nullptr == (pCnt = (*fnPosPage)(pLayoutFrame)) ) + pCnt = (*fnPosPage)(pLayoutFrame); + if( nullptr == pCnt ) return false; else { diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 57db1547a1c6..c8be85e67d2d 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -827,7 +827,8 @@ void SwFrame::InsertBefore( SwLayoutFrame* pParent, SwFrame* pBehind ) mpNext = pBehind; if( pBehind ) { //Insert before pBehind. - if( nullptr != (mpPrev = pBehind->mpPrev) ) + mpPrev = pBehind->mpPrev; + if( nullptr != mpPrev ) mpPrev->mpNext = this; else mpUpper->m_pLower = this; @@ -863,7 +864,8 @@ void SwFrame::InsertBehind( SwLayoutFrame *pParent, SwFrame *pBefore ) if ( pBefore ) { //Insert after pBefore - if ( nullptr != (mpNext = pBefore->mpNext) ) + mpNext = pBefore->mpNext; + if ( nullptr != mpNext ) mpNext->mpPrev = this; pBefore->mpNext = this; } @@ -968,7 +970,8 @@ bool SwFrame::InsertGroupBefore( SwFrame* pParent, SwFrame* pBehind, SwFrame* pS pLast->mpNext = pBehind; if( pBehind ) { // Insert before pBehind. - if( nullptr != (mpPrev = pBehind->mpPrev) ) + mpPrev = pBehind->mpPrev; + if( nullptr != mpPrev ) mpPrev->mpNext = this; else mpUpper->m_pLower = this; @@ -1101,7 +1104,8 @@ void SwContentFrame::Paste( SwFrame* pParent, SwFrame* pSibling) { while ( pNxt && pNxt->IsInTab() ) { - if( nullptr != (pNxt = pNxt->FindTabFrame()) ) + pNxt = pNxt->FindTabFrame(); + if( nullptr != pNxt ) pNxt = pNxt->FindNextCnt(); } if ( pNxt ) @@ -1143,7 +1147,8 @@ void SwContentFrame::Cut() { while ( pNxt && pNxt->IsInTab() ) { - if( nullptr != (pNxt = pNxt->FindTabFrame()) ) + pNxt = pNxt->FindTabFrame(); + if( nullptr != pNxt ) pNxt = pNxt->FindNextCnt(); } if ( pNxt ) @@ -1154,7 +1159,8 @@ void SwContentFrame::Cut() } } - if( nullptr != (pFrame = GetIndNext()) ) + pFrame = GetIndNext(); + if( pFrame ) { // The old follow may have calculated a gap to the predecessor which // now becomes obsolete or different as it becomes the first one itself @@ -1187,7 +1193,8 @@ void SwContentFrame::Cut() { InvalidateNextPos(); //Someone needs to do the retouching: predecessor or upper - if ( nullptr != (pFrame = GetPrev()) ) + pFrame = GetPrev(); + if ( nullptr != pFrame ) { pFrame->SetRetouche(); pFrame->Prepare( PrepareHint::WidowsOrphans ); pFrame->InvalidatePos_(); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index e3e083127f89..d995524615c6 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1297,7 +1297,8 @@ sal_uInt16 SwTable::GetBoxNum( OUString& rStr, bool bFirstPart, sal_Unicode cChar = rStr[nPos]; if ((cChar<'A' || cChar>'Z') && (cChar<'a' || cChar>'z')) break; - if( (cChar -= 'A') >= 26 ) + cChar -= 'A'; + if( cChar >= 26 ) cChar -= 'a' - '['; if( bFirst ) bFirst = false; @@ -1793,7 +1794,8 @@ void sw_GetTableBoxColStr( sal_uInt16 nCol, OUString& rNm ) else rNm = OUStringChar( sal_Unicode('A' + nCalc) ) + rNm; - if( 0 == (nCol = nCol - nCalc) ) + nCol = nCol - nCalc; + if( 0 == nCol ) break; nCol /= coDiff; --nCol; @@ -1851,7 +1853,8 @@ OUString SwTableBox::GetName() const nPos = pBox->GetUpper()->GetBoxPos( pBox ); sTmp = OUString::number(nPos + 1); - if( nullptr != ( pBox = pLine->GetUpper()) ) + pBox = pLine->GetUpper(); + if( nullptr != pBox ) sNm = sTmp + "." + sNm; else sw_GetTableBoxColStr( nPos, sNm ); diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index 5d5b93f1fa44..50f0034090be 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -1210,7 +1210,8 @@ bool SwTextFrame::UnitDown_(SwPaM *pPam, const SwTwips nOffset, return true; } - if( nullptr != ( pTmpFollow = GetFollow() ) ) + pTmpFollow = GetFollow(); + if( nullptr != pTmpFollow ) { // Skip protected follows const SwContentFrame* pTmp = pTmpFollow; SwViewShell *pSh = getRootFrame()->GetCurrShell(); diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx index b285307a8449..087a3dd76c7a 100644 --- a/sw/source/core/text/itrtxt.cxx +++ b/sw/source/core/text/itrtxt.cxx @@ -75,7 +75,8 @@ SwLineLayout *SwTextIter::GetPrev_() return nullptr; while( pLay->GetNext() != m_pCurr ) pLay = pLay->GetNext(); - return m_pPrev = pLay; + m_pPrev = pLay; + return m_pPrev; } const SwLineLayout *SwTextIter::GetPrev() @@ -113,7 +114,8 @@ const SwLineLayout *SwTextIter::Next() m_nY += GetLineHeight(); if( m_pCurr->GetLen() || ( m_nLineNr>1 && !m_pCurr->IsDummy() ) ) ++m_nLineNr; - return m_pCurr = m_pCurr->GetNext(); + m_pCurr = m_pCurr->GetNext(); + return m_pCurr; } else return nullptr; diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index d785a9f3c74d..31602d3c3ac6 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -148,8 +148,8 @@ bool SwFlyCntPortion::Format( SwTextFormatInfo &rInf ) void SwTextFrame::MoveFlyInCnt(SwTextFrame *pNew, TextFrameIndex const nStart, TextFrameIndex const nEnd) { - SwSortedObjs *pObjs = nullptr; - if ( nullptr != (pObjs = GetDrawObjs()) ) + SwSortedObjs *pObjs = GetDrawObjs(); + if ( nullptr != pObjs ) { for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i ) { diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 6b6771ad93d9..6aa977013384 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -2584,8 +2584,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) if ( !nWhich ) { // is called by e. g. HiddenPara with 0 - SwFrame *pNxt; - if ( nullptr != (pNxt = FindNext()) ) + SwFrame *pNxt = FindNext(); + if ( nullptr != pNxt ) pNxt->InvalidatePrt(); } } @@ -3004,8 +3004,8 @@ bool SwTextFrame::Prepare( const PrepareHint ePrep, const void* pVoid, InvalidateSize(); InvalidatePrt_(); - SwFrame* pNxt; - if ( nullptr != ( pNxt = GetIndNext() ) ) + SwFrame* pNxt = GetIndNext(); + if ( nullptr != pNxt ) { pNxt->InvalidatePrt_(); if ( pNxt->IsLayoutFrame() ) @@ -3783,7 +3783,8 @@ void SwTextFrame::ChgThisLines() SwFrame *pNxt = GetNextContentFrame(); while( pNxt && pNxt->IsInTab() ) { - if( nullptr != (pNxt = pNxt->FindTabFrame()) ) + pNxt = pNxt->FindTabFrame(); + if( nullptr != pNxt ) pNxt = pNxt->FindNextCnt(); } if( pNxt ) diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index b41eb943c429..f8e055cf67e0 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -384,9 +384,10 @@ void SwFormatField::UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* p bool SwFormatField::GetInfo( SfxPoolItem& rInfo ) const { - const SwTextNode* pTextNd; - return RES_AUTOFMT_DOCNODE != rInfo.Which() || - !mpTextField || nullptr == ( pTextNd = mpTextField->GetpTextNode() ) || + if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !mpTextField ) + return true; + const SwTextNode* pTextNd = mpTextField->GetpTextNode(); + return nullptr == pTextNd || &pTextNd->GetNodes() != static_cast<SwAutoFormatGetDocNode&>(rInfo).pNodes; } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index fd8f65185987..4f76f4c0704c 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -453,7 +453,8 @@ void SwTextFootnote::MakeNewTextSection( SwNodes& rNodes ) nPoolId = RES_POOLCOLL_FOOTNOTE; } - if( nullptr == (pFormatColl = pInfo->GetFootnoteTextColl() ) ) + pFormatColl = pInfo->GetFootnoteTextColl(); + if( nullptr == pFormatColl ) pFormatColl = rNodes.GetDoc()->getIDocumentStylePoolAccess().GetTextCollFromPool( nPoolId ); SwStartNode* pSttNd = rNodes.MakeTextSection( SwNodeIndex( rNodes.GetEndOfInserts() ), diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 85b9867dd3fc..54c5181b43f4 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -1234,7 +1234,8 @@ void SwUndoSaveSection::SaveSection( SwContentNode* pCNd = aPam.GetContentNode( false ); if( pCNd ) aPam.GetMark()->nContent.Assign( pCNd, 0 ); - if( nullptr != ( pCNd = aPam.GetContentNode()) ) + pCNd = aPam.GetContentNode(); + if( nullptr != pCNd ) aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); // Keep positions as SwIndex so that this section can be deleted in DTOR diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 6888d477f67a..9c4f5ce8f84e 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -124,7 +124,8 @@ SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg, if( pCNd ) aPtPos.nContent.Assign( pCNd, pCNd->Len() ); SwPosition aMkPos( rRg.aStart ); - if( nullptr != ( pCNd = aMkPos.nNode.GetNode().GetContentNode() )) + pCNd = aMkPos.nNode.GetNode().GetContentNode(); + if( nullptr != pCNd ) aMkPos.nContent.Assign( pCNd, 0 ); DelContentIndex( aMkPos, aPtPos, DelContentType::Ftn ); diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index d453f1c79709..ba02dfcda14f 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -3067,10 +3067,14 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) { SolarMutexGuard g; - SwFrameFormat* pFormat; if(IsDescriptor()) + { attachToRange(xTextRange); - else if(nullptr != (pFormat = GetFrameFormat())) + return; + } + + SwFrameFormat* pFormat = GetFrameFormat(); + if( pFormat ) { SwDoc* pDoc = pFormat->GetDoc(); SwUnoInternalPaM aIntPam(*pDoc); @@ -3091,7 +3095,6 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) aAnchor.SetAnchor( aIntPam.Start() ); aSet.Put(aAnchor); pDoc->SetFlyFrameAttr( *pFormat, aSet ); - } } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 5dbf21b716d9..2c93482ebfb5 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -82,8 +82,8 @@ public: void SwPaintQueue::Add( SwViewShell *pNew, const SwRect &rNew ) { - SwQueuedPaint *pPt; - if (nullptr != (pPt = s_pPaintQueue)) + SwQueuedPaint *pPt = s_pPaintQueue; + if (nullptr != pPt) { while ( pPt->pSh != pNew && pPt->pNext ) pPt = pPt->pNext; @@ -132,8 +132,8 @@ void SwPaintQueue::Repaint() void SwPaintQueue::Remove( SwViewShell const *pSh ) { - SwQueuedPaint *pPt; - if (nullptr != (pPt = s_pPaintQueue)) + SwQueuedPaint *pPt = s_pPaintQueue; + if (nullptr != pPt) { SwQueuedPaint *pPrev = nullptr; while ( pPt && pPt->pSh != pSh ) diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index 2cf851d0b558..b3726c49dbf0 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -338,7 +338,8 @@ ErrCode SwASCIIParser::ReadChars() ), &nInfo, &nCntBytes ); - if( 0 != ( nArrOffset = lGCount - nCntBytes ) ) + nArrOffset = lGCount - nCntBytes; + if( 0 != nArrOffset ) memmove( pArr.get(), pArr.get() + nCntBytes, nArrOffset ); pStt = pLastStt = aWork.get(); diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx index cb1aa91335ea..790f91f0d344 100644 --- a/sw/source/filter/docx/swdocxreader.cxx +++ b/sw/source/filter/docx/swdocxreader.cxx @@ -184,7 +184,8 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks ) { SwNodeIndex& rIdx = aPam.GetPoint()->nNode; ++rIdx; - if( nullptr == ( pCNd = rIdx.GetNode().GetTextNode() ) ) + pCNd = rIdx.GetNode().GetTextNode(); + if( nullptr == pCNd ) { pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl ); rIdx = *pCNd; @@ -200,7 +201,8 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks ) if( rIdx.GetNode().GetTextNode() && rIdx.GetNode().GetTextNode()->GetText().isEmpty() ) rIdx = aStart.GetNode().EndOfSectionIndex() - 2; - if( nullptr == ( pCNd = rIdx.GetNode().GetContentNode() ) ) + pCNd = rIdx.GetNode().GetContentNode(); + if( nullptr == pCNd ) { ++rIdx; pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl ); diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 628ef2704630..f60a7dda459f 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -120,7 +120,8 @@ void SwHTMLParser::ConnectImageMaps() while( m_nMissingImgMaps > 0 && nIdx < nEndIdx ) { SwNode *pNd = rNds[nIdx + 1]; - if( nullptr != (pGrfNd = pNd->GetGrfNode()) ) + pGrfNd = pNd->GetGrfNode(); + if( nullptr != pGrfNd ) { SwFrameFormat *pFormat = pGrfNd->GetFlyFormat(); SwFormatURL aURL( pFormat->GetURL() ); diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 501bd8099059..5be2118a284b 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -368,7 +368,8 @@ void Writer::PutNumFormatFontsInAttrPool() if( SVX_NUM_CHAR_SPECIAL == (pFormat = &pRule->Get( nLvl ))->GetNumberingType() || SVX_NUM_BITMAP == pFormat->GetNumberingType() ) { - if( nullptr == ( pFont = pFormat->GetBulletFont() ) ) + pFont = pFormat->GetBulletFont(); + if( nullptr == pFont ) pFont = pDefFont; if( bCheck ) @@ -401,7 +402,8 @@ void Writer::AddFontItems_( SfxItemPool& rPool, sal_uInt16 nW ) const SvxFontItem* pFont = static_cast<const SvxFontItem*>(&rPool.GetDefaultItem( nW )); AddFontItem( rPool, *pFont ); - if( nullptr != ( pFont = static_cast<const SvxFontItem*>(rPool.GetPoolDefaultItem( nW ))) ) + pFont = static_cast<const SvxFontItem*>(rPool.GetPoolDefaultItem( nW )); + if( nullptr != pFont ) AddFontItem( rPool, *pFont ); for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nW)) diff --git a/sw/source/filter/writer/wrt_fn.cxx b/sw/source/filter/writer/wrt_fn.cxx index ded9420df294..7935ef672671 100644 --- a/sw/source/filter/writer/wrt_fn.cxx +++ b/sw/source/filter/writer/wrt_fn.cxx @@ -32,8 +32,8 @@ Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt ) { sal_uInt16 nId = rHt.Which(); OSL_ENSURE( nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" ); - FnAttrOut pOut; - if( nullptr != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] )) + FnAttrOut pOut = pTab[ nId - RES_CHRATR_BEGIN]; + if( nullptr != pOut ) (*pOut)( rWrt, rHt ); return rWrt; @@ -70,7 +70,8 @@ Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt, // pTab only covers POOLATTR_BEGIN..POOLATTR_END. if( pItem->Which() <= POOLATTR_END ) { - if( nullptr != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN]) ) + pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN]; + if( nullptr != pOut ) { (*pOut)( rWrt, *pItem ); } @@ -93,7 +94,8 @@ Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt, *pItem != pSet->GetParent()->Get( nWhich )) )) { - if( nullptr != ( pOut = pTab[ nWhich - RES_CHRATR_BEGIN] )) + pOut = pTab[ nWhich - RES_CHRATR_BEGIN]; + if( nullptr != pOut ) { (*pOut)( rWrt, *pItem ); } @@ -114,7 +116,8 @@ Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt, // may be handled more directly in HTML export to handle them. const std::unique_ptr<SvxBrushItem> aSvxBrushItem(getSvxBrushItemFromSourceSet(*pSet, RES_BACKGROUND, bDeep)); - if( nullptr != ( pOut = pTab[RES_BACKGROUND - RES_CHRATR_BEGIN] )) + pOut = pTab[RES_BACKGROUND - RES_CHRATR_BEGIN]; + if( nullptr != pOut ) { (*pOut)( rWrt, *aSvxBrushItem ); } @@ -146,8 +149,8 @@ Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt ) OSL_FAIL("What kind of node is it now?"); break; } - FnNodeOut pOut; - if( nullptr != ( pOut = pTab[ nId - RES_NODE_BEGIN ] )) + FnNodeOut pOut = pTab[ nId - RES_NODE_BEGIN ]; + if( nullptr != pOut ) (*pOut)( rWrt, *pCNd ); return rWrt; } diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 3cea7bfb88fe..57ef3730a4d0 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -1194,11 +1194,13 @@ void RtfExport::OutColorTable() { auto pCol = GetDfltAttr(RES_CHRATR_COLOR); InsColor(pCol->GetValue()); - if ((pCol = rPool.GetPoolDefaultItem(RES_CHRATR_COLOR))) + pCol = rPool.GetPoolDefaultItem(RES_CHRATR_COLOR); + if (pCol) InsColor(pCol->GetValue()); for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_COLOR)) { - if ((pCol = dynamic_cast<const SvxColorItem*>(pItem))) + pCol = dynamic_cast<const SvxColorItem*>(pItem); + if (pCol) InsColor(pCol->GetValue()); } @@ -1206,7 +1208,8 @@ void RtfExport::OutColorTable() InsColor(pUnder->GetColor()); for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_UNDERLINE)) { - if ((pUnder = dynamic_cast<const SvxUnderlineItem*>(pItem))) + pUnder = dynamic_cast<const SvxUnderlineItem*>(pItem); + if (pUnder) InsColor(pUnder->GetColor()); } @@ -1214,7 +1217,8 @@ void RtfExport::OutColorTable() InsColor(pOver->GetColor()); for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_OVERLINE)) { - if ((pOver = dynamic_cast<const SvxOverlineItem*>(pItem))) + pOver = dynamic_cast<const SvxOverlineItem*>(pItem); + if (pOver) InsColor(pOver->GetColor()); } } @@ -1226,13 +1230,15 @@ void RtfExport::OutColorTable() { auto pBackground = static_cast<const SvxBrushItem*>(GetDfltAttr(*pIds)); InsColor(pBackground->GetColor()); - if ((pBackground = static_cast<const SvxBrushItem*>(rPool.GetPoolDefaultItem(*pIds)))) + pBackground = static_cast<const SvxBrushItem*>(rPool.GetPoolDefaultItem(*pIds)); + if (pBackground) { InsColor(pBackground->GetColor()); } for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(*pIds)) { - if ((pBackground = static_cast<const SvxBrushItem*>(pItem))) + pBackground = static_cast<const SvxBrushItem*>(pItem); + if (pBackground) { InsColor(pBackground->GetColor()); } @@ -1243,13 +1249,15 @@ void RtfExport::OutColorTable() { auto pShadow = GetDfltAttr(RES_SHADOW); InsColor(pShadow->GetColor()); - if (nullptr != (pShadow = rPool.GetPoolDefaultItem(RES_SHADOW))) + pShadow = rPool.GetPoolDefaultItem(RES_SHADOW); + if (nullptr != pShadow) { InsColor(pShadow->GetColor()); } for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_SHADOW)) { - if ((pShadow = dynamic_cast<const SvxShadowItem*>(pItem))) + pShadow = dynamic_cast<const SvxShadowItem*>(pItem); + if (pShadow) { InsColor(pShadow->GetColor()); } @@ -1258,23 +1266,25 @@ void RtfExport::OutColorTable() // frame border color { - const SvxBoxItem* pBox; - if (nullptr != (pBox = rPool.GetPoolDefaultItem(RES_BOX))) + const SvxBoxItem* pBox = rPool.GetPoolDefaultItem(RES_BOX); + if (nullptr != pBox) InsColorLine(*pBox); for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_BOX)) { - if ((pBox = dynamic_cast<const SvxBoxItem*>(pItem))) + pBox = dynamic_cast<const SvxBoxItem*>(pItem); + if (pBox) InsColorLine(*pBox); } } { - const SvxBoxItem* pCharBox; - if ((pCharBox = rPool.GetPoolDefaultItem(RES_CHRATR_BOX))) + const SvxBoxItem* pCharBox = rPool.GetPoolDefaultItem(RES_CHRATR_BOX); + if (pCharBox) InsColorLine(*pCharBox); for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(RES_CHRATR_BOX)) { - if ((pCharBox = dynamic_cast<const SvxBoxItem*>(pItem))) + pCharBox = dynamic_cast<const SvxBoxItem*>(pItem); + if (pCharBox) InsColorLine(*pCharBox); } } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 0c4e6c9d2692..a721682939f9 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1855,7 +1855,8 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush, rPropOpt.AddOpt(ESCHER_Prop_fillBlip,nBlibId,true); } - if (0 != (nOpaque = pGraphicObject->GetAttr().GetTransparency())) + nOpaque = pGraphicObject->GetAttr().GetTransparency(); + if (0 != nOpaque) bSetOpacity = true; rPropOpt.AddOpt( ESCHER_Prop_fillType, ESCHER_FillPicture ); @@ -1869,7 +1870,8 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush, rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff ); rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 ); - if (0 != (nOpaque = rBrush.GetColor().GetTransparency())) + nOpaque = rBrush.GetColor().GetTransparency(); + if (0 != nOpaque) bSetOpacity = true; } @@ -1897,7 +1899,9 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, const SvxBorderLine* pLine; for( SvxBoxItemLine n : o3tl::enumrange<SvxBoxItemLine>() ) - if( nullptr != ( pLine = static_cast<const SvxBoxItem*>(pItem)->GetLine( n )) ) + { + pLine = static_cast<const SvxBoxItem*>(pItem)->GetLine( n ); + if( nullptr != pLine ) { if( bFirstLine ) { @@ -1956,6 +1960,7 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, } else rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(static_cast<const SvxBoxItem*>(pItem)->GetDistance( n )) ); + } } else { @@ -2253,7 +2258,8 @@ SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt) nBorderThick = WriteFlyFrame(*pObj, nShapeId, aSorted); break; case ww8::Frame::eFormControl: - WriteOCXControl(rFormat, nShapeId = GenerateShapeId()); + nShapeId = GenerateShapeId(); + WriteOCXControl(rFormat, nShapeId); break; case ww8::Frame::eDrawing: { @@ -2749,10 +2755,12 @@ sal_Int32 SwEscherEx::WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId, switch( aIdx.GetNode().GetNodeType() ) { case SwNodeType::Grf: - nBorderThick = WriteGrfFlyFrame( rFormat, rShapeId = GenerateShapeId() ); + rShapeId = GenerateShapeId(); + nBorderThick = WriteGrfFlyFrame( rFormat, rShapeId ); break; case SwNodeType::Ole: - nBorderThick = WriteOLEFlyFrame( rFormat, rShapeId = GenerateShapeId() ); + rShapeId = GenerateShapeId(); + nBorderThick = WriteOLEFlyFrame( rFormat, rShapeId ); break; default: if (const SdrObject* pObj = rFormat.FindRealSdrObject()) @@ -2975,7 +2983,8 @@ sal_uInt32 SwEscherEx::GetFlyShapeId(const SwFrameFormat& rFormat, sal_uInt32 nShapeId; if (USHRT_MAX != nPos) { - if (0 == (nShapeId = aFollowShpIds[nPos])) + nShapeId = aFollowShpIds[nPos]; + if (0 == nShapeId) { nShapeId = GenerateShapeId(); aFollowShpIds[ nPos ] = nShapeId; diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 653078824a6c..bfd251918c77 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -874,7 +874,8 @@ void wwFontHelper::InitFontTable(const SwDoc& rDoc) pFont->GetFamily(), pFont->GetCharSet())); const SfxItemPool& rPool = rDoc.GetAttrPool(); - if (nullptr != (pFont = rPool.GetPoolDefaultItem(RES_CHRATR_FONT))) + pFont = rPool.GetPoolDefaultItem(RES_CHRATR_FONT); + if (nullptr != pFont) { GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(), pFont->GetFamily(), pFont->GetCharSet())); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 6bdab61a8e9e..e5723fc0b1c4 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -700,8 +700,9 @@ void WW8Export::ExportDopTypography(WW8DopTypography &rTypo) for (rTypo.m_reserved1=8;rTypo.m_reserved1>0;rTypo.m_reserved1-=2) { - if (nullptr != (pForbidden = m_pDoc->getIDocumentSettingAccess().getForbiddenCharacters(rTypo.GetConvertedLang(), - false))) + pForbidden = m_pDoc->getIDocumentSettingAccess().getForbiddenCharacters(rTypo.GetConvertedLang(), + false); + if (nullptr != pForbidden) { int nIdx = (rTypo.m_reserved1-2)/2; if( lcl_CmpBeginEndChars( pForbidden->endLine, @@ -2496,7 +2497,8 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner const * p &(GetExport().m_pParentFrame->GetFrameFormat()) : GetExport().m_pDoc->GetPageDesc(0).GetPageFormatOfNode(*pTextNd, false); aRect = pParentFormat->FindLayoutRect(true); - if ( 0 == ( nPageSize = aRect.Width() ) ) + nPageSize = aRect.Width(); + if ( 0 == nPageSize ) { const SvxLRSpaceItem& rLR = pParentFormat->GetLRSpace(); nPageSize = pParentFormat->GetFrameSize().GetWidth() - rLR.GetLeft() diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index b11d85931a77..da9e60091df0 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -302,7 +302,8 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b // No explicit adjust set ? if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, bExportParentItemSet ) ) { - if ( nullptr != ( pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet ) ) ) + pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet ); + if ( nullptr != pItem ) { // then set the adjust used by the parent format AttrOutput().OutputItem( *pItem ); diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 6d8cdce2741b..7eb61220ad29 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -116,7 +116,8 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, { SwNodeIndex& rIdx = aPam.GetPoint()->nNode; ++rIdx; - if( nullptr == ( pCNd = rIdx.GetNode().GetTextNode() ) ) + pCNd = rIdx.GetNode().GetTextNode(); + if( nullptr == pCNd ) { pCNd = pD->GetNodes().MakeTextNode( rIdx, pColl ); rIdx = *pCNd; @@ -203,7 +204,8 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool bSaveRelFile ) rStrm->Seek(0); - if ( 0 != (nStrings = static_cast< sal_uInt16 >(aStrings.size()))) + nStrings = static_cast< sal_uInt16 >(aStrings.size()); + if ( 0 != nStrings ) { SfxObjectShellLock xDocSh(new SwDocShell(SfxObjectCreateMode::INTERNAL)); if (xDocSh->DoInitNew()) diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index dd4fea0b066e..68f834514762 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1455,7 +1455,8 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, // If we have just one single inline graphic then // don't insert a field for the single frame, set // the frames hyperlink field attribute directly. - if (nullptr != (pFrame = SwWW8ImplReader::ContainsSingleInlineGraphic(aRegion))) + pFrame = SwWW8ImplReader::ContainsSingleInlineGraphic(aRegion); + if (nullptr != pFrame) { const SwFormatINetFormat *pAttr = static_cast<const SwFormatINetFormat *>( rEntry.pAttr.get()); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index c93daeaeb1a1..2aabab794ed5 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2703,8 +2703,8 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam) } if (-1 != nEnd) { - if (-1 == - (nBegin = sPart.indexOf(',',nEnd))) + nBegin = sPart.indexOf(',',nEnd); + if (-1 == nBegin) { nBegin = sPart.indexOf(';',nEnd); } diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 53bbc0b619e9..81ee630ba8de 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -838,7 +838,8 @@ bool SwInsertDBColAutoPilot::SplitTextToColArr( const OUString& rText, while( -1 != ( nFndPos = sText.indexOf( cDBFieldStart, nSttPos ))) { nSttPos = nFndPos + 1; - if( -1 != ( nEndPos = sText.indexOf( cDBFieldEnd, nSttPos+1 ))) + nEndPos = sText.indexOf( cDBFieldEnd, nSttPos+1 ); + if( -1 != nEndPos ) { // Text in <> brackets found: what is it: SwInsDBColumn aSrch( sText.copy( nSttPos, nEndPos - nSttPos )); diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx index c6eae395ad0e..7f585248eef4 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.cxx +++ b/sw/source/ui/dbui/mmaddressblockpage.cxx @@ -1171,8 +1171,8 @@ void AddressMultiLineEdit::InsertNewEntry( const OUString& rStr ) m_xEditEngine->GetCharAttribs(nPara, aAttribList); sal_Int32 nIndex = aSelection.nEndPara; - const EECharAttrib* pAttrib; - if(nullptr != (pAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList))) + const EECharAttrib* pAttrib = FindCharAttrib(aSelection.nStartPos, aAttribList); + if(nullptr != pAttrib) nIndex = pAttrib->nEnd; InsertNewEntryAtPosition( rStr, nPara, nIndex ); diff --git a/sw/source/ui/fldui/inpdlg.cxx b/sw/source/ui/fldui/inpdlg.cxx index a1cbc81dd78a..7eaa19e9f0c0 100644 --- a/sw/source/ui/fldui/inpdlg.cxx +++ b/sw/source/ui/fldui/inpdlg.cxx @@ -70,8 +70,9 @@ SwFieldInputDlg::SwFieldInputDlg(weld::Widget *pParent, SwWrtShell &rS, case INP_USR: // user field - if( nullptr != ( pUsrType = static_cast<SwUserFieldType*>(rSh.GetFieldType( - SwFieldIds::User, pInpField->GetPar1() ) ) ) ) + pUsrType = static_cast<SwUserFieldType*>(rSh.GetFieldType( + SwFieldIds::User, pInpField->GetPar1() )); + if( nullptr != pUsrType ) aStr = pUsrType->GetContent(); break; } diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index c9fd24297e02..4257215e7c33 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -2914,12 +2914,14 @@ void SwFrameAddPage::Reset(const SfxItemSet *rSet ) const SwFormatChain &rChain = pFormat->GetChain(); const SwFlyFrameFormat* pFlyFormat; OUString sNextChain, sPrevChain; - if ((pFlyFormat = rChain.GetPrev()) != nullptr) + pFlyFormat = rChain.GetPrev(); + if (pFlyFormat != nullptr) { sPrevChain = pFlyFormat->GetName(); } - if ((pFlyFormat = rChain.GetNext()) != nullptr) + pFlyFormat = rChain.GetNext(); + if (pFlyFormat != nullptr) { sNextChain = pFlyFormat->GetName(); } @@ -3063,10 +3065,12 @@ bool SwFrameAddPage::FillItemSet(SfxItemSet *rSet) const SwFormatChain &rChain = pFormat->GetChain(); const SwFlyFrameFormat* pFlyFormat; OUString sNextChain, sPrevChain; - if ((pFlyFormat = rChain.GetPrev()) != nullptr) + pFlyFormat = rChain.GetPrev(); + if (pFlyFormat != nullptr) sPrevChain = pFlyFormat->GetName(); - if ((pFlyFormat = rChain.GetNext()) != nullptr) + pFlyFormat = rChain.GetNext(); + if (pFlyFormat != nullptr) sNextChain = pFlyFormat->GetName(); if(sPrevChain != sCurrentPrevChain) bRet |= nullptr != rSet->Put(SfxStringItem(FN_PARAM_CHAIN_PREVIOUS, sCurrentPrevChain)); diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index d8b3481b3286..ded8f725641a 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -419,7 +419,8 @@ void SwIndexMarkPane::InsertUpdate() m_pSh->EndAllAction(); m_pSh->EndUndo(m_bDel ? SwUndoId::INDEX_ENTRY_DELETE : SwUndoId::INDEX_ENTRY_INSERT); - if((nTypePos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text())) == -1) + nTypePos = m_xTypeDCB->find_text(m_xTypeDCB->get_active_text()); + if(nTypePos == -1) nTypePos = 0; nKey1Pos = m_xKey1DCB->find_text(m_xKey1DCB->get_active_text()); diff --git a/sw/source/ui/vba/vbatablehelper.cxx b/sw/source/ui/vba/vbatablehelper.cxx index b0b88ae2fd16..d580ada05714 100644 --- a/sw/source/ui/vba/vbatablehelper.cxx +++ b/sw/source/ui/vba/vbatablehelper.cxx @@ -107,7 +107,8 @@ OUString SwVbaTableHelper::getColumnStr( sal_Int32 nCol ) else sRet = OUStringChar( sal_Unicode('A' + nCalc) ) + sRet; - if( 0 == ( nCol = nCol - nCalc ) ) + nCol = nCol - nCalc; + if( 0 == nCol ) break; nCol /= coDiff; --nCol; diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index d92879eb3c0e..d4bcf37d4fca 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -317,7 +317,8 @@ SwView* lcl_LoadDoc(SwView* pView, const OUString& rURL) SfxViewShell* pViewShell = pShell->GetViewShell(); if(pViewShell) { - if ((pNewView = dynamic_cast<SwView*>(pViewShell))) + pNewView = dynamic_cast<SwView*>(pViewShell); + if (pNewView) { pNewView->GetViewFrame()->GetFrame().Appear(); } diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index aeb522be5fc9..2669bac63e86 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -747,10 +747,10 @@ bool SwDocShell::ConvertTo( SfxMedium& rMedium ) { SwAsciiOptions aOpt; OUString sItemOpt; - const SfxItemSet* pSet; - const SfxPoolItem* pItem; - if( nullptr != ( pSet = rMedium.GetItemSet() ) ) + const SfxItemSet* pSet = rMedium.GetItemSet(); + if( nullptr != pSet ) { + const SfxPoolItem* pItem; if( SfxItemState::SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) ) sItemOpt = static_cast<const SfxStringItem*>(pItem)->GetValue(); diff --git a/sw/source/uibase/docvw/romenu.cxx b/sw/source/uibase/docvw/romenu.cxx index 75aa8847d3d9..15cdb8e8ccd4 100644 --- a/sw/source/uibase/docvw/romenu.cxx +++ b/sw/source/uibase/docvw/romenu.cxx @@ -118,8 +118,8 @@ SwReadOnlyPopup::SwReadOnlyPopup(const Point &rDPos, SwView &rV) } bool bLink = false; - const Graphic *pGrf; - if ( nullptr == (pGrf = rSh.GetGrfAtPos( rDPos, m_sGrfName, bLink )) ) + const Graphic *pGrf = rSh.GetGrfAtPos( rDPos, m_sGrfName, bLink ); + if ( nullptr == pGrf ) { m_xMenu->EnableItem(m_nReadonlySaveGraphic, false); } diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index ff6b782968ff..4fe926573b45 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -349,8 +349,8 @@ static const SwFieldPack aSwFields[] = // access to the shell static SwWrtShell* lcl_GetShell() { - SwView* pView; - if ( nullptr != (pView = ::GetActiveView()) ) + SwView* pView = ::GetActiveView(); + if ( nullptr != pView ) return pView->GetWrtShellPtr(); OSL_FAIL("no current shell found!"); return nullptr; diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index c366e10c209d..46866d4a87f7 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -369,7 +369,8 @@ void SwRedlineAcceptDlg::Activate() if (&rRedln.GetRedlineData() != pParent->pData) { // Redline-Parents were inserted, changed or deleted - if ((i = CalcDiff(i, false)) == SwRedlineTable::npos) + i = CalcDiff(i, false); + if (i == SwRedlineTable::npos) return; continue; } @@ -380,7 +381,8 @@ void SwRedlineAcceptDlg::Activate() if (!pRedlineData && pBackupData) { // Redline-Children were deleted - if ((i = CalcDiff(i, true)) == SwRedlineTable::npos) + i = CalcDiff(i, true); + if (i == SwRedlineTable::npos) return; continue; } @@ -391,7 +393,8 @@ void SwRedlineAcceptDlg::Activate() if (pRedlineData != pBackupData->pChild) { // Redline-Children were inserted, changed or deleted - if ((i = CalcDiff(i, true)) == SwRedlineTable::npos) + i = CalcDiff(i, true); + if (i == SwRedlineTable::npos) return; continue; } @@ -703,7 +706,8 @@ void SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli if( !pCurrRedline ) { pSh->SwCursorShell::Push(); - if( nullptr == (pCurrRedline = pSh->SelNextRedline())) + pCurrRedline = pSh->SelNextRedline(); + if( nullptr == pCurrRedline ) pCurrRedline = pSh->SelPrevRedline(); pSh->SwCursorShell::Pop(SwCursorShell::PopMode::DeleteCurrent); } diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 186a6d337801..5d69014e0af2 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -1117,13 +1117,17 @@ void SwFrameShell::ExecFrameStyle(SfxRequest const & rReq) std::unique_ptr<SvxBoxItem> aNewBox(static_cast<SvxBoxItem*>(pItem->Clone())); const SvxBorderLine* pBorderLine; - if ((pBorderLine = aBoxItem->GetTop()) != nullptr) + pBorderLine = aBoxItem->GetTop(); + if (pBorderLine != nullptr) lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine); - if ((pBorderLine = aBoxItem->GetBottom()) != nullptr) + pBorderLine = aBoxItem->GetBottom(); + if (pBorderLine != nullptr) lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine); - if ((pBorderLine = aBoxItem->GetLeft()) != nullptr) + pBorderLine = aBoxItem->GetLeft(); + if (pBorderLine != nullptr) lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine); - if ((pBorderLine = aBoxItem->GetRight()) != nullptr) + pBorderLine = aBoxItem->GetRight(); + if (pBorderLine != nullptr) lcl_FrameGetMaxLineWidth(pBorderLine, aBorderLine); if(aBorderLine.GetOutWidth() == 0) diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx index e9808d6be430..f8a8dd844d79 100644 --- a/sw/source/uibase/shells/grfsh.cxx +++ b/sw/source/uibase/shells/grfsh.cxx @@ -167,8 +167,8 @@ void SwGrfShell::Execute(SfxRequest &rReq) } else if (nState == RET_NO) { - const Graphic *pGraphic; - if(nullptr != (pGraphic = rSh.GetGraphic())) + const Graphic *pGraphic = rSh.GetGraphic(); + if(nullptr != pGraphic) { OUString sGrfNm; OUString sFilterNm; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index f92b42b5a28c..15be728d74af 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1917,10 +1917,10 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& break; case WID_DOC_AUTOMATIC_CONTROL_FOCUS: { - SwDrawModel * pDrawDoc; + SwDrawModel * pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(); bool bAuto = *o3tl::doAccess<bool>(aValue); - if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) ) + if ( nullptr != pDrawDoc ) pDrawDoc->SetAutoControlFocus( bAuto ); else if (bAuto) { @@ -1937,10 +1937,10 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& break; case WID_DOC_APPLY_FORM_DESIGN_MODE: { - SwDrawModel * pDrawDoc; + SwDrawModel * pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(); bool bMode = *o3tl::doAccess<bool>(aValue); - if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) ) + if ( nullptr != pDrawDoc ) pDrawDoc->SetOpenInDesignMode( bMode ); else if (!bMode) { @@ -2095,9 +2095,9 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName) break; case WID_DOC_AUTOMATIC_CONTROL_FOCUS: { - SwDrawModel * pDrawDoc; + SwDrawModel * pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(); bool bAuto; - if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) ) + if ( nullptr != pDrawDoc ) bAuto = pDrawDoc->GetAutoControlFocus(); else bAuto = false; @@ -2106,9 +2106,9 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName) break; case WID_DOC_APPLY_FORM_DESIGN_MODE: { - SwDrawModel * pDrawDoc; + SwDrawModel * pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(); bool bMode; - if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) ) + if ( nullptr != pDrawDoc ) bMode = pDrawDoc->GetOpenInDesignMode(); else bMode = true; |