[Libreoffice-commits] core.git: basctl/source include/sal

Stephan Bergmann sbergman at redhat.com
Tue Mar 7 18:44:54 UTC 2017


 basctl/source/basicide/baside2b.cxx |    6 +++---
 basctl/source/basicide/layout.cxx   |   10 +++++-----
 basctl/source/dlged/dlgedobj.cxx    |   15 ++++++++++++---
 include/sal/log-areas.dox           |    1 +
 4 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit ab78f801e0d1f4dc4a9346477cc6979893996aee
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Mar 7 19:43:34 2017 +0100

    loplugin:loopvartoosmall
    
    Change-Id: Ia8c57fb69873d57c3271a8f6d497fecec3db1899

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index a82d57c..c02bac2 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2891,12 +2891,12 @@ UnoTypeCodeCompletetor::UnoTypeCodeCompletetor( const std::vector< OUString >& a
         return;
     }
 
-    unsigned int j = 1;//start from aVect[1]: aVect[0] is the variable name
+    auto j = aVect.begin() + 1;//start from aVect[1]: aVect[0] is the variable name
     OUString sMethName;
 
-    while( j != aVect.size() )
+    while( j != aVect.end() )
     {
-        sMethName = aVect[j];
+        sMethName = *j;
 
         if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
         {
diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
index b93e50a..6d87bf6 100644
--- a/basctl/source/basicide/layout.cxx
+++ b/basctl/source/basicide/layout.cxx
@@ -216,7 +216,7 @@ void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize)
 void Layout::SplittedSide::Remove (DockingWindow* pWin)
 {
     // contains?
-    unsigned iWin;
+    std::vector<Item>::size_type iWin;
     for (iWin = 0; iWin != vItems.size(); ++iWin)
         if (vItems[iWin].pWin == pWin)
             break;
@@ -251,8 +251,8 @@ bool Layout::SplittedSide::IsDocking (DockingWindow const& rWin)
 // IsEmpty() -- are there no windows docked in this strip?
 bool Layout::SplittedSide::IsEmpty () const
 {
-    for (unsigned i = 0; i != vItems.size(); ++i)
-        if (IsDocking(*vItems[i].pWin))
+    for (auto const & i: vItems)
+        if (IsDocking(*i.pWin))
             return false;
     return true;
 }
@@ -301,9 +301,9 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
     // positioning separator lines and windows
     bool bPrevDocking = false; // is the previous window docked?
     long nStartPos = 0; // window position in the strip
-    unsigned iLastWin = vItems.size(); // index of last docking window in the strip
+    std::vector<Item>::size_type iLastWin = vItems.size(); // index of last docking window in the strip
 
-    for (unsigned i = 0; i != vItems.size(); ++i)
+    for (std::vector<Item>::size_type i = 0; i != vItems.size(); ++i)
     {
         // window
         DockingWindow& rWin = *vItems[i].pWin;
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index d33dd9d..be46d58 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <cassert>
+
 #include "dlged.hxx"
 #include "dlgeddef.hxx"
 #include "dlgedlist.hxx"
@@ -541,11 +545,10 @@ void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt )
             Sequence< OUString > aNames = xNameAcc->getElementNames();
             const OUString* pNames = aNames.getConstArray();
             sal_Int32 nCtrls = aNames.getLength();
-            sal_Int16 i;
 
             // create a map of tab indices and control names, sorted by tab index
             IndexToNameMap aIndexToNameMap;
-            for ( i = 0; i < nCtrls; ++i )
+            for ( sal_Int32 i = 0; i < nCtrls; ++i )
             {
                 // get control name
                 OUString aName( pNames[i] );
@@ -588,13 +591,19 @@ void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt )
             aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
 
             // set new tab indices
-            for ( i = 0; i < nCtrls; ++i )
+            for ( sal_Int32 i = 0; i < nCtrls; ++i )
             {
                 Any aCtrl = xNameAcc->getByName( aNameList[i] );
                 Reference< beans::XPropertySet > xPSet;
                    aCtrl >>= xPSet;
                 if ( xPSet.is() )
                 {
+                    assert(i >= SAL_MIN_INT16);
+                    if (i > SAL_MAX_INT16)
+                    {
+                        SAL_WARN("basctl", "tab " << i << " > SAL_MAX_INT16");
+                        continue;
+                    }
                     xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any((sal_Int16) i) );
                 }
             }
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index c8036ab..d5b9934 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -32,6 +32,7 @@ certain functionality.
 
 @section basctl
 
+ at li @c basctl
 @li @c basctl.basicide
 
 @section basic


More information about the Libreoffice-commits mailing list