[Libreoffice-commits] core.git: vcl/headless vcl/source

Julien Nabet serval2412 at yahoo.fr
Sun Jan 28 17:55:24 UTC 2018


 vcl/headless/svpgdi.cxx                |    4 
 vcl/headless/svpprn.cxx                |    6 
 vcl/source/app/IconThemeScanner.cxx    |    4 
 vcl/source/bitmap/bitmapscalesuper.cxx |    5 
 vcl/source/control/button.cxx          |   10 -
 vcl/source/control/field.cxx           |   12 -
 vcl/source/control/tabctrl.cxx         |  202 ++++++++++++++-------------------
 7 files changed, 108 insertions(+), 135 deletions(-)

New commits:
commit 85538dd33b227cabb29e9dc630691a7edb6c3920
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Jan 28 12:38:27 2018 +0100

    Modernize a bit vcl (part1)
    
    by using for-range loops
    + remove useless vars
    + avoid some iterators calculus by using plain loop
    
    Change-Id: I94572bfd56ad9ac76c9899cf68d5ba831009fa7b
    Reviewed-on: https://gerrit.libreoffice.org/48777
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index d2970489980b..2c6dd2486ff5 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -501,9 +501,9 @@ void SvpSalGraphics::clipRegion(cairo_t* cr)
     }
     if (!aRectangles.empty())
     {
-        for (RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
+        for (auto const& rectangle : aRectangles)
         {
-            cairo_rectangle(cr, aRectIter->Left(), aRectIter->Top(), aRectIter->GetWidth(), aRectIter->GetHeight());
+            cairo_rectangle(cr, rectangle.Left(), rectangle.Top(), rectangle.GetWidth(), rectangle.GetHeight());
         }
         cairo_clip(cr);
     }
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index 5e0abfb3df75..a0ec78290429 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -214,12 +214,12 @@ void SvpSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
     ::std::vector< OUString > aPrinters;
     rManager.listPrinters( aPrinters );
 
-    for( ::std::vector< OUString >::iterator it = aPrinters.begin(); it != aPrinters.end(); ++it )
+    for (auto const& printer : aPrinters)
     {
-        const PrinterInfo& rInfo( rManager.getPrinterInfo( *it ) );
+        const PrinterInfo& rInfo( rManager.getPrinterInfo(printer) );
         // create new entry
         SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
-        pInfo->maPrinterName    = *it;
+        pInfo->maPrinterName    = printer;
         pInfo->maDriver         = rInfo.m_aDriverName;
         pInfo->maLocation       = rInfo.m_aLocation;
         pInfo->maComment        = rInfo.m_aComment;
diff --git a/vcl/source/app/IconThemeScanner.cxx b/vcl/source/app/IconThemeScanner.cxx
index 228c4e00f6cf..846eeaa7c942 100644
--- a/vcl/source/app/IconThemeScanner.cxx
+++ b/vcl/source/app/IconThemeScanner.cxx
@@ -92,9 +92,9 @@ void IconThemeScanner::ScanDirectoryForIconThemes(const OUString& paths)
             SAL_WARN("vcl.app", "Could not find any icon themes in the provided directory ('" <<path<<"'.");
             continue;
         }
-        for (std::vector<OUString>::iterator aI = iconThemePaths.begin(); aI != iconThemePaths.end(); ++aI)
+        for (auto const& iconThemePath : iconThemePaths)
         {
-            AddIconThemeByPath(*aI);
+            AddIconThemeByPath(iconThemePath);
         }
     }
 }
diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx
index b574e5743b09..1dc238353c81 100644
--- a/vcl/source/bitmap/bitmapscalesuper.cxx
+++ b/vcl/source/bitmap/bitmapscalesuper.cxx
@@ -94,9 +94,8 @@ public:
     void push( ScaleRangeContext const &aRC ) { maStrips.push_back( aRC ); }
     virtual void doWork() override
     {
-        std::vector< ScaleRangeContext >::iterator it;
-        for (it = maStrips.begin(); it != maStrips.end(); ++it)
-            mpFn( *(it->mrCtx), it->mnStartY, it->mnEndY );
+        for (auto const& strip : maStrips)
+            mpFn( *(strip.mrCtx), strip.mnStartY, strip.mnEndY );
     }
 };
 
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 949cc65d5a9b..249f8be08aec 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2169,11 +2169,11 @@ void RadioButton::group(RadioButton &rOther)
         {
             std::vector< VclPtr<RadioButton> > aOthers(rOther.GetRadioButtonGroup(false));
             //make all members of the group share the same button group
-            for (auto aI = aOthers.begin(), aEnd = aOthers.end(); aI != aEnd; ++aI)
+            for (auto const& elem : aOthers)
             {
-                aFind = std::find(m_xGroup->begin(), m_xGroup->end(), *aI);
+                aFind = std::find(m_xGroup->begin(), m_xGroup->end(), elem);
                 if (aFind == m_xGroup->end())
-                    m_xGroup->push_back(*aI);
+                    m_xGroup->push_back(elem);
             }
         }
 
