[Libreoffice-commits] core.git: svgio/source svl/source svtools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Nov 25 11:29:29 UTC 2018
svgio/source/svgreader/svgtoken.cxx | 6
svl/source/items/IndexedStyleSheets.cxx | 54 ++----
svl/source/items/itempool.cxx | 3
svl/source/items/itemprop.cxx | 16 --
svl/source/items/macitem.cxx | 35 +---
svl/source/items/stylepool.cxx | 55 ++----
svl/source/notify/broadcast.cxx | 16 +-
svl/source/notify/listener.cxx | 11 -
svl/source/numbers/numfmuno.cxx | 8 -
svl/source/numbers/zforlist.cxx | 26 +--
svl/source/passwordcontainer/passwordcontainer.cxx | 78 ++++-----
svl/source/passwordcontainer/syscreds.cxx | 15 -
svl/source/svdde/ddesvr.cxx | 168 ++++++++-------------
svl/source/undo/undo.cxx | 37 +---
svtools/source/contnr/fileview.cxx | 32 +---
svtools/source/contnr/imivctl1.cxx | 11 -
svtools/source/control/inettbc.cxx | 14 +
svtools/source/dialogs/PlaceEditDialog.cxx | 7
svtools/source/dialogs/insdlg.cxx | 15 -
svtools/source/uno/unocontroltablemodel.cxx | 13 -
20 files changed, 232 insertions(+), 388 deletions(-)
New commits:
commit 260002b16f18634a7e1d10d4160378beb0cc0c5f
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Nov 24 23:39:59 2018 +0300
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Nov 25 12:29:05 2018 +0100
Simplify containers iterations in svgio, svl, svtools
Use range-based loop or replace with STL functions
Change-Id: I98a3e55a14c8ac00188c5003f84194c2cc6795fb
Reviewed-on: https://gerrit.libreoffice.org/63959
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svgio/source/svgreader/svgtoken.cxx b/svgio/source/svgreader/svgtoken.cxx
index 4416d32c1de9..6215cc0c6db5 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -324,12 +324,12 @@ namespace svgio
if(aCaseLindependentSVGTokenMapperList.empty())
{
- for(SVGTokenMapper::const_iterator aCurrent(aSVGTokenMapperList.begin()); aCurrent != aSVGTokenMapperList.end(); ++aCurrent)
+ for(const auto& rCurrent : aSVGTokenMapperList)
{
aCaseLindependentSVGTokenMapperList.insert(
SVGTokenValueType(
- aCurrent->first.toAsciiLowerCase(),
- aCurrent->second));
+ rCurrent.first.toAsciiLowerCase(),
+ rCurrent.second));
}
}
diff --git a/svl/source/items/IndexedStyleSheets.cxx b/svl/source/items/IndexedStyleSheets.cxx
index 28a36587c4c8..6b28873a05ba 100644
--- a/svl/source/items/IndexedStyleSheets.cxx
+++ b/svl/source/items/IndexedStyleSheets.cxx
@@ -71,9 +71,8 @@ IndexedStyleSheets::Reindex()
}
unsigned i = 0;
- for (VectorType::const_iterator it = mStyleSheets.begin();
- it != mStyleSheets.end(); ++it) {
- SfxStyleSheetBase* p = it->get();
+ for (const auto& rxStyleSheet : mStyleSheets) {
+ SfxStyleSheetBase* p = rxStyleSheet.get();
Register(*p, i);
++i;
}
@@ -100,22 +99,15 @@ IndexedStyleSheets::RemoveStyleSheet(const rtl::Reference< SfxStyleSheetBase >&
{
OUString styleName = style->GetName();
std::vector<unsigned> positions = FindPositionsByName(styleName);
- bool found = false;
- unsigned stylePosition = 0;
- for (std::vector<unsigned>::const_iterator it = positions.begin();
- it != positions.end(); ++it) {
- if (mStyleSheets.at(*it) == style) {
- found = true;
- stylePosition = *it;
- break;
- }
- }
+ auto it = std::find_if(positions.begin(), positions.end(),
+ [&](const unsigned pos) { return mStyleSheets.at(pos) == style; });
- if (found) {
- mStyleSheets.erase(mStyleSheets.begin() + stylePosition);
+ if (it != positions.end()) {
+ mStyleSheets.erase(mStyleSheets.begin() + *it);
Reindex();
+ return true;
}
- return found;
+ return false;
}
std::vector<unsigned>
@@ -152,14 +144,11 @@ IndexedStyleSheets::FindPositionsByNameAndPredicate(const OUString& name,
unsigned
IndexedStyleSheets::GetNumberOfStyleSheetsWithPredicate(StyleSheetPredicate& predicate) const
{
- unsigned r = 0;
- for (VectorType::const_iterator it = mStyleSheets.begin(); it != mStyleSheets.end(); ++it) {
- const SfxStyleSheetBase *ssheet = it->get();
- if (predicate.Check(*ssheet)) {
- ++r;
- }
- }
- return r;
+ return std::count_if(mStyleSheets.begin(), mStyleSheets.end(),
+ [&predicate](const rtl::Reference<SfxStyleSheetBase>& rxStyleSheet) {
+ const SfxStyleSheetBase *ssheet = rxStyleSheet.get();
+ return predicate.Check(*ssheet);
+ });
}
SfxStyleSheetBase*
@@ -196,8 +185,8 @@ IndexedStyleSheets::FindStyleSheetPosition(const SfxStyleSheetBase& style) const
void
IndexedStyleSheets::Clear(StyleSheetDisposer& disposer)
{
- for (VectorType::iterator it = mStyleSheets.begin(); it != mStyleSheets.end(); ++it) {
- disposer.Dispose(*it);
+ for (auto& rxStyleSheet : mStyleSheets) {
+ disposer.Dispose(rxStyleSheet);
}
mStyleSheets.clear();
mPositionsByName.clear();
@@ -212,13 +201,8 @@ IndexedStyleSheets::HasStyleSheet(const rtl::Reference< SfxStyleSheetBase >& sty
{
OUString styleName = style->GetName();
std::vector<unsigned> positions = FindPositionsByName(styleName);
- for (std::vector<unsigned>::const_iterator it = positions.begin();
- it != positions.end(); ++it) {
- if (mStyleSheets.at(*it) == style) {
- return true;
- }
- }
- return false;
+ return std::any_of(positions.begin(), positions.end(),
+ [&](const unsigned pos) { return mStyleSheets.at(pos) == style; });
}
SfxStyleSheetBase*
@@ -232,8 +216,8 @@ IndexedStyleSheets::GetStyleSheetByPosition(unsigned pos)
void
IndexedStyleSheets::ApplyToAllStyleSheets(StyleSheetCallback& callback) const
{
- for (VectorType::const_iterator it = mStyleSheets.begin(); it != mStyleSheets.end(); ++it) {
- callback.DoIt(**it);
+ for (const auto& rxStyleSheet : mStyleSheets) {
+ callback.DoIt(*rxStyleSheet);
}
}
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index df18182c768c..614db99b1791 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -353,9 +353,8 @@ void SfxItemPool::Free(SfxItemPool* pPool)
// tell all the registered SfxItemPoolUsers that the pool is in destruction
std::vector<SfxItemPoolUser*> aListCopy(pPool->pImpl->maSfxItemPoolUsers.begin(), pPool->pImpl->maSfxItemPoolUsers.end());
- for(std::vector<SfxItemPoolUser*>::const_iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
+ for(SfxItemPoolUser* pSfxItemPoolUser : aListCopy)
{
- SfxItemPoolUser* pSfxItemPoolUser = *aIterator;
DBG_ASSERT(pSfxItemPoolUser, "corrupt SfxItemPoolUser list (!)");
pSfxItemPoolUser->ObjectInDestruction(*pPool);
}
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index 707504c8c0dd..c0beaf2614f4 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -86,18 +86,16 @@ uno::Sequence<beans::Property> const & SfxItemPropertyMap::getProperties() const
m_pImpl->m_aPropSeq.realloc( m_pImpl->size() );
beans::Property* pPropArray = m_pImpl->m_aPropSeq.getArray();
sal_uInt32 n = 0;
- SfxItemPropertyHashMap_t::const_iterator aIt = m_pImpl->begin();
- while( aIt != m_pImpl->end() )
+ for( const auto& rEntry : *m_pImpl )
//for ( const SfxItemPropertyMap *pMap = _pMap; pMap->pName; ++pMap )
{
- const SfxItemPropertySimpleEntry* pEntry = &(*aIt).second;
- pPropArray[n].Name = (*aIt).first;
+ const SfxItemPropertySimpleEntry* pEntry = &rEntry.second;
+ pPropArray[n].Name = rEntry.first;
pPropArray[n].Handle = pEntry->nWID;
pPropArray[n].Type = pEntry->aType;
pPropArray[n].Attributes =
sal::static_int_cast< sal_Int16 >(pEntry->nFlags);
n++;
- ++aIt;
}
}
@@ -143,12 +141,10 @@ PropertyEntryVector_t SfxItemPropertyMap::getPropertyEntries() const
PropertyEntryVector_t aRet;
aRet.reserve(m_pImpl->size());
- SfxItemPropertyHashMap_t::const_iterator aIt = m_pImpl->begin();
- while( aIt != m_pImpl->end() )
+ for( const auto& rEntry : *m_pImpl )
{
- const SfxItemPropertySimpleEntry* pEntry = &(*aIt).second;
- aRet.emplace_back( (*aIt).first, * pEntry );
- ++aIt;
+ const SfxItemPropertySimpleEntry* pEntry = &rEntry.second;
+ aRet.emplace_back( rEntry.first, * pEntry );
}
return aRet;
}
diff --git a/svl/source/items/macitem.cxx b/svl/source/items/macitem.cxx
index f18a575bf2df..5cd29a0269d2 100644
--- a/svl/source/items/macitem.cxx
+++ b/svl/source/items/macitem.cxx
@@ -79,23 +79,16 @@ SvxMacroTableDtor& SvxMacroTableDtor::operator=( const SvxMacroTableDtor& rTbl )
bool SvxMacroTableDtor::operator==( const SvxMacroTableDtor& rOther ) const
{
// Count different => odd in any case
- if ( aSvxMacroTable.size() != rOther.aSvxMacroTable.size() )
- return false;
-
// Compare single ones; the sequence matters due to performance reasons
- SvxMacroTable::const_iterator it1 = aSvxMacroTable.begin();
- SvxMacroTable::const_iterator it2 = rOther.aSvxMacroTable.begin();
- for ( ; it1 != aSvxMacroTable.end(); ++it1, ++it2 )
- {
- const SvxMacro& rOwnMac = it1->second;
- const SvxMacro& rOtherMac = it2->second;
- if ( it1->first != it2->first ||
- rOwnMac.GetLibName() != rOtherMac.GetLibName() ||
- rOwnMac.GetMacName() != rOtherMac.GetMacName() )
- return false;
- }
-
- return true;
+ return std::equal(aSvxMacroTable.begin(), aSvxMacroTable.end(),
+ rOther.aSvxMacroTable.begin(), rOther.aSvxMacroTable.end(),
+ [](const SvxMacroTable::value_type& rOwnEntry, const SvxMacroTable::value_type& rOtherEntry) {
+ const SvxMacro& rOwnMac = rOwnEntry.second;
+ const SvxMacro& rOtherMac = rOtherEntry.second;
+ return rOwnEntry.first == rOtherEntry.first
+ && rOwnMac.GetLibName() == rOtherMac.GetLibName()
+ && rOwnMac.GetMacName() == rOtherMac.GetMacName();
+ });
}
void SvxMacroTableDtor::Read( SvStream& rStrm )
@@ -151,17 +144,17 @@ SvStream& SvxMacroTableDtor::Write( SvStream& rStream ) const
rStream.WriteUInt16( aSvxMacroTable.size() );
- SvxMacroTable::const_iterator it = aSvxMacroTable.begin();
- while( it != aSvxMacroTable.end() && rStream.GetError() == ERRCODE_NONE )
+ for( const auto& rEntry : aSvxMacroTable )
{
- const SvxMacro& rMac = it->second;
- rStream.WriteUInt16( static_cast<sal_uInt16>(it->first) );
+ if (rStream.GetError() != ERRCODE_NONE)
+ break;
+ const SvxMacro& rMac = rEntry.second;
+ rStream.WriteUInt16( static_cast<sal_uInt16>(rEntry.first) );
writeByteString(rStream, rMac.GetLibName());
writeByteString(rStream, rMac.GetMacName());
if( SVX_MACROTBL_VERSION40 <= nVersion )
rStream.WriteUInt16( rMac.GetScriptType() );
- ++it;
}
return rStream;
}
diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx
index 46a4a726b850..faf1e756800b 100644
--- a/svl/source/items/stylepool.cxx
+++ b/svl/source/items/stylepool.cxx
@@ -82,15 +82,11 @@ namespace {
// #i87808#
std::shared_ptr<SfxItemSet> const & Node::getUsedOrLastAddedItemSet() const
{
- std::vector< std::shared_ptr<SfxItemSet> >::const_reverse_iterator aIter;
+ auto aIter = std::find_if(maItemSet.rbegin(), maItemSet.rend(),
+ [](const std::shared_ptr<SfxItemSet>& rxItemSet) { return rxItemSet.use_count() > 1; });
- for ( aIter = maItemSet.rbegin(); aIter != maItemSet.rend(); ++aIter )
- {
- if ( (*aIter).use_count() > 1 )
- {
- return *aIter;
- }
- }
+ if (aIter != maItemSet.rend())
+ return *aIter;
return maItemSet.back();
}
@@ -104,16 +100,8 @@ namespace {
{
if ( bCheckUsage )
{
- std::vector< std::shared_ptr<SfxItemSet> >::const_reverse_iterator aIter;
-
- for ( aIter = maItemSet.rbegin(); aIter != maItemSet.rend(); ++aIter )
- {
- if ( (*aIter).use_count() > 1 )
- {
- bHasItemSet = true;
- break;
- }
- }
+ bHasItemSet = std::any_of(maItemSet.rbegin(), maItemSet.rend(),
+ [](const std::shared_ptr<SfxItemSet>& rxItemSet) { return rxItemSet.use_count() > 1; });
}
else
{
@@ -208,23 +196,14 @@ namespace {
// #i86923#
bool Node::hasIgnorableChildren( const bool bCheckUsage ) const
{
- bool bHasIgnorableChildren( false );
-
- auto aIter = mChildren.begin();
- while( aIter != mChildren.end() && !bHasIgnorableChildren )
- {
- Node* pChild = aIter->get();
- if ( pChild->mbIsItemIgnorable )
- {
- bHasIgnorableChildren =
- !bCheckUsage ||
- ( pChild->hasItemSet( bCheckUsage /* == true */ ) ||
- pChild->hasIgnorableChildren( bCheckUsage /* == true */ ) );
- }
- ++aIter;
- }
-
- return bHasIgnorableChildren;
+ return std::any_of(mChildren.begin(), mChildren.end(),
+ [&bCheckUsage](const std::unique_ptr<Node>& rxChild) {
+ Node* pChild = rxChild.get();
+ return pChild->mbIsItemIgnorable &&
+ (!bCheckUsage ||
+ ( pChild->hasItemSet( bCheckUsage /* == true */ ) ||
+ pChild->hasIgnorableChildren( bCheckUsage /* == true */ ) ));
+ });
}
const std::shared_ptr<SfxItemSet> Node::getItemSetOfIgnorableChild(
@@ -233,10 +212,9 @@ namespace {
DBG_ASSERT( hasIgnorableChildren( bSkipUnusedItemSets ),
"<Node::getItemSetOfIgnorableChild> - node has no ignorable children" );
- auto aIter = mChildren.begin();
- while( aIter != mChildren.end() )
+ for( const auto& rxChild : mChildren )
{
- Node* pChild = aIter->get();
+ Node* pChild = rxChild.get();
if ( pChild->mbIsItemIgnorable )
{
if ( pChild->hasItemSet( bSkipUnusedItemSets ) )
@@ -252,7 +230,6 @@ namespace {
}
}
}
- ++aIter;
}
std::shared_ptr<SfxItemSet> pReturn;
diff --git a/svl/source/notify/broadcast.cxx b/svl/source/notify/broadcast.cxx
index 626a48a332e9..9a63e4b2b67b 100644
--- a/svl/source/notify/broadcast.cxx
+++ b/svl/source/notify/broadcast.cxx
@@ -101,14 +101,14 @@ SvtBroadcaster::~SvtBroadcaster()
// listeners, with the exception of those that already asked to be removed
// during their own destruction
ListenersType::const_iterator dest(maDestructedListeners.begin());
- for (ListenersType::iterator it(maListeners.begin()); it != maListeners.end(); ++it)
+ for (auto& rpListener : maListeners)
{
// skip the destructed ones
- while (dest != maDestructedListeners.end() && (*dest < *it))
+ while (dest != maDestructedListeners.end() && (*dest < rpListener))
++dest;
- if (dest == maDestructedListeners.end() || *dest != *it)
- (*it)->BroadcasterDying(*this);
+ if (dest == maDestructedListeners.end() || *dest != rpListener)
+ rpListener->BroadcasterDying(*this);
}
}
@@ -118,14 +118,14 @@ void SvtBroadcaster::Broadcast( const SfxHint &rHint )
ListenersType::const_iterator dest(maDestructedListeners.begin());
ListenersType aListeners(maListeners); // this copy is important to avoid erasing entries while iterating
- for (ListenersType::iterator it(aListeners.begin()); it != aListeners.end(); ++it)
+ for (auto& rpListener : aListeners)
{
// skip the destructed ones
- while (dest != maDestructedListeners.end() && (*dest < *it))
+ while (dest != maDestructedListeners.end() && (*dest < rpListener))
++dest;
- if (dest == maDestructedListeners.end() || *dest != *it)
- (*it)->Notify(rHint);
+ if (dest == maDestructedListeners.end() || *dest != rpListener)
+ rpListener->Notify(rHint);
}
}
diff --git a/svl/source/notify/listener.cxx b/svl/source/notify/listener.cxx
index 6a54f6465c75..22d5508a3cef 100644
--- a/svl/source/notify/listener.cxx
+++ b/svl/source/notify/listener.cxx
@@ -76,11 +76,9 @@ void SvtListener::BroadcasterDying( SvtBroadcaster& rBroadcaster )
void SvtListener::EndListeningAll()
{
- BroadcastersType::iterator it = maBroadcasters.begin();
- BroadcastersType::const_iterator itEnd = maBroadcasters.end();
- for (; it != itEnd; ++it)
+ for (SvtBroadcaster* p : maBroadcasters)
{
- SvtBroadcaster& rBC = **it;
+ SvtBroadcaster& rBC = *p;
rBC.Remove(this);
}
maBroadcasters.clear();
@@ -92,11 +90,8 @@ void SvtListener::CopyAllBroadcasters( const SvtListener& r )
EndListeningAll();
BroadcastersType aCopy(r.maBroadcasters);
maBroadcasters.swap(aCopy);
- BroadcastersType::iterator it = maBroadcasters.begin();
- BroadcastersType::const_iterator itEnd = maBroadcasters.end();
- for (; it != itEnd; ++it)
+ for (SvtBroadcaster* p : maBroadcasters)
{
- SvtBroadcaster* p = *it;
p->Add(this);
}
}
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx
index f290d8cb37ec..4fa91ec9a0cd 100644
--- a/svl/source/numbers/numfmuno.cxx
+++ b/svl/source/numbers/numfmuno.cxx
@@ -388,9 +388,11 @@ uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType
uno::Sequence<sal_Int32> aSeq(nCount);
sal_Int32* pAry = aSeq.getArray();
sal_uInt32 i=0;
- for (SvNumberFormatTable::const_iterator it = rTable.begin(); it != rTable.end(); ++it, ++i)
- pAry[i] = it->first;
-
+ for (const auto& rEntry : rTable)
+ {
+ pAry[i] = rEntry.first;
+ ++i;
+ }
return aSeq;
}
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index aab66e24013f..955a3a593f24 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -203,15 +203,9 @@ SvNumberFormatterRegistry_Impl::~SvNumberFormatterRegistry_Impl()
void SvNumberFormatterRegistry_Impl::Remove( SvNumberFormatter const * pThis )
{
- for (SvNumberFormatterList_impl::iterator it = aFormatters.begin();
- it != aFormatters.end(); ++it)
- {
- if ( *it == pThis )
- {
- aFormatters.erase( it );
- break;
- }
- }
+ auto it = std::find(aFormatters.begin(), aFormatters.end(), pThis);
+ if (it != aFormatters.end())
+ aFormatters.erase( it );
}
void SvNumberFormatterRegistry_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*,
@@ -3142,11 +3136,10 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
sal_uInt32 nCLOffset = 0;
sal_uInt32 nOldKey, nOffset, nNewKey;
- auto it = rTable.aFTable.begin();
- while (it != rTable.aFTable.end())
+ for (const auto& rEntry : rTable.aFTable)
{
- SvNumberformat* pFormat = it->second.get();
- nOldKey = it->first;
+ SvNumberformat* pFormat = rEntry.second.get();
+ nOldKey = rEntry.first;
nOffset = nOldKey % SV_COUNTRY_LANGUAGE_OFFSET; // relative index
if (nOffset == 0) // 1st format of CL
{
@@ -3198,7 +3191,6 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
(*pMergeTable)[nOldKey] = nNewKey;
}
}
- ++it;
}
return pMergeTable.get();
}
@@ -3212,10 +3204,10 @@ SvNumberFormatterMergeMap SvNumberFormatter::ConvertMergeTableToMap()
return SvNumberFormatterMergeMap();
}
SvNumberFormatterMergeMap aMap;
- for (SvNumberFormatterIndexTable::const_iterator it = pMergeTable->begin(); it != pMergeTable->end(); ++it)
+ for (const auto& rEntry : *pMergeTable)
{
- sal_uInt32 nOldKey = it->first;
- aMap[ nOldKey ] = it->second;
+ sal_uInt32 nOldKey = rEntry.first;
+ aMap[ nOldKey ] = rEntry.second;
}
ClearMergeTable();
return aMap;
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index eb52bc98e520..38a6bfd134dc 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -886,20 +886,20 @@ void SAL_CALL PasswordContainer::remove( const OUString& aURL, const OUString& a
if( aIter == m_aContainer.end() )
return;
- for( std::vector< NamePassRecord >::iterator aNPIter = aIter->second.begin(); aNPIter != aIter->second.end(); ++aNPIter )
- if( aNPIter->GetUserName() == aName )
- {
- if( aNPIter->HasPasswords( PERSISTENT_RECORD ) && m_pStorageFile )
- m_pStorageFile->remove( aURL, aName ); // remove record ( aURL, aName )
+ auto aNPIter = std::find_if(aIter->second.begin(), aIter->second.end(),
+ [&aName](const NamePassRecord& rNPRecord) { return rNPRecord.GetUserName() == aName; });
- // the iterator will not be used any more so it can be removed directly
- aIter->second.erase( aNPIter );
+ if (aNPIter != aIter->second.end())
+ {
+ if( aNPIter->HasPasswords( PERSISTENT_RECORD ) && m_pStorageFile )
+ m_pStorageFile->remove( aURL, aName ); // remove record ( aURL, aName )
- if( aIter->second.empty() )
- m_aContainer.erase( aIter );
+ // the iterator will not be used any more so it can be removed directly
+ aIter->second.erase( aNPIter );
- return;
- }
+ if( aIter->second.empty() )
+ m_aContainer.erase( aIter );
+ }
}
@@ -926,26 +926,26 @@ void SAL_CALL PasswordContainer::removePersistent( const OUString& aURL, const O
if( aIter == m_aContainer.end() )
return;
- for( std::vector< NamePassRecord >::iterator aNPIter = aIter->second.begin(); aNPIter != aIter->second.end(); ++aNPIter )
- if( aNPIter->GetUserName() == aName )
- {
- if( aNPIter->HasPasswords( PERSISTENT_RECORD ) )
- {
- // TODO/LATER: should the password be converted to MemoryPassword?
- aNPIter->RemovePasswords( PERSISTENT_RECORD );
+ auto aNPIter = std::find_if(aIter->second.begin(), aIter->second.end(),
+ [&aName](const NamePassRecord& rNPRecord) { return rNPRecord.GetUserName() == aName; });
- if ( m_pStorageFile )
- m_pStorageFile->remove( aURL, aName ); // remove record ( aURL, aName )
- }
+ if (aNPIter != aIter->second.end())
+ {
+ if( aNPIter->HasPasswords( PERSISTENT_RECORD ) )
+ {
+ // TODO/LATER: should the password be converted to MemoryPassword?
+ aNPIter->RemovePasswords( PERSISTENT_RECORD );
- if( !aNPIter->HasPasswords( MEMORY_RECORD ) )
- aIter->second.erase( aNPIter );
+ if ( m_pStorageFile )
+ m_pStorageFile->remove( aURL, aName ); // remove record ( aURL, aName )
+ }
- if( aIter->second.empty() )
- m_aContainer.erase( aIter );
+ if( !aNPIter->HasPasswords( MEMORY_RECORD ) )
+ aIter->second.erase( aNPIter );
- return;
- }
+ if( aIter->second.empty() )
+ m_aContainer.erase( aIter );
+ }
}
void SAL_CALL PasswordContainer::removeAllPersistent()
@@ -990,10 +990,10 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere
Sequence< UrlRecord > aResult;
::osl::MutexGuard aGuard( mMutex );
- for( PassMap::const_iterator aIter = m_aContainer.begin(); aIter != m_aContainer.end(); ++aIter )
+ for( const auto& rEntry : m_aContainer )
{
Sequence< UserRecord > aUsers;
- for (auto const& aNP : aIter->second)
+ for (auto const& aNP : rEntry.second)
if( aNP.HasPasswords( PERSISTENT_RECORD ) )
{
sal_Int32 oldLen = aUsers.getLength();
@@ -1005,7 +1005,7 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere
{
sal_Int32 oldLen = aResult.getLength();
aResult.realloc( oldLen + 1 );
- aResult[ oldLen ] = UrlRecord( aIter->first, aUsers );
+ aResult[ oldLen ] = UrlRecord( rEntry.first, aUsers );
}
}
@@ -1262,24 +1262,22 @@ void PasswordContainer::Notify()
{
::osl::MutexGuard aGuard( mMutex );
- PassMap::iterator aIter;
-
// remove the cached persistent values in the memory
- for( aIter = m_aContainer.begin(); aIter != m_aContainer.end(); ++aIter )
+ for( auto& rEntry : m_aContainer )
{
- for( std::vector< NamePassRecord >::iterator aNPIter = aIter->second.begin(); aNPIter != aIter->second.end(); )
+ for( std::vector< NamePassRecord >::iterator aNPIter = rEntry.second.begin(); aNPIter != rEntry.second.end(); )
{
if( aNPIter->HasPasswords( PERSISTENT_RECORD ) )
{
aNPIter->RemovePasswords( PERSISTENT_RECORD );
if ( m_pStorageFile )
- m_pStorageFile->remove( aIter->first, aNPIter->GetUserName() ); // remove record ( aURL, aName )
+ m_pStorageFile->remove( rEntry.first, aNPIter->GetUserName() ); // remove record ( aURL, aName )
}
if( !aNPIter->HasPasswords( MEMORY_RECORD ) )
{
- aNPIter = aIter->second.erase(aNPIter);
+ aNPIter = rEntry.second.erase(aNPIter);
}
else
++aNPIter;
@@ -1290,14 +1288,14 @@ void PasswordContainer::Notify()
if( m_pStorageFile )
addon = m_pStorageFile->getInfo();
- for( aIter = addon.begin(); aIter != addon.end(); ++aIter )
+ for( const auto& rEntry : addon )
{
- PassMap::iterator aSearchIter = m_aContainer.find( aIter->first );
+ PassMap::iterator aSearchIter = m_aContainer.find( rEntry.first );
if( aSearchIter != m_aContainer.end() )
- for (auto const& aNP : aIter->second)
+ for (auto const& aNP : rEntry.second)
UpdateVector( aSearchIter->first, aSearchIter->second, aNP, false );
else
- m_aContainer.insert( PairUrlRecord( aIter->first, aIter->second ) );
+ m_aContainer.insert( PairUrlRecord( rEntry.first, rEntry.second ) );
}
}
diff --git a/svl/source/passwordcontainer/syscreds.cxx b/svl/source/passwordcontainer/syscreds.cxx
index 9828f13b7c17..74ef2d0b6950 100644
--- a/svl/source/passwordcontainer/syscreds.cxx
+++ b/svl/source/passwordcontainer/syscreds.cxx
@@ -240,26 +240,19 @@ uno::Sequence< OUString > SysCredentialsConfig::list( bool bOnlyPersistent )
+ ( bOnlyPersistent ? 0 : m_aMemContainer.size() );
uno::Sequence< OUString > aResult( nCount );
- StringSet::const_iterator it = m_aCfgContainer.begin();
- StringSet::const_iterator end = m_aCfgContainer.end();
sal_Int32 n = 0;
- while ( it != end )
+ for ( const auto& rItem : m_aCfgContainer )
{
- aResult[ n ] = *it;
- ++it;
+ aResult[ n ] = rItem;
++n;
}
if ( !bOnlyPersistent )
{
- it = m_aMemContainer.begin();
- end = m_aMemContainer.end();
-
- while ( it != end )
+ for ( const auto& rItem : m_aMemContainer )
{
- aResult[ n ] = *it;
- ++it;
+ aResult[ n ] = rItem;
++n;
}
}
diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx
index b9b6bcce4660..cb1fd8be147d 100644
--- a/svl/source/svdde/ddesvr.cxx
+++ b/svl/source/svdde/ddesvr.cxx
@@ -66,9 +66,9 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
DdeQueryStringW( pInst->hDdeInstSvr, hText1, chTopicBuf,
SAL_N_ELEMENTS(chTopicBuf), CP_WINUNICODE );
- for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
+ for (auto& rpService : rAll)
{
- pService = *aI;
+ pService = rpService;
if ( !hText2 || ( *pService->pName == hText2 ) )
{
OUString sTopics( pService->Topics() );
@@ -96,9 +96,9 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
auto pPairs = std::unique_ptr<HSZPAIR[]>(new HSZPAIR [nTopics + 1]);
HSZPAIR* q = pPairs.get();
- for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
+ for (auto& rpService : rAll)
{
- pService = *aI;
+ pService = rpService;
if ( !hText2 || (*pService->pName == hText2 ) )
{
OUString sTopics( pService->Topics() );
@@ -159,9 +159,9 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback(
return nullptr;
}
- for (DdeServices::iterator aI = rAll.begin(); aI != rAll.end(); ++aI)
+ for (auto& rpService : rAll)
{
- pService = *aI;
+ pService = rpService;
for ( size_t i = 0, n = pService->m_vConv.size(); i < n; ++i )
{
pC = pService->m_vConv[ i ].get();
@@ -176,16 +176,10 @@ found:
if ( nCode == XTYP_DISCONNECT)
{
DisconnectTopic(*pC->pTopic, hConv);
- for ( ConvList::iterator it = pService->m_vConv.begin();
- it != pService->m_vConv.end();
- ++it
- ) {
- if ( it->get() == pC )
- {
- pService->m_vConv.erase( it );
- break;
- }
- }
+ auto it = std::find_if(pService->m_vConv.begin(), pService->m_vConv.end(),
+ [&pC](const std::unique_ptr<Conversation>& rxConv) { return rxConv.get() == pC; });
+ if (it != pService->m_vConv.end())
+ pService->m_vConv.erase( it );
return nullptr;
}
@@ -284,17 +278,13 @@ found:
pTopic->aItems.erase(it);
std::vector<DdeItem*>::iterator iter;
- for( iter = pTopic->aItems.begin();
- iter != pTopic->aItems.end();
- ++iter )
+ iter = std::find_if(pTopic->aItems.begin(), pTopic->aItems.end(),
+ [&hText2](const DdeItem* pDdeItem) { return *pDdeItem->pName == hText2; });
+ if (iter != pTopic->aItems.end())
{
- if( *(*iter)->pName == hText2 )
- {
- // It was exchanged indeed
- delete pItem;
- pItem = nullptr;
- break;
- }
+ // It was exchanged indeed
+ delete pItem;
+ pItem = nullptr;
}
if( pItem )
@@ -342,28 +332,24 @@ found:
DdeService* DdeInternal::FindService( HSZ hService )
{
DdeServices& rSvc = DdeService::GetServices();
- for (DdeServices::iterator aI = rSvc.begin(); aI != rSvc.end(); ++aI)
- {
- DdeService* s = *aI;
- if ( *s->pName == hService )
- return s;
- }
+ auto aI = std::find_if(rSvc.begin(), rSvc.end(),
+ [&hService](const DdeService* s) { return *s->pName == hService; });
+ if (aI != rSvc.end())
+ return *aI;
return nullptr;
}
DdeTopic* DdeInternal::FindTopic( DdeService& rService, HSZ hTopic )
{
- std::vector<DdeTopic*>::iterator iter;
std::vector<DdeTopic*> &rTopics = rService.aTopics;
DdeInstData* pInst = ImpGetInstData();
assert(pInst);
- for ( iter = rTopics.begin(); iter != rTopics.end(); ++iter )
- {
- if ( *(*iter)->pName == hTopic )
- return *iter;
- }
+ auto iter = std::find_if(rTopics.begin(), rTopics.end(),
+ [&hTopic](const DdeTopic* pTopic) { return *pTopic->pName == hTopic; });
+ if (iter != rTopics.end())
+ return *iter;
return nullptr;
}
@@ -378,11 +364,10 @@ DdeItem* DdeInternal::FindItem( DdeTopic& rTopic, HSZ hItem )
do
{ // middle check loop
- for ( iter = rItems.begin(); iter != rItems.end(); ++iter )
- {
- if ( *(*iter)->pName == hItem )
- return *iter;
- }
+ iter = std::find_if(rItems.begin(), rItems.end(),
+ [&hItem](const DdeItem* pItem) { return *pItem->pName == hItem; });
+ if (iter != rItems.end())
+ return *iter;
bContinue = !bContinue;
if( !bContinue )
break;
@@ -486,31 +471,26 @@ void DdeService::AddTopic( const DdeTopic& rTopic )
void DdeService::RemoveTopic( const DdeTopic& rTopic )
{
- std::vector<DdeTopic*>::iterator iter;
- for ( iter = aTopics.begin(); iter != aTopics.end(); ++iter )
+ auto iter = std::find_if(aTopics.begin(), aTopics.end(),
+ [&rTopic](const DdeTopic* pTopic) { return DdeCmpStringHandles(pTopic->pName->getHSZ(), rTopic.pName->getHSZ()) == 0; });
+ if (iter != aTopics.end())
{
- if ( !DdeCmpStringHandles ((*iter)->pName->getHSZ(), rTopic.pName->getHSZ() ) )
+ aTopics.erase(iter);
+ // Delete all conversions!
+ // Or else we work on deleted topics!
+ for( size_t n = m_vConv.size(); n; )
{
- aTopics.erase(iter);
- // Delete all conversions!
- // Or else we work on deleted topics!
- for( size_t n = m_vConv.size(); n; )
- {
- auto const& pC = m_vConv[ --n ];
- if( pC->pTopic == &rTopic )
- m_vConv.erase( m_vConv.begin() + n );
- }
- break;
+ auto const& pC = m_vConv[ --n ];
+ if( pC->pTopic == &rTopic )
+ m_vConv.erase( m_vConv.begin() + n );
}
}
}
bool DdeService::HasCbFormat( sal_uInt16 nFmt )
{
- for ( size_t i = 0, n = aFormats.size(); i < n; ++i )
- if ( aFormats[ i ] == nFmt )
- return true;
- return false;
+ return std::any_of(aFormats.begin(), aFormats.end(),
+ [nFmt](const long nFormat) { return nFormat == nFmt; });
}
bool DdeService::HasFormat(SotClipboardFormatId nFmt)
@@ -521,23 +501,19 @@ bool DdeService::HasFormat(SotClipboardFormatId nFmt)
void DdeService::AddFormat(SotClipboardFormatId nFmt)
{
sal_uLong nExternalFmt = DdeData::GetExternalFormat( nFmt );
- for ( size_t i = 0, n = aFormats.size(); i < n; ++i )
- if ( static_cast<sal_uLong>(aFormats[ i ]) == nExternalFmt )
- return;
+ if (std::any_of(aFormats.begin(), aFormats.end(),
+ [nExternalFmt](const long nFormat) { return static_cast<sal_uLong>(nFormat) == nExternalFmt; }))
+ return;
aFormats.push_back( nExternalFmt );
}
void DdeService::RemoveFormat(SotClipboardFormatId nFmt)
{
sal_uLong nExternalFmt = DdeData::GetExternalFormat( nFmt );
- for ( DdeFormats::iterator it = aFormats.begin(); it != aFormats.end(); ++it )
- {
- if ( static_cast<sal_uLong>(*it) == nExternalFmt )
- {
- aFormats.erase( it );
- break;
- }
- }
+ auto it = std::find_if(aFormats.begin(), aFormats.end(),
+ [nExternalFmt](const long nFormat) { return static_cast<sal_uLong>(nFormat) == nExternalFmt; });
+ if (it != aFormats.end())
+ aFormats.erase( it );
}
DdeTopic::DdeTopic( const OUString& rName )
@@ -549,11 +525,10 @@ DdeTopic::DdeTopic( const OUString& rName )
DdeTopic::~DdeTopic()
{
- std::vector<DdeItem*>::iterator iter;
- for (iter = aItems.begin(); iter != aItems.end(); ++iter)
+ for (auto& rpItem : aItems)
{
- (*iter)->pMyTopic = nullptr;
- delete *iter;
+ rpItem->pMyTopic = nullptr;
+ delete rpItem;
}
delete pName;
@@ -593,12 +568,8 @@ void DdeTopic::InsertItem( DdeItem* pNew )
void DdeTopic::RemoveItem( const DdeItem& r )
{
- std::vector<DdeItem*>::iterator iter;
- for (iter = aItems.begin(); iter != aItems.end(); ++iter)
- {
- if ( !DdeCmpStringHandles ((*iter)->pName->getHSZ(), r.pName->getHSZ() ) )
- break;
- }
+ auto iter = std::find_if(aItems.begin(), aItems.end(),
+ [&r](const DdeItem* pItem) { return DdeCmpStringHandles(pItem->pName->getHSZ(), r.pName->getHSZ()) == 0; });
if ( iter != aItems.end() )
{
@@ -610,25 +581,19 @@ void DdeTopic::RemoveItem( const DdeItem& r )
void DdeTopic::NotifyClient( const OUString& rItem )
{
- std::vector<DdeItem*>::iterator iter;
DdeInstData* pInst = ImpGetInstData();
assert(pInst);
- for ( iter = aItems.begin(); iter != aItems.end(); ++iter)
- {
- if ( (*iter)->GetName().equals(rItem) && (*iter)->pImpData)
- {
- DdePostAdvise( pInst->hDdeInstSvr, pName->getHSZ(), (*iter)->pName->getHSZ() );
- break;
- }
- }
+ auto iter = std::find_if(aItems.begin(), aItems.end(),
+ [&rItem](const DdeItem* pItem) { return pItem->GetName().equals(rItem) && pItem->pImpData; });
+ if (iter != aItems.end())
+ DdePostAdvise( pInst->hDdeInstSvr, pName->getHSZ(), (*iter)->pName->getHSZ() );
}
void DdeInternal::DisconnectTopic(DdeTopic & rTopic, HCONV nId)
{
- std::vector<DdeItem*>::iterator iter;
- for (iter = rTopic.aItems.begin(); iter != rTopic.aItems.end(); ++iter)
+ for (const auto& rpItem : rTopic.aItems)
{
- DecMonitor(*iter, nId);
+ DecMonitor(rpItem, nId);
}
}
@@ -810,18 +775,17 @@ void DdeGetPutItem::AdviseLoop( bool )
OUString DdeService::SysItems()
{
OUString s;
- std::vector<DdeTopic*>::iterator iter;
- std::vector<DdeItem*>::iterator iterItem;
- for ( iter = aTopics.begin(); iter != aTopics.end(); ++iter )
+ for ( const auto& rpTopic : aTopics )
{
- if ( (*iter)->GetName() == SZDDESYS_TOPIC )
+ if ( rpTopic->GetName() == SZDDESYS_TOPIC )
{
short n = 0;
- for ( iterItem = (*iter)->aItems.begin(); iterItem != (*iter)->aItems.end(); ++iterItem, n++ )
+ for ( const auto& rpItem : rpTopic->aItems )
{
if ( n )
s += "\t";
- s += (*iterItem)->GetName();
+ s += rpItem->GetName();
+ n++;
}
s += "\r\n";
}
@@ -833,14 +797,14 @@ OUString DdeService::SysItems()
OUString DdeService::Topics()
{
OUString s;
- std::vector<DdeTopic*>::iterator iter;
short n = 0;
- for ( iter = aTopics.begin(); iter != aTopics.end(); ++iter, n++ )
+ for ( const auto& rpTopic : aTopics )
{
if ( n )
s += "\t";
- s += (*iter)->GetName();
+ s += rpTopic->GetName();
+ n++;
}
s += "\r\n";
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 480c85037ecf..7802985e6e1e 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -900,17 +900,9 @@ void SfxUndoManager::AddUndoListener( SfxUndoListener& i_listener )
void SfxUndoManager::RemoveUndoListener( SfxUndoListener& i_listener )
{
UndoManagerGuard aGuard( *m_xData );
- for ( UndoListeners::iterator lookup = m_xData->aListeners.begin();
- lookup != m_xData->aListeners.end();
- ++lookup
- )
- {
- if ( (*lookup) == &i_listener )
- {
- m_xData->aListeners.erase( lookup );
- break;
- }
- }
+ auto lookup = std::find(m_xData->aListeners.begin(), m_xData->aListeners.end(), &i_listener);
+ if (lookup != m_xData->aListeners.end())
+ m_xData->aListeners.erase( lookup );
}
/**
@@ -1106,16 +1098,11 @@ void SfxUndoManager::RemoveMark( UndoStackMark const i_mark )
for ( size_t i=0; i<m_xData->pUndoArray->maUndoActions.size(); ++i )
{
MarkedUndoAction& rAction = m_xData->pUndoArray->maUndoActions[i];
- for ( ::std::vector< UndoStackMark >::iterator markPos = rAction.aMarks.begin();
- markPos != rAction.aMarks.end();
- ++markPos
- )
+ auto markPos = std::find(rAction.aMarks.begin(), rAction.aMarks.end(), i_mark);
+ if (markPos != rAction.aMarks.end())
{
- if ( *markPos == i_mark )
- {
- rAction.aMarks.erase( markPos );
- return;
- }
+ rAction.aMarks.erase( markPos );
+ return;
}
}
SAL_WARN("svl", "SfxUndoManager::RemoveMark: mark not found!");
@@ -1136,16 +1123,8 @@ bool SfxUndoManager::HasTopUndoActionMark( UndoStackMark const i_mark )
const MarkedUndoAction& rAction =
m_xData->pUndoArray->maUndoActions[ nActionPos-1 ];
- for ( ::std::vector< UndoStackMark >::const_iterator markPos = rAction.aMarks.begin();
- markPos != rAction.aMarks.end();
- ++markPos
- )
- {
- if ( *markPos == i_mark )
- return true;
- }
- return false;
+ return std::find(rAction.aMarks.begin(), rAction.aMarks.end(), i_mark) != rAction.aMarks.end();
}
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index d2dbee92ccbd..01085eef1f67 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -1464,32 +1464,16 @@ void SvtFileView_Impl::FilterFolderContent_Impl( const OUString &rFilter )
// do the filtering
- auto aContentLoop = maContent.begin();
- OUString sCompareString;
- do
- {
- if ( (*aContentLoop)->mbIsFolder )
- ++aContentLoop;
- else
- {
+ maContent.erase(std::remove_if(maContent.begin(), maContent.end(),
+ [&aFilters](const std::unique_ptr<SortingData_Impl>& rxContent) {
+ if (rxContent->mbIsFolder)
+ return false;
// normalize the content title (we always match case-insensitive)
// 91872 - 11.09.2001 - frank.schoenheit at sun.com
- sCompareString = (*aContentLoop)->GetFileName(); // filter works on file name, not on title!
- bool bDelete;
-
- bDelete = ::std::none_of( aFilters.begin(), aFilters.end(),
- FilterMatch( sCompareString ) );
-
- if( bDelete )
- {
- // none of the filters did match
- aContentLoop = maContent.erase(aContentLoop);
- }
- else
- ++aContentLoop;
- }
- }
- while ( aContentLoop != maContent.end() );
+ OUString sCompareString = rxContent->GetFileName(); // filter works on file name, not on title!
+ return std::none_of(aFilters.begin(), aFilters.end(), FilterMatch(sCompareString));
+ }),
+ maContent.end());
}
diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx
index 80e9d88a224b..0f11688fe863 100644
--- a/svtools/source/contnr/imivctl1.cxx
+++ b/svtools/source/contnr/imivctl1.cxx
@@ -2036,14 +2036,11 @@ void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry )
&& pEntry != maZOrderList.back()))
return;
- for( auto it = maZOrderList.begin(); it != maZOrderList.end(); ++it)
+ auto it = std::find(maZOrderList.begin(), maZOrderList.end(), pEntry);
+ if (it != maZOrderList.end())
{
- if ( *it == pEntry )
- {
- maZOrderList.erase( it );
- maZOrderList.push_back( pEntry );
- break;
- }
+ maZOrderList.erase( it );
+ maZOrderList.push_back( pEntry );
}
}
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index ccfb0c021548..5120dfdbb53f 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -1023,9 +1023,12 @@ void SvtMatchContext_Impl::doExecute()
aObj.SetSmartProtocol( eSmartProt == INetProtocol::NotValid ? INetProtocol::Http : eSmartProt );
for( ;; )
{
- for(std::vector<OUString>::iterator i = aPickList.begin(); schedule() && i != aPickList.end(); ++i)
+ for(const auto& rPick : aPickList)
{
- aCurObj.SetURL(*i);
+ if (!schedule())
+ break;
+
+ aCurObj.SetURL(rPick);
aCurObj.SetSmartURL( aCurObj.GetURLNoPass());
aCurMainURL = aCurObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
@@ -1264,9 +1267,12 @@ void MatchContext_Impl::doExecute()
aObj.SetSmartProtocol( eSmartProt == INetProtocol::NotValid ? INetProtocol::Http : eSmartProt );
for( ;; )
{
- for(std::vector<OUString>::iterator i = aPickList.begin(); schedule() && i != aPickList.end(); ++i)
+ for(const auto& rPick : aPickList)
{
- aCurObj.SetURL(*i);
+ if (!schedule())
+ break;
+
+ aCurObj.SetURL(rPick);
aCurObj.SetSmartURL( aCurObj.GetURLNoPass());
aCurMainURL = aCurObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx
index 069a165dc6aa..dfaba1f22488 100644
--- a/svtools/source/dialogs/PlaceEditDialog.cxx
+++ b/svtools/source/dialogs/PlaceEditDialog.cxx
@@ -318,11 +318,10 @@ IMPL_LINK_NOARG( PlaceEditDialog, EditLabelHdl, weld::Entry&, void )
IMPL_LINK_NOARG( PlaceEditDialog, EditUsernameHdl, weld::Entry&, void )
{
- for ( std::vector< std::shared_ptr< DetailsContainer > >::iterator it = m_aDetailsContainers.begin( );
- it != m_aDetailsContainers.end( ); ++it )
+ for ( auto& rxDetailsContainer : m_aDetailsContainers )
{
- ( *it )->setUsername( m_xEDUsername->get_text() );
- ( *it )->setPassword( m_xEDPassword->get_text() );
+ rxDetailsContainer->setUsername( m_xEDUsername->get_text() );
+ rxDetailsContainer->setPassword( m_xEDPassword->get_text() );
}
EditHdl(nullptr);
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx
index bb0ea1f07393..01f699d4b835 100644
--- a/svtools/source/dialogs/insdlg.cxx
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -78,18 +78,9 @@ const SvObjectServer * SvObjectServerList::Get( const SvGlobalName & rName ) con
void SvObjectServerList::Remove( const SvGlobalName & rName )
{
- for( size_t i = 0; i < aObjectServerList.size(); )
- {
- if( aObjectServerList[ i ].GetClassName() == rName )
- {
- SvObjectServerList_impl::iterator it = aObjectServerList.begin() + i;
- aObjectServerList.erase( it );
- }
- else
- {
- ++i;
- }
- }
+ aObjectServerList.erase(std::remove_if(aObjectServerList.begin(), aObjectServerList.end(),
+ [rName](const SvObjectServer& rServer) { return rServer.GetClassName() == rName; }),
+ aObjectServerList.end());
}
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index 238aa92a9a08..c0aad3af8a8c 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -390,16 +390,11 @@ namespace svt { namespace table
void UnoControlTableModel::removeTableModelListener( const PTableModelListener& i_listener )
{
DBG_CHECK_ME();
- for ( ModellListeners::iterator lookup = m_pImpl->m_aListeners.begin();
- lookup != m_pImpl->m_aListeners.end();
- ++lookup
- )
+ auto lookup = std::find(m_pImpl->m_aListeners.begin(), m_pImpl->m_aListeners.end(), i_listener);
+ if (lookup != m_pImpl->m_aListeners.end())
{
- if ( *lookup == i_listener )
- {
- m_pImpl->m_aListeners.erase( lookup );
- return;
- }
+ m_pImpl->m_aListeners.erase( lookup );
+ return;
}
OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" );
}
More information about the Libreoffice-commits
mailing list