summaryrefslogtreecommitdiff
path: root/framework
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 /framework
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>
Diffstat (limited to 'framework')
-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
9 files changed, 26 insertions, 93 deletions
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;