@@ -2238,9 +2238,9 @@ void RadioButton::ImplUncheckAllOther()
 
     std::vector<VclPtr<RadioButton> > aGroup(GetRadioButtonGroup(false));
     // iterate over radio button group and checked buttons
-    for (auto aI = aGroup.begin(), aEnd = aGroup.end(); aI != aEnd; ++aI)
+    for (auto const& elem : aGroup)
     {
-        VclPtr<RadioButton> pWindow = *aI;
+        VclPtr<RadioButton> pWindow = elem;
         if ( pWindow->IsChecked() )
         {
             pWindow->SetState( false );
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index bd341cfe06fd..1e5085cf007e 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -998,10 +998,10 @@ static const OUString ImplMetricToString( FieldUnit rUnit )
     if( pList )
     {
         // return unit's default string (ie, the first one )
-        for( FieldUnitStringList::const_iterator it = pList->begin(); it != pList->end(); ++it )
+        for (auto const& elem : *pList)
         {
-            if ( it->second == rUnit )
-                return it->first;
+            if ( elem.second == rUnit )
+                return elem.first;
         }
     }
 
@@ -1015,10 +1015,10 @@ FieldUnit MetricFormatter::StringToMetric(const OUString &rMetricString)
     {
         // return FieldUnit
         OUString aStr = rMetricString.toAsciiLowerCase().replaceAll(" ", "");
-        for( FieldUnitStringList::const_iterator it = pList->begin(); it != pList->end(); ++it )
+        for (auto const& elem : *pList)
         {
-            if ( it->first == aStr )
-                return it->second;
+            if ( elem.first == aStr )
+                return elem.second;
         }
     }
 
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 11d1bb0058ae..94b964dc52c1 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -203,11 +203,10 @@ void TabControl::dispose()
 
 ImplTabItem* TabControl::ImplGetItem( sal_uInt16 nId ) const
 {
-    for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        if( it->mnId == nId )
-            return &(*it);
+        if( item.mnId == nId )
+            return &item;
     }
 
     return nullptr;
@@ -373,10 +372,9 @@ bool TabControl::ImplPlaceTabs( long nWidth )
 
     //collect widths
     std::vector<sal_Int32> aWidths;
-    for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        aWidths.push_back(ImplGetItemSize( &(*it), nMaxWidth ).Width());
+        aWidths.push_back(ImplGetItemSize( &item, nMaxWidth ).Width());
     }
 
     //aBreakIndexes will contain the indexes of the last tab on each row
@@ -400,10 +398,9 @@ bool TabControl::ImplPlaceTabs( long nWidth )
     size_t nIndex = 0;
     sal_uInt16 nPos = 0;
 
-    for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it, ++nIndex )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        Size aSize = ImplGetItemSize( &(*it), nMaxWidth );
+        Size aSize = ImplGetItemSize( &item, nMaxWidth );
 
         bool bNewLine = false;
         if (!aBreakIndexes.empty() && nIndex > aBreakIndexes.front())
@@ -425,19 +422,20 @@ bool TabControl::ImplPlaceTabs( long nWidth )
         }
 
         tools::Rectangle aNewRect( Point( nX, nY ), aSize );
-        if ( mbSmallInvalidate && (it->maRect != aNewRect) )
+        if ( mbSmallInvalidate && (item.maRect != aNewRect) )
             mbSmallInvalidate = false;
-        it->maRect = aNewRect;
-        it->mnLine = nLines;
-        it->mbFullVisible = true;
+        item.maRect = aNewRect;
+        item.mnLine = nLines;
+        item.mbFullVisible = true;
 
         nLineWidthAry[nLines] += aSize.Width();
         nX += aSize.Width();
 
-        if ( it->mnId == mnCurPageId )
+        if ( item.mnId == mnCurPageId )
             nCurLine = nLines;
 
-        nPos++;
+        ++nPos;
+        ++nIndex;
     }
 
     if ( nLines )
@@ -461,8 +459,8 @@ bool TabControl::ImplPlaceTabs( long nWidth )
 
         sal_uInt16 i = 0;
         sal_uInt16 n = 0;
