diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-06 22:36:02 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-07 07:20:18 +0100 |
commit | 1b0beef8794210b2af49d8c4a00ca7d4e3ebedb7 (patch) | |
tree | 33ab3e47f8643ea48f6bee5a1aaa145f1c5b05d5 | |
parent | 9d1f56903b05841020dfae21dca0c686483b2494 (diff) |
Use for-range loops in desktop (part2)
+ use 1 time replace size() > 0 by !empty()
Change-Id: If62a17171fc09e0bead7c0a791758705f62920d1
Reviewed-on: https://gerrit.libreoffice.org/50847
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r-- | desktop/source/deployment/registry/dp_registry.cxx | 45 | ||||
-rw-r--r-- | desktop/source/deployment/registry/package/dp_package.cxx | 19 | ||||
-rw-r--r-- | desktop/source/migration/migration.cxx | 137 | ||||
-rw-r--r-- | desktop/source/migration/services/basicmigration.cxx | 16 | ||||
-rw-r--r-- | desktop/source/migration/services/oo3extensionmigration.cxx | 16 | ||||
-rw-r--r-- | desktop/source/migration/services/wordbookmigration.cxx | 18 | ||||
-rw-r--r-- | desktop/source/pkgchk/unopkg/unopkg_misc.cxx | 6 |
7 files changed, 113 insertions, 144 deletions
diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 09180c066a83..83cd03179119 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -134,10 +134,9 @@ inline void PackageRegistryImpl::check() void PackageRegistryImpl::disposing() { // dispose all backends: - t_registryset::const_iterator iPos( m_allBackends.begin() ); - t_registryset::const_iterator const iEnd( m_allBackends.end() ); - for ( ; iPos != iEnd; ++iPos ) { - try_dispose( *iPos ); + for (auto const& backend : m_allBackends) + { + try_dispose(backend); } m_mediaType2backend = t_string2registry(); m_ambiguousBackends = t_registryset(); @@ -265,10 +264,9 @@ void PackageRegistryImpl::insertBackend( } // cut out ambiguous filters: - t_stringset::const_iterator iPos( ambiguousFilters.begin() ); - const t_stringset::const_iterator iEnd( ambiguousFilters.end() ); - for ( ; iPos != iEnd; ++iPos ) { - m_filter2mediaType.erase( *iPos ); + for (auto const& ambiguousFilter : ambiguousFilters) + { + m_filter2mediaType.erase(ambiguousFilter); } } @@ -366,18 +364,16 @@ Reference<deployment::XPackageRegistry> PackageRegistryImpl::create( { t_registryset allBackends; dp_misc::TRACE("> [dp_registry.cxx] media-type detection:\n\n" ); - for ( t_string2string::const_iterator iPos( - that->m_filter2mediaType.begin() ); - iPos != that->m_filter2mediaType.end(); ++iPos ) + for (auto const& elem : that->m_filter2mediaType) { OUStringBuffer buf; buf.append( "extension \"" ); - buf.append( iPos->first ); + buf.append( elem.first ); buf.append( "\" maps to media-type \"" ); - buf.append( iPos->second ); + buf.append( elem.second ); buf.append( "\" maps to backend " ); const Reference<deployment::XPackageRegistry> xBackend( - that->m_mediaType2backend.find( iPos->second )->second ); + that->m_mediaType2backend.find( elem.second )->second ); allBackends.insert( xBackend ); buf.append( Reference<lang::XServiceInfo>( xBackend, UNO_QUERY_THROW ) @@ -385,17 +381,15 @@ Reference<deployment::XPackageRegistry> PackageRegistryImpl::create( dp_misc::TRACE( buf.makeStringAndClear() + "\n"); } dp_misc::TRACE( "> [dp_registry.cxx] ambiguous backends:\n\n" ); - for ( t_registryset::const_iterator iPos( - that->m_ambiguousBackends.begin() ); - iPos != that->m_ambiguousBackends.end(); ++iPos ) + for (auto const& ambiguousBackend : that->m_ambiguousBackends) { OUStringBuffer buf; buf.append( Reference<lang::XServiceInfo>( - *iPos, UNO_QUERY_THROW )->getImplementationName() ); + ambiguousBackend, UNO_QUERY_THROW )->getImplementationName() ); buf.append( ": " ); const Sequence< Reference<deployment::XPackageTypeInfo> > types( - (*iPos)->getSupportedPackageTypes() ); + ambiguousBackend->getSupportedPackageTypes() ); for ( sal_Int32 pos = 0; pos < types.getLength(); ++pos ) { Reference<deployment::XPackageTypeInfo> const & xInfo = types[ pos ]; @@ -425,10 +419,9 @@ Reference<deployment::XPackageRegistry> PackageRegistryImpl::create( void PackageRegistryImpl::update() { check(); - t_registryset::const_iterator iPos( m_allBackends.begin() ); - const t_registryset::const_iterator iEnd( m_allBackends.end() ); - for ( ; iPos != iEnd; ++iPos ) { - const Reference<util::XUpdatable> xUpdatable( *iPos, UNO_QUERY ); + for (auto const& backend : m_allBackends) + { + const Reference<util::XUpdatable> xUpdatable(backend, UNO_QUERY); if (xUpdatable.is()) xUpdatable->update(); } @@ -479,12 +472,10 @@ Reference<deployment::XPackage> PackageRegistryImpl::bindPackage( if (mediaType.isEmpty()) { // try ambiguous backends: - t_registryset::const_iterator iPos( m_ambiguousBackends.begin() ); - const t_registryset::const_iterator iEnd( m_ambiguousBackends.end() ); - for ( ; iPos != iEnd; ++iPos ) + for (auto const& ambiguousBackend : m_ambiguousBackends) { try { - return (*iPos)->bindPackage( url, mediaType, bRemoved, + return ambiguousBackend->bindPackage( url, mediaType, bRemoved, identifier, xCmdEnv ); } catch (const lang::IllegalArgumentException &) { diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 834505c4f0a8..7ea79fd9454d 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -327,9 +327,9 @@ void BackendImpl::packageRemoved(OUString const & url, OUString const & /*mediaT //Notify the backend responsible for processing the different media //types that this extension was removed. ExtensionBackendDb::Data data = readDataFromDb(url); - for (ExtensionBackendDb::Data::ITC_ITEMS i = data.items.begin(); i != data.items.end(); ++i) + for (auto const& item : data.items) { - m_xRootRegistry->packageRemoved(i->first, i->second); + m_xRootRegistry->packageRemoved(item.first, item.second); } if (m_backendDb.get()) @@ -1239,12 +1239,10 @@ Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle( Reference<deployment::XPackage> * pret = ret.getArray(); sal_Int32 lower_end = 0; sal_Int32 upper_end = ret.getLength(); - t_packagevec::const_iterator iPos( bundle.begin() ); - t_packagevec::const_iterator const iEnd( bundle.end() ); - for ( ; iPos != iEnd; ++iPos ) + for (auto const& elem : bundle) { const Reference<deployment::XPackageTypeInfo> xPackageType( - (*iPos)->getPackageType() ); + elem->getPackageType() ); OSL_ASSERT( xPackageType.is() ); if (xPackageType.is()) { @@ -1257,11 +1255,11 @@ Sequence< Reference<deployment::XPackage> > BackendImpl::PackageImpl::getBundle( subType.equalsIgnoreAsciiCase( "vnd.sun.star.configuration-data"))) { --upper_end; - pret[ upper_end ] = *iPos; + pret[ upper_end ] = elem; continue; } } - pret[ lower_end ] = *iPos; + pret[ lower_end ] = elem; ++lower_end; } OSL_ASSERT( lower_end == upper_end ); @@ -1573,11 +1571,10 @@ BackendImpl::PackageImpl::getPackagesFromDb( { std::vector<Reference<deployment::XPackage> > retVector; - typedef std::vector< std::pair<OUString, OUString> >::const_iterator ITC; - for (ITC i = m_dbData.items.begin(); i != m_dbData.items.end(); ++i) + for (auto const& item : m_dbData.items) { Reference<deployment::XPackage> xExtension = - bindBundleItem(i->first, i->second, true, m_identifier, xCmdEnv); + bindBundleItem(item.first, item.second, true, m_identifier, xCmdEnv); OSL_ASSERT(xExtension.is()); if (xExtension.is()) retVector.push_back(xExtension); diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 86925c518a15..7f5b52a74b02 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -518,13 +518,13 @@ install_info MigrationImpl::findInstallation(const strings_v& rVersions) #endif install_info aInfo; - strings_v::const_iterator i_ver = rVersions.begin(); - while (i_ver != rVersions.end()) { + for (auto const& elem : rVersions) + { OUString aVersion, aProfileName; - sal_Int32 nSeparatorIndex = (*i_ver).indexOf('='); + sal_Int32 nSeparatorIndex = elem.indexOf('='); if ( nSeparatorIndex != -1 ) { - aVersion = (*i_ver).copy( 0, nSeparatorIndex ); - aProfileName = (*i_ver).copy( nSeparatorIndex+1 ); + aVersion = elem.copy( 0, nSeparatorIndex ); + aProfileName = elem.copy( nSeparatorIndex+1 ); } if ( !aVersion.isEmpty() && !aProfileName.isEmpty() && @@ -538,7 +538,6 @@ install_info MigrationImpl::findInstallation(const strings_v& rVersions) setInstallInfoIfExist(aInfo, aPreXDGTopConfigDir + aProfileName, aVersion); #endif } - ++i_ver; } return aInfo; @@ -549,16 +548,15 @@ sal_Int32 MigrationImpl::findPreferredMigrationProcess(const migrations_availabl sal_Int32 nIndex( -1 ); sal_Int32 i( 0 ); - migrations_available::const_iterator rIter = rAvailableMigrations.begin(); - while ( rIter != rAvailableMigrations.end() ) { - install_info aInstallInfo = findInstallation(rIter->supported_versions); + for (auto const& availableMigration : rAvailableMigrations) + { + install_info aInstallInfo = findInstallation(availableMigration.supported_versions); if (!aInstallInfo.productname.isEmpty() ) { m_aInfo = aInstallInfo; nIndex = i; break; } ++i; - ++rIter; } SAL_INFO( "desktop.migration", " preferred migration is from product '" << m_aInfo.productname << "'"); @@ -571,23 +569,20 @@ strings_vr MigrationImpl::applyPatterns(const strings_v& vSet, const strings_v& { using namespace utl; strings_vr vrResult(new strings_v); - strings_v::const_iterator i_set; - strings_v::const_iterator i_pat = vPatterns.begin(); - while (i_pat != vPatterns.end()) { + for (auto const& pattern : vPatterns) + { // find matches for this pattern in input set // and copy them to the result - SearchParam param(*i_pat, SearchParam::SearchType::Regexp); + SearchParam param(pattern, SearchParam::SearchType::Regexp); TextSearch ts(param, LANGUAGE_DONTKNOW); - i_set = vSet.begin(); sal_Int32 start = 0; sal_Int32 end = 0; - while (i_set != vSet.end()) { - end = i_set->getLength(); - if (ts.SearchForward(*i_set, &start, &end)) - vrResult->push_back(*i_set); - ++i_set; + for (auto const& elem : vSet) + { + end = elem.getLength(); + if (ts.SearchForward(elem, &start, &end)) + vrResult->push_back(elem); } - ++i_pat; } return vrResult; } @@ -615,11 +610,10 @@ strings_vr MigrationImpl::getAllFiles(const OUString& baseURL) const } // recurse subfolders - strings_v::const_iterator i = vSubDirs.begin(); - while (i != vSubDirs.end()) { - vrSubResult = getAllFiles(*i); + for (auto const& subDir : vSubDirs) + { + vrSubResult = getAllFiles(subDir); vrResult->insert(vrResult->end(), vrSubResult->begin(), vrSubResult->end()); - ++i; } } return vrResult; @@ -655,13 +649,12 @@ strings_vr MigrationImpl::compileFileList() strings_vr vrFiles = getAllFiles(m_aInfo.userdata); // get a file list result for each migration step - migrations_v::const_iterator i_migr = m_vrMigrations->begin(); - while (i_migr != m_vrMigrations->end()) { - vrInclude = applyPatterns(*vrFiles, i_migr->includeFiles); - vrExclude = applyPatterns(*vrFiles, i_migr->excludeFiles); + for (auto const& rMigration : *m_vrMigrations) + { + vrInclude = applyPatterns(*vrFiles, rMigration.includeFiles); + vrExclude = applyPatterns(*vrFiles, rMigration.excludeFiles); strings_v sub(subtract(*vrInclude, *vrExclude)); vrResult->insert(vrResult->end(), sub.begin(), sub.end()); - ++i_migr; } return vrResult; } @@ -696,9 +689,9 @@ uno::Sequence< OUString > setToSeq(std::set< OUString > const & set) } uno::Sequence< OUString > seq(static_cast< sal_Int32 >(n)); sal_Int32 i = 0; - for (std::set< OUString >::const_iterator j(set.begin()); - j != set.end(); ++j) { - seq[i++] = *j; + for (auto const& elem : set) + { + seq[i++] = elem; } return seq; } @@ -734,8 +727,9 @@ void MigrationImpl::copyConfig() regFile.close(); } - for (Components::const_iterator i(comps.begin()); i != comps.end(); ++i) { - if (!i->second.includedPaths.empty()) { + for (auto const& comp : comps) + { + if (!comp.second.includedPaths.empty()) { if (!bRegistryModificationsXcuExists) { // shared registrymodifications.xcu does not exists // the configuration is split in many registry files @@ -744,13 +738,13 @@ void MigrationImpl::copyConfig() buf.append("/user/registry/data"); sal_Int32 n = 0; do { - OUString seg(i->first.getToken(0, '.', n)); + OUString seg(comp.first.getToken(0, '.', n)); OUString enc( rtl::Uri::encode( seg, rtl_UriCharClassPchar, rtl_UriEncodeStrict, RTL_TEXTENCODING_UTF8)); if (enc.isEmpty() && !seg.isEmpty()) { - SAL_INFO( "desktop.migration", "configuration migration component " << i->first << " ignored (cannot be encoded as file path)" ); + SAL_INFO( "desktop.migration", "configuration migration component " << comp.first << " ignored (cannot be encoded as file path)" ); goto next; } buf.append('/'); @@ -762,10 +756,10 @@ void MigrationImpl::copyConfig() configuration::Update::get( comphelper::getProcessComponentContext())-> insertModificationXcuFile( - regFilePath, setToSeq(i->second.includedPaths), - setToSeq(i->second.excludedPaths)); + regFilePath, setToSeq(comp.second.includedPaths), + setToSeq(comp.second.excludedPaths)); } else { - SAL_INFO( "desktop.migration", "configuration migration component " << i->first << " ignored (only excludes, no includes)" ); + SAL_INFO( "desktop.migration", "configuration migration component " << comp.first << " ignored (only excludes, no includes)" ); } next: ; @@ -803,16 +797,16 @@ uno::Reference< XNameAccess > MigrationImpl::getConfigAccess(const sal_Char* pPa void MigrationImpl::copyFiles() { - strings_v::const_iterator i_file = m_vrFileList->begin(); OUString localName; OUString destName; OUString userInstall; utl::Bootstrap::PathStatus aStatus; aStatus = utl::Bootstrap::locateUserInstallation(userInstall); if (aStatus == utl::Bootstrap::PATH_EXISTS) { - while (i_file != m_vrFileList->end()) { + for (auto const& rFile : *m_vrFileList) + { // remove installation prefix from file - localName = i_file->copy(m_aInfo.userdata.getLength()); + localName = rFile.copy(m_aInfo.userdata.getLength()); if (localName.endsWith( "/autocorr/acor_.dat")) { // Previous versions used an empty language tag for // LANGUAGE_DONTKNOW with the "[All]" autocorrection entry. @@ -825,11 +819,10 @@ void MigrationImpl::copyFiles() // check whether destination directory exists aURL.removeSegment(); _checkAndCreateDirectory(aURL); - FileBase::RC copyResult = File::copy(*i_file, destName); + FileBase::RC copyResult = File::copy(rFile, destName); if (copyResult != FileBase::E_None) { - SAL_WARN( "desktop", "Cannot copy " << *i_file << " to " << destName); + SAL_WARN( "desktop", "Cannot copy " << rFile << " to " << destName); } - ++i_file; } } else { OSL_FAIL("copyFiles: UserInstall does not exist"); @@ -851,22 +844,22 @@ void MigrationImpl::runServices() uno::Reference< XJob > xMigrationJob; uno::Reference< uno::XComponentContext > xContext(comphelper::getProcessComponentContext()); - migrations_v::const_iterator i_mig = m_vrMigrations->begin(); - while (i_mig != m_vrMigrations->end()) { - if( !i_mig->service.isEmpty()) { + for (auto const& rMigration : *m_vrMigrations) + { + if( !rMigration.service.isEmpty()) { try { // set black list for extension migration uno::Sequence< OUString > seqExtBlackList; - sal_uInt32 nSize = i_mig->excludeExtensions.size(); + sal_uInt32 nSize = rMigration.excludeExtensions.size(); if ( nSize > 0 ) seqExtBlackList = comphelper::arrayToSequence< OUString >( - &i_mig->excludeExtensions[0], nSize ); + &rMigration.excludeExtensions[0], nSize ); seqArguments[2] <<= NamedValue("ExtensionBlackList", uno::makeAny( seqExtBlackList )); xMigrationJob.set( - xContext->getServiceManager()->createInstanceWithArgumentsAndContext(i_mig->service, seqArguments, xContext), + xContext->getServiceManager()->createInstanceWithArgumentsAndContext(rMigration.service, seqArguments, xContext), uno::UNO_QUERY_THROW); xMigrationJob->execute(uno::Sequence< NamedValue >()); @@ -874,15 +867,14 @@ void MigrationImpl::runServices() } catch (const Exception& e) { SAL_WARN( "desktop", "Execution of migration service failed (Exception caught).\nService: " - << i_mig->service + << rMigration.service << "\nMessage: " << e); } catch (...) { SAL_WARN( "desktop", "Execution of migration service failed (Exception caught).\nService: " - << i_mig->service << "\nNo message available"); + << rMigration.service << "\nNo message available"); } } - ++i_mig; } } @@ -997,20 +989,19 @@ void MigrationImpl::compareOldAndNewConfig(const OUString& sParent, } } - std::vector< MigrationItem >::iterator it; - OUString sSibling; - for (it = vOldItems.begin(); it!=vOldItems.end(); ++it) { - std::vector< MigrationItem >::iterator pFound = std::find(vNewItems.begin(), vNewItems.end(), *it); - if (pFound != vNewItems.end() && it->m_xPopupMenu.is()) { + for (auto const& oldItem : vOldItems) + { + std::vector< MigrationItem >::iterator pFound = std::find(vNewItems.begin(), vNewItems.end(), oldItem); + if (pFound != vNewItems.end() && oldItem.m_xPopupMenu.is()) { OUString sName; if (!sParent.isEmpty()) - sName = sParent + MENU_SEPARATOR + it->m_sCommandURL; + sName = sParent + MENU_SEPARATOR + oldItem.m_sCommandURL; else - sName = it->m_sCommandURL; - compareOldAndNewConfig(sName, it->m_xPopupMenu, pFound->m_xPopupMenu, sResourceURL); + sName = oldItem.m_sCommandURL; + compareOldAndNewConfig(sName, oldItem.m_xPopupMenu, pFound->m_xPopupMenu, sResourceURL); } else if (pFound == vNewItems.end()) { - MigrationItem aMigrationItem(sParent, sSibling, it->m_sCommandURL, it->m_xPopupMenu); + MigrationItem aMigrationItem(sParent, sSibling, oldItem.m_sCommandURL, oldItem.m_xPopupMenu); if (m_aOldVersionItemsHashMap.find(sResourceURL)==m_aOldVersionItemsHashMap.end()) { std::vector< MigrationItem > vMigrationItems; m_aOldVersionItemsHashMap.emplace(sResourceURL, vMigrationItems); @@ -1021,7 +1012,7 @@ void MigrationImpl::compareOldAndNewConfig(const OUString& sParent, } } - sSibling = it->m_sCommandURL; + sSibling = oldItem.m_sCommandURL; } } @@ -1034,11 +1025,11 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat if (pFound==m_aOldVersionItemsHashMap.end()) return; - std::vector< MigrationItem >::iterator it; - for (it=pFound->second.begin(); it!=pFound->second.end(); ++it) { + for (auto const& elem : pFound->second) + { uno::Reference< container::XIndexContainer > xTemp = xIndexContainer; - OUString sParentNodeName = it->m_sParentNodeName; + OUString sParentNodeName = elem.m_sParentNodeName; sal_Int32 nIndex = 0; do { OUString sToken = sParentNodeName.getToken(0, '|', nIndex).trim(); @@ -1075,13 +1066,13 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat uno::Sequence< beans::PropertyValue > aPropSeq(3); aPropSeq[0].Name = ITEM_DESCRIPTOR_COMMANDURL; - aPropSeq[0].Value <<= it->m_sCommandURL; + aPropSeq[0].Value <<= elem.m_sCommandURL; aPropSeq[1].Name = ITEM_DESCRIPTOR_LABEL; - aPropSeq[1].Value <<= retrieveLabelFromCommand(it->m_sCommandURL, sModuleIdentifier); + aPropSeq[1].Value <<= retrieveLabelFromCommand(elem.m_sCommandURL, sModuleIdentifier); aPropSeq[2].Name = ITEM_DESCRIPTOR_CONTAINER; - aPropSeq[2].Value <<= it->m_xPopupMenu; + aPropSeq[2].Value <<= elem.m_xPopupMenu; - if (it->m_sPrevSibling.isEmpty()) + if (elem.m_sPrevSibling.isEmpty()) xTemp->insertByIndex(0, uno::makeAny(aPropSeq)); else { sal_Int32 nCount = xTemp->getCount(); @@ -1097,7 +1088,7 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat } } - if (sCmd == it->m_sPrevSibling) + if (sCmd == elem.m_sPrevSibling) break; } diff --git a/desktop/source/migration/services/basicmigration.cxx b/desktop/source/migration/services/basicmigration.cxx index 1b407adba228..a3f266d4f88b 100644 --- a/desktop/source/migration/services/basicmigration.cxx +++ b/desktop/source/migration/services/basicmigration.cxx @@ -87,12 +87,10 @@ namespace migration } // iterate recursive over subfolders - TStringVector::const_iterator aI = aSubDirs.begin(); - while ( aI != aSubDirs.end() ) + for (auto const& subDir : aSubDirs) { - TStringVectorPtr aSubResult = getFiles( *aI ); + TStringVectorPtr aSubResult = getFiles(subDir); aResult->insert( aResult->end(), aSubResult->begin(), aSubResult->end() ); - ++aI; } } @@ -121,21 +119,19 @@ namespace migration { sTargetDir += sTargetUserBasic; TStringVectorPtr aFileList = getFiles( m_sSourceDir ); - TStringVector::const_iterator aI = aFileList->begin(); - while ( aI != aFileList->end() ) + for (auto const& elem : *aFileList) { - OUString sLocalName = aI->copy( m_sSourceDir.getLength() ); + OUString sLocalName = elem.copy( m_sSourceDir.getLength() ); OUString sTargetName = sTargetDir + sLocalName; INetURLObject aURL( sTargetName ); aURL.removeSegment(); checkAndCreateDirectory( aURL ); - ::osl::FileBase::RC aResult = ::osl::File::copy( *aI, sTargetName ); + ::osl::FileBase::RC aResult = ::osl::File::copy( elem, sTargetName ); if ( aResult != ::osl::FileBase::E_None ) { SAL_WARN( "desktop", "BasicMigration::copyFiles: cannot copy " - << *aI << " to " << sTargetName ); + << elem << " to " << sTargetName ); } - ++aI; } } else diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index b98b90bf559f..75bbf5864c45 100644 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -152,11 +152,11 @@ OO3ExtensionMigration::ScanResult OO3ExtensionMigration::scanExtensionFolder( co } } - TStringVector::const_iterator pIter = aDirectories.begin(); - while ( pIter != aDirectories.end() && aResult == SCANRESULT_NOTFOUND ) + for (auto const& directory : aDirectories) { - aResult = scanExtensionFolder( *pIter ); - ++pIter; + aResult = scanExtensionFolder(directory); + if (aResult != SCANRESULT_NOTFOUND) + break; } } return aResult; @@ -345,13 +345,11 @@ Any OO3ExtensionMigration::execute( const Sequence< beans::NamedValue >& ) sSourceDir += "/user/uno_packages/cache/uno_packages"; TStringVector aExtensionToMigrate; scanUserExtensions( sSourceDir, aExtensionToMigrate ); - if ( aExtensionToMigrate.size() > 0 ) + if (!aExtensionToMigrate.empty()) { - TStringVector::iterator pIter = aExtensionToMigrate.begin(); - while ( pIter != aExtensionToMigrate.end() ) + for (auto const& extensionToMigrate : aExtensionToMigrate) { - migrateExtension( *pIter ); - ++pIter; + migrateExtension(extensionToMigrate); } } } diff --git a/desktop/source/migration/services/wordbookmigration.cxx b/desktop/source/migration/services/wordbookmigration.cxx index 8730a8707b29..3a0f4bd1c165 100644 --- a/desktop/source/migration/services/wordbookmigration.cxx +++ b/desktop/source/migration/services/wordbookmigration.cxx @@ -80,12 +80,10 @@ namespace migration } // iterate recursive over subfolders - TStringVector::const_iterator aI = aSubDirs.begin(); - while ( aI != aSubDirs.end() ) + for (auto const& subDir : aSubDirs) { - TStringVectorPtr aSubResult = getFiles( *aI ); + TStringVectorPtr aSubResult = getFiles(subDir); aResult->insert( aResult->end(), aSubResult->begin(), aSubResult->end() ); - ++aI; } } @@ -152,24 +150,22 @@ bool IsUserWordbook( const OUString& rFile ) { sTargetDir += "/user/wordbook"; TStringVectorPtr aFileList = getFiles( m_sSourceDir ); - TStringVector::const_iterator aI = aFileList->begin(); - while ( aI != aFileList->end() ) + for (auto const& elem : *aFileList) { - if (IsUserWordbook(*aI) ) + if (IsUserWordbook(elem) ) { - OUString sSourceLocalName = aI->copy( m_sSourceDir.getLength() ); + OUString sSourceLocalName = elem.copy( m_sSourceDir.getLength() ); OUString sTargetName = sTargetDir + sSourceLocalName; INetURLObject aURL( sTargetName ); aURL.removeSegment(); checkAndCreateDirectory( aURL ); - ::osl::FileBase::RC aResult = ::osl::File::copy( *aI, sTargetName ); + ::osl::FileBase::RC aResult = ::osl::File::copy( elem, sTargetName ); if ( aResult != ::osl::FileBase::E_None ) { SAL_WARN( "desktop", "WordbookMigration::copyFiles: cannot copy " - << *aI << " to " << sTargetName); + << elem << " to " << sTargetName); } } - ++aI; } } else diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index aca6d5d0936a..70c8ac5249ee 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -316,12 +316,12 @@ void printf_packages( else { int index = 0; - for (auto i = allExtensions.begin(); i != allExtensions.end(); ++i, ++index) + for (auto const& extension : allExtensions) { if (vecUnaccepted[index]) - printf_unaccepted_licenses(*i); + printf_unaccepted_licenses(extension); else - printf_package( *i, xCmdEnv, level ); + printf_package( extension, xCmdEnv, level ); dp_misc::writeConsole("\n"); } } |