summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-01-16 09:44:13 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-17 07:34:03 +0100
commit2b56117c188989a7b86cb74133b211cb7fadcca6 (patch)
treef401939f10aef1db4e5aed91d1381d199962f8be /sc
parentdbbdc76f7fc8f762d9c9e8494cae61b527f7ddca (diff)
Simplify containers iterations in sc/source/ui/[A-Sa-d]*
Use range-based loop or replace with STL functions Change-Id: I261dcba1778a9d895491452fb3fee3dd4e8dfc33 Reviewed-on: https://gerrit.libreoffice.org/66422 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/Accessibility/AccessibleCsvControl.cxx4
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx47
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx65
-rw-r--r--sc/source/ui/Accessibility/AccessibleGlobal.cxx11
-rw-r--r--sc/source/ui/Accessibility/AccessiblePageHeader.cxx24
-rw-r--r--sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx40
-rw-r--r--sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx10
-rw-r--r--sc/source/ui/app/drwtrans.cxx5
-rw-r--r--sc/source/ui/app/inputhdl.cxx55
-rw-r--r--sc/source/ui/app/inputwin.cxx18
-rw-r--r--sc/source/ui/app/rfindlst.cxx8
-rw-r--r--sc/source/ui/cctrl/checklistmenu.cxx46
-rw-r--r--sc/source/ui/cctrl/tbzoomsliderctrl.cxx30
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx37
-rw-r--r--sc/source/ui/condformat/condformatdlgentry.cxx28
-rw-r--r--sc/source/ui/condformat/condformatmgr.cxx6
-rw-r--r--sc/source/ui/dbgui/dbnamdlg.cxx5
-rw-r--r--sc/source/ui/dbgui/filtdlg.cxx5
-rw-r--r--sc/source/ui/dbgui/pfiltdlg.cxx5
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx28
-rw-r--r--sc/source/ui/dbgui/sfiltdlg.cxx9
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx6
22 files changed, 189 insertions, 303 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
index dba9bdfa36db..3d5a283b7105 100644
--- a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
@@ -847,8 +847,8 @@ ScAccessibleCsvGrid::~ScAccessibleCsvGrid()
void ScAccessibleCsvGrid::disposing()
{
SolarMutexGuard aGuard;
- for (XAccessibleSet::iterator aI = maAccessibleChildren.begin(); aI != maAccessibleChildren.end(); ++aI)
- aI->second->dispose();
+ for (auto& rEntry : maAccessibleChildren)
+ rEntry.second->dispose();
maAccessibleChildren.clear();
ScAccessibleCsvControl::disposing();
}
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 3782bd827ba7..2adccc76a3e9 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -811,33 +811,20 @@ uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedC
}
else
{
- SortedShapes::iterator aItr = maZOrderedShapes.begin();
- SortedShapes::iterator aEndItr = maZOrderedShapes.end();
- bool bFound(false);
- while(!bFound && aItr != aEndItr)
+ for(const auto& rpShape : maZOrderedShapes)
{
- if (*aItr)
+ if (!rpShape || rpShape->bSelected)
{
- if ((*aItr)->bSelected)
+ if (nSelectedChildIndex == 0)
{
- if (nSelectedChildIndex == 0)
- bFound = true;
- else
- --nSelectedChildIndex;
+ if (rpShape)
+ xAccessible = rpShape->pAccShape.get();
+ break;
}
- }
- else
- {
- if (nSelectedChildIndex == 0)
- bFound = true;
else
--nSelectedChildIndex;
}
- if (!bFound)
- ++aItr;
}
- if (bFound && *aItr)
- xAccessible = (*aItr)->pAccShape.get();
}
return xAccessible;
@@ -1103,8 +1090,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X
}
else
{
- SortedShapes::iterator vi = vecSelectedShapeAdd.begin();
- for (; vi != vecSelectedShapeAdd.end() ; ++vi )
+ for (const auto& rpShape : vecSelectedShapeAdd)
{
AccessibleEventObject aEvent;
if (bHasSelect)
@@ -1116,18 +1102,17 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X
aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
}
aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument);
- uno::Reference< XAccessible > xChild( (*vi)->pAccShape.get());
+ uno::Reference< XAccessible > xChild( rpShape->pAccShape.get());
aEvent.NewValue <<= xChild;
mpAccessibleDocument->CommitChange(aEvent);
}
}
- SortedShapes::iterator vi = vecSelectedShapeRemove.begin();
- for (; vi != vecSelectedShapeRemove.end() ; ++vi )
+ for (const auto& rpShape : vecSelectedShapeRemove)
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument);
- uno::Reference< XAccessible > xChild( (*vi)->pAccShape.get());
+ uno::Reference< XAccessible > xChild( rpShape->pAccShape.get());
aEvent.NewValue <<= xChild;
mpAccessibleDocument->CommitChange(aEvent);
}
@@ -1304,16 +1289,8 @@ bool ScChildrenShapes::FindShape(const uno::Reference<drawing::XShape>& xShape,
bResult = true; // if the shape is found
#if OSL_DEBUG_LEVEL > 0 // test whether it finds truly the correct shape (perhaps it is not really sorted)
- SortedShapes::iterator aDebugItr = maZOrderedShapes.begin();
- SortedShapes::iterator aEndItr = maZOrderedShapes.end();
- bool bFound(false);
- while (!bFound && aDebugItr != aEndItr)
- {
- if (*aDebugItr && ((*aDebugItr)->xShape.get() == xShape.get()))
- bFound = true;
- else
- ++aDebugItr;
- }
+ SortedShapes::iterator aDebugItr = std::find_if(maZOrderedShapes.begin(), maZOrderedShapes.end(),
+ [&xShape](const ScAccessibleShapeData* pShape) { return pShape && (pShape->xShape.get() == xShape.get()); });
bool bResult2 = (aDebugItr != maZOrderedShapes.end());
OSL_ENSURE((bResult == bResult2) && ((bResult && (rItr == aDebugItr)) || !bResult), "wrong Shape found");
#endif
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index 6b8e825c7ac3..4ca8f3f1836f 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -849,16 +849,14 @@ sal_Int32 ScShapeChildren::GetBackShapeCount() const
uno::Reference<XAccessible> ScShapeChildren::GetBackShape(sal_Int32 nIndex) const
{
uno::Reference<XAccessible> xAccessible;
- ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
- ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
- while ((aItr != aEndItr) && !xAccessible.is())
+ for (const auto& rShapeRange : maShapeRanges)
{
- sal_Int32 nCount(aItr->maBackShapes.size());
+ sal_Int32 nCount(rShapeRange.maBackShapes.size());
if(nIndex < nCount)
- xAccessible = GetAccShape(aItr->maBackShapes, nIndex);
- else
- ++aItr;
+ xAccessible = GetAccShape(rShapeRange.maBackShapes, nIndex);
nIndex -= nCount;
+ if (xAccessible.is())
+ break;
}
if (nIndex >= 0)
@@ -878,16 +876,14 @@ sal_Int32 ScShapeChildren::GetForeShapeCount() const
uno::Reference<XAccessible> ScShapeChildren::GetForeShape(sal_Int32 nIndex) const
{
uno::Reference<XAccessible> xAccessible;
- ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
- ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
- while ((aItr != aEndItr) && !xAccessible.is())
+ for (const auto& rShapeRange : maShapeRanges)
{
- sal_Int32 nCount(aItr->maForeShapes.size());
+ sal_Int32 nCount(rShapeRange.maForeShapes.size());
if(nIndex < nCount)
- xAccessible = GetAccShape(aItr->maForeShapes, nIndex);
- else
- ++aItr;
+ xAccessible = GetAccShape(rShapeRange.maForeShapes, nIndex);
nIndex -= nCount;
+ if (xAccessible.is())
+ break;
}
if (nIndex >= 0)
@@ -907,16 +903,14 @@ sal_Int32 ScShapeChildren::GetControlCount() const
uno::Reference<XAccessible> ScShapeChildren::GetControl(sal_Int32 nIndex) const
{
uno::Reference<XAccessible> xAccessible;
- ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
- ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
- while ((aItr != aEndItr) && !xAccessible.is())
+ for (const auto& rShapeRange : maShapeRanges)
{
- sal_Int32 nCount(aItr->maControls.size());
+ sal_Int32 nCount(rShapeRange.maControls.size());
if(nIndex < nCount)
- xAccessible = GetAccShape(aItr->maControls, nIndex);
- else
- ++aItr;
+ xAccessible = GetAccShape(rShapeRange.maControls, nIndex);
nIndex -= nCount;
+ if (xAccessible.is())
+ break;
}
if (nIndex >= 0)
@@ -942,21 +936,20 @@ uno::Reference<XAccessible> ScShapeChildren::GetForegroundShapeAt(const awt::Poi
{
uno::Reference<XAccessible> xAcc;
- ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
- ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
- while((aItr != aEndItr) && !xAcc.is())
+ for(const auto& rShapeRange : maShapeRanges)
{
- ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), ScShapePointFound(rPoint));
- if (aFindItr != aItr->maForeShapes.end())
+ ScShapeChildVec::const_iterator aFindItr = std::find_if(rShapeRange.maForeShapes.begin(), rShapeRange.maForeShapes.end(), ScShapePointFound(rPoint));
+ if (aFindItr != rShapeRange.maForeShapes.end())
xAcc = GetAccShape(*aFindItr);
else
{
- ScShapeChildVec::const_iterator aCtrlItr = std::find_if(aItr->maControls.begin(), aItr->maControls.end(), ScShapePointFound(rPoint));
- if (aCtrlItr != aItr->maControls.end())
+ ScShapeChildVec::const_iterator aCtrlItr = std::find_if(rShapeRange.maControls.begin(), rShapeRange.maControls.end(), ScShapePointFound(rPoint));
+ if (aCtrlItr != rShapeRange.maControls.end())
xAcc = GetAccShape(*aCtrlItr);
- else
- ++aItr;
}
+
+ if (xAcc.is())
+ break;
}
return xAcc;
@@ -966,15 +959,13 @@ uno::Reference<XAccessible> ScShapeChildren::GetBackgroundShapeAt(const awt::Poi
{
uno::Reference<XAccessible> xAcc;
- ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
- ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
- while((aItr != aEndItr) && !xAcc.is())
+ for(const auto& rShapeRange : maShapeRanges)
{
- ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), ScShapePointFound(rPoint));
- if (aFindItr != aItr->maBackShapes.end())
+ ScShapeChildVec::const_iterator aFindItr = std::find_if(rShapeRange.maBackShapes.begin(), rShapeRange.maBackShapes.end(), ScShapePointFound(rPoint));
+ if (aFindItr != rShapeRange.maBackShapes.end())
xAcc = GetAccShape(*aFindItr);
- else
- ++aItr;
+ if (xAcc.is())
+ break;
}
return xAcc;
diff --git a/sc/source/ui/Accessibility/AccessibleGlobal.cxx b/sc/source/ui/Accessibility/AccessibleGlobal.cxx
index 71615a0fe1e8..31d810bd2d0b 100644
--- a/sc/source/ui/Accessibility/AccessibleGlobal.cxx
+++ b/sc/source/ui/Accessibility/AccessibleGlobal.cxx
@@ -19,6 +19,8 @@
#include <AccessibleGlobal.hxx>
+#include <comphelper/sequence.hxx>
+
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Sequence;
using ::std::set;
@@ -59,14 +61,7 @@ sal_Bool SAL_CALL ScAccessibleStateSet::containsAll(
Sequence<sal_Int16> SAL_CALL ScAccessibleStateSet::getStates()
{
- Sequence<sal_Int16> aSeq(0);
- set<sal_Int16>::const_iterator itr = maStates.begin(), itrEnd = maStates.end();
- for (size_t i = 0; itr != itrEnd; ++itr, ++i)
- {
- aSeq.realloc(i+1);
- aSeq[i] = *itr;
- }
- return aSeq;
+ return comphelper::containerToSequence(maStates);
}
void ScAccessibleStateSet::insert(sal_Int16 nState)
diff --git a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx
index fd04472b9172..c97d4ef72aa1 100644
--- a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx
+++ b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx
@@ -227,20 +227,20 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleChil
if(mnChildCount < 0)
getAccessibleChildCount();
- auto aItr = maAreas.begin();
- auto aEndItr = maAreas.end();
- while (!xRet.is() && (nIndex >= 0) && (aItr != aEndItr))
- {
- if (aItr->is())
+ if (nIndex >= 0)
+ for (const auto& rxArea : maAreas)
{
- if (nIndex == 0)
- xRet = aItr->get();
- else
- --nIndex;
+ if (rxArea.is())
+ {
+ if (nIndex == 0)
+ {
+ xRet = rxArea.get();
+ break;
+ }
+ else
+ --nIndex;
+ }
}
- else
- ++aItr;
- }
if ( !xRet.is() )
throw lang::IndexOutOfBoundsException();
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index 45c353495a0d..e2d69a6f4f48 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -99,10 +99,8 @@ ScMyAddress ScAccessibleSpreadsheet::CalcScAddressFromRangeList(ScRangeList *pMa
{
m_vecTempCol.clear();
{
- VEC_RANGE::const_iterator vi = m_vecTempRange.begin();
- for (; vi < m_vecTempRange.end(); ++vi)
+ for (ScRange const & r : m_vecTempRange)
{
- ScRange const & r = *vi;
if ( row >= r.aStart.Row() && row <= r.aEnd.Row())
{
m_vecTempCol.emplace_back(r.aStart.Col(),r.aEnd.Col());
@@ -111,14 +109,12 @@ ScMyAddress ScAccessibleSpreadsheet::CalcScAddressFromRangeList(ScRangeList *pMa
}
std::sort(m_vecTempCol.begin(),m_vecTempCol.end(),CompMinCol);
{
- VEC_COL::const_iterator vic = m_vecTempCol.begin();
- for(; vic != m_vecTempCol.end(); ++vic)
+ for(const PAIR_COL &pairCol : m_vecTempCol)
{
- const PAIR_COL &pariCol = *vic;
- sal_uInt16 nCol = pariCol.second - pariCol.first + 1;
+ sal_uInt16 nCol = pairCol.second - pairCol.first + 1;
if (nCol + nCurrentIndex > nSelectedChildIndex)
{
- return ScMyAddress(static_cast<SCCOL>(pariCol.first + nSelectedChildIndex - nCurrentIndex), row, maActiveCell.Tab());
+ return ScMyAddress(static_cast<SCCOL>(pairCol.first + nSelectedChildIndex - nCurrentIndex), row, maActiveCell.Tab());
}
nCurrentIndex += nCol;
}
@@ -621,11 +617,10 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
}
else
{
- VEC_MYADDR::iterator viAddr = vecNew.begin();
- for(; viAddr < vecNew.end() ; ++viAddr )
+ for(const auto& rAddr : vecNew)
{
- uno::Reference< XAccessible > xChild = getAccessibleCellAt(viAddr->Row(),viAddr->Col());
- if (!(bNewPosCellFocus && *viAddr == aNewCell) )
+ uno::Reference< XAccessible > xChild = getAccessibleCellAt(rAddr.Row(),rAddr.Col());
+ if (!(bNewPosCellFocus && rAddr == aNewCell) )
{
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS;
aEvent.NewValue <<= xChild;
@@ -634,7 +629,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD;
aEvent.NewValue <<= xChild;
CommitChange(aEvent);
- m_mapSelectionSend.emplace(*viAddr,xChild);
+ m_mapSelectionSend.emplace(rAddr,xChild);
}
}
}
@@ -724,10 +719,7 @@ void ScAccessibleSpreadsheet::RemoveSelection(const ScMarkData &refScMarkData)
aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
aEvent.NewValue <<= miRemove->second;
CommitChange(aEvent);
- MAP_ADDR_XACC::iterator miNext = miRemove;
- ++miNext;
- m_mapSelectionSend.erase(miRemove);
- miRemove = miNext;
+ miRemove = m_mapSelectionSend.erase(miRemove);
}
}
void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell)
@@ -1564,17 +1556,16 @@ void ScAccessibleSpreadsheet::NotifyRefMode()
}
else
{
- VEC_MYADDR::iterator viAddr = vecNew.begin();
- for(; viAddr != vecNew.end() ; ++viAddr )
+ for(const auto& rAddr : vecNew)
{
uno::Reference< XAccessible > xChild;
- if (*viAddr == aFormulaAddr)
+ if (rAddr == aFormulaAddr)
{
xChild = m_pAccFormulaCell.get();
}
else
{
- xChild = getAccessibleCellAt(viAddr->Row(),viAddr->Col());
+ xChild = getAccessibleCellAt(rAddr.Row(),rAddr.Col());
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS;
aEvent.NewValue <<= xChild;
CommitChange(aEvent);
@@ -1582,7 +1573,7 @@ void ScAccessibleSpreadsheet::NotifyRefMode()
aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD;
aEvent.NewValue <<= xChild;
CommitChange(aEvent);
- m_mapFormulaSelectionSend.emplace(*viAddr,xChild);
+ m_mapFormulaSelectionSend.emplace(rAddr,xChild);
}
}
m_vecFormulaLastMyAddr.swap(vecCurSel);
@@ -1606,10 +1597,7 @@ void ScAccessibleSpreadsheet::RemoveFormulaSelection(bool bRemoveAll )
aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
aEvent.NewValue <<= miRemove->second;
CommitChange(aEvent);
- MAP_ADDR_XACC::iterator miNext = miRemove;
- ++miNext;
- m_mapFormulaSelectionSend.erase(miRemove);
- miRemove = miNext;
+ miRemove = m_mapFormulaSelectionSend.erase(miRemove);
}
}
diff --git a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
index 376dd26c5e32..15936bc2d518 100644
--- a/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
+++ b/sc/source/ui/StatisticsDialogs/TableFillingAndNavigationTools.cxx
@@ -38,15 +38,13 @@ void FormulaTemplate::setTemplate(const char* aTemplate)
const OUString& FormulaTemplate::getTemplate()
{
- RangeReplacementMap::iterator itRange;
- for (itRange = mRangeReplacementMap.begin(); itRange != mRangeReplacementMap.end(); ++itRange)
+ for (const auto& [rVariable, rRange] : mRangeReplacementMap)
{
- applyRange(itRange->first, itRange->second, mbUse3D);
+ applyRange(rVariable, rRange, mbUse3D);
}
- AddressReplacementMap::iterator itAddress;
- for (itAddress = mAddressReplacementMap.begin(); itAddress != mAddressReplacementMap.end(); ++itAddress)
+ for (const auto& [rVariable, rAddress] : mAddressReplacementMap)
{
- applyAddress(itAddress->first, itAddress->second, mbUse3D);
+ applyAddress(rVariable, rAddress, mbUse3D);
}
return mTemplate;
}
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
index 59cb1ac4454f..163f155a2ebc 100644
--- a/sc/source/ui/app/drwtrans.cxx
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -326,10 +326,9 @@ void ScDrawTransferObj::AddSupportedFormats()
// (this must be after inserting the default formats!)
DataFlavorExVector aVector( m_aOleData.GetDataFlavorExVector() );
- DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() );
- while( aIter != aEnd )
- AddFormat( *aIter++ );
+ for( const auto& rItem : aVector )
+ AddFormat( rItem );
}
}
else // any drawing objects
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 377495e609d1..aabcc77ec6a4 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -114,6 +114,9 @@ ScTypedCaseStrSet::const_iterator findText(
const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator const & itPos,
const OUString& rStart, OUString& rResult, bool bBack)
{
+ auto lIsMatch = [&rStart](const ScTypedStrData& rData) {
+ return (rData.GetStringType() != ScTypedStrData::Value) && ScGlobal::GetpTransliteration()->isMatch(rStart, rData.GetString()); };
+
if (bBack) // Backwards
{
ScTypedCaseStrSet::const_reverse_iterator it = rDataSet.rbegin(), itEnd = rDataSet.rend();
@@ -125,42 +128,25 @@ ScTypedCaseStrSet::const_iterator findText(
++it;
}
- for (; it != itEnd; ++it)
+ it = std::find_if(it, itEnd, lIsMatch);
+ if (it != itEnd)
{
- const ScTypedStrData& rData = *it;
- if (rData.GetStringType() == ScTypedStrData::Value)
- // skip values
- continue;
-
- if (!ScGlobal::GetpTransliteration()->isMatch(rStart, rData.GetString()))
- // not a match
- continue;
-
- rResult = rData.GetString();
+ rResult = it->GetString();
return (++it).base(); // convert the reverse iterator back to iterator.
}
}
else // Forwards
{
ScTypedCaseStrSet::const_iterator it = rDataSet.begin(), itEnd = rDataSet.end();
- if (itPos != rDataSet.end())
+ if (itPos != itEnd)
{
- it = itPos;
- ++it;
+ it = std::next(itPos);
}
- for (; it != itEnd; ++it)
+ it = std::find_if(it, itEnd, lIsMatch);
+ if (it != itEnd)
{
- const ScTypedStrData& rData = *it;
- if (rData.GetStringType() == ScTypedStrData::Value)
- // skip values
- continue;
-
- if (!ScGlobal::GetpTransliteration()->isMatch(rStart, rData.GetString()))
- // not a match
- continue;
-
- rResult = rData.GetString();
+ rResult = it->GetString();
return it;
}
}
@@ -170,18 +156,13 @@ ScTypedCaseStrSet::const_iterator findText(
OUString getExactMatch(const ScTypedCaseStrSet& rDataSet, const OUString& rString)
{
- ScTypedCaseStrSet::const_iterator it = rDataSet.begin(), itEnd = rDataSet.end();
- for (; it != itEnd; ++it)
- {
- const ScTypedStrData& rData = *it;
- if (rData.GetStringType() == ScTypedStrData::Value)
- continue;
-
- if (!ScGlobal::GetpTransliteration()->isEqual(rData.GetString(), rString))
- continue;
-
- return rData.GetString();
- }
+ auto it = std::find_if(rDataSet.begin(), rDataSet.end(),
+ [&rString](const ScTypedStrData& rData) {
+ return (rData.GetStringType() != ScTypedStrData::Value)
+ && ScGlobal::GetpTransliteration()->isEqual(rData.GetString(), rString);
+ });
+ if (it != rDataSet.end())
+ return it->GetString();
return rString;
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 2162eb6b9f74..3e276a1c2149 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1882,11 +1882,10 @@ void ScPosWnd::FillRangeNames()
ScRange aDummy;
std::set<OUString> aSet;
ScRangeName* pRangeNames = rDoc.GetRangeName();
- ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
- for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
+ for (const auto& rEntry : *pRangeNames)
{
- if (itr->second->IsValidReference(aDummy))
- aSet.insert(itr->second->GetName());
+ if (rEntry.second->IsValidReference(aDummy))
+ aSet.insert(rEntry.second->GetName());
}
for (SCTAB i = 0; i < rDoc.GetTableCount(); ++i)
{
@@ -1895,18 +1894,17 @@ void ScPosWnd::FillRangeNames()
{
OUString aTableName;
rDoc.GetName(i, aTableName);
- for (ScRangeName::const_iterator itr = pLocalRangeName->begin(); itr != pLocalRangeName->end(); ++itr)
+ for (const auto& rEntry : *pLocalRangeName)
{
- if (itr->second->IsValidReference(aDummy))
- aSet.insert(createLocalRangeName(itr->second->GetName(), aTableName));
+ if (rEntry.second->IsValidReference(aDummy))
+ aSet.insert(createLocalRangeName(rEntry.second->GetName(), aTableName));
}
}
}
- for (std::set<OUString>::iterator itr = aSet.begin();
- itr != aSet.end(); ++itr)
+ for (const auto& rItem : aSet)
{
- InsertEntry(*itr);
+ InsertEntry(rItem);
}
}
SetText(aPosStr);
diff --git a/sc/source/ui/app/rfindlst.cxx b/sc/source/ui/app/rfindlst.cxx
index 93ee2d254f0f..f0188a9fbeb3 100644
--- a/sc/source/ui/app/rfindlst.cxx
+++ b/sc/source/ui/app/rfindlst.cxx
@@ -35,12 +35,8 @@ ScRangeFindList::ScRangeFindList(const OUString& rName) :
Color ScRangeFindList::Insert( const ScRangeFindData &rNew )
{
- std::vector<ScRangeFindData>::iterator it=maEntries.begin();
- for( ; it!=maEntries.end(); ++it)
- {
- if(it->aRef == rNew.aRef)
- break;
- }
+ auto it = std::find_if(maEntries.begin(), maEntries.end(),
+ [&rNew](const ScRangeFindData& rEntry) { return rEntry.aRef == rNew.aRef; });
ScRangeFindData insertData(rNew);
insertData.nColor = ( it != maEntries.end() ? it->nColor :
ScRangeFindList::GetColorName( maEntries.size() ) );
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 8153d13b581b..72aa34c6bc91 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -101,8 +101,8 @@ ScMenuFloatingWindow::~ScMenuFloatingWindow()
void ScMenuFloatingWindow::dispose()
{
EndPopupMode();
- for (auto i = maMenuItems.begin(); i != maMenuItems.end(); ++i)
- i->mpSubMenuWin.disposeAndClear();
+ for (auto& rMenuItem : maMenuItems)
+ rMenuItem.mpSubMenuWin.disposeAndClear();
mpParentMenu.clear();
PopupMenuFloatingWindow::dispose();
}
@@ -284,11 +284,11 @@ Reference<XAccessible> ScMenuFloatingWindow::CreateAccessible()
ScAccessibleFilterMenu* p = static_cast<ScAccessibleFilterMenu*>(
mxAccessible.get());
- vector<MenuItemData>::const_iterator itr, itrBeg = maMenuItems.begin(), itrEnd = maMenuItems.end();
- for (itr = itrBeg; itr != itrEnd; ++itr)
+ size_t nPos = 0;
+ for (const auto& rMenuItem : maMenuItems)
{
- size_t nPos = ::std::distance(itrBeg, itr);
- p->appendMenuItem(itr->maText, nPos);
+ p->appendMenuItem(rMenuItem.maText, nPos);
+ ++nPos;
}
}
@@ -332,15 +332,13 @@ Size ScMenuFloatingWindow::getMenuSize() const
if (maMenuItems.empty())
return Size();
- vector<MenuItemData>::const_iterator itr = maMenuItems.begin(), itrEnd = maMenuItems.end();
- long nTextWidth = 0;
- for (; itr != itrEnd; ++itr)
- {
- if (itr->mbSeparator)
- continue;
-
- nTextWidth = ::std::max(GetTextWidth(itr->maText), nTextWidth);
- }
+ auto itr = std::max_element(maMenuItems.begin(), maMenuItems.end(),
+ [this](const MenuItemData& a, const MenuItemData& b) {
+ long aTextWidth = a.mbSeparator ? 0 : GetTextWidth(a.maText);
+ long bTextWidth = b.mbSeparator ? 0 : GetTextWidth(b.maText);
+ return aTextWidth < bTextWidth;
+ });
+ long nTextWidth = itr->mbSeparator ? 0 : GetTextWidth(itr->maText);
size_t nLastPos = maMenuItems.size()-1;
Point aPos;
@@ -592,11 +590,11 @@ void ScMenuFloatingWindow::endSubMenu(ScMenuFloatingWindow* pSubMenu)
void ScMenuFloatingWindow::fillMenuItemsToAccessible(ScAccessibleFilterMenu* pAccMenu) const
{
- vector<MenuItemData>::const_iterator itr, itrBeg = maMenuItems.begin(), itrEnd = maMenuItems.end();
- for (itr = itrBeg; itr != itrEnd; ++itr)
+ size_t nPos = 0;
+ for (const auto& rMenuItem : maMenuItems)
{
- size_t nPos = ::std::distance(itrBeg, itr);
- pAccMenu->appendMenuItem(itr->maText, nPos);
+ pAccMenu->appendMenuItem(rMenuItem.maText, nPos);
+ ++nPos;
}
}
@@ -1134,9 +1132,9 @@ void ScCheckListMenuWindow::setAllMemberState(bool bSet)
aParents.insert(maMembers[i].mpParent);
}
- for (auto itr = aParents.begin(), itrEnd = aParents.end(); itr != itrEnd; ++itr)
+ for (const auto& pParent : aParents)
{
- if (!(*itr))
+ if (!pParent)
{
sal_uInt32 nCount = maChecks->GetEntryCount();
for( sal_uInt32 i = 0; i < nCount; ++i)
@@ -1150,10 +1148,10 @@ void ScCheckListMenuWindow::setAllMemberState(bool bSet)
}
else
{
- SvTreeListEntries& rEntries = (*itr)->GetChildEntries();
- for (auto it = rEntries.begin(), itEnd = rEntries.end(); it != itEnd; ++ it)
+ SvTreeListEntries& rEntries = pParent->GetChildEntries();
+ for (const auto& rxEntry : rEntries)
{
- maChecks->CheckEntry(it->get(), bSet);
+ maChecks->CheckEntry(rxEntry.get(), bSet);
}
}
}
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
index 9eb38a66ddd7..af8b1b798191 100644
--- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -139,20 +139,13 @@ sal_uInt16 ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
return mpImpl->mnMaxZoom;
// check for snapping points:
- sal_uInt16 nCount = 0;
- std::vector< long >::iterator aSnappingPointIter;
- for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
- aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
- ++aSnappingPointIter )
+ auto aSnappingPointIter = std::find_if(mpImpl->maSnappingPointOffsets.begin(), mpImpl->maSnappingPointOffsets.end(),
+ [nOffset](const long nCurrent) { return std::abs(nCurrent - nOffset) < nSnappingEpsilon; });
+ if (aSnappingPointIter != mpImpl->maSnappingPointOffsets.end())
{
- const long nCurrent = *aSnappingPointIter;
- if ( std::abs(nCurrent - nOffset) < nSnappingEpsilon )
- {
- nOffset = nCurrent;
- nRet = mpImpl->maSnappingPointZooms[ nCount ];
- break;
- }
- ++nCount;
+ nOffset = *aSnappingPointIter;
+ auto nCount = static_cast<sal_uInt16>(std::distance(mpImpl->maSnappingPointOffsets.begin(), aSnappingPointIter));
+ nRet = mpImpl->maSnappingPointZooms[ nCount ];
}
if( 0 == nRet )
@@ -355,12 +348,10 @@ void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
}
// remove snapping points that are to close to each other:
- std::set< sal_uInt16 >::iterator aSnappingPointIter;
long nLastOffset = 0;
- for ( aSnappingPointIter = aTmpSnappingPoints.begin(); aSnappingPointIter != aTmpSnappingPoints.end(); ++aSnappingPointIter )
+ for ( const sal_uInt16 nCurrent : aTmpSnappingPoints )
{
- const sal_uInt16 nCurrent = *aSnappingPointIter;
const long nCurrentOffset = Zoom2Offset( nCurrent );
if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist )
@@ -439,16 +430,13 @@ void ScZoomSliderWnd::DoPaint(vcl::RenderContext& rRenderContext)
pVDev->DrawRect(aLeft);
// draw snapping points:
- std::vector<long>::iterator aSnappingPointIter;
- for (aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
- aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
- ++aSnappingPointIter)
+ for (const auto& rSnappingPointOffset : mpImpl->maSnappingPointOffsets)
{
pVDev->SetLineColor(COL_GRAY);
tools::Rectangle aSnapping(aRect);
aSnapping.SetBottom( aSlider.Top() );
aSnapping.SetTop( aSnapping.Bottom() - nSnappingHeight );
- aSnapping.AdjustLeft(*aSnappingPointIter );
+ aSnapping.AdjustLeft(rSnappingPointOffset );
aSnapping.SetRight( aSnapping.Left() );
pVDev->DrawRect(aSnapping);
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 79e0e3f233d6..a599a0ec5e2b 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -59,8 +59,8 @@ void ScCondFormatList::dispose()
Freeze();
mpDialogParent.clear();
mpScrollBar.disposeAndClear();
- for (auto it = maEntries.begin(); it != maEntries.end(); ++it)
- it->disposeAndClear();
+ for (auto& rxEntry : maEntries)
+ rxEntry.disposeAndClear();
maEntries.clear();
Control::dispose();
}
@@ -268,12 +268,8 @@ void ScCondFormatList::DoScroll(long nDelta)
IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox&, rBox, void)
{
- EntryContainer::iterator itr = maEntries.begin();
- for(; itr != maEntries.end(); ++itr)
- {
- if((*itr)->IsSelected())
- break;
- }
+ EntryContainer::iterator itr = std::find_if(maEntries.begin(), maEntries.end(),
+ [](const VclPtr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
if(itr == maEntries.end())
return;
@@ -333,12 +329,8 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox&, rBox, void)
IMPL_LINK(ScCondFormatList, AfterTypeListHdl, void*, p, void)
{
ListBox* pBox = static_cast<ListBox*>(p);
- EntryContainer::iterator itr = maEntries.begin();
- for(; itr != maEntries.end(); ++itr)
- {
- if((*itr)->IsSelected())
- break;
- }
+ EntryContainer::iterator itr = std::find_if(maEntries.begin(), maEntries.end(),
+ [](const VclPtr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
if(itr == maEntries.end())
return;
@@ -405,9 +397,9 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, Button*, void )
Freeze();
VclPtr<ScCondFrmtEntry> pNewEntry = VclPtr<ScConditionFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos);
maEntries.push_back( pNewEntry );
- for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+ for(auto& rxEntry : maEntries)
{
- (*itr)->SetInactive();
+ rxEntry->SetInactive();
}
mpDialogParent->InvalidateRefData();
pNewEntry->SetActive();
@@ -419,15 +411,12 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, Button*, void )
IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, Button*, void )
{
Freeze();
- for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+ auto itr = std::find_if(maEntries.begin(), maEntries.end(),
+ [](const VclPtr<ScCondFrmtEntry>& widget) { return widget->IsSelected(); });
+ if (itr != maEntries.end())
{
- auto widget = *itr;
- if (widget->IsSelected())
- {
- maEntries.erase(itr);
- widget.disposeAndClear();
- break;
- }
+ itr->disposeAndClear();
+ maEntries.erase(itr);
}
mpDialogParent->InvalidateRefData();
mpDialogParent->OnSelectionChange(0, maEntries.size(), false);
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 47870c52f257..312bd8d50bac 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -155,10 +155,9 @@ void FillStyleListBox( const ScDocument* pDoc, ListBox& rLbStyle )
{
aStyleNames.insert(pStyle->GetName());
}
- for(std::set<OUString>::const_iterator itr = aStyleNames.begin(), itrEnd = aStyleNames.end();
- itr != itrEnd; ++itr)
+ for(const auto& rStyleName : aStyleNames)
{
- rLbStyle.InsertEntry( *itr );
+ rLbStyle.InsertEntry( rStyleName );
}
}
@@ -1584,8 +1583,8 @@ ScIconSetFrmtEntry::~ScIconSetFrmtEntry()
void ScIconSetFrmtEntry::dispose()
{
- for (auto it = maEntries.begin(); it != maEntries.end(); ++it)
- it->disposeAndClear();
+ for (auto& rxEntry : maEntries)
+ rxEntry.disposeAndClear();
maEntries.clear();
maIconParent.clear();
maLbColorFormat.clear();
@@ -1609,8 +1608,8 @@ IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl, ListBox&, void )
sal_Int32 nPos = maLbIconSetType->GetSelectedEntryPos();
sal_uInt32 nElements = pMap[nPos].nElements;
- for (auto it = maEntries.begin(); it != maEntries.end(); ++it)
- it->disposeAndClear();
+ for (auto& rxEntry : maEntries)
+ rxEntry.disposeAndClear();
maEntries.clear();
for(size_t i = 0; i < nElements; ++i)
@@ -1633,10 +1632,9 @@ void ScIconSetFrmtEntry::SetActive()
{
maLbColorFormat->Show();
maLbIconSetType->Show();
- for(ScIconSetFrmtDataEntriesType::iterator itr = maEntries.begin(),
- itrEnd = maEntries.end(); itr != itrEnd; ++itr)
+ for(auto& rxEntry : maEntries)
{
- (*itr)->Show();
+ rxEntry->Show();
}
Select();
@@ -1646,10 +1644,9 @@ void ScIconSetFrmtEntry::SetInactive()
{
maLbColorFormat->Hide();
maLbIconSetType->Hide();
- for(ScIconSetFrmtDataEntriesType::iterator itr = maEntries.begin(),
- itrEnd = maEntries.end(); itr != itrEnd; ++itr)
+ for(auto& rxEntry : maEntries)
{
- (*itr)->Hide();
+ rxEntry->Hide();
}
Deselect();
@@ -1661,10 +1658,9 @@ ScFormatEntry* ScIconSetFrmtEntry::GetEntry() const
ScIconSetFormatData* pData = new ScIconSetFormatData;
pData->eIconSetType = static_cast<ScIconSetType>(maLbIconSetType->GetSelectedEntryPos());
- for(ScIconSetFrmtDataEntriesType::const_iterator itr = maEntries.begin(),
- itrEnd = maEntries.end(); itr != itrEnd; ++itr)
+ for(const auto& rxEntry : maEntries)
{
- pData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>((*itr)->CreateEntry(mpDoc, maPos)));
+ pData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>(rxEntry->CreateEntry(mpDoc, maPos)));
}
pFormat->SetIconSetData(pData);
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index e5be9c7435ca..057ef9a963a7 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -50,10 +50,10 @@ void ScCondFormatManagerWindow::Init()
if (mpFormatList)
{
- for(ScConditionalFormatList::iterator itr = mpFormatList->begin(); itr != mpFormatList->end(); ++itr)
+ for(const auto& rItem : *mpFormatList)
{
- SvTreeListEntry* pEntry = InsertEntryToColumn( createEntryString(**itr) );
- maMapLBoxEntryToCondIndex.insert(std::pair<SvTreeListEntry*,sal_Int32>(pEntry, (*itr)->GetKey()));
+ SvTreeListEntry* pEntry = InsertEntryToColumn( createEntryString(*rItem) );
+ maMapLBoxEntryToCondIndex.insert(std::pair<SvTreeListEntry*,sal_Int32>(pEntry, rItem->GetKey()));
}
}
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index dbf04283986e..581234369dac 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -344,9 +344,8 @@ void ScDbNameDlg::UpdateNames()
if (!rDBs.empty())
{
- DBsType::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
- for (; itr != itrEnd; ++itr)
- m_pEdName->InsertEntry((*itr)->GetName());
+ for (const auto& rxDB : rDBs)
+ m_pEdName->InsertEntry(rxDB->GetName());
}
else
{
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index 61b691040635..d9b6f599483e 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -534,10 +534,9 @@ void ScFilterDlg::UpdateValueList( size_t nList )
OSL_ASSERT(pList);
- std::vector<ScTypedStrData>::const_iterator it = pList->maFilterEntries.begin(), itEnd = pList->maFilterEntries.end();
- for (; it != itEnd; ++it)
+ for (const auto& rEntry : pList->maFilterEntries)
{
- pValList->InsertEntry(it->GetString(), nListPos++);
+ pValList->InsertEntry(rEntry.GetString(), nListPos++);
}
}
pValList->SetText( aCurValue );
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
index 1aa225bbcd85..dc394d0cf9d2 100644
--- a/sc/source/ui/dbgui/pfiltdlg.cxx
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -314,10 +314,9 @@ void ScPivotFilterDlg::UpdateValueList( sal_uInt16 nList )
}
const ScFilterEntries* pColl = m_pEntryLists[nColumn].get();
- std::vector<ScTypedStrData>::const_iterator it = pColl->begin(), itEnd = pColl->end();
- for (; it != itEnd; ++it)
+ for (const auto& rEntry : *pColl)
{
- pValList->InsertEntry(it->GetString(), nListPos);
+ pValList->InsertEntry(rEntry.GetString(), nListPos);
nListPos++;
}
}
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index c6998ce26b31..bec114c331c0 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -76,10 +76,9 @@ template< typename ListBoxType >
bool lclFillListBox( ListBoxType& rLBox, const vector<ScDPLabelData::Member>& rMembers, sal_Int32 nEmptyPos = LISTBOX_APPEND )
{
bool bEmpty = false;
- vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rMember : rMembers)
{
- OUString aName = itr->getDisplayName();
+ OUString aName = rMember.getDisplayName();
if (!aName.isEmpty())
rLBox.InsertEntry(aName);
else
@@ -271,12 +270,12 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScPivotFuncDa
// base field list box
OUString aSelectedEntry;
- for( ScDPLabelDataVector::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
+ for( const auto& rxLabel : mrLabelVec )
{
- mpLbBaseField->InsertEntry((*aIt)->getDisplayName());
- maBaseFieldNameMap.emplace((*aIt)->getDisplayName(), (*aIt)->maName);
- if ((*aIt)->maName == rFuncData.maFieldRef.ReferenceField)
- aSelectedEntry = (*aIt)->getDisplayName();
+ mpLbBaseField->InsertEntry(rxLabel->getDisplayName());
+ maBaseFieldNameMap.emplace(rxLabel->getDisplayName(), rxLabel->maName);
+ if (rxLabel->maName == rFuncData.maFieldRef.ReferenceField)
+ aSelectedEntry = rxLabel->getDisplayName();
}
// base item list box
@@ -396,9 +395,8 @@ IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox&, rLBox, void )
mbEmptyItem = lclFillListBox(*mpLbBaseItem, rMembers, SC_BASEITEM_USER_POS);
// build cache for base names.
NameMapType aMap;
- vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
- for (; itr != itrEnd; ++itr)
- aMap.emplace(itr->getDisplayName(), itr->maName);
+ for (const auto& rMember : rMembers)
+ aMap.emplace(rMember.getDisplayName(), rMember.maName);
maBaseItemNameMap.swap(aMap);
}
@@ -653,13 +651,13 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayou
// sort fields list box
m_pLbSortBy->InsertEntry(maLabelData.getDisplayName());
- for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
+ for( const auto& rDataField : rDataFields )
{
// Cache names for later lookup.
- maDataFieldNameMap.emplace(aIt->maLayoutName, *aIt);
+ maDataFieldNameMap.emplace(rDataField.maLayoutName, rDataField);
- m_pLbSortBy->InsertEntry( aIt->maLayoutName );
- m_pLbShowUsing->InsertEntry( aIt->maLayoutName ); // for AutoShow
+ m_pLbSortBy->InsertEntry( rDataField.maLayoutName );
+ m_pLbShowUsing->InsertEntry( rDataField.maLayoutName ); // for AutoShow
}
if( m_pLbSortBy->GetEntryCount() > SC_SORTDATA_POS )
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
index 583b5d61517c..41859bc89848 100644
--- a/sc/source/ui/dbgui/sfiltdlg.cxx
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -163,15 +163,14 @@ void ScSpecialFilterDlg::Init( const SfxItemSet& rArgSet )
pLbFilterArea->Clear();
pLbFilterArea->InsertEntry( aStrUndefined, 0 );
- ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rEntry : *pRangeNames)
{
- if (!itr->second->HasType(ScRangeData::Type::Criteria))
+ if (!rEntry.second->HasType(ScRangeData::Type::Criteria))
continue;
- const sal_Int32 nInsert = pLbFilterArea->InsertEntry(itr->second->GetName());
+ const sal_Int32 nInsert = pLbFilterArea->InsertEntry(rEntry.second->GetName());
OUString aSymbol;
- itr->second->GetSymbol(aSymbol);
+ rEntry.second->GetSymbol(aSymbol);
pLbFilterArea->SetEntryData(nInsert, new OUString(aSymbol));
}
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 72f4b3ccd55c..aedce9624ee5 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -440,10 +440,8 @@ IMPL_LINK( ScTabPageSortFields, SelectHdl, weld::ComboBox&, rLb, void )
}
// Find selected listbox
- for ( pIter = m_aSortWin.m_aSortKeyItems.begin(); pIter != m_aSortWin.m_aSortKeyItems.end(); ++pIter )
- {
- if ( (*pIter)->m_xLbSort.get() == &rLb ) break;
- }
+ pIter = std::find_if(m_aSortWin.m_aSortKeyItems.begin(), m_aSortWin.m_aSortKeyItems.end(),
+ [&rLb](const ScSortKeyItems::value_type& rItem) { return rItem->m_xLbSort.get() == &rLb; });
if (pIter == m_aSortWin.m_aSortKeyItems.end())
return;