-        for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-             it != mpTabCtrlData->maItemList.end(); ++it )
+
+        for (auto & item : mpTabCtrlData->maItemList)
         {
             if ( i == nLinePosAry[n] )
             {
@@ -484,16 +482,16 @@ bool TabControl::ImplPlaceTabs( long nWidth )
                 n++;
             }
 
-            it->maRect.Left() += nIDX;
-            it->maRect.Right() += nIDX + nDX;
-            it->maRect.Top() = nLineHeightAry[n-1];
-            it->maRect.Bottom() = nLineHeightAry[n-1] + nIH;
+            item.maRect.Left() += nIDX;
+            item.maRect.Right() += nIDX + nDX;
+            item.maRect.Top() = nLineHeightAry[n-1];
+            item.maRect.Bottom() = nLineHeightAry[n-1] + nIH;
             nIDX += nDX;
 
             if ( nModDX )
             {
                 nIDX++;
-                it->maRect.Right()++;
+                item.maRect.Right()++;
                 nModDX--;
             }
 
@@ -505,16 +503,14 @@ bool TabControl::ImplPlaceTabs( long nWidth )
         if(ImplGetSVData()->maNWFData.mbCenteredTabs)
         {
             int nRightSpace = nMaxWidth;//space left on the right by the tabs
-            for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-                 it != mpTabCtrlData->maItemList.end(); ++it )
+            for (auto const& item : mpTabCtrlData->maItemList)
             {
-                nRightSpace -= it->maRect.Right()-it->maRect.Left();
+                nRightSpace -= item.maRect.Right()-item.maRect.Left();
             }
-            for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-                 it != mpTabCtrlData->maItemList.end(); ++it )
+            for (auto & item : mpTabCtrlData->maItemList)
             {
-                it->maRect.Left() += nRightSpace / 2;
-                it->maRect.Right() += nRightSpace / 2;
+                item.maRect.Left() += nRightSpace / 2;
+                item.maRect.Right() += nRightSpace / 2;
             }
         }
     }
