From 40ab4d8fda9b69b388ac674c1ee4e88084af9519 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Sun, 14 Oct 2018 20:25:12 +0300 Subject: Simplify containers iterations in unotools, unoxml, uui, vbahelper Use range-based loop or replace with STL functions. Change-Id: I5a43f6fc62c81453dcef3820bb715f4da76915af Reviewed-on: https://gerrit.libreoffice.org/61762 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vbahelper/source/vbahelper/vbacommandbarhelper.cxx | 11 ++++------- vbahelper/source/vbahelper/vbaeventshelperbase.cxx | 4 ++-- vbahelper/source/vbahelper/vbahelper.cxx | 7 ++----- 3 files changed, 8 insertions(+), 14 deletions(-) (limited to 'vbahelper') diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx index 058ddc2a4142..708b59a0da41 100644 --- a/vbahelper/source/vbahelper/vbacommandbarhelper.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarhelper.cxx @@ -73,13 +73,10 @@ public: OUString findBuildinToolbar( const OUString& sToolbarName ) { - MSO2OOCommandbarMap::iterator it = maBuildinToolbarMap.begin(); - for(; it != maBuildinToolbarMap.end(); ++it ) - { - OUString sName = it->first; - if( sName.equalsIgnoreAsciiCase( sToolbarName ) ) - return it->second; - } + auto it = std::find_if(maBuildinToolbarMap.begin(), maBuildinToolbarMap.end(), + [&sToolbarName](const MSO2OOCommandbarMap::value_type& rItem) { return rItem.first.equalsIgnoreAsciiCase( sToolbarName ); }); + if( it != maBuildinToolbarMap.end() ) + return it->second; return OUString(); } }; diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx index cf30602f5e3c..99d49625c3e9 100644 --- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -344,9 +344,9 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co sal_Int32 nModuleType = getModuleType( rModuleName ); // search for all event handlers ModulePathMap& rPathMap = maEventPaths[ rModuleName ]; - for( EventHandlerInfoMap::iterator aIt = maEventInfos.begin(), aEnd = maEventInfos.end(); aIt != aEnd; ++aIt ) + for( const auto& rEventInfo : maEventInfos ) { - const EventHandlerInfo& rInfo = aIt->second; + const EventHandlerInfo& rInfo = rEventInfo.second; if( rInfo.mnModuleType == nModuleType ) rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName ); } diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 4ebc80e743c4..e1a148274604 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -724,12 +724,9 @@ void setCursorHelper( const uno::Reference< frame::XModel >& xModel, const Point } } - for ( ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin(); - controller != aControllers.end(); - ++controller - ) + for ( const auto& rController : aControllers ) { - const uno::Reference< frame::XFrame > xFrame ( (*controller)->getFrame(), uno::UNO_SET_THROW ); + const uno::Reference< frame::XFrame > xFrame ( rController->getFrame(), uno::UNO_SET_THROW ); const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); VclPtr pWindow = VCLUnoHelper::GetWindow( xWindow ); -- cgit