diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-09-10 19:34:42 +0200 |
---|---|---|
committer | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-09-10 21:37:23 +0200 |
commit | ca29f20ea682f6fbae0fbf6a8146e656f635a0d5 (patch) | |
tree | d5a9d0b13582b261a5213b35f3e2b3b3930ef703 /sc | |
parent | 2cd664b3d618e6085be8b44ee86eada6cd5f8789 (diff) |
cppcheck: knownConditionTrueFalse 'bTestMerge' is always true
true since introduced in
commit 11b5e05a827851e287315345bf563fda7e24d151
Date: Tue Nov 14 14:57:04 2006 +0000
INTEGRATION: CWS aw024 (1.26.134); FILE MERGED
Change-Id: I86fd4d203c2c59209b9190faf82e27065d251cd7
Reviewed-on: https://gerrit.libreoffice.org/42141
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jochen Nitschke <j.nitschke+logerrit@ok.de>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 103 |
1 files changed, 45 insertions, 58 deletions
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 97ff7c9cef00..5ffe55505ddf 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1782,13 +1782,12 @@ void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelR PutInOrder( nX1, nX2 ); PutInOrder( nY1, nY2 ); - bool bTestMerge = true; bool bRepeat = true; SCCOL nTestX2 = nX2; SCROW nTestY2 = nY2; - if (bTestMerge) - pDoc->ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab ); + + pDoc->ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab ); SCCOL nPosX = pViewData->GetPosX( eHWhich ); SCROW nPosY = pViewData->GetPosY( eVWhich ); @@ -1849,21 +1848,19 @@ void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelR bool bDoRow = ( nHeightTwips != 0 ); if (bDoRow) { - if (bTestMerge) - if (bWasHidden) // test hidden merge - { - bDoHidden = true; - bDoRow = true; - } + if (bWasHidden) // test hidden merge + { + bDoHidden = true; + bDoRow = true; + } bWasHidden = false; } else { bWasHidden = true; - if (bTestMerge) - if (nY==nY2) - bDoRow = true; // last cell of the block + if (nY==nY2) + bDoRow = true; // last cell of the block } if ( bDoRow ) @@ -1887,64 +1884,54 @@ void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelR if ( nWidth > 0 ) { long nEndX = nScrX + ( nWidth - 1 ) * nLayoutSign; - if (bTestMerge) + + SCROW nThisY = nY; + const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab ); + const ScMergeFlagAttr* pMergeFlag = static_cast<const ScMergeFlagAttr*>( &pPattern-> + GetItem(ATTR_MERGE_FLAG) ); + if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) ) { - SCROW nThisY = nY; - const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab ); - const ScMergeFlagAttr* pMergeFlag = static_cast<const ScMergeFlagAttr*>( &pPattern-> - GetItem(ATTR_MERGE_FLAG) ); - if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) ) + while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 && + (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) ) { - while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 && - (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) ) - { - --nThisY; - pPattern = pDoc->GetPattern( nX, nThisY, nTab ); - pMergeFlag = static_cast<const ScMergeFlagAttr*>( &pPattern->GetItem(ATTR_MERGE_FLAG) ); - } + --nThisY; + pPattern = pDoc->GetPattern( nX, nThisY, nTab ); + pMergeFlag = static_cast<const ScMergeFlagAttr*>( &pPattern->GetItem(ATTR_MERGE_FLAG) ); } + } - // only the rest of the merged is seen ? - SCCOL nThisX = nX; - if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 ) + // only the rest of the merged is seen ? + SCCOL nThisX = nX; + if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 ) + { + while ( pMergeFlag->IsHorOverlapped() ) { - while ( pMergeFlag->IsHorOverlapped() ) - { - --nThisX; - pPattern = pDoc->GetPattern( nThisX, nThisY, nTab ); - pMergeFlag = static_cast<const ScMergeFlagAttr*>( &pPattern->GetItem(ATTR_MERGE_FLAG) ); - } + --nThisX; + pPattern = pDoc->GetPattern( nThisX, nThisY, nTab ); + pMergeFlag = static_cast<const ScMergeFlagAttr*>( &pPattern->GetItem(ATTR_MERGE_FLAG) ); } + } - if ( aMultiMark.IsCellMarked( nThisX, nThisY, true ) == bRepeat ) + if ( aMultiMark.IsCellMarked( nThisX, nThisY, true ) == bRepeat ) + { + if ( !pMergeFlag->IsOverlapped() ) { - if ( !pMergeFlag->IsOverlapped() ) + const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(&pPattern->GetItem(ATTR_MERGE)); + if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0) { - const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(&pPattern->GetItem(ATTR_MERGE)); - if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0) + Point aEndPos = pViewData->GetScrPos( + nThisX + pMerge->GetColMerge(), + nThisY + pMerge->GetRowMerge(), eWhich ); + if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY ) { - Point aEndPos = pViewData->GetScrPos( - nThisX + pMerge->GetColMerge(), - nThisY + pMerge->GetRowMerge(), eWhich ); - if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY ) - { - aInvert.AddRect( tools::Rectangle( nScrX,nScrY, - aEndPos.X()-nLayoutSign,aEndPos.Y()-1 ) ); - } - } - else if ( nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY ) - { - aInvert.AddRect( tools::Rectangle( nScrX,nScrY,nEndX,nEndY ) ); + aInvert.AddRect( tools::Rectangle( nScrX,nScrY, + aEndPos.X()-nLayoutSign,aEndPos.Y()-1 ) ); } } - } - } - else // !bTestMerge - { - if ( aMultiMark.IsCellMarked( nX, nY, true ) == bRepeat && - nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY ) - { - aInvert.AddRect( tools::Rectangle( nScrX,nScrY,nEndX,nEndY ) ); + else if ( nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY ) + { + aInvert.AddRect( tools::Rectangle( nScrX,nScrY,nEndX,nEndY ) ); + } } } |