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

Noel Grandin noel.grandin at collabora.co.uk
Tue Apr 25 09:54:15 UTC 2017


 svtools/source/brwbox/brwbox2.cxx           |    2 --
 svtools/source/contnr/fileview.cxx          |    5 +----
 svtools/source/contnr/iconviewimpl.cxx      |    5 +----
 svtools/source/contnr/imivctl1.cxx          |    9 ++-------
 svtools/source/contnr/svimpbox.cxx          |   13 +++----------
 svtools/source/contnr/treelistbox.cxx       |    4 +---
 svtools/source/contnr/treelistentry.cxx     |    4 +---
 svtools/source/control/headbar.cxx          |   15 +++------------
 svtools/source/control/ruler.cxx            |    5 +----
 svtools/source/control/tabbar.cxx           |   15 +++------------
 svtools/source/dialogs/roadmapwizard.cxx    |    5 +----
 svtools/source/dialogs/wizardmachine.cxx    |    4 +---
 svtools/source/misc/embedhlp.cxx            |   10 ++--------
 svtools/source/misc/imageresourceaccess.cxx |    7 ++-----
 svtools/source/table/gridtablerenderer.cxx  |    5 +----
 15 files changed, 23 insertions(+), 85 deletions(-)

New commits:
commit 9d7b96e00909fa6798aafb9b385e58cda360e05f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Apr 25 10:32:23 2017 +0200

    clang-tidy readability-simplify-boolean-expr in svtools
    
    Change-Id: I13286a691348e136d16c07473285313c3ba5bba2
    Reviewed-on: https://gerrit.libreoffice.org/36928
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index af6c7a036236..1e9fee93487c 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -238,8 +238,6 @@ void BrowseBox::ToggleSelection()
 
     // only highlight painted areas!
     bNotToggleSel = true;
-    if ( false && !pDataWin->bInPaint )
-        pDataWin->Update();
 
     // accumulate areas of rows to highlight
     RectangleList aHighlightList;
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index b310c60282ee..0d7d75bdb158 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -1973,10 +1973,7 @@ bool CompareSortingData_Impl( SortingData_Impl* const aOne, SortingData_Impl* co
 
     if ( aOne->mbIsFolder != aTwo->mbIsFolder )
     {
-        if ( aOne->mbIsFolder )
-            bRet = true;
-        else
-            bRet = false;
+        bRet = aOne->mbIsFolder;
 
         // !!! pb: #100376# folder always on top
         if ( !gbAscending )
diff --git a/svtools/source/contnr/iconviewimpl.cxx b/svtools/source/contnr/iconviewimpl.cxx
index 5b90ca87b795..acda2f088bb5 100644
--- a/svtools/source/contnr/iconviewimpl.cxx
+++ b/svtools/source/contnr/iconviewimpl.cxx
@@ -262,10 +262,7 @@ bool IconViewImpl::IsEntryInView( SvTreeListEntry* pEntry ) const
         return false;
 
     long nStart = GetEntryLine( pEntry ) - GetEntryLine( pStartEntry );
-    if( nStart < 0 )
-        return false;
-
-    return true;
+    return nStart >= 0;
 }
 
 void IconViewImpl::AdjustScrollBars( Size& rSize )
diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx
index 8e728c707fd8..a57732f9b6a6 100644
--- a/svtools/source/contnr/imivctl1.cxx
+++ b/svtools/source/contnr/imivctl1.cxx
@@ -2263,10 +2263,7 @@ sal_Int32 SvxIconChoiceCtrl_Impl::GetSelectionCount() const
 void SvxIconChoiceCtrl_Impl::ToggleSelection( SvxIconChoiceCtrlEntry* pEntry )
 {
     bool bSel;
-    if( pEntry->IsSelected() )
-        bSel = false;
-    else
-        bSel = true;
+    bSel = !pEntry->IsSelected();
     SelectEntry( pEntry, bSel, true );
 }
 
@@ -2676,9 +2673,7 @@ IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, DocRectChangedHdl, Timer *, void)
 bool SvxIconChoiceCtrl_Impl::IsTextHit( SvxIconChoiceCtrlEntry* pEntry, const Point& rDocPos )
 {
     tools::Rectangle aRect( CalcTextRect( pEntry ));
-    if( aRect.IsInside( rDocPos ) )
-        return true;
-    return false;
+    return aRect.IsInside( rDocPos );
 }
 
 IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, EditTimeoutHdl, Timer *, void)
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index b733cd3fa59c..f6ad77160d18 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -794,10 +794,7 @@ bool SvImpLBox::EntryReallyHit(SvTreeListEntry* pEntry, const Point& rPosPixel,
 
     Point aPos( rPosPixel );
     aPos -= pView->GetMapMode().GetOrigin();
-    if( aRect.IsInside( aPos ) )
-        bRet = true;
-    else
-        bRet = false;
+    bRet = aRect.IsInside( aPos );
     return bRet;
 }
 
