diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-05 22:29:17 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-05 23:58:20 +0100 |
commit | cbc58ebf14bd77a5f9297b7f2948952ed22460e7 (patch) | |
tree | 41a7966a0c92a6556de12bbd7a1914c6037801dd /desktop/source | |
parent | ba490001c2d82c1172854ca16d7099b19e29cb60 (diff) |
Use for-range loops in desktop (part1)
+ remove some useless typedef
+ some reindent
Change-Id: Ic1e445a7096b1663ca8cbc58c40bb8f7af0c70e1
Reviewed-on: https://gerrit.libreoffice.org/50787
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'desktop/source')
20 files changed, 175 insertions, 214 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 77152718287e..175a12304b26 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1090,10 +1090,9 @@ void restartOnMac(bool passArguments) { } } std::vector< char const * > argPtrs; - for (std::vector< OString >::iterator i(args.begin()); i != args.end(); - ++i) + for (auto const& elem : args) { - argPtrs.push_back(i->getStr()); + argPtrs.push_back(elem.getStr()); } argPtrs.push_back(nullptr); execv(execPath8.getStr(), const_cast< char ** >(&argPtrs[0])); diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 2e302be587a3..2363b36722f0 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -116,10 +116,9 @@ void Desktop::RegisterServices(Reference< XComponentContext > const & context) } std::vector< OUString > const & conDcp = rCmdLine.GetAccept(); - for (std::vector< OUString >::const_iterator i(conDcp.begin()); - i != conDcp.end(); ++i) + for (auto const& elem : conDcp) { - createAcceptor(*i); + createAcceptor(elem); } configureUcb(); diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 3317189531b0..e67f204866e9 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -62,10 +62,9 @@ std::vector< OUString > translateExternalUris( std::vector< OUString > const & input) { std::vector< OUString > t; - for (std::vector< OUString >::const_iterator i(input.begin()); - i != input.end(); ++i) + for (auto const& elem : input) { - t.push_back(translateExternalUris(*i)); + t.push_back(translateExternalUris(elem)); } return t; } diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 72aba80344ec..b70e3d5396c0 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -974,20 +974,18 @@ bool IpcThread::process(OString const & arguments, bool * waitProcessed) { // handle request for acceptor std::vector< OUString > const & accept = aCmdLineArgs->GetAccept(); - for (std::vector< OUString >::const_iterator i(accept.begin()); - i != accept.end(); ++i) + for (auto const& elem : accept) { ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::Type::Accept, *i); + ApplicationEvent::Type::Accept, elem); ImplPostForeignAppEvent( pAppEvent ); } // handle acceptor removal std::vector< OUString > const & unaccept = aCmdLineArgs->GetUnaccept(); - for (std::vector< OUString >::const_iterator i(unaccept.begin()); - i != unaccept.end(); ++i) + for (auto const& elem : unaccept) { ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::Type::Unaccept, *i); + ApplicationEvent::Type::Unaccept, elem); ImplPostForeignAppEvent( pAppEvent ); } @@ -1233,10 +1231,9 @@ static void AddToDispatchList( const OUString& aParam, const OUString& aFactory ) { - for (std::vector< OUString >::const_iterator i(aRequestList.begin()); - i != aRequestList.end(); ++i) + for (auto const& request : aRequestList) { - rDispatchList.push_back({nType, *i, cwdUrl, aParam, aFactory}); + rDispatchList.push_back({nType, request, cwdUrl, aParam, aFactory}); } } @@ -1303,10 +1300,9 @@ static void AddConversionsToDispatchList( if( !rImgOut.trim().isEmpty() ) aParam += "|" + aImgOut; - for (std::vector< OUString >::const_iterator i(rRequestList.begin()); - i != rRequestList.end(); ++i) + for (auto const& request : rRequestList) { - rDispatchList.push_back({nType, *i, cwdUrl, aParam, rFactory}); + rDispatchList.push_back({nType, request, cwdUrl, aParam, rFactory}); } } diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index 867b5f737329..e90cf3bd1991 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -478,11 +478,11 @@ update_info parse_response(const std::string& rResponse) aUpdateInfo.aUpdateFile = parse_update_file(aUpdateNode); std::vector<orcus::pstring> aLanguages = aLanguageNode.keys(); - for (auto itr = aLanguages.begin(), itrEnd = aLanguages.end(); itr != itrEnd; ++itr) + for (auto const& language : aLanguages) { language_file aLanguageFile; - auto aLangEntry = aLanguageNode.child(*itr); - aLanguageFile.aLangCode = toOUString(itr->str()); + auto aLangEntry = aLanguageNode.child(language); + aLanguageFile.aLangCode = toOUString(language.str()); aLanguageFile.aUpdateFile = parse_update_file(aLangEntry); aUpdateInfo.aLanguageFiles.push_back(aLanguageFile); } diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx index 2e5a047cd864..83074def69eb 100644 --- a/desktop/source/deployment/dp_persmap.cxx +++ b/desktop/source/deployment/dp_persmap.cxx @@ -231,16 +231,16 @@ void PersistentMap::flush() m_MapFile.write( PmapMagic, sizeof(PmapMagic), nBytesWritten); // write key value pairs - t_string2string_map::const_iterator it = m_entries.begin(); - for(; it != m_entries.end(); ++it) { + for (auto const& entry : m_entries) + { // write line for key - const OString aKeyString = encodeString( (*it).first); + const OString aKeyString = encodeString( entry.first); const sal_Int32 nKeyLen = aKeyString.getLength(); m_MapFile.write( aKeyString.getStr(), nKeyLen, nBytesWritten); OSL_ASSERT( nKeyLen == static_cast<sal_Int32>(nBytesWritten)); m_MapFile.write( "\n", 1, nBytesWritten); // write line for value - const OString& rValString = encodeString( (*it).second); + const OString& rValString = encodeString( entry.second); const sal_Int32 nValLen = rValString.getLength(); m_MapFile.write( rValString.getStr(), nValLen, nBytesWritten); OSL_ASSERT( nValLen == static_cast<sal_Int32>(nBytesWritten)); diff --git a/desktop/source/deployment/gui/dp_gui_dependencydialog.cxx b/desktop/source/deployment/gui/dp_gui_dependencydialog.cxx index 1dcdafd73bc9..1ddda6e43794 100644 --- a/desktop/source/deployment/gui/dp_gui_dependencydialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_dependencydialog.cxx @@ -42,10 +42,9 @@ DependencyDialog::DependencyDialog( set_height_request(200); SetMinOutputSizePixel(GetOutputSizePixel()); m_list->SetReadOnly(); - for (std::vector< OUString >::const_iterator i(dependencies.begin()); - i != dependencies.end(); ++i) + for (auto const& dependency : dependencies) { - m_list->InsertEntry(*i); + m_list->InsertEntry(dependency); } } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index 9888958807b0..1364ab48a94c 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -713,13 +713,14 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() // All files at top: xFilePicker->appendFilter( StrAllFiles::get(), "*.*" ); // then supported ones: - t_string2string::const_iterator iPos( title2filter.begin() ); - const t_string2string::const_iterator iEnd( title2filter.end() ); - for ( ; iPos != iEnd; ++iPos ) { - try { - xFilePicker->appendFilter( iPos->first, iPos->second ); + for (auto const& elem : title2filter) + { + try + { + xFilePicker->appendFilter( elem.first, elem.second ); } - catch (const lang::IllegalArgumentException & exc) { + catch (const lang::IllegalArgumentException & exc) + { SAL_WARN( "desktop", exc ); } } diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 331acea1e170..ac0ec58b6c40 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -906,14 +906,13 @@ void ExtensionCmdQueue::Thread::_checkForUpdates( // open the install dialog. std::vector< UpdateData > dataDownload; int countWebsiteDownload = 0; - typedef std::vector< dp_gui::UpdateData >::const_iterator cit; - for ( cit i = vData.begin(); i < vData.end(); ++i ) + for (auto const& data : vData) { - if ( !i->sWebsiteURL.isEmpty() ) + if ( !data.sWebsiteURL.isEmpty() ) countWebsiteDownload ++; else - dataDownload.push_back( *i ); + dataDownload.push_back(data); } short nDialogResult = RET_OK; @@ -928,10 +927,10 @@ void ExtensionCmdQueue::Thread::_checkForUpdates( //Now start the webbrowser and navigate to the websites where we get the updates if ( RET_OK == nDialogResult ) { - for ( cit i = vData.begin(); i < vData.end(); ++i ) + for (auto const& data : vData) { - if ( m_pDialogHelper && ( !i->sWebsiteURL.isEmpty() ) ) - m_pDialogHelper->openWebBrowser( i->sWebsiteURL, m_pDialogHelper->getWindow()->GetText() ); + if ( m_pDialogHelper && ( !data.sWebsiteURL.isEmpty() ) ) + m_pDialogHelper->openWebBrowser( data.sWebsiteURL, m_pDialogHelper->getWindow()->GetText() ); } } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 5c57b4f9d3d0..fd0d98fc049b 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -243,12 +243,10 @@ void ExtensionBox_Impl::dispose() m_bInDelete = true; - typedef std::vector< TEntry_Impl >::iterator ITER; - - for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) + for (auto const& entry : m_vEntries) { - (*iIndex)->m_pPublisher.disposeAndClear(); - (*iIndex)->m_xPackage->removeEventListener( m_xRemoveListener.get() ); + entry->m_pPublisher.disposeAndClear(); + entry->m_xPackage->removeEventListener( m_xRemoveListener.get() ); } m_vEntries.clear(); @@ -351,11 +349,9 @@ void ExtensionBox_Impl::DeleteRemoved() if ( ! m_vRemovedEntries.empty() ) { - typedef std::vector< TEntry_Impl >::iterator ITER; - - for ( ITER iIndex = m_vRemovedEntries.begin(); iIndex < m_vRemovedEntries.end(); ++iIndex ) + for (auto const& removedEntry : m_vRemovedEntries) { - (*iIndex)->m_pPublisher.disposeAndClear(); + removedEntry->m_pPublisher.disposeAndClear(); } m_vRemovedEntries.clear(); @@ -688,12 +684,11 @@ void ExtensionBox_Impl::Paint(vcl::RenderContext& rRenderContext, const tools::R const ::osl::MutexGuard aGuard( m_entriesMutex ); - typedef std::vector< TEntry_Impl >::iterator ITER; - for (ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex) + for (auto const& entry : m_vEntries) { - aSize.setHeight( (*iIndex)->m_bActive ? m_nActiveHeight : m_nStdHeight ); + aSize.setHeight( entry->m_bActive ? m_nActiveHeight : m_nStdHeight ); tools::Rectangle aEntryRect( aStart, aSize ); - DrawRow(rRenderContext, aEntryRect, *iIndex); + DrawRow(rRenderContext, aEntryRect, entry); aStart.AdjustY(aSize.Height() ); } } @@ -887,8 +882,7 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const long nSta void ExtensionBox_Impl::cleanVecListenerAdded() { - typedef std::vector<uno::WeakReference<deployment::XPackage> >::iterator IT; - IT i = m_vListenerAdded.begin(); + auto i = m_vListenerAdded.begin(); while( i != m_vListenerAdded.end()) { const uno::Reference<deployment::XPackage> hardRef(*i); @@ -967,25 +961,24 @@ void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > & void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage > &xPackage ) { - typedef std::vector< TEntry_Impl >::iterator ITER; - for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) + for (auto const& entry : m_vEntries) { - if ( (*iIndex)->m_xPackage == xPackage ) + if ( entry->m_xPackage == xPackage ) { PackageState eState = TheExtensionManager::getPackageState( xPackage ); - (*iIndex)->m_bHasOptions = m_pManager->supportsOptions( xPackage ); - (*iIndex)->m_eState = eState; - (*iIndex)->m_sTitle = xPackage->getDisplayName(); - (*iIndex)->m_sVersion = xPackage->getVersion(); - (*iIndex)->m_sDescription = xPackage->getDescription(); + entry->m_bHasOptions = m_pManager->supportsOptions( xPackage ); + entry->m_eState = eState; + entry->m_sTitle = xPackage->getDisplayName(); + entry->m_sVersion = xPackage->getVersion(); + entry->m_sDescription = xPackage->getDescription(); if ( eState == REGISTERED ) - (*iIndex)->m_bMissingLic = false; + entry->m_bMissingLic = false; if ( eState == AMBIGUOUS ) - (*iIndex)->m_sErrorText = DpResId( RID_STR_ERROR_UNKNOWN_STATUS ); - else if ( ! (*iIndex)->m_bMissingLic ) - (*iIndex)->m_sErrorText.clear(); + entry->m_sErrorText = DpResId( RID_STR_ERROR_UNKNOWN_STATUS ); + else if ( ! entry->m_bMissingLic ) + entry->m_sErrorText.clear(); if ( IsReallyVisible() ) Invalidate(); @@ -1007,9 +1000,7 @@ void ExtensionBox_Impl::removeEntry( const uno::Reference< deployment::XPackage { ::osl::ClearableMutexGuard aGuard( m_entriesMutex ); - typedef std::vector< TEntry_Impl >::iterator ITER; - - for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) + for ( auto iIndex = m_vEntries.begin(); iIndex != m_vEntries.end(); ++iIndex ) { if ( (*iIndex)->m_xPackage == xPackage ) { @@ -1065,14 +1056,12 @@ void ExtensionBox_Impl::RemoveUnlocked() ::osl::ClearableMutexGuard aGuard( m_entriesMutex ); - typedef std::vector< TEntry_Impl >::iterator ITER; - - for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) + for (auto const& entry : m_vEntries) { - if ( !(*iIndex)->m_bLocked ) + if ( !entry->m_bLocked ) { bAllRemoved = false; - uno::Reference< deployment::XPackage> xPackage = (*iIndex)->m_xPackage; + uno::Reference< deployment::XPackage> xPackage = entry->m_xPackage; aGuard.clear(); removeEntry( xPackage ); break; @@ -1085,11 +1074,10 @@ void ExtensionBox_Impl::RemoveUnlocked() void ExtensionBox_Impl::prepareChecking() { m_bInCheckMode = true; - typedef std::vector< TEntry_Impl >::iterator ITER; - for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) + for (auto const& entry : m_vEntries) { - (*iIndex)->m_bChecked = false; - (*iIndex)->m_bNew = false; + entry->m_bChecked = false; + entry->m_bNew = false; } } @@ -1102,9 +1090,8 @@ void ExtensionBox_Impl::checkEntries() bool bNeedsUpdate = false; ::osl::ClearableMutexGuard guard(m_entriesMutex); - typedef std::vector< TEntry_Impl >::iterator ITER; - ITER iIndex = m_vEntries.begin(); - while ( iIndex < m_vEntries.end() ) + auto iIndex = m_vEntries.begin(); + while ( iIndex != m_vEntries.end() ) { if ( !(*iIndex)->m_bChecked ) { @@ -1136,8 +1123,7 @@ void ExtensionBox_Impl::checkEntries() m_bHasActive = false; } m_vRemovedEntries.push_back( *iIndex ); - m_vEntries.erase( iIndex ); - iIndex = m_vEntries.begin() + nPos; + iIndex = m_vEntries.erase( iIndex ); } } else diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 0760bf339efc..0e12991f1ee8 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -278,14 +278,12 @@ void UpdateDialog::Thread::execute() dp_misc::UpdateInfoMap updateInfoMap = dp_misc::getOnlineUpdateInfos( m_context, extMgr, m_updateInformation, &m_vExtensionList, errors); - typedef std::vector<std::pair<uno::Reference<deployment::XPackage>, - uno::Any> >::const_iterator ITERROR; - for (ITERROR ite = errors.begin(); ite != errors.end(); ++ite ) - handleSpecificError(ite->first, ite->second); + for (auto const& elem : errors) + handleSpecificError(elem.first, elem.second); - for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); ++i) + for (auto const& updateInfo : updateInfoMap) { - dp_misc::UpdateInfo const & info = i->second; + dp_misc::UpdateInfo const & info = updateInfo.second; UpdateData updateData(info.extension); DisabledUpdate disableUpdate; //determine if online updates meet the requirements @@ -547,13 +545,13 @@ void UpdateDialog::dispose() { storeIgnoredUpdates(); - for ( std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() ); i != m_ListboxEntries.end(); ++i ) + for (auto const& listboxEntry : m_ListboxEntries) { - delete *i; + delete listboxEntry; } - for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + for (auto const& ignoredUpdate : m_ignoredUpdates) { - delete *i; + delete ignoredUpdate; } m_pUpdates.disposeAndClear(); m_pchecking.clear(); @@ -993,20 +991,20 @@ void UpdateDialog::storeIgnoredUpdates() uno::Reference< container::XNameContainer > xNameContainer( xConfig->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationUpdateAccess", args ), uno::UNO_QUERY_THROW ); - for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + for (auto const& ignoredUpdate : m_ignoredUpdates) { - if ( xNameContainer->hasByName( (*i)->sExtensionID ) ) + if ( xNameContainer->hasByName( ignoredUpdate->sExtensionID ) ) { - if ( (*i)->bRemoved ) - xNameContainer->removeByName( (*i)->sExtensionID ); + if ( ignoredUpdate->bRemoved ) + xNameContainer->removeByName( ignoredUpdate->sExtensionID ); else - uno::Reference< beans::XPropertySet >( xNameContainer->getByName( (*i)->sExtensionID ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( (*i)->sVersion ) ); + uno::Reference< beans::XPropertySet >( xNameContainer->getByName( ignoredUpdate->sExtensionID ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( ignoredUpdate->sVersion ) ); } - else if ( ! (*i)->bRemoved ) + else if ( ! ignoredUpdate->bRemoved ) { uno::Reference< beans::XPropertySet > elem( uno::Reference< lang::XSingleServiceFactory >( xNameContainer, uno::UNO_QUERY_THROW )->createInstance(), uno::UNO_QUERY_THROW ); - elem->setPropertyValue( PROPERTY_VERSION, uno::Any( (*i)->sVersion ) ); - xNameContainer->insertByName( (*i)->sExtensionID, uno::Any( elem ) ); + elem->setPropertyValue( PROPERTY_VERSION, uno::Any( ignoredUpdate->sVersion ) ); + xNameContainer->insertByName( ignoredUpdate->sExtensionID, uno::Any( elem ) ); } } @@ -1044,17 +1042,17 @@ bool UpdateDialog::isIgnoredUpdate( UpdateDialog::Index * index ) aVersion = aInfoset.getVersion(); } - for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + for (auto const& ignoredUpdate : m_ignoredUpdates) { - if ( (*i)->sExtensionID == aExtensionID ) + if ( ignoredUpdate->sExtensionID == aExtensionID ) { - if ( ( !(*i)->sVersion.isEmpty() ) || ( (*i)->sVersion == aVersion ) ) + if ( ( !ignoredUpdate->sVersion.isEmpty() ) || ( ignoredUpdate->sVersion == aVersion ) ) { bIsIgnored = true; index->m_bIgnored = true; } else // when we find another update of an ignored version, we will remove the old one to keep the ignored list small - (*i)->bRemoved = true; + ignoredUpdate->bRemoved = true; break; } } @@ -1092,12 +1090,12 @@ void UpdateDialog::setIgnoredUpdate( UpdateDialog::Index const *pIndex, bool bIg if ( !aExtensionID.isEmpty() ) { bool bFound = false; - for ( std::vector< UpdateDialog::IgnoredUpdate* >::iterator i( m_ignoredUpdates.begin() ); i != m_ignoredUpdates.end(); ++i ) + for (auto const& ignoredUpdate : m_ignoredUpdates) { - if ( (*i)->sExtensionID == aExtensionID ) + if ( ignoredUpdate->sExtensionID == aExtensionID ) { - (*i)->sVersion = aVersion; - (*i)->bRemoved = !bIgnore; + ignoredUpdate->sVersion = aVersion; + ignoredUpdate->bRemoved = !bIgnore; bFound = true; break; } @@ -1218,11 +1216,10 @@ IMPL_LINK_NOARG(UpdateDialog, allHandler, CheckBox&, void) m_pDescription->Enable(); m_pDescriptions->Enable(); - for (std::vector< UpdateDialog::Index* >::iterator i( m_ListboxEntries.begin() ); - i != m_ListboxEntries.end(); ++i ) + for (auto const& listboxEntry : m_ListboxEntries) { - if ( (*i)->m_bIgnored || ( (*i)->m_eKind != ENABLED_UPDATE ) ) - insertItem( (*i), SvLBoxButtonKind::DisabledCheckbox ); + if ( listboxEntry->m_bIgnored || ( listboxEntry->m_eKind != ENABLED_UPDATE ) ) + insertItem( listboxEntry, SvLBoxButtonKind::DisabledCheckbox ); } } else @@ -1255,10 +1252,9 @@ IMPL_LINK_NOARG(UpdateDialog, okHandler, Button*, void) { //If users are going to update a shared extension then we need //to warn them - typedef std::vector<UpdateData>::const_iterator CIT; - for (CIT i = m_enabledUpdates.begin(); i < m_enabledUpdates.end(); ++i) + for (auto const& enableUpdate : m_enabledUpdates) { - OSL_ASSERT(i->aInstalledPackage.is()); + OSL_ASSERT(enableUpdate.aInstalledPackage.is()); //If the user has no write access to the shared folder then the update //for a shared extension is disable, that is it cannot be in m_enabledUpdates } diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index ede28929eddb..481beee3c729 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -350,16 +350,13 @@ void UpdateInstallDialog::Thread::downloadExtensions() sal_uInt16 count = 0; - typedef std::vector<UpdateData>::iterator It; - for (It i = m_aVecUpdateData.begin(); i != m_aVecUpdateData.end(); ++i) + for (auto & updateData : m_aVecUpdateData) { - UpdateData & curData = *i; - - if (!curData.aUpdateInfo.is() || curData.aUpdateSource.is()) + if (!updateData.aUpdateInfo.is() || updateData.aUpdateSource.is()) continue; //We assume that m_aVecUpdateData contains only information about extensions which //can be downloaded directly. - OSL_ASSERT(curData.sWebsiteURL.isEmpty()); + OSL_ASSERT(updateData.sWebsiteURL.isEmpty()); //update the name of the extension which is to be downloaded { @@ -367,12 +364,12 @@ void UpdateInstallDialog::Thread::downloadExtensions() if (m_stop) { return; } - m_dialog.m_pFt_extension_name->SetText(curData.aInstalledPackage->getDisplayName()); + m_dialog.m_pFt_extension_name->SetText(updateData.aInstalledPackage->getDisplayName()); sal_uInt16 prog = (sal::static_int_cast<sal_uInt16>(100) * ++count) / sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size()); m_dialog.m_pStatusbar->SetValue(prog); } - dp_misc::DescriptionInfoset info(m_xComponentContext, curData.aUpdateInfo); + dp_misc::DescriptionInfoset info(m_xComponentContext, updateData.aUpdateInfo); //remember occurring exceptions in case we need to print out error information std::vector< std::pair<OUString, cssu::Exception> > vecExceptions; cssu::Sequence<OUString> seqDownloadURLs = info.getUpdateDownloadUrls(); @@ -382,8 +379,8 @@ void UpdateInstallDialog::Thread::downloadExtensions() try { OSL_ENSURE(!seqDownloadURLs[j].isEmpty(), "Download URL is empty!"); - bool bCancelled = download(seqDownloadURLs[j], curData); - if (bCancelled || !curData.sLocalURL.isEmpty()) + bool bCancelled = download(seqDownloadURLs[j], updateData); + if (bCancelled || !updateData.sLocalURL.isEmpty()) break; } catch ( cssu::Exception & e ) @@ -401,21 +398,22 @@ void UpdateInstallDialog::Thread::downloadExtensions() if (m_stop) { return; } - if (curData.sLocalURL.isEmpty()) + if (updateData.sLocalURL.isEmpty()) { //Construct a string of all messages contained in the exceptions plus the respective download URLs OUStringBuffer buf(256); - typedef std::vector< std::pair<OUString, cssu::Exception > >::const_iterator CIT; - for (CIT j = vecExceptions.begin(); j != vecExceptions.end(); ++j) + size_t nPos = 0; + for (auto const& elem : vecExceptions) { - if (j != vecExceptions.begin()) + if (nPos) buf.append("\n"); buf.append("Could not download "); - buf.append(j->first); + buf.append(elem.first); buf.append(". "); - buf.append(j->second.Message); + buf.append(elem.second.Message); + ++nPos; } - m_dialog.setError(UpdateInstallDialog::ERROR_DOWNLOAD, curData.aInstalledPackage->getDisplayName(), + m_dialog.setError(UpdateInstallDialog::ERROR_DOWNLOAD, updateData.aInstalledPackage->getDisplayName(), buf.makeStringAndClear()); } } @@ -445,8 +443,7 @@ void UpdateInstallDialog::Thread::installExtensions() } sal_uInt16 count = 0; - typedef std::vector<UpdateData>::iterator It; - for (It i = m_aVecUpdateData.begin(); i != m_aVecUpdateData.end(); ++i, ++count) + for (auto const& updateData : m_aVecUpdateData) { //update the name of the extension which is to be installed { @@ -460,17 +457,16 @@ void UpdateInstallDialog::Thread::installExtensions() (sal::static_int_cast<sal_uInt16>(100) * count) / sal::static_int_cast<sal_uInt16>(m_aVecUpdateData.size())); } - m_dialog.m_pFt_extension_name->SetText(i->aInstalledPackage->getDisplayName()); + m_dialog.m_pFt_extension_name->SetText(updateData.aInstalledPackage->getDisplayName()); } bool bError = false; bool bLicenseDeclined = false; cssu::Reference<css::deployment::XPackage> xExtension; - UpdateData & curData = *i; cssu::Exception exc; try { cssu::Reference< css::task::XAbortChannel > xAbortChannel( - curData.aInstalledPackage->createAbortChannel() ); + updateData.aInstalledPackage->createAbortChannel() ); { SolarMutexGuard g; if (m_stop) { @@ -478,33 +474,33 @@ void UpdateInstallDialog::Thread::installExtensions() } m_abort = xAbortChannel; } - if (!curData.aUpdateSource.is() && !curData.sLocalURL.isEmpty()) + if (!updateData.aUpdateSource.is() && !updateData.sLocalURL.isEmpty()) { css::beans::NamedValue prop("EXTENSION_UPDATE", css::uno::makeAny(OUString("1"))); - if (!curData.bIsShared) + if (!updateData.bIsShared) xExtension = m_dialog.getExtensionManager()->addExtension( - curData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1), + updateData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1), "user", xAbortChannel, m_updateCmdEnv.get()); else xExtension = m_dialog.getExtensionManager()->addExtension( - curData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1), + updateData.sLocalURL, css::uno::Sequence<css::beans::NamedValue>(&prop, 1), "shared", xAbortChannel, m_updateCmdEnv.get()); } - else if (curData.aUpdateSource.is()) + else if (updateData.aUpdateSource.is()) { - OSL_ASSERT(curData.aUpdateSource.is()); + OSL_ASSERT(updateData.aUpdateSource.is()); //I am not sure if we should obtain the install properties and pass them into //add extension. Currently it contains only "SUPPRESS_LICENSE". So it could happen //that a license is displayed when updating from the shared repository, although the //shared extension was installed using "SUPPRESS_LICENSE". css::beans::NamedValue prop("EXTENSION_UPDATE", css::uno::makeAny(OUString("1"))); - if (!curData.bIsShared) + if (!updateData.bIsShared) xExtension = m_dialog.getExtensionManager()->addExtension( - curData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1), + updateData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1), "user", xAbortChannel, m_updateCmdEnv.get()); else xExtension = m_dialog.getExtensionManager()->addExtension( - curData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1), + updateData.aUpdateSource->getURL(), css::uno::Sequence<css::beans::NamedValue>(&prop, 1), "shared", xAbortChannel, m_updateCmdEnv.get()); } } @@ -533,7 +529,7 @@ void UpdateInstallDialog::Thread::installExtensions() return; } m_dialog.setError(UpdateInstallDialog::ERROR_LICENSE_DECLINED, - curData.aInstalledPackage->getDisplayName(), OUString()); + updateData.aInstalledPackage->getDisplayName(), OUString()); } else if (!xExtension.is() || bError) { @@ -542,8 +538,9 @@ void UpdateInstallDialog::Thread::installExtensions() return; } m_dialog.setError(UpdateInstallDialog::ERROR_INSTALLATION, - curData.aInstalledPackage->getDisplayName(), exc.Message); + updateData.aInstalledPackage->getDisplayName(), exc.Message); } + ++count; } { SolarMutexGuard g; diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index 2f7993b9287a..f520e3301ea0 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -166,21 +166,20 @@ ActivePackages::Entries ActivePackages::getEntries() const { Entries es; #if HAVE_FEATURE_EXTENSIONS ::dp_misc::t_string2string_map m(m_map.getEntries()); - for (::dp_misc::t_string2string_map::const_iterator i(m.begin()); - i != m.end(); ++i) + for (auto const& elem : m) { - if (!i->first.isEmpty() && i->first[0] == separator) { + if (!elem.first.isEmpty() && elem.first[0] == separator) { es.emplace_back( OUString( - i->first.getStr() + 1, i->first.getLength() - 1, + elem.first.getStr() + 1, elem.first.getLength() - 1, RTL_TEXTENCODING_UTF8), - decodeNewData(i->second)); + decodeNewData(elem.second)); } else { OUString fn( - OStringToOUString(i->first, RTL_TEXTENCODING_UTF8)); + OStringToOUString(elem.first, RTL_TEXTENCODING_UTF8)); es.emplace_back( ::dp_misc::generateLegacyIdentifier(fn), - decodeOldData(fn, i->second)); + decodeOldData(fn, elem.second)); } } #else diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index f9f2eb7fa110..195fafa4a183 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -89,12 +89,11 @@ OUString CompIdentifiers::getName(std::vector<Reference<css::deployment::XPackag OSL_ASSERT(a.size() == 3); //get the first non-null reference Reference<css::deployment::XPackage> extension; - std::vector<Reference<css::deployment::XPackage> >::const_iterator it = a.begin(); - for (; it != a.end(); ++it) + for (auto const& elem : a) { - if (it->is()) + if (elem.is()) { - extension = *it; + extension = elem; break; } } @@ -1104,20 +1103,17 @@ uno::Sequence< uno::Sequence<Reference<css::deployment::XPackage> > > //copy the values of the map to a vector for sorting std::vector< std::vector<Reference<css::deployment::XPackage> > > vecExtensions; - id2extensions::const_iterator mapIt = mapExt.begin(); - for (;mapIt != mapExt.end(); ++mapIt) - vecExtensions.push_back(mapIt->second); + for (auto const& elem : mapExt) + vecExtensions.push_back(elem.second); //sort the element according to the identifier std::sort(vecExtensions.begin(), vecExtensions.end(), CompIdentifiers()); - std::vector< std::vector<Reference<css::deployment::XPackage> > >::const_iterator - citVecVec = vecExtensions.begin(); sal_Int32 j = 0; uno::Sequence< uno::Sequence<Reference<css::deployment::XPackage> > > seqSeq(vecExtensions.size()); - for (;citVecVec != vecExtensions.end(); ++citVecVec, j++) + for (auto const& elem : vecExtensions) { - seqSeq[j] = comphelper::containerToSequence(*citVecVec); + seqSeq[j++] = comphelper::containerToSequence(elem); } return seqSeq; diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx index 81102f03fe53..c95fc229973d 100644 --- a/desktop/source/deployment/manager/dp_informationprovider.cxx +++ b/desktop/source/deployment/manager/dp_informationprovider.cxx @@ -191,9 +191,9 @@ PackageInformationProvider::isUpdateAvailable( const OUString& _sExtensionId ) } int nCount = 0; - for (dp_misc::UpdateInfoMap::iterator i(updateInfoMap.begin()); i != updateInfoMap.end(); ++i) + for (auto const& updateInfo : updateInfoMap) { - dp_misc::UpdateInfo const & info = i->second; + dp_misc::UpdateInfo const & info = updateInfo.second; OUString sOnlineVersion; if (info.info.is()) @@ -250,7 +250,7 @@ PackageInformationProvider::isUpdateAvailable( const OUString& _sExtensionId ) { OUString aNewEntry[2]; - aNewEntry[0] = i->first; + aNewEntry[0] = updateInfo.first; aNewEntry[1] = updateVersion; aList.realloc( ++nCount ); aList[ nCount-1 ] = ::uno::Sequence< OUString >( aNewEntry, 2 ); diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index c012750573d3..b46bc24ff197 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -1011,16 +1011,14 @@ PackageManagerImpl::getDeployedPackages_( { std::vector< Reference<deployment::XPackage> > packages; ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - ActivePackages::Entries::const_iterator iPos( id2temp.begin() ); - ActivePackages::Entries::const_iterator const iEnd( id2temp.end() ); - for ( ; iPos != iEnd; ++iPos ) + for (auto const& elem : id2temp) { - if (! (iPos->second.failedPrerequisites == "0")) + if (! (elem.second.failedPrerequisites == "0")) continue; try { packages.push_back( getDeployedPackage_( - iPos->first, iPos->second, xCmdEnv, + elem.first, elem.second, xCmdEnv, true /* xxx todo: think of GUI: ignore other platforms than the current one */ ) ); } @@ -1195,15 +1193,15 @@ bool PackageManagerImpl::synchronizeRemovedExtensions( bool bShared = (m_context == "shared"); - for (auto i = id2temp.begin(); i != id2temp.end(); ++i) + for (auto const& elem : id2temp) { try { //Get the URL to the extensions folder, first make the url for the //shared repository including the temporary name - OUString url = makeURL(m_activePackages, i->second.temporaryName); + OUString url = makeURL(m_activePackages, elem.second.temporaryName); if (bShared) - url = makeURLAppendSysPathSegment( url + "_", i->second.fileName); + url = makeURLAppendSysPathSegment( url + "_", elem.second.fileName); bool bRemoved = false; //Check if the URL to the extension is still the same @@ -1227,7 +1225,7 @@ bool PackageManagerImpl::synchronizeRemovedExtensions( if (create_ucb_content( &contentRemoved, m_activePackages_expanded + "/" + - i->second.temporaryName + "removed", + elem.second.temporaryName + "removed", Reference<XCommandEnvironment>(), false)) { bRemoved = true; @@ -1244,8 +1242,8 @@ bool PackageManagerImpl::synchronizeRemovedExtensions( "must have an identifier and a version"); if (infoset.hasDescription() && infoset.getIdentifier() && - ( i->first != *(infoset.getIdentifier()) - || i->second.version != infoset.getVersion())) + ( elem.first != *(infoset.getIdentifier()) + || elem.second.version != infoset.getVersion())) { bRemoved = true; } @@ -1254,7 +1252,7 @@ bool PackageManagerImpl::synchronizeRemovedExtensions( if (bRemoved) { Reference<deployment::XPackage> xPackage = m_xRegistry->bindPackage( - url, i->second.mediaType, true, i->first, xCmdEnv ); + url, elem.second.mediaType, true, elem.first, xCmdEnv ); OSL_ASSERT(xPackage.is()); //Even if the files are removed, we must get the object. xPackage->revokePackage(true, xAbortChannel, xCmdEnv); removePackage(xPackage->getIdentifier().Value, xPackage->getName(), @@ -1434,13 +1432,12 @@ Sequence< Reference<deployment::XPackage> > PackageManagerImpl::getExtensionsWit // clean up activation layer, scan for zombie temp dirs: ActivePackages::Entries id2temp( m_activePackagesDB->getEntries() ); - ActivePackages::Entries::const_iterator i = id2temp.begin(); bool bShared = (m_context == "shared"); - for (; i != id2temp.end(); ++i ) + for (auto const& elem : id2temp) { //Get the database entry - ActivePackages::Data const & dbData = i->second; + ActivePackages::Data const & dbData = elem.second; sal_Int32 failedPrereq = dbData.failedPrerequisites.toInt32(); //If the installation failed for other reason then the license then we //ignore it. @@ -1448,9 +1445,9 @@ Sequence< Reference<deployment::XPackage> > PackageManagerImpl::getExtensionsWit continue; //Prepare the URL to the extension - OUString url = makeURL(m_activePackages, i->second.temporaryName); + OUString url = makeURL(m_activePackages, elem.second.temporaryName); if (bShared) - url = makeURLAppendSysPathSegment( url + "_", i->second.fileName); + url = makeURLAppendSysPathSegment( url + "_", elem.second.fileName); Reference<deployment::XPackage> p = m_xRegistry->bindPackage( url, OUString(), false, OUString(), xCmdEnv ); diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx index b04f751a69ff..5b7c7e11a3f0 100644 --- a/desktop/source/deployment/manager/dp_managerfac.cxx +++ b/desktop/source/deployment/manager/dp_managerfac.cxx @@ -96,10 +96,8 @@ void PackageManagerFactoryImpl::disposing() { // dispose all managers: ::osl::MutexGuard guard( getMutex() ); - t_string2weakref::const_iterator iPos( m_managers.begin() ); - t_string2weakref::const_iterator const iEnd( m_managers.end() ); - for ( ; iPos != iEnd; ++iPos ) - try_dispose( iPos->second ); + for (auto const& elem : m_managers) + try_dispose( elem.second ); m_managers = t_string2weakref(); // the below are already disposed: m_xUserMgr.clear(); diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 1f0aa57443ec..62e721e028e0 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -692,9 +692,9 @@ DescriptionInfoset::getLocalizedChild( const OUString & sParent) const { // Already tried full tag, continue with first fallback. const std::vector< OUString > aFallbacks( getOfficeLanguageTag().getFallbackStrings( false)); - for (std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it) + for (auto const& fallback : aFallbacks) { - nodeMatch = matchLanguageTag(xParent, *it); + nodeMatch = matchLanguageTag(xParent, fallback); if (nodeMatch.is()) break; } diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx index e2785fb1b922..fc11d261baef 100644 --- a/desktop/source/deployment/misc/dp_update.cxx +++ b/desktop/source/deployment/misc/dp_update.cxx @@ -88,13 +88,13 @@ void getOwnUpdateInfos( bool & out_allFound) { bool bAllHaveOwnUpdateInformation = true; - for (UpdateInfoMap::iterator i = inout_map.begin(); i != inout_map.end(); ++i) + for (auto & inout : inout_map) { - OSL_ASSERT(i->second.extension.is()); - Sequence<OUString> urls(i->second.extension->getUpdateInformationURLs()); + OSL_ASSERT(inout.second.extension.is()); + Sequence<OUString> urls(inout.second.extension->getUpdateInformationURLs()); if (urls.getLength()) { - const OUString search_id = dp_misc::getIdentifier(i->second.extension); + const OUString search_id = dp_misc::getIdentifier(inout.second.extension); SAL_INFO( "extensions.update", "Searching update for " << search_id ); uno::Any anyError; //It is unclear from the idl if there can be a null reference returned. @@ -102,7 +102,7 @@ void getOwnUpdateInfos( Sequence<Reference< xml::dom::XElement > > infos(getUpdateInformation(updateInformation, urls, search_id, anyError)); if (anyError.hasValue()) - out_errors.emplace_back(i->second.extension, anyError); + out_errors.emplace_back(inout.second.extension, anyError); for (sal_Int32 j = 0; j < infos.getLength(); ++j) { @@ -118,8 +118,8 @@ void getOwnUpdateInfos( << infoset.getVersion() << " for " << *result_id ); if (*result_id != search_id) continue; - i->second.version = infoset.getVersion(); - i->second.info.set(infos[j], UNO_QUERY_THROW); + inout.second.version = infoset.getVersion(); + inout.second.info.set(infos[j], UNO_QUERY_THROW); break; } } @@ -192,13 +192,14 @@ bool onlyBundledExtensions( bool bOnlyBundled = true; if (extensionList) { - typedef std::vector<Reference<deployment::XPackage > >::const_iterator CIT; - for (CIT i(extensionList->begin()), aEnd(extensionList->end()); bOnlyBundled && i != aEnd; ++i) + for (auto const& elem : *extensionList) { Sequence<Reference<deployment::XPackage> > seqExt = xExtMgr->getExtensionsWithSameIdentifier( - dp_misc::getIdentifier(*i), (*i)->getName(), Reference<ucb::XCommandEnvironment>()); + dp_misc::getIdentifier(elem), elem->getName(), Reference<ucb::XCommandEnvironment>()); bOnlyBundled = containsBundledOnly(seqExt); + if (!bOnlyBundled) + break; } } else @@ -367,12 +368,11 @@ UpdateInfoMap getOnlineUpdateInfos( } else { - typedef std::vector<Reference<deployment::XPackage > >::const_iterator CIT; - for (CIT i = extensionList->begin(); i != extensionList->end(); ++i) + for (auto const& elem : *extensionList) { - OSL_ASSERT(i->is()); + OSL_ASSERT(elem.is()); std::pair<UpdateInfoMap::iterator, bool> insertRet = infoMap.emplace( - dp_misc::getIdentifier(*i), UpdateInfo(*i)); + dp_misc::getIdentifier(elem), UpdateInfo(elem)); OSL_ASSERT(insertRet.second); } } diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index 46be07058768..3d91177d7e58 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -117,8 +117,8 @@ void PackageRegistryBackend::check() void PackageRegistryBackend::disposing() { try { - for ( t_string2ref::const_iterator i = m_bound.begin(); i != m_bound.end(); ++i) - i->second->removeEventListener(this); + for (auto const& elem : m_bound) + elem.second->removeEventListener(this); m_bound.clear(); m_xComponentContext.clear(); WeakComponentImplHelperBase::disposing(); |