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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Nov 10 09:39:58 UTC 2018


 sw/source/core/layout/trvlfrm.cxx |   31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

New commits:
commit 03a21573479c867ea8bdf3dfc834410c424295e0
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Nov 8 16:47:05 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Nov 10 10:39:36 2018 +0100

    tdf#120703 PVS: V547 Expression 'bRet' is always true
    
    Change-Id: I637ba12d0c1b7baa8f7f4be456e6101594eb934a
    Reviewed-on: https://gerrit.libreoffice.org/63227
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 1dda19b28375..584b74c5f98e 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -172,7 +172,6 @@ bool SwLayoutFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
 bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
                              SwCursorMoveState* pCMS, bool bTestBackground ) const
 {
-    bool bRet = false;
     Point aPoint( rPoint );
 
     // check, if we have to adjust the point
@@ -184,9 +183,7 @@ bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
         aPoint.setY( std::min( aPoint.Y(), getFrameArea().Bottom() ) );
     }
 
-    bool bTextRet = false;
-    bool bBackRet = false;
-
+    bool bRet = false;
     //Could it be a free flying one?
     //If his content should be protected, we can't set the Cursor in it, thus
     //all changes should be impossible.
@@ -203,11 +200,7 @@ bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
         //We fix the StartPoint if no Content below the page 'answers' and then
         //start all over again one page before the current one.
         //However we can't use Flys in such a case.
-        if ( SwLayoutFrame::GetCursorOfst( &aTextPos, aPoint, pCMS ) )
-        {
-            bTextRet = true;
-        }
-        else
+        if (!SwLayoutFrame::GetCursorOfst(&aTextPos, aPoint, pCMS))
         {
             if ( pCMS && (pCMS->m_bStop || pCMS->m_bExactOnly) )
             {
@@ -220,6 +213,8 @@ bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
             if ( pCMS && pCMS->m_bStop )
                 return false;
 
+            bool bTextRet = false;
+
             OSL_ENSURE( pCnt, "Cursor is gone to a Black hole" );
             if( pCMS && pCMS->m_pFill && pCnt->IsTextFrame() )
                 bTextRet = pCnt->GetCursorOfst( &aTextPos, rPoint, pCMS );
@@ -239,7 +234,6 @@ bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
                     assert(pCnt->IsNoTextFrame());
                     aTextPos = SwPosition( *static_cast<SwNoTextFrame const*>(pCnt)->GetNode() );
                 }
-                bTextRet = true;
             }
         }
 
@@ -258,23 +252,22 @@ bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
             }
         }
 
+        bool bBackRet = false;
         // Check objects in the background if nothing else matched
         if ( GetSortedObjs() )
         {
             bBackRet = lcl_GetCursorOfst_Objects( this, true, &aBackPos, rPoint, pCMS );
         }
 
-        if ( ( bConsiderBackground && bTestBackground && bBackRet ) || !bTextRet )
+        if (bConsiderBackground && bTestBackground && bBackRet)
         {
-            bRet = bBackRet;
             (*pPos) = aBackPos;
         }
-        else if (bTextRet && !bBackRet)
+        else if (!bBackRet)
         {
-            bRet = bTextRet;
             (*pPos) = aTextPos;
         }
-        else
+        else // bBackRet && !(bConsiderBackground && bTestBackground)
         {
             /* In order to provide a selection as accurate as possible when we have both
              * text and background object, then we compute the distance between both
@@ -349,21 +342,17 @@ bool SwPageFrame::GetCursorOfst( SwPosition *pPos, Point &rPoint,
 
             if ( bValidTextDistance && bValidBackDistance && basegfx::fTools::more( nTextDistance, nBackDistance ) )
             {
-                bRet = bBackRet;
                 (*pPos) = aBackPos;
             }
             else
             {
-                bRet = bTextRet;
                 (*pPos) = aTextPos;
             }
         }
     }
 
-    if ( bRet )
-        rPoint = aPoint;
-
-    return bRet;
+    rPoint = aPoint;
+    return true;
 }
 
 bool SwLayoutFrame::FillSelection( SwSelectionList& rList, const SwRect& rRect ) const


More information about the Libreoffice-commits mailing list