diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-17 21:42:27 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-17 23:08:48 +0100 |
commit | 823ef9ef3238efd92895254e0f8042ff1e543bb6 (patch) | |
tree | 08d58131644869f46319b246b919a33bbf64f46e /framework/source/accelerators | |
parent | b9cf7da2907f759c98b801939e7c04cf0b80388f (diff) |
Use for-range loops in framework
Change-Id: I72ea832848fd7c76863bcee70a3303de488c0b0f
Reviewed-on: https://gerrit.libreoffice.org/51471
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'framework/source/accelerators')
-rw-r--r-- | framework/source/accelerators/acceleratorcache.cxx | 16 | ||||
-rw-r--r-- | framework/source/accelerators/acceleratorconfiguration.cxx | 78 | ||||
-rw-r--r-- | framework/source/accelerators/storageholder.cxx | 62 |
3 files changed, 62 insertions, 94 deletions
diff --git a/framework/source/accelerators/acceleratorcache.cxx b/framework/source/accelerators/acceleratorcache.cxx index ec5d35323953..18512cc826cf 100644 --- a/framework/source/accelerators/acceleratorcache.cxx +++ b/framework/source/accelerators/acceleratorcache.cxx @@ -71,13 +71,9 @@ AcceleratorCache::TKeyList AcceleratorCache::getAllKeys() const TKeyList lKeys; lKeys.reserve(m_lKey2Commands.size()); - TKey2Commands::const_iterator pIt; - TKey2Commands::const_iterator pEnd = m_lKey2Commands.end(); - for ( pIt = m_lKey2Commands.begin(); - pIt != pEnd; - ++pIt ) + for (auto const& key2Command : m_lKey2Commands) { - lKeys.push_back(pIt->first); + lKeys.push_back(key2Command.first); } return lKeys; @@ -141,13 +137,9 @@ void AcceleratorCache::removeCommand(const OUString& sCommand) SolarMutexGuard g; const TKeyList& lKeys = getKeysByCommand(sCommand); - AcceleratorCache::TKeyList::const_iterator pKey; - for ( pKey = lKeys.begin(); - pKey != lKeys.end(); - ++pKey ) + for (auto const& lKey : lKeys) { - const css::awt::KeyEvent& rKey = *pKey; - removeKey(rKey); + removeKey(lKey); } m_lCommand2Keys.erase(sCommand); } diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx index 935d9f399fda..276cb4547936 100644 --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -507,10 +507,8 @@ css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XCUBasedAcceleratorConfigurati AcceleratorCache::TKeyList lSecondaryKeys = impl_getCFG(false).getAllKeys(); //get keys from SecondaryKeys set lKeys.reserve(lKeys.size()+lSecondaryKeys.size()); - AcceleratorCache::TKeyList::const_iterator pIt; - AcceleratorCache::TKeyList::const_iterator pEnd = lSecondaryKeys.end(); - for ( pIt = lSecondaryKeys.begin(); pIt != pEnd; ++pIt ) - lKeys.push_back(*pIt); + for (auto const& secondaryKey : lSecondaryKeys) + lKeys.push_back(secondaryKey); return comphelper::containerToSequence(lKeys); } @@ -671,9 +669,8 @@ css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XCUBasedAcceleratorConfigurati AcceleratorCache::TKeyList lKeys = rPrimaryCache.getKeysByCommand(sCommand); AcceleratorCache::TKeyList lSecondaryKeys = rSecondaryCache.getKeysByCommand(sCommand); - AcceleratorCache::TKeyList::const_iterator pIt; - for (pIt = lSecondaryKeys.begin(); pIt != lSecondaryKeys.end(); ++pIt) - lKeys.push_back(*pIt); + for (auto const& secondaryKey : lSecondaryKeys) + lKeys.push_back(secondaryKey); return comphelper::containerToSequence(lKeys); } @@ -845,14 +842,14 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::storeToStorage(const css::uno::R if (m_pSecondaryWriteCache!=nullptr) { lKeys = m_pSecondaryWriteCache->getAllKeys(); - for ( pIt=lKeys.begin(); pIt!=lKeys.end(); ++pIt ) - aCache.setKeyCommandPair(*pIt, m_pSecondaryWriteCache->getCommandByKey(*pIt)); + for (auto const& lKey : lKeys) + aCache.setKeyCommandPair(lKey, m_pSecondaryWriteCache->getCommandByKey(lKey)); } else { lKeys = m_aSecondaryReadCache.getAllKeys(); - for ( pIt=lKeys.begin(); pIt!=lKeys.end(); ++pIt ) - aCache.setKeyCommandPair(*pIt, m_aSecondaryReadCache.getCommandByKey(*pIt)); + for (auto const& lKey : lKeys) + aCache.setKeyCommandPair(lKey, m_aSecondaryReadCache.getCommandByKey(lKey)); } } @@ -1019,26 +1016,31 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css: for ( sal_Int32 j=0; j<nLocales; ++j ) aLocales.push_back(lLocales[j]); - ::std::vector< OUString >::const_iterator pFound; - for ( pFound = aLocales.begin(); pFound != aLocales.end(); ++pFound ) + OUString sLocale; + for (auto const& locale : aLocales) { - if ( *pFound == sIsoLang ) + if ( locale == sIsoLang ) + { + sLocale = locale; break; + } } - if ( pFound == aLocales.end() ) + if (sLocale.isEmpty()) { - for ( pFound = aLocales.begin(); pFound != aLocales.end(); ++pFound ) + for (auto const& locale : aLocales) { - if ( *pFound == sDefaultLocale ) + if ( locale == sDefaultLocale ) + { + sLocale = locale; break; + } } - if ( pFound == aLocales.end() ) + if (sLocale.isEmpty()) continue; } - OUString sLocale = *pFound; OUString sCommand; xCommand->getByName(sLocale) >>= sCommand; if (sCommand.isEmpty()) @@ -1096,28 +1098,27 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred) { if (bPreferred) { - AcceleratorCache::TKeyList::const_iterator pIt; AcceleratorCache::TKeyList lPrimaryReadKeys = m_aPrimaryReadCache.getAllKeys(); AcceleratorCache::TKeyList lPrimaryWriteKeys = m_pPrimaryWriteCache->getAllKeys(); - for ( pIt = lPrimaryReadKeys.begin(); pIt != lPrimaryReadKeys.end(); ++pIt ) + for (auto const& primaryReadKey : lPrimaryReadKeys) { - if (!m_pPrimaryWriteCache->hasKey(*pIt)) - removeKeyFromConfiguration(*pIt, true); + if (!m_pPrimaryWriteCache->hasKey(primaryReadKey)) + removeKeyFromConfiguration(primaryReadKey, true); } - for ( pIt = lPrimaryWriteKeys.begin(); pIt != lPrimaryWriteKeys.end(); ++pIt ) + for (auto const& primaryWriteKey : lPrimaryWriteKeys) { - OUString sCommand = m_pPrimaryWriteCache->getCommandByKey(*pIt); - if (!m_aPrimaryReadCache.hasKey(*pIt)) + OUString sCommand = m_pPrimaryWriteCache->getCommandByKey(primaryWriteKey); + if (!m_aPrimaryReadCache.hasKey(primaryWriteKey)) { - insertKeyToConfiguration(*pIt, sCommand, true); + insertKeyToConfiguration(primaryWriteKey, sCommand, true); } else { - OUString sReadCommand = m_aPrimaryReadCache.getCommandByKey(*pIt); + OUString sReadCommand = m_aPrimaryReadCache.getCommandByKey(primaryWriteKey); if (sReadCommand != sCommand) - insertKeyToConfiguration(*pIt, sCommand, true); + insertKeyToConfiguration(primaryWriteKey, sCommand, true); } } @@ -1135,28 +1136,27 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred) else { - AcceleratorCache::TKeyList::const_iterator pIt; AcceleratorCache::TKeyList lSecondaryReadKeys = m_aSecondaryReadCache.getAllKeys(); AcceleratorCache::TKeyList lSecondaryWriteKeys = m_pSecondaryWriteCache->getAllKeys(); - for ( pIt = lSecondaryReadKeys.begin(); pIt != lSecondaryReadKeys.end(); ++pIt) + for (auto const& secondaryReadKey : lSecondaryReadKeys) { - if (!m_pSecondaryWriteCache->hasKey(*pIt)) - removeKeyFromConfiguration(*pIt, false); + if (!m_pSecondaryWriteCache->hasKey(secondaryReadKey)) + removeKeyFromConfiguration(secondaryReadKey, false); } - for ( pIt = lSecondaryWriteKeys.begin(); pIt != lSecondaryWriteKeys.end(); ++pIt ) + for (auto const& secondaryWriteKey : lSecondaryWriteKeys) { - OUString sCommand = m_pSecondaryWriteCache->getCommandByKey(*pIt); - if (!m_aSecondaryReadCache.hasKey(*pIt)) + OUString sCommand = m_pSecondaryWriteCache->getCommandByKey(secondaryWriteKey); + if (!m_aSecondaryReadCache.hasKey(secondaryWriteKey)) { - insertKeyToConfiguration(*pIt, sCommand, false); + insertKeyToConfiguration(secondaryWriteKey, sCommand, false); } else { - OUString sReadCommand = m_aSecondaryReadCache.getCommandByKey(*pIt); + OUString sReadCommand = m_aSecondaryReadCache.getCommandByKey(secondaryWriteKey); if (sReadCommand != sCommand) - insertKeyToConfiguration(*pIt, sCommand, false); + insertKeyToConfiguration(secondaryWriteKey, sCommand, false); } } diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx index b444fa30da27..1cf4ca98719d 100644 --- a/framework/source/accelerators/storageholder.cxx +++ b/framework/source/accelerators/storageholder.cxx @@ -59,12 +59,9 @@ StorageHolder::~StorageHolder() void StorageHolder::forgetCachedStorages() { osl::MutexGuard g(m_mutex); - TPath2StorageInfo::iterator pIt; - for ( pIt = m_lStorages.begin(); - pIt != m_lStorages.end(); - ++pIt ) + for (auto & lStorage : m_lStorages) { - TStorageInfo& rInfo = pIt->second; + TStorageInfo& rInfo = lStorage.second; // TODO think about listener ! rInfo.Storage.clear(); } @@ -97,14 +94,10 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri css::uno::Reference< css::embed::XStorage > xChild; OUString sRelPath; - std::vector<OUString>::const_iterator pIt; - for ( pIt = lFolders.begin(); - pIt != lFolders.end(); - ++pIt ) + for (auto const& lFolder : lFolders) { - const OUString& sChild = *pIt; - OUString sCheckPath (sRelPath + sChild + PATH_SEPARATOR); + OUString sCheckPath (sRelPath + lFolder + PATH_SEPARATOR); // SAFE -> ------------------------------ aReadLock.reset(); @@ -129,7 +122,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri try { - xChild = StorageHolder::openSubStorageWithFallback(xParent, sChild, nOpenMode); // TODO think about delegating fallback decision to our own caller! + xChild = StorageHolder::openSubStorageWithFallback(xParent, lFolder, nOpenMode); // TODO think about delegating fallback decision to our own caller! } catch(const css::uno::RuntimeException&) { throw; } @@ -155,7 +148,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri } xParent = xChild; - sRelPath += sChild + PATH_SEPARATOR; + sRelPath += lFolder + PATH_SEPARATOR; } // TODO think about return last storage as working storage ... but don't caching it inside this holder! @@ -171,16 +164,12 @@ StorageHolder::TStorageList StorageHolder::getAllPathStorages(const OUString& sP StorageHolder::TStorageList lStoragesOfPath; OUString sRelPath; - std::vector<OUString>::const_iterator pIt; osl::MutexGuard g(m_mutex); - for ( pIt = lFolders.begin(); - pIt != lFolders.end(); - ++pIt ) + for (auto const& lFolder : lFolders) { - const OUString& sChild = *pIt; - OUString sCheckPath (sRelPath + sChild + PATH_SEPARATOR); + OUString sCheckPath (sRelPath + lFolder + PATH_SEPARATOR); TPath2StorageInfo::iterator pCheck = m_lStorages.find(sCheckPath); if (pCheck == m_lStorages.end()) @@ -194,7 +183,7 @@ StorageHolder::TStorageList StorageHolder::getAllPathStorages(const OUString& sP TStorageInfo& rInfo = pCheck->second; lStoragesOfPath.push_back(rInfo.Storage); - sRelPath += sChild + PATH_SEPARATOR; + sRelPath += lFolder + PATH_SEPARATOR; } return lStoragesOfPath; @@ -236,14 +225,11 @@ void StorageHolder::closePath(const OUString& rPath) [1] = "path_2" => "path_1/path_2" [2] = "path_3" => "path_1/path_2/path_3" */ - std::vector<OUString>::iterator pIt1; OUString sParentPath; - for ( pIt1 = lFolders.begin(); - pIt1 != lFolders.end(); - ++pIt1 ) + for (auto & lFolder : lFolders) { - OUString sCurrentRelPath(sParentPath + *pIt1 + PATH_SEPARATOR); - *pIt1 = sCurrentRelPath; + OUString sCurrentRelPath(sParentPath + lFolder + PATH_SEPARATOR); + lFolder = sCurrentRelPath; sParentPath = sCurrentRelPath; } @@ -280,14 +266,10 @@ void StorageHolder::notifyPath(const OUString& sPath) return; TStorageInfo& rInfo = pIt1->second; - TStorageListenerList::iterator pIt2; - for ( pIt2 = rInfo.Listener.begin(); - pIt2 != rInfo.Listener.end(); - ++pIt2 ) + for (auto const& listener : rInfo.Listener) { - XMLBasedAcceleratorConfiguration* pListener = *pIt2; - if (pListener) - pListener->changesOccurred(); + if (listener) + listener->changesOccurred(); } } @@ -329,20 +311,14 @@ OUString StorageHolder::getPathOfStorage(const css::uno::Reference< css::embed:: { osl::MutexGuard g(m_mutex); - TPath2StorageInfo::const_iterator pIt; - for ( pIt = m_lStorages.begin(); - pIt != m_lStorages.end(); - ++pIt ) + for (auto const& lStorage : m_lStorages) { - const TStorageInfo& rInfo = pIt->second; + const TStorageInfo& rInfo = lStorage.second; if (rInfo.Storage == xStorage) - break; + return lStorage.first; } - if (pIt == m_lStorages.end()) - return OUString(); - - return pIt->first; + return OUString(); } css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(const css::uno::Reference< css::embed::XStorage >& xChild) |