summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-01-06 15:02:59 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 07:24:05 +0100
commit892a5cfe557edb405ec0037676f02a1c24dd76ec (patch)
treebb023d0858cd0f34ded726e2b54933a2481cc6b1
parenttdf#121812 colibre and breeze wrong icon for roman uppercase list (diff)
downloadcore-892a5cfe557edb405ec0037676f02a1c24dd76ec.tar.gz
core-892a5cfe557edb405ec0037676f02a1c24dd76ec.zip
Simplify containers iterations in sc/source/ui/{unoobj,vba}
Use range-based loop or replace with STL functions Change-Id: Ia8a8cfb71047e5612aa62c817c76ae0dfb7b3fa2 Reviewed-on: https://gerrit.libreoffice.org/65903 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/ui/unoobj/afmtuno.cxx7
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx37
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx115
-rw-r--r--sc/source/ui/unoobj/condformatuno.cxx12
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx13
-rw-r--r--sc/source/ui/unoobj/datauno.cxx21
-rw-r--r--sc/source/ui/unoobj/docuno.cxx17
-rw-r--r--sc/source/ui/unoobj/linkuno.cxx11
-rw-r--r--sc/source/ui/unoobj/nameuno.cxx26
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx77
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx14
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx22
-rw-r--r--sc/source/ui/vba/vbafont.cxx7
-rw-r--r--sc/source/ui/vba/vbarange.cxx20
-rw-r--r--sc/source/ui/vba/vbasheetobjects.cxx7
-rw-r--r--sc/source/ui/vba/vbawindow.cxx7
-rw-r--r--sc/source/ui/vba/vbaworksheets.cxx7
17 files changed, 180 insertions, 240 deletions
diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx
index 83533d2715d9..81aee84f9a3d 100644
--- a/sc/source/ui/unoobj/afmtuno.cxx
+++ b/sc/source/ui/unoobj/afmtuno.cxx
@@ -333,10 +333,11 @@ uno::Sequence<OUString> SAL_CALL ScAutoFormatsObj::getElementNames()
ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
uno::Sequence<OUString> aSeq(pFormats->size());
OUString* pAry = aSeq.getArray();
- ScAutoFormat::const_iterator it = pFormats->begin(), itEnd = pFormats->end();
- for (size_t i = 0; it != itEnd; ++it, ++i)
+ size_t i = 0;
+ for (const auto& rEntry : *pFormats)
{
- pAry[i] = it->second->GetName();
+ pAry[i] = rEntry.second->GetName();
+ ++i;
}
return aSeq;
}
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 956b0ee64bc1..86381a2a755d 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -4004,10 +4004,13 @@ sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSea
SCTAB nTabCount = rDoc.GetTableCount();
bool bProtected = !pDocShell->IsEditable();
- ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
- for (; itr != itrEnd && *itr < nTabCount; ++itr)
- if ( rDoc.IsTabProtected(*itr) )
+ for (const auto& rTab : aMark)
+ {
+ if (rTab >= nTabCount)
+ break;
+ if ( rDoc.IsTabProtected(rTab) )
bProtected = true;
+ }
if (bProtected)
{
//! Exception, or what?
@@ -4025,10 +4028,13 @@ sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSea
pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nTab, nTab );
}
- itr = aMark.begin();
- for (; itr != itrEnd && *itr < nTabCount; ++itr)
- if ( *itr != nTab && bUndo)
- pUndoDoc->AddUndoTab( *itr, *itr );
+ for (const auto& rTab : aMark)
+ {
+ if (rTab >= nTabCount)
+ break;
+ if (rTab != nTab && bUndo)
+ pUndoDoc->AddUndoTab( rTab, rTab );
+ }
std::unique_ptr<ScMarkData> pUndoMark;
if (bUndo)
pUndoMark.reset(new ScMarkData(aMark));
@@ -9317,9 +9323,8 @@ const ScRangeList& ScUniqueFormatsEntry::GetRanges()
// move remaining entries from aJoinedRanges to aCompletedRanges
- ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
- for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
- aCompletedRanges.push_back( aJoinedIter->second );
+ for ( const auto& rEntry : aJoinedRanges )
+ aCompletedRanges.push_back( rEntry.second );
aJoinedRanges.clear();
// sort all ranges for a predictable API result
@@ -9329,9 +9334,8 @@ const ScRangeList& ScUniqueFormatsEntry::GetRanges()
// fill and return ScRangeList
aReturnRanges = new ScRangeList;
- ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
- for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
- aReturnRanges->push_back( *aCompIter );
+ for ( const auto& rCompletedRange : aCompletedRanges )
+ aReturnRanges->push_back( rCompletedRange );
aCompletedRanges.clear();
return *aReturnRanges;
@@ -9382,15 +9386,12 @@ ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange
// Fill the vector aRangeLists with the range lists from the hash map
aRangeLists.reserve( aHashMap.size() );
- ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
- ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
- while ( aMapIter != aMapEnd )
+ for ( auto& rMapEntry : aHashMap )
{
- ScUniqueFormatsEntry& rEntry = aMapIter->second;
+ ScUniqueFormatsEntry& rEntry = rMapEntry.second;
const ScRangeList& rRanges = rEntry.GetRanges();
aRangeLists.push_back( rRanges ); // copy ScRangeList
rEntry.Clear(); // free memory, don't hold both copies of all ranges
- ++aMapIter;
}
// Sort the vector by first range's start position, to avoid random shuffling
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 5fc78815f602..01b41cc63fd5 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -541,10 +541,9 @@ void Chart2Positioner::glueState()
SCCOL nEndCol = 0;
SCROW nEndRow = 0;
- for (vector<ScTokenRef>::const_iterator itr = mrRefTokens.begin(), itrEnd = mrRefTokens.end()
- ; itr != itrEnd; ++itr)
+ for (const auto& rxToken : mrRefTokens)
{
- ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, rxToken);
SCCOLROW n1 = aData.Ref1.Col();
SCCOLROW n2 = aData.Ref2.Col();
if (n1 > MAXCOL)
@@ -614,11 +613,10 @@ void Chart2Positioner::calcGlueState(SCCOL nColSize, SCROW nRowSize)
vector<State> aCellStates(nCR, Hole);
// Mark all referenced cells "occupied".
- for (vector<ScTokenRef>::const_iterator itr = mrRefTokens.begin(), itrEnd = mrRefTokens.end();
- itr != itrEnd; ++itr)
+ for (const auto& rxToken : mrRefTokens)
{
ScComplexRefData aData;
- ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, rxToken);
SCCOL nCol1 = aData.Ref1.Col() - mnStartCol;
SCCOL nCol2 = aData.Ref2.Col() - mnStartCol;
SCROW nRow1 = aData.Ref1.Row() - mnStartRow;
@@ -721,11 +719,8 @@ void Chart2Positioner::createPositionMap()
bool bNoGlue = (meGlue == GLUETYPE_NONE);
FormulaTokenMapMap aCols;
SCROW nNoGlueRow = 0;
- for (vector<ScTokenRef>::const_iterator itr = mrRefTokens.begin(), itrEnd = mrRefTokens.end();
- itr != itrEnd; ++itr)
+ for (const ScTokenRef& pToken : mrRefTokens)
{
- const ScTokenRef& pToken = *itr;
-
bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0;
svl::SharedString aTabName = svl::SharedString::getEmptyString();
@@ -733,7 +728,7 @@ void Chart2Positioner::createPositionMap()
aTabName = pToken->GetString();
ScComplexRefData aData;
- if( !ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr) )
+ if( !ScRefTokenHelper::getDoubleRefDataFromToken(aData, pToken) )
break;
const ScSingleRefData& s = aData.Ref1;
const ScSingleRefData& e = aData.Ref2;
@@ -798,12 +793,12 @@ void Chart2Positioner::createPositionMap()
if (bNoGlue)
{
FormulaTokenMap& rFirstCol = aCols.begin()->second;
- for (FormulaTokenMap::iterator it1 = rFirstCol.begin(); it1 != rFirstCol.end(); ++it1)
+ for (const auto& rFirstColEntry : rFirstCol)
{
- SCROW nKey = it1->first;
- for (FormulaTokenMapMap::iterator it2 = aCols.begin(); it2 != aCols.end(); ++it2)
+ SCROW nKey = rFirstColEntry.first;
+ for (auto& rEntry : aCols)
{
- FormulaTokenMap& rCol = it2->second;
+ FormulaTokenMap& rCol = rEntry.second;
if (rCol.find(nKey) == rCol.end())
rCol[ nKey ] = nullptr;
}
@@ -1229,15 +1224,14 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
// 2) The three adjacent cells of that corner cell are included.
bool bRight = false, bBottom = false, bDiagonal = false;
- for (itr = rRefTokens.begin(); itr != itrEnd; ++itr)
+ for (const auto& rxToken : rRefTokens)
{
- pToken = *itr;
- switch (pToken->GetType())
+ switch (rxToken->GetType())
{
case svSingleRef:
case svExternalSingleRef:
{
- const ScSingleRefData& rData = *pToken->GetSingleRef();
+ const ScSingleRefData& rData = *rxToken->GetSingleRef();
if (rData.Col() == nMinCol && rData.Row() == nMinRow)
// The corner cell is contained.
return false;
@@ -1255,7 +1249,7 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
case svDoubleRef:
case svExternalDoubleRef:
{
- const ScComplexRefData& rData = *pToken->GetDoubleRef();
+ const ScComplexRefData& rData = *rxToken->GetDoubleRef();
const ScSingleRefData& r1 = rData.Ref1;
const ScSingleRefData& r2 = rData.Ref2;
if (r1.Col() <= nMinCol && nMinCol <= r2.Col() &&
@@ -1452,13 +1446,12 @@ ScChart2DataProvider::createDataSource(
if(bTimeBased)
{
// limit to first sheet
- for(vector<ScTokenRef>::iterator itr = aRefTokens.begin(),
- itrEnd = aRefTokens.end(); itr != itrEnd; ++itr)
+ for(const auto& rxToken : aRefTokens)
{
- if ((*itr)->GetType() != svDoubleRef)
+ if (rxToken->GetType() != svDoubleRef)
continue;
- ScComplexRefData& rData = *(*itr)->GetDoubleRef();
+ ScComplexRefData& rData = *rxToken->GetDoubleRef();
ScSingleRefData& s = rData.Ref1;
ScSingleRefData& e = rData.Ref2;
@@ -1555,16 +1548,12 @@ ScChart2DataProvider::createDataSource(
}
}
- ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >::iterator aVectorItr( aSeqVector.begin() );
- ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >::iterator aVectorEndItr( aSeqVector.end() );
- while(aVectorItr != aVectorEndItr)
+ for(const uno::Reference< chart2::data::XLabeledDataSequence >& xSeq : aSeqVector)
{
- uno::Reference< chart2::data::XLabeledDataSequence > xSeq( *aVectorItr );
if ( xSeq.is() )
{
pDS->AddLabeledSequence( xSeq );
}
- ++aVectorItr;
}
xResult.set( pDS );
@@ -1648,10 +1637,8 @@ void RangeAnalyzer::initRangeAnalyzer( const vector<ScTokenRef>& rTokens )
}
mbEmpty=false;
- vector<ScTokenRef>::const_iterator itr = rTokens.begin(), itrEnd = rTokens.end();
- for (; itr != itrEnd ; ++itr)
+ for (const ScTokenRef& aRefToken : rTokens)
{
- ScTokenRef aRefToken = *itr;
StackVar eVar = aRefToken->GetType();
if (eVar == svDoubleRef || eVar == svExternalDoubleRef)
{
@@ -1794,12 +1781,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
ScRefTokenHelper::compileRangeRepresentation(
aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar(), true);
aLabel.initRangeAnalyzer(aTokens);
- vector<ScTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rxToken : aTokens)
{
- ScRefTokenHelper::join(aAllTokens, *itr, ScAddress());
+ ScRefTokenHelper::join(aAllTokens, rxToken, ScAddress());
if(!bThisIsCategories)
- ScRefTokenHelper::join(aAllSeriesLabelTokens, *itr, ScAddress());
+ ScRefTokenHelper::join(aAllSeriesLabelTokens, rxToken, ScAddress());
}
if(bThisIsCategories)
bHasCategoriesLabels=true;
@@ -1813,12 +1799,11 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
ScRefTokenHelper::compileRangeRepresentation(
aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar(), true);
aValues.initRangeAnalyzer(aTokens);
- vector<ScTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rxToken : aTokens)
{
- ScRefTokenHelper::join(aAllTokens, *itr, ScAddress());
+ ScRefTokenHelper::join(aAllTokens, rxToken, ScAddress());
if(bThisIsCategories)
- ScRefTokenHelper::join(aAllCategoriesValuesTokens, *itr, ScAddress());
+ ScRefTokenHelper::join(aAllCategoriesValuesTokens, rxToken, ScAddress());
}
}
//detect row source
@@ -2439,11 +2424,10 @@ void ScChart2DataSequence::RefChanged()
pCLC->EndListeningHiddenRange(m_pHiddenListener.get());
}
- vector<ScTokenRef>::const_iterator itr = m_aTokens.begin(), itrEnd = m_aTokens.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rxToken : m_aTokens)
{
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress()))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, rxToken, ScAddress()))
continue;
m_pDocument->StartListeningArea(aRange, false, m_pValueListener.get());
@@ -2466,17 +2450,16 @@ void ScChart2DataSequence::BuildDataCache()
::std::vector<sal_Int32> aHiddenValues;
sal_Int32 nDataCount = 0;
- for (vector<ScTokenRef>::const_iterator itr = m_aTokens.begin(), itrEnd = m_aTokens.end();
- itr != itrEnd; ++itr)
+ for (const auto& rxToken : m_aTokens)
{
- if (ScRefTokenHelper::isExternalRef(*itr))
+ if (ScRefTokenHelper::isExternalRef(rxToken))
{
- nDataCount += FillCacheFromExternalRef(*itr);
+ nDataCount += FillCacheFromExternalRef(rxToken);
}
else
{
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress()))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, rxToken, ScAddress()))
continue;
SCCOL nLastCol = -1;
@@ -2682,10 +2665,9 @@ void ScChart2DataSequence::StopListeningToAllExternalRefs()
return;
const std::unordered_set<sal_uInt16>& rFileIds = m_pExtRefListener->getAllFileIds();
- std::unordered_set<sal_uInt16>::const_iterator itr = rFileIds.begin(), itrEnd = rFileIds.end();
ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
- for (; itr != itrEnd; ++itr)
- pRefMgr->removeLinkListener(*itr, m_pExtRefListener.get());
+ for (const auto& rFileId : rFileIds)
+ pRefMgr->removeLinkListener(rFileId, m_pExtRefListener.get());
m_pExtRefListener.reset();
}
@@ -2715,11 +2697,10 @@ void ScChart2DataSequence::CopyData(const ScChart2DataSequence& r)
ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
m_pExtRefListener.reset(new ExternalRefListener(*this, m_pDocument));
const std::unordered_set<sal_uInt16>& rFileIds = r.m_pExtRefListener->getAllFileIds();
- std::unordered_set<sal_uInt16>::const_iterator itr = rFileIds.begin(), itrEnd = rFileIds.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rFileId : rFileIds)
{
- pRefMgr->addLinkListener(*itr, m_pExtRefListener.get());
- m_pExtRefListener->addFileId(*itr);
+ pRefMgr->addLinkListener(rFileId, m_pExtRefListener.get());
+ m_pExtRefListener->addFileId(rFileId);
}
}
}
@@ -3173,10 +3154,9 @@ uno::Reference< util::XCloneable > SAL_CALL ScChart2DataSequence::createClone()
// Clone tokens.
vector<ScTokenRef> aTokensNew;
aTokensNew.reserve(m_aTokens.size());
- vector<ScTokenRef>::const_iterator itr = m_aTokens.begin(), itrEnd = m_aTokens.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rxToken : m_aTokens)
{
- ScTokenRef p((*itr)->Clone());
+ ScTokenRef p(rxToken->Clone());
aTokensNew.push_back(p);
}
@@ -3211,11 +3191,10 @@ void SAL_CALL ScChart2DataSequence::addModifyListener( const uno::Reference< uti
if( m_pDocument )
{
ScChartListenerCollection* pCLC = m_pDocument->GetChartListenerCollection();
- vector<ScTokenRef>::const_iterator itr = m_aTokens.begin(), itrEnd = m_aTokens.end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rxToken : m_aTokens)
{
ScRange aRange;
- if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr, ScAddress()))
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, rxToken, ScAddress()))
continue;
m_pDocument->StartListeningArea( aRange, false, m_pValueListener.get() );
@@ -3389,13 +3368,12 @@ sal_Bool ScChart2DataSequence::switchToNext(sal_Bool bWrap)
return false;
}
- for(vector<ScTokenRef>::iterator itr = m_aTokens.begin(),
- itrEnd = m_aTokens.end(); itr != itrEnd; ++itr)
+ for(const auto& rxToken : m_aTokens)
{
- if ((*itr)->GetType() != svDoubleRef)
+ if (rxToken->GetType() != svDoubleRef)
continue;
- ScComplexRefData& rData = *(*itr)->GetDoubleRef();
+ ScComplexRefData& rData = *rxToken->GetDoubleRef();
ScSingleRefData& s = rData.Ref1;
ScSingleRefData& e = rData.Ref2;
@@ -3423,13 +3401,12 @@ sal_Bool ScChart2DataSequence::setToPointInTime(sal_Int32 nPoint)
return false;
SCTAB nTab = mnTimeBasedStart + nPoint;
- for(vector<ScTokenRef>::iterator itr = m_aTokens.begin(),
- itrEnd = m_aTokens.end(); itr != itrEnd; ++itr)
+ for(const auto& rxToken : m_aTokens)
{
- if ((*itr)->GetType() != svDoubleRef)
+ if (rxToken->GetType() != svDoubleRef)
continue;
- ScComplexRefData& rData = *(*itr)->GetDoubleRef();
+ ScComplexRefData& rData = *rxToken->GetDoubleRef();
ScSingleRefData& s = rData.Ref1;
ScSingleRefData& e = rData.Ref2;
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 9dd0cd45a6d9..8456a8fb84e5 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -376,9 +376,11 @@ uno::Sequence<uno::Reference<sheet::XConditionalFormat> > ScCondFormatsObj::getC
size_t n = pFormatList->size();
uno::Sequence<uno::Reference<sheet::XConditionalFormat> > aCondFormats(n);
sal_Int32 i = 0;
- for (ScConditionalFormatList::const_iterator itr = pFormatList->begin(); itr != pFormatList->end(); ++itr, ++i) {
- uno::Reference<sheet::XConditionalFormat> xCondFormat(new ScCondFormatObj(mpDocShell, this, (*itr)->GetKey()));
+ for (const auto& rFormat : *pFormatList)
+ {
+ uno::Reference<sheet::XConditionalFormat> xCondFormat(new ScCondFormatObj(mpDocShell, this, rFormat->GetKey()));
aCondFormats[i] = xCondFormat;
+ ++i;
}
return aCondFormats;
@@ -1631,9 +1633,9 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert
break;
case IconSetEntries:
{
- uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries(getCoreObject()->size());
- size_t i = 0;
- for (auto it = getCoreObject()->begin(), itEnd = getCoreObject()->end(); it != itEnd; ++it, ++i)
+ size_t nSize = getCoreObject()->size();
+ uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries(nSize);
+ for (size_t i = 0; i < nSize; ++i)
{
aEntries[i] = new ScIconSetEntryObj(this, i);
}
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 56a409e5f0a0..45200badbc83 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -2852,8 +2852,11 @@ Sequence< OUString > SAL_CALL ScDataPilotFieldGroupsObj::getElementNames()
{
aSeq.realloc( static_cast< sal_Int32 >( maGroups.size() ) );
OUString* pName = aSeq.getArray();
- for( ScFieldGroups::iterator aIt = maGroups.begin(), aEnd = maGroups.end(); aIt != aEnd; ++aIt, ++pName )
- *pName = aIt->maName;
+ for( const auto& rGroup : maGroups )
+ {
+ *pName = rGroup.maName;
+ ++pName;
+ }
}
return aSeq;
}
@@ -2989,10 +2992,8 @@ void ScDataPilotFieldGroupsObj::renameFieldGroup( const OUString& rOldName, cons
ScFieldGroups::iterator ScDataPilotFieldGroupsObj::implFindByName( const OUString& rName )
{
- for( ScFieldGroups::iterator aIt = maGroups.begin(), aEnd = maGroups.end(); aIt != aEnd; ++aIt )
- if( aIt->maName == rName )
- return aIt;
- return maGroups.end();
+ return std::find_if(maGroups.begin(), maGroups.end(),
+ [&rName](const ScFieldGroup& rGroup) { return rGroup.maName == rName; });
}
namespace {
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index a268d9c264db..7bd845b02437 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1275,13 +1275,13 @@ uno::Sequence<sheet::TableFilterField3> SAL_CALL ScFilterDescriptorBase::getFilt
const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
size_t nItemCount = rItems.size();
aField.Values.realloc(nItemCount);
- ScQueryEntry::QueryItemsType::const_iterator itr = rItems.begin(), itrEnd = rItems.end();
- for (size_t j = 0; itr != itrEnd; ++itr, ++j)
+ size_t j = 0;
+ for (const auto& rItem : rItems)
{
- aField.Values[j].IsNumeric = itr->meType != ScQueryEntry::ByString;
- aField.Values[j].StringValue = itr->maString.getString();
- aField.Values[j].NumericValue = itr->mfVal;
-
+ aField.Values[j].IsNumeric = rItem.meType != ScQueryEntry::ByString;
+ aField.Values[j].StringValue = rItem.maString.getString();
+ aField.Values[j].NumericValue = rItem.mfVal;
+ ++j;
}
}
@@ -2277,9 +2277,12 @@ uno::Sequence<OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
{
const ScDBCollection::NamedDBs& rDBs = pNames->getNamedDBs();
uno::Sequence<OUString> aSeq(rDBs.size());
- ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
- for (size_t i = 0; itr != itrEnd; ++itr, ++i)
- aSeq[i] = (*itr)->GetName();
+ size_t i = 0;
+ for (const auto& rDB : rDBs)
+ {
+ aSeq[i] = rDB->GetName();
+ ++i;
+ }
return aSeq;
}
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 268f246e4ed6..74fa335a9eab 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2092,11 +2092,9 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
// iterate over the hyperlinks that were output for this page
std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->GetBookmarks();
- std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIter = rBookmarks.begin();
- std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
- while ( aIter != aIEnd )
+ for ( const auto& rBookmark : rBookmarks )
{
- OUString aBookmark = aIter->aBookmark;
+ OUString aBookmark = rBookmark.aBookmark;
if ( aBookmark.toChar() == '#' )
{
// try to resolve internal link
@@ -2161,15 +2159,14 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
}
if ( nPage >= 0 )
- pPDFData->SetLinkDest( aIter->nLinkId, pPDFData->CreateDest( aArea, nPage ) );
+ pPDFData->SetLinkDest( rBookmark.nLinkId, pPDFData->CreateDest( aArea, nPage ) );
}
}
else
{
// external link, use as-is
- pPDFData->SetLinkURL( aIter->nLinkId, aBookmark );
+ pPDFData->SetLinkURL( rBookmark.nLinkId, aBookmark );
}
- ++aIter;
}
rBookmarks.clear();
}
@@ -3078,10 +3075,10 @@ void ScModelObj::NotifyChanges( const OUString& rOperation, const ScRangeList& r
aMarkData.MarkFromRangeList( rRanges, false );
ScDocument& rDoc = pDocShell->GetDocument();
SCTAB nTabCount = rDoc.GetTableCount();
- ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
- for (; itr != itrEnd && *itr < nTabCount; ++itr)
+ for (const SCTAB& nTab : aMarkData)
{
- SCTAB nTab = *itr;
+ if (nTab >= nTabCount)
+ break;
const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
if (pEvents)
{
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index 42ac15dcf61f..a9035ce04766 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <comphelper/sequence.hxx>
#include <svl/hint.hxx>
#include <sfx2/linkmgr.hxx>
#include <vcl/svapp.hxx>
@@ -1529,14 +1530,10 @@ Sequence< OUString > SAL_CALL ScExternalDocLinkObj::getElementNames()
// #i116940# be consistent with getByName: include only table names which have a cache already
vector<OUString> aValidNames;
- for (vector<OUString>::iterator aIter = aTabNames.begin(); aIter != aTabNames.end(); ++aIter)
- if (mpRefMgr->getCacheTable(mnFileId, *aIter, false))
- aValidNames.push_back(*aIter);
+ std::copy_if(aTabNames.begin(), aTabNames.end(), std::back_inserter(aValidNames),
+ [&](const OUString& rTabName) { return mpRefMgr->getCacheTable(mnFileId, rTabName, false); });
- size_t n = aValidNames.size();
- Sequence<OUString> aSeq(n);
- for (size_t i = 0; i < n; ++i)
- aSeq[i] = aValidNames[i];
+ Sequence<OUString> aSeq(comphelper::containerToSequence(aValidNames));
return aSeq;
}
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 0c92d9a0f7dc..07a7162e1280 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -587,9 +587,8 @@ sal_Int32 SAL_CALL ScNamedRangesObj::getCount()
ScRangeName* pNames = GetRangeName_Impl();
if (pNames)
{
- ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
- for (; itr != itrEnd; ++itr)
- if (lcl_UserVisibleName(*itr->second))
+ for (const auto& rName : *pNames)
+ if (lcl_UserVisibleName(*rName.second))
++nRet;
}
}
@@ -669,11 +668,10 @@ uno::Sequence<OUString> SAL_CALL ScNamedRangesObj::getElementNames()
uno::Sequence<OUString> aSeq(nVisCount);
OUString* pAry = aSeq.getArray();
sal_uInt16 nVisPos = 0;
- ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
- for (; itr != itrEnd; ++itr)
+ for (const auto& rName : *pNames)
{
- if (lcl_UserVisibleName(*itr->second))
- pAry[nVisPos++] = itr->second->GetName();
+ if (lcl_UserVisibleName(*rName.second))
+ pAry[nVisPos++] = rName.second->GetName();
}
return aSeq;
}
@@ -798,14 +796,13 @@ ScNamedRangeObj* ScGlobalNamedRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex
if (!pNames)
return nullptr;
- ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
sal_uInt16 nPos = 0;
- for (; itr != itrEnd; ++itr)
+ for (const auto& rName : *pNames)
{
- if (lcl_UserVisibleName(*itr->second))
+ if (lcl_UserVisibleName(*rName.second))
{
if (nPos == nIndex)
- return new ScNamedRangeObj(this, pDocShell, itr->second->GetName());
+ return new ScNamedRangeObj(this, pDocShell, rName.second->GetName());
}
++nPos;
}
@@ -864,14 +861,13 @@ ScNamedRangeObj* ScLocalNamedRangesObj::GetObjectByIndex_Impl( sal_uInt16 nIndex
if (!pNames)
return nullptr;
- ScRangeName::const_iterator itr = pNames->begin(), itrEnd = pNames->end();
sal_uInt16 nPos = 0;
- for (; itr != itrEnd; ++itr)
+ for (const auto& rName : *pNames)
{
- if (lcl_UserVisibleName(*itr->second))
+ if (lcl_UserVisibleName(*rName.second))
{
if (nPos == nIndex)
- return new ScNamedRangeObj(this, pDocShell, itr->second->GetName(), mxSheet);
+ return new ScNamedRangeObj(this, pDocShell, rName.second->GetName(), mxSheet);
}
++nPos;
}
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index e5514e9d7e9f..576a9d6e43a2 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -1338,13 +1338,9 @@ void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Referenc
{
SolarMutexGuard aGuard;
sal_uInt16 nCount = aMouseClickHandlers.size();
- for (XMouseClickHandlerVector::iterator it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
- {
- if ( *it == aListener )
- it = aMouseClickHandlers.erase(it);
- else
- ++it;
- }
+ aMouseClickHandlers.erase(
+ std::remove(aMouseClickHandlers.begin(), aMouseClickHandlers.end(), aListener),
+ aMouseClickHandlers.end());
if (aMouseClickHandlers.empty() && (nCount > 0)) // only if last listener removed
EndMouseListening();
}
@@ -1365,13 +1361,9 @@ void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference<
{
SolarMutexGuard aGuard;
sal_uInt16 nCount = aActivationListeners.size();
- for (XActivationEventListenerVector::iterator it = aActivationListeners.begin(); it != aActivationListeners.end(); )
- {
- if ( *it == aListener )
- it = aActivationListeners.erase(it);
- else
- ++it;
- }
+ aActivationListeners.erase(
+ std::remove(aActivationListeners.begin(), aActivationListeners.end(), aListener),
+ aActivationListeners.end());
if (aActivationListeners.empty() && (nCount > 0)) // only if last listener removed
EndActivationListening();
}
@@ -1649,15 +1641,9 @@ void SAL_CALL ScTabViewObj::removeSelectionChangeListener(
const uno::Reference< view::XSelectionChangeListener >& xListener )
{
SolarMutexGuard aGuard;
- for (XSelectionChangeListenerVector::iterator it = aSelectionChgListeners.begin();
- it != aSelectionChgListeners.end(); ++it )
- {
- if ( *it == xListener ) //! why the hassle with queryInterface?
- {
- aSelectionChgListeners.erase(it);
- break;
- }
- }
+ auto it = std::find(aSelectionChgListeners.begin(), aSelectionChgListeners.end(), xListener); //! why the hassle with queryInterface?
+ if (it != aSelectionChgListeners.end())
+ aSelectionChgListeners.erase(it);
}
void ScTabViewObj::SelectionChanged()
@@ -1914,15 +1900,9 @@ void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPr
const uno::Reference<beans::XPropertyChangeListener >& xListener )
{
SolarMutexGuard aGuard;
- for (XViewPropertyChangeListenerVector::iterator it = aPropertyChgListeners.begin();
- it != aPropertyChgListeners.end(); ++it )
- {
- if ( *it == xListener ) //! Why the nonsense with queryInterface?
- {
- aPropertyChgListeners.erase(it);
- break;
- }
- }
+ auto it = std::find(aPropertyChgListeners.begin(), aPropertyChgListeners.end(), xListener); //! Why the nonsense with queryInterface?
+ if (it != aPropertyChgListeners.end())
+ aPropertyChgListeners.erase(it);
}
void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
@@ -2006,15 +1986,9 @@ void SAL_CALL ScTabViewObj::removeRangeSelectionListener(
const uno::Reference<sheet::XRangeSelectionListener>& xListener )
{
SolarMutexGuard aGuard;
- for (XRangeSelectionListenerVector::iterator it = aRangeSelListeners.begin();
- it != aRangeSelListeners.end(); ++it )
- {
- if ( *it == xListener )
- {
- aRangeSelListeners.erase(it);
- break;
- }
- }
+ auto it = std::find(aRangeSelListeners.begin(), aRangeSelListeners.end(), xListener);
+ if (it != aRangeSelListeners.end())
+ aRangeSelListeners.erase(it);
}
void SAL_CALL ScTabViewObj::addRangeSelectionChangeListener(
@@ -2028,15 +2002,9 @@ void SAL_CALL ScTabViewObj::removeRangeSelectionChangeListener(
const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
{
SolarMutexGuard aGuard;
- for (XRangeSelectionChangeListenerVector::iterator it = aRangeChgListeners.begin();
- it != aRangeChgListeners.end(); ++it )
- {
- if ( *it == xListener )
- {
- aRangeChgListeners.erase(it);
- break;
- }
- }
+ auto it = std::find(aRangeChgListeners.begin(), aRangeChgListeners.end(), xListener);
+ if (it != aRangeChgListeners.end())
+ aRangeChgListeners.erase(it);
}
void ScTabViewObj::RangeSelDone( const OUString& rText )
@@ -2183,9 +2151,12 @@ namespace {
uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
{
uno::Sequence<sal_Int32> aRet(rSelected.size());
- ScMarkData::MarkedTabsType::const_iterator itr = rSelected.begin(), itrEnd = rSelected.end();
- for (size_t i = 0; itr != itrEnd; ++itr, ++i)
- aRet[i] = static_cast<sal_Int32>(*itr);
+ size_t i = 0;
+ for (const auto& rTab : rSelected)
+ {
+ aRet[i] = static_cast<sal_Int32>(rTab);
+ ++i;
+ }
return aRet;
}
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index e756fe36e69a..6b79eff7d549 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -357,20 +357,18 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >&
sDocModuleNames.push_back( aName );
}
- std::vector<OUString>::iterator it_end = sDocModuleNames.end();
-
- for ( std::vector<OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it )
+ for ( const auto& rName : sDocModuleNames )
{
script::ModuleInfo sModuleInfo;
- uno::Any aName= xVBACodeNamedObjectAccess->getByName( *it );
+ uno::Any aName= xVBACodeNamedObjectAccess->getByName( rName );
sModuleInfo.ModuleObject.set( aName, uno::UNO_QUERY );
sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
- xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo );
- if( xLib->hasByName( *it ) )
- xLib->replaceByName( *it, uno::makeAny( OUString( "Option VBASupport 1\n") ) );
+ xVBAModuleInfo->insertModuleInfo( rName, sModuleInfo );
+ if( xLib->hasByName( rName ) )
+ xLib->replaceByName( rName, uno::makeAny( OUString( "Option VBASupport 1\n") ) );
else
- xLib->insertByName( *it, uno::makeAny( OUString( "Option VBASupport 1\n" ) ) );
+ xLib->insertByName( rName, uno::makeAny( OUString( "Option VBASupport 1\n" ) ) );
}
}
}
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 57d61297d842..2ae5b7b208fd 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1124,19 +1124,19 @@ void lclIntersectRanges( ListOfScRange& rList, const uno::Any& rArg )
// join ranges from passed argument
lclJoinRanges( aList2 );
// calculate intersection of the ranges in both lists
- for( ListOfScRange::const_iterator aOuterIt = aList1.begin(), aOuterEnd = aList1.end(); aOuterIt != aOuterEnd; ++aOuterIt )
+ for( const auto& rOuterItem : aList1 )
{
- for( ListOfScRange::const_iterator aInnerIt = aList2.begin(), aInnerEnd = aList2.end(); aInnerIt != aInnerEnd; ++aInnerIt )
+ for( const auto& rInnerItem : aList2 )
{
- if( aOuterIt->Intersects( *aInnerIt ) )
+ if( rOuterItem.Intersects( rInnerItem ) )
{
ScRange aIsectRange(
- std::max( aOuterIt->aStart.Col(), aInnerIt->aStart.Col() ),
- std::max( aOuterIt->aStart.Row(), aInnerIt->aStart.Row() ),
- std::max( aOuterIt->aStart.Tab(), aInnerIt->aStart.Tab() ),
- std::min( aOuterIt->aEnd.Col(), aInnerIt->aEnd.Col() ),
- std::min( aOuterIt->aEnd.Row(), aInnerIt->aEnd.Row() ),
- std::min( aOuterIt->aEnd.Tab(), aInnerIt->aEnd.Tab() ) );
+ std::max( rOuterItem.aStart.Col(), rInnerItem.aStart.Col() ),
+ std::max( rOuterItem.aStart.Row(), rInnerItem.aStart.Row() ),
+ std::max( rOuterItem.aStart.Tab(), rInnerItem.aStart.Tab() ),
+ std::min( rOuterItem.aEnd.Col(), rInnerItem.aEnd.Col() ),
+ std::min( rOuterItem.aEnd.Row(), rInnerItem.aEnd.Row() ),
+ std::min( rOuterItem.aEnd.Tab(), rInnerItem.aEnd.Tab() ) );
rList.push_back( aIsectRange );
}
}
@@ -1159,8 +1159,8 @@ uno::Reference< excel::XRange > lclCreateVbaRange(
if( !pDocShell ) throw uno::RuntimeException();
ScRangeList aCellRanges;
- for( ListOfScRange::const_iterator aIt = rList.begin(), aEnd = rList.end(); aIt != aEnd; ++aIt )
- aCellRanges.push_back( *aIt );
+ for( const auto& rItem : rList )
+ aCellRanges.push_back( rItem );
if( aCellRanges.size() == 1 )
{
diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx
index 35684116de28..d4100a4263d8 100644
--- a/sc/source/ui/vba/vbafont.cxx
+++ b/sc/source/ui/vba/vbafont.cxx
@@ -148,13 +148,12 @@ ScVbaFont::setFontStyle( const uno::Any& aValue )
aTokens.push_back( aToken );
}while( nIndex >= 0 );
- std::vector< OUString >::iterator it;
- for( it = aTokens.begin(); it != aTokens.end(); ++it )
+ for( const auto& rToken : aTokens )
{
- if( (*it).equalsIgnoreAsciiCase("Bold") )
+ if( rToken.equalsIgnoreAsciiCase("Bold") )
bBold = true;
- if( (*it).equalsIgnoreAsciiCase("Italic") )
+ if( rToken.equalsIgnoreAsciiCase("Italic") )
bItalic = true;
}
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 1f32f959981b..dee057079db0 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1177,14 +1177,11 @@ bool getScRangeListForAddress( const OUString& sName, ScDocShell* pDocSh, const
if ( vNames.empty() )
vNames.push_back( sName );
- std::vector< OUString >::iterator it = vNames.begin();
- std::vector< OUString >::iterator it_end = vNames.end();
- for ( ; it != it_end; ++it )
+ for ( const auto& rName : vNames )
{
-
formula::FormulaGrammar::AddressConvention eConv = aConv;
// spaces are illegal ( but the user of course can enter them )
- OUString sAddress = (*it).trim();
+ OUString sAddress = rName.trim();
// if a local name ( on the active sheet ) exists this will
// take precedence over a global with the same name
if ( !xNameAccess->hasByName( sAddress ) )
@@ -2440,9 +2437,10 @@ ScVbaRange::setMergeCells( const uno::Any& aIsMerged )
{
uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( mxRanges->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
table::CellRangeAddress aAddress = xRangeAddr->getRangeAddress();
- for( ::std::vector< table::CellRangeAddress >::const_iterator aIt = aList.begin(), aEnd = aList.end(); aIt != aEnd; ++aIt )
- if( ScUnoConversion::Intersects( *aIt, aAddress ) )
- return;
+ if (std::any_of(aList.begin(), aList.end(),
+ [&aAddress](const table::CellRangeAddress& rAddress)
+ { return ScUnoConversion::Intersects( rAddress, aAddress ); }))
+ return;
aList.push_back( aAddress );
}
@@ -5405,12 +5403,10 @@ ScVbaRange::SpecialCells( const uno::Any& _oType, const uno::Any& _oValue)
}
}
ScRangeList aCellRanges;
- std::vector< table::CellRangeAddress >::iterator it = rangeResults.begin();
- std::vector< table::CellRangeAddress >::iterator it_end = rangeResults.end();
- for ( ; it != it_end; ++ it )
+ for ( const auto& rRangeResult : rangeResults )
{
ScRange refRange;
- ScUnoConversion::FillScRange( refRange, *it );
+ ScUnoConversion::FillScRange( refRange, rRangeResult );
aCellRanges.push_back( refRange );
}
// Single range
diff --git a/sc/source/ui/vba/vbasheetobjects.cxx b/sc/source/ui/vba/vbasheetobjects.cxx
index e5fb39b4abfa..eb2797fcb0bb 100644
--- a/sc/source/ui/vba/vbasheetobjects.cxx
+++ b/sc/source/ui/vba/vbasheetobjects.cxx
@@ -222,9 +222,10 @@ uno::Any ScVbaObjectContainer::createCollectionObject( const uno::Any& rSource )
uno::Any ScVbaObjectContainer::getItemByStringIndex( const OUString& rIndex )
{
- for( ShapeVector::iterator aIt = maShapes.begin(), aEnd = maShapes.end(); aIt != aEnd; ++aIt )
- if( rIndex == implGetShapeName( *aIt ) )
- return createCollectionObject( uno::Any( *aIt ) );
+ auto aIt = std::find_if(maShapes.begin(), maShapes.end(),
+ [&rIndex, this](const ShapeVector::value_type& rxShape) { return rIndex == implGetShapeName( rxShape ); });
+ if (aIt != maShapes.end())
+ return createCollectionObject( uno::Any( *aIt ) );
throw uno::RuntimeException();
}
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index 91bcc5d2be87..1e155a7d47d6 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -117,10 +117,11 @@ public:
sheets.reserve( nTabCount );
uno::Reference <sheet::XSpreadsheetDocument> xSpreadSheet( m_xModel, uno::UNO_QUERY_THROW );
uno::Reference <container::XIndexAccess> xIndex( xSpreadSheet->getSheets(), uno::UNO_QUERY_THROW );
- ScMarkData::const_iterator itr = rMarkData.begin(), itrEnd = rMarkData.end();
- for (; itr != itrEnd && *itr < nTabCount; ++itr)
+ for (const auto& rTab : rMarkData)
{
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex( *itr ), uno::UNO_QUERY_THROW );
+ if (rTab >= nTabCount)
+ break;
+ uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex( rTab ), uno::UNO_QUERY_THROW );
uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
sheets.push_back( xSheet );
namesToIndices[ xNamed->getName() ] = nIndex++;
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index 63f790afba87..9c23794c19a4 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -100,13 +100,12 @@ public:
{
uno::Sequence< OUString > sNames( mSheetMap.size() );
OUString* pString = sNames.getArray();
- SheetMap::iterator it = mSheetMap.begin();
- SheetMap::iterator it_end = mSheetMap.end();
- for ( ; it != it_end; ++it, ++pString )
+ for ( const auto& rItem : mSheetMap )
{
- uno::Reference< container::XNamed > xName( *it, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNamed > xName( rItem, uno::UNO_QUERY_THROW );
*pString = xName->getName();
+ ++pString;
}
return sNames;
}