@@ -1444,9 +1441,7 @@ bool SvImpLBox::IsEntryInView( SvTreeListEntry* pEntry ) const
     if( nY < 0 )
         return false;
     long nMax = nVisibleCount * pView->GetEntryHeight();
-    if( nY >= nMax )
-        return false;
-    return true;
+    return nY < nMax;
 }
 
 
@@ -1955,9 +1950,7 @@ bool SvImpLBox::IsNodeButton( const Point& rPosPixel, SvTreeListEntry* pEntry )
     if( nMouseX < nX )
         return false;
     nX += nNodeBmpWidth;
-    if( nMouseX > nX )
-        return false;
-    return true;
+    return nMouseX <= nX;
 }
 
 // false == hit no node button
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 0605f321e442..12de87dbd8fb 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -1045,9 +1045,7 @@ bool SvTreeListBox::HandleKeyInput( const KeyEvent& _rKEvt )
 
 bool SvTreeListBox::EditingCanceled() const
 {
-    if( pEdCtrl && pEdCtrl->EditingCanceled() )
-        return true;
-    return false;
+    return pEdCtrl && pEdCtrl->EditingCanceled();
 }
 
 
diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx
index 029abb3366d9..dbc04f23c7f7 100644
--- a/svtools/source/contnr/treelistentry.cxx
+++ b/svtools/source/contnr/treelistentry.cxx
@@ -91,9 +91,7 @@ bool SvTreeListEntry::HasChildren() const
 
 bool SvTreeListEntry::HasChildListPos() const
 {
-    if( pParent && !(pParent->nListPos & 0x80000000) )
-        return true;
-    else return false;
+    return pParent && !(pParent->nListPos & 0x80000000);
 }
 
 sal_uLong SvTreeListEntry::GetChildListPos() const
diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx
index 9f863884de6b..0b5bc8de630c 100644
--- a/svtools/source/control/headbar.cxx
+++ b/svtools/source/control/headbar.cxx
@@ -209,10 +209,7 @@ sal_uInt16 HeaderBar::ImplHitTest( const Point& rPos,
             return nMode;
         }
 
-        if ( pItem->mnBits & HeaderBarItemBits::FIXED )
-            bLastFixed = true;
-        else
-            bLastFixed = false;
+        bLastFixed = static_cast<bool>(pItem->mnBits & HeaderBarItemBits::FIXED);
 
         nX += pItem->mnSize;
     }
@@ -708,10 +705,7 @@ void HeaderBar::ImplDrag( const Point& rMousePos )
         bool bNewOutDrag;
 
         tools::Rectangle aItemRect = ImplGetItemRect( nPos );
