summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-02-16 18:39:23 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-18 07:41:05 +0100
commit44841a6778821be3e68ab15819b39064b20e968f (patch)
tree8e9119cf35764f18f5b008e7758c6f950306fb8c
parentbcfbd24be02d2de5d4d27c147dc58c4515a9a0f5 (diff)
Simplify containers iterations in [f-l]*
Use range-based loop or replace with STL functions Change-Id: Ib3fab47318d1bfbb4df8f886a8cd9596525a420f Reviewed-on: https://gerrit.libreoffice.org/67914 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--filter/source/graphicfilter/icgm/elements.cxx10
-rw-r--r--filter/source/msfilter/escherex.cxx11
-rw-r--r--filter/source/msfilter/msdffimp.cxx39
-rw-r--r--filter/source/msfilter/svdfppt.cxx13
-rw-r--r--filter/source/xsltdialog/typedetectionimport.cxx9
-rw-r--r--forms/source/component/EventThread.cxx8
-rw-r--r--forms/source/misc/InterfaceContainer.cxx13
-rw-r--r--forms/source/xforms/namedcollection.hxx19
-rw-r--r--fpicker/source/office/OfficeFilePicker.cxx12
-rw-r--r--fpicker/source/office/iodlg.cxx7
-rw-r--r--fpicker/source/win32/FilterContainer.cxx12
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx16
-rw-r--r--framework/source/accelerators/presethandler.cxx8
-rw-r--r--framework/source/dispatch/dispatchinformationprovider.cxx12
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx14
-rw-r--r--framework/source/services/ContextChangeEventMultiplexer.cxx12
-rw-r--r--framework/source/services/autorecovery.cxx23
-rw-r--r--framework/source/services/desktop.cxx6
-rw-r--r--framework/source/services/pathsettings.cxx21
-rw-r--r--framework/source/uifactory/uielementfactorymanager.cxx7
-rw-r--r--i18nlangtag/source/languagetag/languagetag.cxx37
-rw-r--r--i18npool/source/characterclassification/characterclassificationImpl.cxx4
-rw-r--r--i18npool/source/localedata/localedata.cxx8
-rw-r--r--idlc/source/astenum.cxx13
-rw-r--r--idlc/source/astscope.cxx14
-rw-r--r--idlc/source/astservice.cxx24
-rw-r--r--l10ntools/source/po.cxx4
-rw-r--r--lotuswordpro/source/filter/lwpstory.cxx41
28 files changed, 124 insertions, 293 deletions
diff --git a/filter/source/graphicfilter/icgm/elements.cxx b/filter/source/graphicfilter/icgm/elements.cxx
index 8d324b68340c..915edc363630 100644
--- a/filter/source/graphicfilter/icgm/elements.cxx
+++ b/filter/source/graphicfilter/icgm/elements.cxx
@@ -320,12 +320,10 @@ Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle )
Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
if ( pBundle )
{
- for ( BundleList::iterator it = rList.begin(); it != rList.end(); ++it ) {
- if ( it->get() == pBundle ) {
- rList.erase( it );
- break;
- }
- }
+ auto it = std::find_if(rList.begin(), rList.end(),
+ [&pBundle](const std::unique_ptr<Bundle>& rxBundle) { return rxBundle.get() == pBundle; });
+ if (it != rList.end())
+ rList.erase( it );
}
rList.push_back( rBundle.Clone() );
return rList.back().get();
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 50e10a4af1fb..32756294d391 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -3794,13 +3794,10 @@ void EscherPersistTable::PtInsert( sal_uInt32 nID, sal_uInt32 nOfs )
void EscherPersistTable::PtDelete( sal_uInt32 nID )
{
- for(auto it = maPersistTable.begin(); it != maPersistTable.end() ; ++it)
- {
- if ( (*it)->mnID == nID ) {
- maPersistTable.erase( it );
- break;
- }
- }
+ auto it = std::find_if(maPersistTable.begin(), maPersistTable.end(),
+ [&nID](const std::unique_ptr<EscherPersistEntry>& rxEntry) { return rxEntry->mnID == nID; });
+ if (it != maPersistTable.end())
+ maPersistTable.erase( it );
}
sal_uInt32 EscherPersistTable::PtGetOffsetByID( sal_uInt32 nID )
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 45c8836f9d10..df759c529693 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1176,30 +1176,22 @@ static void ApplyRectangularGradientAsBitmap( const SvxMSDffManager& rManager, S
if ( fD != 0.0 )
fDist /= fD;
- std::vector< ShadeColor >::const_iterator aIter( rShadeColors.begin() );
double fA = 0.0;
- Color aColorA = aIter->aColor;
+ Color aColorA = rShadeColors.front().aColor;
double fB = 1.0;
Color aColorB( aColorA );
- while ( aIter != rShadeColors.end() )
+ for ( const auto& rShadeColor : rShadeColors )
{
- if ( aIter->fDist <= fDist )
+ if ( fA <= rShadeColor.fDist && rShadeColor.fDist <= fDist )
{
- if ( aIter->fDist >= fA )
- {
- fA = aIter->fDist;
- aColorA = aIter->aColor;
- }
+ fA = rShadeColor.fDist;
+ aColorA = rShadeColor.aColor;
}
- if ( aIter->fDist > fDist )
+ if ( fDist < rShadeColor.fDist && rShadeColor.fDist <= fB )
{
- if ( aIter->fDist <= fB )
- {
- fB = aIter->fDist;
- aColorB = aIter->aColor;
- }
+ fB = rShadeColor.fDist;
+ aColorB = rShadeColor.aColor;
}
- ++aIter;
}
double fRed = aColorA.GetRed(), fGreen = aColorA.GetGreen(), fBlue = aColorA.GetBlue();
double fD1 = fB - fA;
@@ -7501,17 +7493,10 @@ void SvxMSDffManager::insertShapeId( sal_Int32 nShapeId, SdrObject* pShape )
void SvxMSDffManager::removeShapeId( SdrObject const * pShape )
{
- SvxMSDffShapeIdContainer::iterator aIter( maShapeIdContainer.begin() );
- const SvxMSDffShapeIdContainer::iterator aEnd( maShapeIdContainer.end() );
- while( aIter != aEnd )
- {
- if( (*aIter).second == pShape )
- {
- maShapeIdContainer.erase( aIter );
- break;
- }
- ++aIter;
- }
+ SvxMSDffShapeIdContainer::iterator aIter = std::find_if(maShapeIdContainer.begin(), maShapeIdContainer.end(),
+ [&pShape](const SvxMSDffShapeIdContainer::value_type& rEntry) { return rEntry.second == pShape; });
+ if (aIter != maShapeIdContainer.end())
+ maShapeIdContainer.erase( aIter );
}
SdrObject* SvxMSDffManager::getShapeForId( sal_Int32 nShapeId )
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 8321b494d598..2f92c28b5822 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -6903,12 +6903,9 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
if (xEntry)
{
// sorting fields ( hi >> lo )
- auto it = FieldList.begin();
- for( ; it != FieldList.end(); ++it ) {
- if ( (*it)->nPos < xEntry->nPos ) {
- break;
- }
- }
+ auto it = std::find_if(FieldList.begin(), FieldList.end(),
+ [&xEntry](const std::unique_ptr<PPTFieldEntry>& rxField) {
+ return rxField->nPos < xEntry->nPos; });
if ( it != FieldList.end() ) {
FieldList.insert(it, std::move(xEntry));
} else {
@@ -6935,8 +6932,8 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
while ( ( FE < FieldList.end() ) && nCount-- )
{
nPos--;
- while ( ( FE < FieldList.end() ) && ( (*FE)->nPos > nPos ) )
- ++FE;
+ FE = std::find_if(FE, FieldList.end(),
+ [&nPos](const std::unique_ptr<PPTFieldEntry>& rxField) {return rxField->nPos <= nPos;});
if ( !(FE < FieldList.end()) )
break;
diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx
index e1c3d8147b9d..5a0ebdb8c05a 100644
--- a/filter/source/xsltdialog/typedetectionimport.cxx
+++ b/filter/source/xsltdialog/typedetectionimport.cxx
@@ -115,11 +115,10 @@ static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rD
Node* TypeDetectionImporter::findTypeNode( const OUString& rType )
{
- for (auto aIter(maTypeNodes.begin()), aEnd(maTypeNodes.end()); aIter != aEnd; ++aIter)
- {
- if( (*aIter)->maName == rType )
- return aIter->get();
- }
+ auto aIter = std::find_if(maTypeNodes.begin(), maTypeNodes.end(),
+ [&rType](const std::unique_ptr<Node>& rxNode) { return rxNode->maName == rType; });
+ if (aIter != maTypeNodes.end())
+ return aIter->get();
return nullptr;
}
diff --git a/forms/source/component/EventThread.cxx b/forms/source/component/EventThread.cxx
index 76022a84f62d..a44349e36bc1 100644
--- a/forms/source/component/EventThread.cxx
+++ b/forms/source/component/EventThread.cxx
@@ -71,11 +71,9 @@ Any SAL_CALL OComponentEventThread::queryInterface(const Type& _rType)
void OComponentEventThread::impl_clearEventQueue()
{
- while ( !m_aEvents.empty() )
- {
- delete *m_aEvents.begin();
- m_aEvents.erase( m_aEvents.begin() );
- }
+ for ( auto& rEvent : m_aEvents )
+ delete rEvent;
+ m_aEvents.clear();
m_aControls.erase( m_aControls.begin(), m_aControls.end() );
m_aFlags.erase( m_aFlags.begin(), m_aFlags.end() );
}
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index eefe6b5dc552..dd65163908e9 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -866,8 +866,8 @@ void OInterfaceContainer::removeElementsNoEvents()
OInterfaceArray::iterator i = m_aItems.begin();
css::uno::Reference<css::uno::XInterface> xElement(*i);
- OInterfaceMap::iterator j = m_aMap.begin();
- while (j != m_aMap.end() && (*j).second != xElement) ++j;
+ OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&xElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second == xElement; });
m_aItems.erase(i);
m_aMap.erase(j);
@@ -930,9 +930,8 @@ void OInterfaceContainer::implReplaceByIndex( const sal_Int32 _nIndex, const Any
"OInterfaceContainer::implReplaceByIndex: elements should be held normalized!" );
// locate the old element in the map
- OInterfaceMap::iterator j = m_aMap.begin();
- while ( ( j != m_aMap.end() ) && ( j->second.get() != xOldElement.get() ) )
- ++j;
+ OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&xOldElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second.get() == xOldElement.get(); });
// remove event knittings
if ( m_xEventAttacher.is() )
@@ -1011,8 +1010,8 @@ void OInterfaceContainer::implRemoveByIndex( const sal_Int32 _nIndex, ::osl::Cle
OInterfaceArray::iterator i = m_aItems.begin() + _nIndex;
css::uno::Reference<css::uno::XInterface> xElement(*i);
- OInterfaceMap::iterator j = m_aMap.begin();
- while (j != m_aMap.end() && (*j).second != xElement) ++j;
+ OInterfaceMap::iterator j = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&xElement](const OInterfaceMap::value_type& rEntry) { return rEntry.second == xElement; });
m_aItems.erase(i);
m_aMap.erase(j);
diff --git a/forms/source/xforms/namedcollection.hxx b/forms/source/xforms/namedcollection.hxx
index a9931eb97c3d..72c8b36e68a2 100644
--- a/forms/source/xforms/namedcollection.hxx
+++ b/forms/source/xforms/namedcollection.hxx
@@ -53,12 +53,10 @@ public:
{
// iterate over members, and collect all those that have names
std::vector<OUString> aNames;
- for( typename std::vector<T>::const_iterator aIter = maItems.begin();
- aIter != maItems.end();
- ++aIter )
+ for( const T& rItem : maItems )
{
css::uno::Reference<css::container::XNamed>
- xNamed( *aIter, css::uno::UNO_QUERY );
+ xNamed( rItem, css::uno::UNO_QUERY );
if( xNamed.is() )
aNames.push_back( xNamed->getName() );
}
@@ -69,16 +67,11 @@ public:
protected:
typename std::vector<T>::const_iterator findItem( const OUString& rName ) const
{
- for( typename std::vector<T>::const_iterator aIter = maItems.begin();
- aIter != maItems.end();
- ++aIter )
- {
+ return std::find_if(maItems.begin(), maItems.end(), [&rName](const T& rItem) {
css::uno::Reference<css::container::XNamed>
- xNamed( *aIter, css::uno::UNO_QUERY );
- if( xNamed.is() && xNamed->getName() == rName )
- return aIter;
- }
- return maItems.end();
+ xNamed( rItem, css::uno::UNO_QUERY );
+ return xNamed.is() && xNamed->getName() == rName;
+ });
}
public:
diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx
index e5fc93325a0d..dd6712541722 100644
--- a/fpicker/source/office/OfficeFilePicker.cxx
+++ b/fpicker/source/office/OfficeFilePicker.cxx
@@ -573,17 +573,7 @@ Sequence< OUString > SAL_CALL SvtFilePicker::getSelectedFiles()
return aEmpty;
}
- std::vector<OUString> aPathList(getDialog()->GetPathList());
- size_t nCount = aPathList.size();
-
- Sequence< OUString > aFiles(nCount);
-
- for(size_t i = 0; i < aPathList.size(); ++i)
- {
- aFiles[i] = aPathList[i];
- }
-
- return aFiles;
+ return comphelper::containerToSequence(getDialog()->GetPathList());
}
Sequence< OUString > SAL_CALL SvtFilePicker::getFiles()
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index 8064dca1c8fe..b3e5ace8c95d 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -1767,12 +1767,9 @@ void SvtFileDialog::EnableUI( bool _bEnable )
if ( _bEnable )
{
- for ( auto aLoop = m_aDisabledControls.begin();
- aLoop != m_aDisabledControls.end();
- ++aLoop
- )
+ for ( auto& rxControl : m_aDisabledControls )
{
- (*aLoop)->Enable( false );
+ rxControl->Enable( false );
}
}
}
diff --git a/fpicker/source/win32/FilterContainer.cxx b/fpicker/source/win32/FilterContainer.cxx
index 8b3ceb4926af..678c8791d5b7 100644
--- a/fpicker/source/win32/FilterContainer.cxx
+++ b/fpicker/source/win32/FilterContainer.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
+#include <algorithm>
#include <memory>
#include <stdexcept>
#include <osl/diagnose.h>
@@ -150,13 +151,10 @@ sal_Int32 CFilterContainer::getFilterTagPos( const OUString& aName ) const
{
if ( !m_vFilters.empty() )
{
- sal_Int32 i = 0;
- FILTER_VECTOR_T::const_iterator iter;
- FILTER_VECTOR_T::const_iterator iter_end = m_vFilters.end( );
-
- for ( iter = m_vFilters.begin( ); iter != iter_end; ++iter, ++i )
- if ( ( *iter ).first.equalsIgnoreAsciiCase( aName ) )
- return i;
+ FILTER_VECTOR_T::const_iterator iter = std::find_if(m_vFilters.begin(), m_vFilters.end(),
+ [&aName](const FILTER_ENTRY_T& rFilter) { return rFilter.first.equalsIgnoreAsciiCase(aName); });
+ if (iter != m_vFilters.end())
+ return std::distance(m_vFilters.begin(), iter);
}
return -1;
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index 559be7efbb1b..596e5e2937c6 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -668,20 +668,8 @@ css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XCUBasedAcceleratorConfigurati
static AcceleratorCache::TKeyList::const_iterator lcl_getPreferredKey(const AcceleratorCache::TKeyList& lKeys)
{
- AcceleratorCache::TKeyList::const_iterator pIt;
- for ( pIt = lKeys.begin ();
- pIt != lKeys.end ();
- ++pIt )
- {
- const css::awt::KeyEvent& rAWTKey = *pIt;
- const vcl::KeyCode aVCLKey = ::svt::AcceleratorExecute::st_AWTKey2VCLKey(rAWTKey);
- const OUString sName = aVCLKey.GetName();
-
- if (!sName.isEmpty())
- return pIt;
- }
-
- return lKeys.end();
+ return std::find_if(lKeys.begin(), lKeys.end(), [](const css::awt::KeyEvent& rAWTKey) {
+ return !::svt::AcceleratorExecute::st_AWTKey2VCLKey(rAWTKey).GetName().isEmpty(); });
}
css::uno::Sequence< css::uno::Any > SAL_CALL XCUBasedAcceleratorConfiguration::getPreferredKeyEventsForCommandList(const css::uno::Sequence< OUString >& lCommandList)
diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx
index 2c0b96f78f02..34c94719e6df 100644
--- a/framework/source/accelerators/presethandler.cxx
+++ b/framework/source/accelerators/presethandler.cxx
@@ -729,13 +729,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
}
else
{
- for ( pFound = lLocalizedValues.begin();
- pFound != lLocalizedValues.end();
- ++pFound )
- {
- if (*pFound == rLanguageTag)
- break;
- }
+ pFound = std::find(lLocalizedValues.begin(), lLocalizedValues.end(), rLanguageTag);
}
return pFound;
diff --git a/framework/source/dispatch/dispatchinformationprovider.cxx b/framework/source/dispatch/dispatchinformationprovider.cxx
index 1f4e98f41616..90842801c454 100644
--- a/framework/source/dispatch/dispatchinformationprovider.cxx
+++ b/framework/source/dispatch/dispatchinformationprovider.cxx
@@ -105,17 +105,7 @@ css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL DispatchInformati
{ continue; }
}
- c1 = static_cast<sal_Int32>(lInfos.size());
- i1 = 0;
-
- css::uno::Sequence< css::frame::DispatchInformation > lReturn(c1);
- for (auto pStepp = lInfos.begin();
- pStepp != lInfos.end () && i1<c1;
- ++pStepp, ++i1 )
- {
- lReturn[i1] = pStepp->second;
- }
- return lReturn;
+ return comphelper::mapValuesToSequence(lInfos);
}
css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > DispatchInformationProvider::implts_getAllSubProvider()
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index 0c23aaa80f37..e39555328362 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -54,15 +54,11 @@ namespace {
PatternHash::const_iterator findPatternKey(PatternHash const * hash, const OUString& sURL)
{
- auto pItem = hash->begin();
- while( pItem!=hash->end() )
- {
- WildCard aPattern(pItem->first);
- if (aPattern.Matches(sURL))
- break;
- ++pItem;
- }
- return pItem;
+ return std::find_if(hash->begin(), hash->end(),
+ [&sURL](const PatternHash::value_type& rEntry) {
+ WildCard aPattern(rEntry.first);
+ return aPattern.Matches(sURL);
+ });
}
}
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index 66755c88ccc9..e8e1c769d1f2 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -205,17 +205,13 @@ void SAL_CALL ContextChangeEventMultiplexer::removeAllContextChangeEventListener
"can not remove an empty reference",
static_cast<XWeak*>(this), 0);
- for (ListenerMap::iterator
- iContainer(maListeners.begin()),
- iEnd(maListeners.end());
- iContainer!=iEnd;
- ++iContainer)
+ for (auto& rContainer : maListeners)
{
const ListenerContainer::iterator iListener (
- ::std::find(iContainer->second.maListeners.begin(), iContainer->second.maListeners.end(), rxListener));
- if (iListener != iContainer->second.maListeners.end())
+ ::std::find(rContainer.second.maListeners.begin(), rContainer.second.maListeners.end(), rxListener));
+ if (iListener != rContainer.second.maListeners.end())
{
- iContainer->second.maListeners.erase(iListener);
+ rContainer.second.maListeners.erase(iListener);
// We hold on to the focus descriptor even when the last listener has been removed.
// This allows us to keep track of the current context and send it to new listeners.
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index 60f4762146d5..4f8210d405b1 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -2667,16 +2667,8 @@ void AutoRecovery::implts_markDocumentAsSaved(const css::uno::Reference< css::fr
AutoRecovery::TDocumentList::iterator AutoRecovery::impl_searchDocument( AutoRecovery::TDocumentList& rList ,
const css::uno::Reference< css::frame::XModel >& xDocument)
{
- AutoRecovery::TDocumentList::iterator pIt;
- for ( pIt = rList.begin();
- pIt != rList.end();
- ++pIt )
- {
- const AutoRecovery::TDocumentInfo& rInfo = *pIt;
- if (rInfo.Document == xDocument)
- break;
- }
- return pIt;
+ return std::find_if(rList.begin(), rList.end(),
+ [&xDocument](const AutoRecovery::TDocumentInfo& rInfo) { return rInfo.Document == xDocument; });
}
void lcl_changeVisibility( const css::uno::Reference< css::frame::XFramesSupplier >& i_rFrames, bool i_bVisible )
@@ -3816,21 +3808,16 @@ void AutoRecovery::implts_cleanUpWorkingEntry(const DispatchParams& aParams)
{
CacheLockGuard aCacheLock(this, cppu::WeakComponentImplHelperBase::rBHelper.rMutex, m_nDocCacheLock, LOCK_FOR_CACHE_ADD_REMOVE);
- AutoRecovery::TDocumentList::iterator pIt;
- for ( pIt = m_lDocCache.begin();
- pIt != m_lDocCache.end();
- ++pIt )
+ AutoRecovery::TDocumentList::iterator pIt = std::find_if(m_lDocCache.begin(), m_lDocCache.end(),
+ [&aParams](const AutoRecovery::TDocumentInfo& rInfo) { return rInfo.ID == aParams.m_nWorkingEntryID; });
+ if (pIt != m_lDocCache.end())
{
AutoRecovery::TDocumentInfo& rInfo = *pIt;
- if (rInfo.ID != aParams.m_nWorkingEntryID)
- continue;
-
AutoRecovery::st_impl_removeFile(rInfo.OldTempURL);
AutoRecovery::st_impl_removeFile(rInfo.NewTempURL);
implts_flushConfigItem(rInfo, true); // sal_True => remove it from xml config!
m_lDocCache.erase(pIt);
- break; /// !!! pIt is not defined any longer ... further this function has finished it's work
}
}
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index a0d3479bf031..460f97a46e7b 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -1610,15 +1610,11 @@ void Desktop::impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerL
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
- Desktop::TTerminateListenerList::const_iterator pIt;
- for ( pIt = lCalledListener.begin();
- pIt != lCalledListener.end ();
- ++pIt )
+ for (const css::uno::Reference<css::frame::XTerminateListener>& xListener : lCalledListener)
{
try
{
// Note: cancelTermination() is a new and optional interface method !
- css::uno::Reference< css::frame::XTerminateListener > xListener = *pIt;
css::uno::Reference< css::frame::XTerminateListener2 > xListenerGeneration2(xListener, css::uno::UNO_QUERY);
if ( ! xListenerGeneration2.is() )
continue;
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index 070d62a6752b..74831fa22d79 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -999,8 +999,6 @@ std::vector<OUString> PathSettings::impl_convertOldStyle2Path(const OUString& sO
void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
std::vector<OUString>& lList)
{
- std::vector<OUString>::iterator pIt;
-
// Erase items in the internal path list from lList.
// Also erase items in the internal path list from the user path list.
for (auto const& internalPath : rPath.lInternalPaths)
@@ -1014,20 +1012,11 @@ void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
}
// Erase items not in lList from the user path list.
- pIt = rPath.lUserPaths.begin();
- while ( pIt != rPath.lUserPaths.end() )
- {
- const OUString& rItem = *pIt;
- std::vector<OUString>::iterator pItem = std::find(lList.begin(), lList.end(), rItem);
- if ( pItem == lList.end() )
- {
- pIt = rPath.lUserPaths.erase(pIt);
- }
- else
- {
- ++pIt;
- }
- }
+ rPath.lUserPaths.erase(std::remove_if(rPath.lUserPaths.begin(), rPath.lUserPaths.end(),
+ [&lList](const OUString& rItem) {
+ return std::find(lList.begin(), lList.end(), rItem) == lList.end();
+ }),
+ rPath.lUserPaths.end());
// Erase items in the user path list from lList.
for (auto const& userPath : rPath.lUserPaths)
diff --git a/framework/source/uifactory/uielementfactorymanager.cxx b/framework/source/uifactory/uielementfactorymanager.cxx
index 6afbc11e136f..de9f6ce5d893 100644
--- a/framework/source/uifactory/uielementfactorymanager.cxx
+++ b/framework/source/uifactory/uielementfactorymanager.cxx
@@ -154,10 +154,9 @@ Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFac
Sequence< Sequence< PropertyValue > > aSeqSeq;
sal_Int32 nIndex( 0 );
- FactoryManagerMap::const_iterator pIter = m_aFactoryManagerMap.begin();
- while ( pIter != m_aFactoryManagerMap.end() )
+ for ( const auto& rEntry : m_aFactoryManagerMap )
{
- OUString aFactory = pIter->first;
+ OUString aFactory = rEntry.first;
if ( !aFactory.isEmpty() )
{
sal_Int32 nToken = 0;
@@ -181,8 +180,6 @@ Sequence< Sequence< PropertyValue > > ConfigurationAccess_FactoryManager::getFac
aSeqSeq[nIndex++] = aSeq;
}
-
- ++pIter;
}
return aSeqSeq;
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index c0e27492f912..fecfb0bd3703 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -20,6 +20,7 @@
#include <osl/mutex.hxx>
#include <rtl/instance.hxx>
#include <rtl/locale.h>
+#include <algorithm>
#include <map>
#include <unordered_set>
@@ -2581,14 +2582,10 @@ LanguageTagImpl::Extraction LanguageTagImpl::simpleExtract( const OUString& rBcp
if (rList.empty())
return rList.end();
- ::std::vector< OUString >::const_iterator it;
-
// Try the simple case first without constructing fallbacks.
- for (it = rList.begin(); it != rList.end(); ++it)
- {
- if (*it == rReference)
- return it; // exact match
- }
+ ::std::vector< OUString >::const_iterator it = std::find(rList.begin(), rList.end(), rReference);
+ if (it != rList.end())
+ return it; // exact match
::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings( false));
if (rReference != "en-US")
@@ -2606,13 +2603,11 @@ LanguageTagImpl::Extraction LanguageTagImpl::simpleExtract( const OUString& rBcp
* "x-no-translate" and "x-notranslate" apparently was never used anywhere.
* Did that ever work? Was it supposed to work at all like this? */
- for (::std::vector< OUString >::const_iterator fb = aFallbacks.begin(); fb != aFallbacks.end(); ++fb)
+ for (const auto& fb : aFallbacks)
{
- for (it = rList.begin(); it != rList.end(); ++it)
- {
- if (*it == *fb)
- return it; // fallback found
- }
+ it = std::find(rList.begin(), rList.end(), fb);
+ if (it != rList.end())
+ return it; // fallback found
}
// Did not find anything so return something of the list, the first value
@@ -2630,16 +2625,14 @@ LanguageTagImpl::Extraction LanguageTagImpl::simpleExtract( const OUString& rBcp
if (rList.empty())
return rList.end();
- ::std::vector< lang::Locale >::const_iterator it;
-
// Try the simple case first without constructing fallbacks.
- for (it = rList.begin(); it != rList.end(); ++it)
- {
- if ( (*it).Language == rReference.Language &&
- (*it).Country == rReference.Country &&
- (*it).Variant == rReference.Variant)
- return it; // exact match
- }
+ ::std::vector< lang::Locale >::const_iterator it = std::find_if(rList.begin(), rList.end(),
+ [&rReference](const lang::Locale& rLocale) {
+ return rLocale.Language == rReference.Language
+ && rLocale.Country == rReference.Country
+ && rLocale.Variant == rReference.Variant; });
+ if (it != rList.end())
+ return it; // exact match
// Now for each reference fallback test the fallbacks of the list in order.
::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings( false));
diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx
index b9f008d26930..fda7c6e0cf6d 100644
--- a/i18npool/source/characterclassification/characterclassificationImpl.cxx
+++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx
@@ -167,9 +167,9 @@ CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Loca
if (!bLoaded)
{
::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
- for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
+ for (const auto& rFallback : aFallbacks)
{
- bLoaded = createLocaleSpecificCharacterClassification( *it, rLocale);
+ bLoaded = createLocaleSpecificCharacterClassification(rFallback, rLocale);
if (bLoaded)
break;
}
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 118781d7a6b4..c4f68f0a319a 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -1459,9 +1459,9 @@ oslGenericFunction LocaleDataImpl::getFunctionSymbol( const Locale& rLocale, con
if (!pSymbol)
{
::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
- for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
+ for (const auto& rFallback : aFallbacks)
{
- pSymbol = rLookupTable.getFunctionSymbolByName( *it, pFunction, &pCachedItem);
+ pSymbol = rLookupTable.getFunctionSymbolByName(rFallback, pFunction, &pCachedItem);
if (pSymbol)
break;
}
@@ -1611,9 +1611,9 @@ OUString LocaleDataImpl::getFirstLocaleServiceName( const css::lang::Locale & rL
if (rLocale.Language == I18NLANGTAG_QLT)
{
aVec = LanguageTag( rLocale).getFallbackStrings( false);
- for (::std::vector< OUString >::iterator it(aVec.begin()); it != aVec.end(); ++it)
+ for (auto& rItem : aVec)
{
- *it = (*it).replace( cHyphen, cUnder);
+ rItem = rItem.replace(cHyphen, cUnder);
}
}
else if (!rLocale.Country.isEmpty())
diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx
index 69fb0c7bfd89..4254f7264eaa 100644
--- a/idlc/source/astenum.cxx
+++ b/idlc/source/astenum.cxx
@@ -38,16 +38,11 @@ AstConstant* AstEnum::checkValue(AstExpression* pExpr)
DeclList::const_iterator iter = getIteratorBegin();
DeclList::const_iterator end = getIteratorEnd();
- while ( iter != end)
- {
- AstDeclaration* pDecl = *iter;
- AstConstant* pConst = static_cast<AstConstant*>(pDecl);
-
- if (pConst->getConstValue()->compareLong(pExpr))
- return pConst;
+ iter = std::find_if(iter, end, [&pExpr](AstDeclaration* pDecl) {
+ return static_cast<AstConstant*>(pDecl)->getConstValue()->compareLong(pExpr); });
- ++iter;
- }
+ if (iter != end)
+ return static_cast<AstConstant*>(*iter);
if ( pExpr->getExprValue()->u.lval > m_enumValueCount )
m_enumValueCount = pExpr->getExprValue()->u.lval + 1;
diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx
index 1ddda3984458..9af691501a8a 100644
--- a/idlc/source/astscope.cxx
+++ b/idlc/source/astscope.cxx
@@ -85,18 +85,8 @@ AstDeclaration* AstScope::addDeclaration(AstDeclaration* pDecl)
sal_uInt16 AstScope::getNodeCount(NodeType nodeType) const
{
- DeclList::const_iterator iter = getIteratorBegin();
- DeclList::const_iterator end = getIteratorEnd();
- sal_uInt16 count = 0;
-
- while ( iter != end )
- {
- AstDeclaration* pDecl = *iter;
- if ( pDecl->getNodeType() == nodeType )
- count++;
- ++iter;
- }
- return count;
+ return static_cast<sal_uInt16>(std::count_if(getIteratorBegin(), getIteratorEnd(),
+ [&nodeType](const AstDeclaration* pDecl) { return pDecl->getNodeType() == nodeType; }));
}
AstDeclaration* AstScope::lookupByName(const OString& scopedName)
diff --git a/idlc/source/astservice.cxx b/idlc/source/astservice.cxx
index f92aa6ab94c4..c90ded6b4d7a 100644
--- a/idlc/source/astservice.cxx
+++ b/idlc/source/astservice.cxx
@@ -37,22 +37,14 @@ bool AstService::checkLastConstructor() const {
}
sal_uInt32 n = ctor->nMembers();
if (n == last->nMembers()) {
- for (DeclList::const_iterator i1(ctor->getIteratorBegin()),
- i2(last->getIteratorBegin());
- i1 != ctor->getIteratorEnd(); ++i1, ++i2)
- {
- sal_Int32 r1;
- AstDeclaration const * t1 = deconstructAndResolveTypedefs(
- static_cast< AstMember * >(*i1)->getType(), &r1);
- sal_Int32 r2;
- AstDeclaration const * t2 = deconstructAndResolveTypedefs(
- static_cast< AstMember * >(*i2)->getType(), &r2);
- if (r1 != r2 || t1->getScopedName() != t2->getScopedName())
- {
- return false;
- }
- }
- return true;
+ return std::equal(ctor->getIteratorBegin(), ctor->getIteratorEnd(), last->getIteratorBegin(),
+ [](AstDeclaration* a, AstDeclaration* b) {
+ sal_Int32 r1;
+ AstDeclaration const * t1 = deconstructAndResolveTypedefs(static_cast< AstMember * >(a)->getType(), &r1);
+ sal_Int32 r2;
+ AstDeclaration const * t2 = deconstructAndResolveTypedefs(static_cast< AstMember * >(b)->getType(), &r2);
+ return r1 == r2 && t1->getScopedName() == t2->getScopedName();
+ });
}
}
}
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index b1507a16ae65..f8749ace650d 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -137,8 +137,8 @@ void GenPoEntry::writeToFile(std::ofstream& rOFStream) const
rOFStream
<< "#. "
<< m_sExtractCom.toString().replaceAll("\n","\n#. ") << std::endl;
- for(std::vector<OString>::const_iterator it = m_sReferences.begin(); it != m_sReferences.end(); ++it)
- rOFStream << "#: " << *it << std::endl;
+ for(const auto& rReference : m_sReferences)
+ rOFStream << "#: " << rReference << std::endl;
if ( m_bFuzzy )
rOFStream << "#, fuzzy" << std::endl;
if ( m_bCFormat )
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index b0f9586270e2..32d6342e47dc 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -68,6 +68,7 @@
#include "lwppagelayout.hxx"
#include <rtl/ustrbuf.hxx>
+#include <algorithm>
#include <set>
@@ -183,17 +184,9 @@ void LwpStory::SetCurrentLayout(LwpPageLayout *pPageLayout)
**************************************************************************/
LwpPageLayout* LwpStory::GetNextPageLayout()
{
- std::vector<LwpPageLayout*>::iterator it;
- for( it = m_LayoutList.begin(); it != m_LayoutList.end(); ++it )
- {
- if(m_pCurrentLayout == *it)
- {
- if((it+1) !=m_LayoutList.end())
- {
- return *(it+1);
- }
- }
- }
+ std::vector<LwpPageLayout*>::iterator it = std::find(m_LayoutList.begin(), m_LayoutList.end(), m_pCurrentLayout);
+ if (it != m_LayoutList.end() && (it+1) != m_LayoutList.end())
+ return *(it+1);
return nullptr;
}
/**************************************************************************
@@ -222,22 +215,15 @@ void LwpStory::SortPageLayout()
xLayout = GetLayout(xLayout.get());
}
// sort the pagelayout according to their position
- std::vector<LwpPageLayout*>::iterator aIt;
if (!aLayoutList.empty())
{
- for( aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt)
+ for( std::vector<LwpPageLayout*>::iterator aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt)
{
for( std::vector<LwpPageLayout*>::iterator bIt = aIt +1; bIt != aLayoutList.end(); ++bIt )
{
- if(**aIt < **bIt)
+ if(!(**aIt < **bIt))
{
- continue;
- }
- else
- {
- LwpPageLayout* pTemp = *aIt;
- *aIt = *bIt;
- *bIt = pTemp;
+ std::swap(*aIt, *bIt);
}
}
}
@@ -477,17 +463,8 @@ OUString LwpStory::RegisterFirstFribStyle()
bool LwpStory::IsBullStyleUsedBefore(const OUString& rStyleName, sal_uInt8 nPos)
{
- std::vector <NamePosPair>::reverse_iterator rIter;
- for (rIter = m_vBulletStyleNameList.rbegin(); rIter != m_vBulletStyleNameList.rend(); ++rIter)
- {
- OUString aName = (*rIter).first;
- sal_uInt8 nPosition = (*rIter).second;
- if (aName == rStyleName && nPosition == nPos)
- {
- return true;
- }
- }
- return false;
+ return std::any_of(m_vBulletStyleNameList.rbegin(), m_vBulletStyleNameList.rend(),
+ [&rStyleName, &nPos](const NamePosPair& rPair) { return rPair.first == rStyleName && rPair.second == nPos; });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */