[Libreoffice-commits] core.git: sc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Sun Sep 10 19:37:45 UTC 2017


 sc/source/ui/view/gridwin4.cxx |  103 +++++++++++++++++------------------------
 1 file changed, 45 insertions(+), 58 deletions(-)

New commits:
commit ca29f20ea682f6fbae0fbf6a8146e656f635a0d5
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Sun Sep 10 19:34:42 2017 +0200

    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 at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jochen Nitschke <j.nitschke+logerrit at ok.de>

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 ) );
+                            }
                         }
                     }
 


More information about the Libreoffice-commits mailing list