-        if ( aItemRect.IsInside( rMousePos ) )
-            bNewOutDrag = false;
-        else
-            bNewOutDrag = true;
+        bNewOutDrag = !aItemRect.IsInside( rMousePos );
 
         //  if needed switch on ItemDrag
         if ( bNewOutDrag && mbDragable && !mbItemDrag &&
@@ -727,10 +721,7 @@ void HeaderBar::ImplDrag( const Point& rMousePos )
         sal_uInt16 nOldItemDragPos = mnItemDragPos;
         if ( mbItemDrag )
         {
-            if ( (rMousePos.Y() < -HEADERBAR_DRAGOUTOFF) || (rMousePos.Y() > mnDY+HEADERBAR_DRAGOUTOFF) )
-                bNewOutDrag = true;
-            else
-                bNewOutDrag = false;
+            bNewOutDrag = (rMousePos.Y() < -HEADERBAR_DRAGOUTOFF) || (rMousePos.Y() > mnDY+HEADERBAR_DRAGOUTOFF);
 
             if ( bNewOutDrag )
                 mnItemDragPos = HEADERBAR_ITEM_NOTFOUND;
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 717ec9109efa..0adcbe5bf445 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -2566,10 +2566,7 @@ void Ruler::SetLines( sal_uInt32 aLineArraySize, const RulerLine* pLineArray )
 
     // New values and new share issue
     bool bMustUpdate;
-    if ( IsReallyVisible() && IsUpdateMode() )
-        bMustUpdate = true;
-    else
-        bMustUpdate = false;
+    bMustUpdate = IsReallyVisible() && IsUpdateMode();
 
     // Delete old lines
     if ( bMustUpdate )
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 259036550741..11c2e938dd18 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -1016,10 +1016,7 @@ void TabBar::MouseButtonDown(const MouseEvent& rMEvt)
                     while (n < nCurPos)
                     {
                         auto pItem = mpImpl->mpItemList[n];
-                        if (n < nPos)
-                            bSelect = false;
-                        else
-                            bSelect = true;
+                        bSelect = n >= nPos;
 
                         if (pItem->mbSelect != bSelect)
                         {
@@ -1043,10 +1040,7 @@ void TabBar::MouseButtonDown(const MouseEvent& rMEvt)
                     {
                         auto pItem = mpImpl->mpItemList[n];
 
-                        if (n <= nPos)
-                            bSelect = true;
-                        else
-                            bSelect = false;
+                        bSelect = n <= nPos;
 
                         if (pItem->mbSelect != bSelect)
                         {
@@ -1777,10 +1771,7 @@ bool TabBar::IsPageEnabled(sal_uInt16 nPageId) const
 {
     sal_uInt16 nPos = GetPagePos(nPageId);
 
-    if (nPos != PAGE_NOT_FOUND)
-        return true;
-    else
-        return false;
+    return nPos != PAGE_NOT_FOUND;
 }
 
 void TabBar::SetPageBits(sal_uInt16 nPageId, TabBarPageBits nBits)
diff --git a/svtools/source/dialogs/roadmapwizard.cxx b/svtools/source/dialogs/roadmapwizard.cxx
index bc6f53487e2a..356988b4bc6f 100644
--- a/svtools/source/dialogs/roadmapwizard.cxx
+++ b/svtools/source/dialogs/roadmapwizard.cxx
@@ -400,10 +400,7 @@ namespace svt
         }
 
         const WizardPath& rPath = m_pImpl->aPaths[ m_pImpl->nActivePath ];
-        if ( *rPath.rbegin() == getCurrentState() )
-            return false;
-
-        return true;
+        return *rPath.rbegin() != getCurrentState();
     }
 
 
diff --git a/svtools/source/dialogs/wizardmachine.cxx b/svtools/source/dialogs/wizardmachine.cxx
index 17be17e7e2fa..6edc96012d01 100644
--- a/svtools/source/dialogs/wizardmachine.cxx
+++ b/svtools/source/dialogs/wizardmachine.cxx
@@ -280,9 +280,7 @@ namespace svt
     bool OWizardMachine::DeactivatePage()
     {
         WizardState nCurrentState = getCurrentState();
-        if (!leaveState(nCurrentState) || !WizardDialog::DeactivatePage())
-            return false;
-        return true;
+        return leaveState(nCurrentState) && WizardDialog::DeactivatePage();
     }
 
 
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index b73538a35d24..2c5ddc63be30 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -786,16 +786,10 @@ uno::Reference< io::XInputStream > EmbeddedObjectRef::GetGraphicReplacementStrea
 bool EmbeddedObjectRef::IsChart(const css::uno::Reference < css::embed::XEmbeddedObject >& xObj)
 {
     SvGlobalName aObjClsId(xObj->getClassID());
-    if(
-        SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
+    return SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
         || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
         || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
-        || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
-    {
-        return true;
-    }
-
-    return false;
+        || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId;
 }
 
 bool EmbeddedObjectRef::IsGLChart(const css::uno::Reference < css::embed::XEmbeddedObject >& xObj)
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx
index f8dd078f2bf1..7211bf23670d 100644
--- a/svtools/source/misc/imageresourceaccess.cxx
+++ b/svtools/source/misc/imageresourceaccess.cxx
@@ -127,14 +127,11 @@ namespace svt
 
     bool GraphicAccess::isSupportedURL( const OUString& _rURL )
     {
-        if  (  _rURL.startsWith( "private:resource/" )
+        return _rURL.startsWith( "private:resource/" )
             || _rURL.startsWith( "private:graphicrepository/" )
             || _rURL.startsWith( "private:standardimage/" )
             || _rURL.startsWith( "vnd.sun.star.GraphicObject:" )
-            || _rURL.startsWith( "vnd.sun.star.extension://" )
-            )
-            return true;
-        return false;
+            || _rURL.startsWith( "vnd.sun.star.extension://" );
     }
 
 
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index 8a486187a8ea..7df61b8db309 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -589,10 +589,7 @@ namespace svt { namespace table
             return false;
 
         long const nTextWidth = i_targetDevice.GetTextWidth( sText );
-        if ( nTextWidth > aTargetArea.GetWidth() )
-            return false;
-
-        return true;
+        return nTextWidth <= aTargetArea.GetWidth();
     }
 
 


More information about the Libreoffice-commits mailing list