@@ -828,10 +824,9 @@ void TabControl::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem* p
     if (IsMouseOver() && pItem->maRect.IsInside(GetPointerPosPixel()))
     {
         nState |= ControlState::ROLLOVER;
-        for (std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin();
-             it != mpTabCtrlData->maItemList.end(); ++it)
+        for (auto const& item : mpTabCtrlData->maItemList)
         {
-            if( (&(*it) != pItem) && (it->maRect.IsInside(GetPointerPosPixel())))
+            if( (&item != pItem) && (item.maRect.IsInside(GetPointerPosPixel())))
             {
                 nState &= ~ControlState::ROLLOVER; // avoid multiple highlighted tabs
                 break;
@@ -1054,12 +1049,11 @@ void TabControl::ImplPaint(vcl::RenderContext& rRenderContext, const tools::Rect
 
     // find current item
     ImplTabItem* pCurItem = nullptr;
-    for (std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        if (it->mnId == mnCurPageId)
+        if (item.mnId == mnCurPageId)
         {
-            pCurItem = &(*it);
+            pCurItem = &item;
             break;
         }
     }
@@ -1265,11 +1259,10 @@ void TabControl::setAllocation(const Size &rAllocation)
     // check what needs to be invalidated
     Size aNewSize = rAllocation;
     long nNewWidth = aNewSize.Width();
-    for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        if ( !it->mbFullVisible ||
-             (it->maRect.Right()-2 >= nNewWidth) )
+        if ( !item.mbFullVisible ||
+             (item.maRect.Right()-2 >= nNewWidth) )
         {
             mbSmallInvalidate = false;
             break;
@@ -1453,13 +1446,12 @@ void TabControl::Command( const CommandEvent& rCEvt )
         if ( bMenu )
         {
             ScopedVclPtrInstance<PopupMenu> aMenu;
-            for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-                 it != mpTabCtrlData->maItemList.end(); ++it )
+            for (auto const& item : mpTabCtrlData->maItemList)
             {
-                aMenu->InsertItem( it->mnId, it->maText, MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK );
-                if ( it->mnId == mnCurPageId )
-                    aMenu->CheckItem( it->mnId );
-                aMenu->SetHelpId( it->mnId, it->maHelpId );
+                aMenu->InsertItem( item.mnId, item.maText, MenuItemBits::CHECKABLE | MenuItemBits::RADIOCHECK );
+                if ( item.mnId == mnCurPageId )
+                    aMenu->CheckItem( item.mnId );
+                aMenu->SetHelpId( item.mnId, item.maHelpId );
             }
 
             sal_uInt16 nId = aMenu->Execute( this, aMenuPos );
@@ -1523,14 +1515,13 @@ tools::Rectangle* TabControl::ImplFindPartRect( const Point& rPt )
 {
     ImplTabItem* pFoundItem = nullptr;
     int nFound = 0;
-    for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        if ( it->maRect.IsInside( rPt ) )
+        if ( item.maRect.IsInside( rPt ) )
         {
             // assure that only one tab is highlighted at a time
             nFound++;
-            pFoundItem = &(*it);
+            pFoundItem = &item;
         }
     }
     // assure that only one tab is highlighted at a time
@@ -1773,11 +1764,12 @@ sal_uInt16 TabControl::GetPageId( sal_uInt16 nPos ) const
 
 sal_uInt16 TabControl::GetPagePos( sal_uInt16 nPageId ) const
 {
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    sal_uInt16 nPos = 0;
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        if ( it->mnId == nPageId )
-            return static_cast<sal_uInt16>(it - mpTabCtrlData->maItemList.begin());
+        if ( item.mnId == nPageId )
+            return nPos;
+        ++nPos;
     }
 
     return TAB_PAGE_NOTFOUND;
@@ -1796,11 +1788,10 @@ sal_uInt16 TabControl::GetPageId( const Point& rPos ) const
 
 sal_uInt16 TabControl::GetPageId( const TabPage& rPage ) const
 {
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        if ( it->mpTabPage == &rPage )
-            return it->mnId;
+        if ( item.mpTabPage == &rPage )
+            return item.mnId;
     }
 
     return 0;
@@ -1808,11 +1799,10 @@ sal_uInt16 TabControl::GetPageId( const TabPage& rPage ) const
 
 sal_uInt16 TabControl::GetPageId( const OString& rName ) const
 {
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        if ( it->maTabName == rName )
-            return it->mnId;
+        if ( item.maTabName == rName )
+            return item.mnId;
     }
 
     return 0;
@@ -2110,18 +2100,17 @@ Size TabControl::calculateRequisition() const
     Size aOptimalPageSize(0, 0);
 
     sal_uInt16 nOrigPageId = GetCurPageId();
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        const TabPage *pPage = it->mpTabPage;
+        const TabPage *pPage = item.mpTabPage;
         //it's a real nuisance if the page is not inserted yet :-(
         //We need to force all tabs to exist to get overall optimal size for dialog
         if (!pPage)
         {
             TabControl *pThis = const_cast<TabControl*>(this);
-            pThis->SetCurPageId(it->mnId);
+            pThis->SetCurPageId(item.mnId);
             pThis->ActivatePage();
-            pPage = it->mpTabPage;
+            pPage = item.mpTabPage;
         }
 
         if (!pPage)
@@ -2146,12 +2135,11 @@ Size TabControl::calculateRequisition() const
     }
 
     long nTabLabelsBottom = 0, nTabLabelsRight = 0;
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (sal_uInt16 nPos(0), sizeList(static_cast <sal_uInt16> (mpTabCtrlData->maItemList.size()));
+            nPos < sizeList; ++nPos)
     {
         TabControl* pThis = const_cast<TabControl*>(this);
 
-        sal_uInt16 nPos = it - mpTabCtrlData->maItemList.begin();
         tools::Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX);
         if (aTabRect.Bottom() > nTabLabelsBottom)
             nTabLabelsBottom = aTabRect.Bottom();
@@ -2183,10 +2171,9 @@ void TabControl::queue_resize(StateChangedType eReason)
 std::vector<sal_uInt16> TabControl::GetPageIDs() const
 {
     std::vector<sal_uInt16> aIDs;
-    for (auto itr = mpTabCtrlData->maItemList.begin(), itrEnd = mpTabCtrlData->maItemList.end();
-            itr != itrEnd; ++itr)
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        aIDs.push_back(itr->mnId);
+        aIDs.push_back(item.mnId);
     }
 
     return aIDs;
@@ -2362,13 +2349,12 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
 
     //collect widths
     std::vector<sal_Int32> aWidths;
-    for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        if( it->mbEnabled )
+        if( item.mbEnabled )
         {
-            long aSize = ImplGetItemSize( &(*it), nMaxWidth ).getWidth();
-            if( !it->maText.isEmpty() && aSize < 100)
+            long aSize = ImplGetItemSize( &item, nMaxWidth ).getWidth();
+            if( !item.maText.isEmpty() && aSize < 100)
             {
                 nFullWidth += 100;
                 aSize = 100;
@@ -2392,55 +2378,46 @@ bool NotebookbarTabControlBase::ImplPlaceTabs( long nWidth )
     long nLineWidthAry[100];
     nLineWidthAry[0] = 0;
 
-    size_t nIndex = 0;
-    sal_uInt16 nPos = 0;
-
-    for( std::vector<ImplTabItem>::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it, ++nIndex )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        Size aSize = ImplGetItemSize( &(*it), nMaxWidth );
+        Size aSize = ImplGetItemSize( &item, nMaxWidth );
 
-        if ( !it->mbEnabled )
+        if ( !item.mbEnabled )
         {
-            nPos++;
             continue;
         }
 
         // set minimum tab size
-        if( nFullWidth < nMaxWidth && !it->maText.isEmpty() && aSize.getWidth() < 100)
+        if( nFullWidth < nMaxWidth && !item.maText.isEmpty() && aSize.getWidth() < 100)
             aSize.Width() = 100;
 
-        if( !it->maText.isEmpty() && aSize.getHeight() < 28 )
+        if( !item.maText.isEmpty() && aSize.getHeight() < 28 )
             aSize.Height() = 28;
 
         tools::Rectangle aNewRect( Point( nX, nY ), aSize );
-        if ( mbSmallInvalidate && (it->maRect != aNewRect) )
+        if ( mbSmallInvalidate && (item.maRect != aNewRect) )
             mbSmallInvalidate = false;
 
-        it->maRect = aNewRect;
-        it->mnLine = 0;
-        it->mbFullVisible = true;
+        item.maRect = aNewRect;
+        item.mnLine = 0;
+        item.mbFullVisible = true;
 
         nLineWidthAry[0] += aSize.Width();
         nX += aSize.Width();
-
-        nPos++;
     }
 
     // only one line
     if(ImplGetSVData()->maNWFData.mbCenteredTabs)
     {
         int nRightSpace = nMaxWidth;//space left on the right by the tabs
-        for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-                it != mpTabCtrlData->maItemList.end(); ++it )
+        for (auto const& item : mpTabCtrlData->maItemList)
         {
-            nRightSpace -= it->maRect.Right()-it->maRect.Left();
+            nRightSpace -= item.maRect.Right()-item.maRect.Left();
         }
-        for( std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-                it != mpTabCtrlData->maItemList.end(); ++it )
+        for (auto & item : mpTabCtrlData->maItemList)
         {
-            it->maRect.Left() += nRightSpace / 2;
-            it->maRect.Right() += nRightSpace / 2;
+            item.maRect.Left() += nRightSpace / 2;
+            item.maRect.Right() += nRightSpace / 2;
         }
     }
 
@@ -2462,12 +2439,11 @@ void NotebookbarTabControlBase::ImplPaint(vcl::RenderContext& rRenderContext, co
 
     // find current item
     ImplTabItem* pCurItem = nullptr;
-    for (std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto & item : mpTabCtrlData->maItemList)
     {
-        if (it->mnId == mnCurPageId)
+        if (item.mnId == mnCurPageId)
         {
-            pCurItem = &(*it);
+            pCurItem = &item;
             break;
         }
     }
@@ -2653,18 +2629,17 @@ Size NotebookbarTabControlBase::calculateRequisition() const
     Size aOptimalPageSize(0, 0);
 
     sal_uInt16 nOrigPageId = GetCurPageId();
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (auto const& item : mpTabCtrlData->maItemList)
     {
-        const TabPage *pPage = it->mpTabPage;
+        const TabPage *pPage = item.mpTabPage;
         //it's a real nuisance if the page is not inserted yet :-(
         //We need to force all tabs to exist to get overall optimal size for dialog
         if (!pPage)
         {
             NotebookbarTabControlBase *pThis = const_cast<NotebookbarTabControlBase*>(this);
-            pThis->SetCurPageId(it->mnId);
+            pThis->SetCurPageId(item.mnId);
             pThis->ActivatePage();
-            pPage = it->mpTabPage;
+            pPage = item.mpTabPage;
         }
 
         if (!pPage)
@@ -2689,12 +2664,11 @@ Size NotebookbarTabControlBase::calculateRequisition() const
     }
 
     long nTabLabelsBottom = 0, nTabLabelsRight = 0;
-    for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin();
-         it != mpTabCtrlData->maItemList.end(); ++it )
+    for (sal_uInt16 nPos(0), sizeList(static_cast <sal_uInt16> (mpTabCtrlData->maItemList.size()));
+            nPos < sizeList; ++nPos)
     {
         NotebookbarTabControlBase* pThis = const_cast<NotebookbarTabControlBase*>(this);
 
-        sal_uInt16 nPos = it - mpTabCtrlData->maItemList.begin();
         tools::Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX);
         if (aTabRect.Bottom() > nTabLabelsBottom)
         {


More information about the Libreoffice-commits mailing list