summaryrefslogtreecommitdiff
path: root/cui/source/options
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-05-19 19:16:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-05-20 08:37:46 +0200
commit9a0faf09a8963556eafe172ae16735472f24659d (patch)
tree1791665f1840951aeebcfa85d3b525e839ab90a5 /cui/source/options
parent442c7b95e2ee94b66a9854d0cb22f8ecb76532c6 (diff)
use for-range on Sequence in cppuhelper,cui
Change-Id: I482d48e29ddc9690d9c671cde2f6b0c611ec378d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94550 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui/source/options')
-rw-r--r--cui/source/options/optaboutconfig.cxx24
-rw-r--r--cui/source/options/optcolor.cxx7
-rw-r--r--cui/source/options/optlingu.cxx73
-rw-r--r--cui/source/options/treeopt.cxx15
-rw-r--r--cui/source/options/webconninfo.cxx22
5 files changed, 66 insertions, 75 deletions
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 799f31c38962..44bacb1e1195 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -259,10 +259,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
{
OUString sPath = Reference< XHierarchicalName >(
xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName();
- uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
- for( sal_Int32 i = 0; i < seqItems.getLength(); ++i )
+ const uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
+ for( const OUString& item : seqItems )
{
- Any aNode = xNameAccess->getByName( seqItems[i] );
+ Any aNode = xNameAccess->getByName( item );
bool bNotLeaf = false;
@@ -287,7 +287,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
m_vectorUserData.push_back(std::make_unique<UserData>(xNextNameAccess, lineage + 1));
OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_vectorUserData.back().get())));
- m_xPrefBox->insert(pParentEntry, -1, &seqItems[i], &sId, nullptr, nullptr, nullptr, true, m_xScratchIter.get());
+ m_xPrefBox->insert(pParentEntry, -1, &item, &sId, nullptr, nullptr, nullptr, true, m_xScratchIter.get());
//It is needed, without this the selection line will be truncated.
m_xPrefBox->set_text(*m_xScratchIter, "", 1);
m_xPrefBox->set_text(*m_xScratchIter, "", 2);
@@ -297,7 +297,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
else
{
// leaf node
- OUString sPropertyName = seqItems[i];
+ OUString sPropertyName = item;
auto it = std::find_if(m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(),
[&sPath, &sPropertyName](const prefBoxEntry& rEntry) -> bool
{
@@ -352,10 +352,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
else if( sType == "[]byte" )
{
uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >();
- for( sal_Int32 j = 0; j != seq.getLength(); ++j )
+ for( sal_Int8 j : seq )
{
OUString s = OUString::number(
- static_cast<sal_uInt8>(seq[j]), 16 );
+ static_cast<sal_uInt8>(j), 16 );
if( s.getLength() == 1 )
{
sValue.append("0");
@@ -372,10 +372,10 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
{
sValue.append(",");
}
- for( sal_Int32 k = 0; k != seq[j].getLength(); ++k )
+ for( sal_Int8 k : seq[j] )
{
OUString s = OUString::number(
- static_cast<sal_uInt8>(seq[j][k]), 16 );
+ static_cast<sal_uInt8>(k), 16 );
if( s.getLength() == 1 )
{
sValue.append("0");
@@ -448,7 +448,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
{
SAL_WARN(
"cui.options",
- "path \"" << sPath << "\" member " << seqItems[i]
+ "path \"" << sPath << "\" member " << item
<< " of unsupported type " << sType);
}
break;
@@ -456,7 +456,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
default:
SAL_WARN(
"cui.options",
- "path \"" << sPath << "\" member " << seqItems[i]
+ "path \"" << sPath << "\" member " << item
<< " of unsupported type " << sType);
break;
}
@@ -467,7 +467,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
for(int j = 1; j < lineage; ++j)
index = sPath.indexOf("/", index + 1);
- InsertEntry(sPath, sPath.copy(index+1), seqItems[i], sType, sValue.makeStringAndClear(), pParentEntry, !bLoadAll);
+ InsertEntry(sPath, sPath.copy(index+1), item, sType, sValue.makeStringAndClear(), pParentEntry, !bLoadAll);
}
}
}
diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx
index 384f5f23ed16..f7807adc57e9 100644
--- a/cui/source/options/optcolor.cxx
+++ b/cui/source/options/optcolor.cxx
@@ -785,10 +785,9 @@ void SvxColorOptionsTabPage::Reset( const SfxItemSet* )
//has to be called always to speed up accessibility tools
m_xColorConfigCT->SetScrollPosition(sUser.toInt32());
m_xColorSchemeLB->clear();
- uno::Sequence< OUString > aSchemes = pColorConfig->GetSchemeNames();
- const OUString* pSchemes = aSchemes.getConstArray();
- for(sal_Int32 i = 0; i < aSchemes.getLength(); i++)
- m_xColorSchemeLB->append_text(pSchemes[i]);
+ const uno::Sequence< OUString > aSchemes = pColorConfig->GetSchemeNames();
+ for(const OUString& s : aSchemes)
+ m_xColorSchemeLB->append_text(s);
m_xColorSchemeLB->set_active_text(pColorConfig->GetCurrentSchemeName());
m_xColorSchemeLB->save_value();
m_xDeleteSchemePB->set_sensitive( aSchemes.getLength() > 1 );
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 57149d726bda..296451e6a380 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -466,30 +466,31 @@ ServiceInfo_Impl * SvxLinguData_Impl::GetInfoByImplName( const OUString &rSvcImp
static void lcl_MergeLocales(Sequence< Locale >& aAllLocales, const Sequence< Locale >& rAdd)
{
- const Locale* pAdd = rAdd.getConstArray();
Sequence<Locale> aLocToAdd(rAdd.getLength());
- const Locale* pAllLocales = aAllLocales.getConstArray();
Locale* pLocToAdd = aLocToAdd.getArray();
sal_Int32 nFound = 0;
- sal_Int32 i;
- for(i = 0; i < rAdd.getLength(); i++)
+ for(const Locale& i : rAdd)
{
bool bFound = false;
- for(sal_Int32 j = 0; j < aAllLocales.getLength() && !bFound; j++)
+ for(const Locale& j : std::as_const(aAllLocales))
{
- bFound = pAdd[i].Language == pAllLocales[j].Language &&
- pAdd[i].Country == pAllLocales[j].Country &&
- pAdd[i].Variant == pAllLocales[j].Variant;
+ if (i.Language == j.Language &&
+ i.Country == j.Country &&
+ i.Variant == j.Variant)
+ {
+ bFound = true;
+ break;
+ }
}
if(!bFound)
{
- pLocToAdd[nFound++] = pAdd[i];
+ pLocToAdd[nFound++] = i;
}
}
sal_Int32 nLength = aAllLocales.getLength();
aAllLocales.realloc( nLength + nFound);
Locale* pAllLocales2 = aAllLocales.getArray();
- for(i = 0; i < nFound; i++)
+ for(sal_Int32 i = 0; i < nFound; i++)
pAllLocales2[nLength++] = pLocToAdd[i];
}
@@ -558,15 +559,13 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
aArgs.getArray()[0] <<= LinguMgr::GetLinguPropertySet();
//read spell checker
- Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
+ const Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
cSpell, Locale() );
- const OUString* pSpellNames = aSpellNames.getConstArray();
- sal_Int32 nIdx;
- for(nIdx = 0; nIdx < aSpellNames.getLength(); nIdx++)
+ for(const OUString& spellName : aSpellNames)
{
ServiceInfo_Impl aInfo;
- aInfo.sSpellImplName = pSpellNames[nIdx];
+ aInfo.sSpellImplName = spellName;
aInfo.xSpell.set(
xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sSpellImplName, aArgs, xContext), UNO_QUERY);
@@ -584,13 +583,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
}
//read grammar checker
- Sequence< OUString > aGrammarNames = xLinguSrvcMgr->getAvailableServices(
+ const Sequence< OUString > aGrammarNames = xLinguSrvcMgr->getAvailableServices(
cGrammar, Locale() );
- const OUString* pGrammarNames = aGrammarNames.getConstArray();
- for(nIdx = 0; nIdx < aGrammarNames.getLength(); nIdx++)
+ for(const OUString& grammarName : aGrammarNames)
{
ServiceInfo_Impl aInfo;
- aInfo.sGrammarImplName = pGrammarNames[nIdx];
+ aInfo.sGrammarImplName = grammarName;
aInfo.xGrammar.set(
xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sGrammarImplName, aArgs, xContext), UNO_QUERY);
@@ -608,13 +606,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
}
//read hyphenator
- Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
+ const Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
cHyph, Locale() );
- const OUString* pHyphNames = aHyphNames.getConstArray();
- for(nIdx = 0; nIdx < aHyphNames.getLength(); nIdx++)
+ for(const OUString& hyphName : aHyphNames)
{
ServiceInfo_Impl aInfo;
- aInfo.sHyphImplName = pHyphNames[nIdx];
+ aInfo.sHyphImplName = hyphName;
aInfo.xHyph.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sHyphImplName, aArgs, xContext), UNO_QUERY);
uno::Reference<XServiceDisplayName> xDispName(aInfo.xHyph, UNO_QUERY);
@@ -631,13 +628,12 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
}
//read thesauri
- Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
+ const Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
cThes, Locale() );
- const OUString* pThesNames = aThesNames.getConstArray();
- for(nIdx = 0; nIdx < aThesNames.getLength(); nIdx++)
+ for(const OUString& thesName : aThesNames)
{
ServiceInfo_Impl aInfo;
- aInfo.sThesImplName = pThesNames[nIdx];
+ aInfo.sThesImplName = thesName;
aInfo.xThes.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sThesImplName, aArgs, xContext), UNO_QUERY);
uno::Reference<XServiceDisplayName> xDispName(aInfo.xThes, UNO_QUERY);
@@ -654,27 +650,26 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
}
Sequence< OUString > aCfgSvcs;
- const Locale* pAllLocales = aAllServiceLocales.getConstArray();
- for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
+ for(auto const & locale : std::as_const(aAllServiceLocales))
{
- LanguageType nLang = LanguageTag::convertToLanguageType( pAllLocales[nLocale] );
+ LanguageType nLang = LanguageTag::convertToLanguageType( locale );
- aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cSpell, pAllLocales[nLocale]);
+ aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cSpell, locale);
SetChecked( aCfgSvcs );
if (aCfgSvcs.hasElements())
aCfgSpellTable[ nLang ] = aCfgSvcs;
- aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cGrammar, pAllLocales[nLocale]);
+ aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cGrammar, locale);
SetChecked( aCfgSvcs );
if (aCfgSvcs.hasElements())
aCfgGrammarTable[ nLang ] = aCfgSvcs;
- aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cHyph, pAllLocales[nLocale]);
+ aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cHyph, locale);
SetChecked( aCfgSvcs );
if (aCfgSvcs.hasElements())
aCfgHyphTable[ nLang ] = aCfgSvcs;
- aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cThes, pAllLocales[nLocale]);
+ aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cThes, locale);
SetChecked( aCfgSvcs );
if (aCfgSvcs.hasElements())
aCfgThesTable[ nLang ] = aCfgSvcs;
@@ -683,15 +678,14 @@ SvxLinguData_Impl::SvxLinguData_Impl() :
void SvxLinguData_Impl::SetChecked(const Sequence<OUString>& rConfiguredServices)
{
- const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
- for(sal_Int32 n = 0; n < rConfiguredServices.getLength(); n++)
+ for(OUString const & configService : rConfiguredServices)
{
for (sal_uInt32 i = 0; i < nDisplayServices; ++i)
{
ServiceInfo_Impl& rEntry = aDisplayServiceArr[i];
if (!rEntry.bConfigured)
{
- const OUString &rSrvcImplName = pConfiguredServices[n];
+ const OUString &rSrvcImplName = configService;
if (!rSrvcImplName.isEmpty() &&
(rEntry.sSpellImplName == rSrvcImplName ||
rEntry.sGrammarImplName == rSrvcImplName ||
@@ -1583,10 +1577,9 @@ SvxEditModulesDlg::SvxEditModulesDlg(weld::Window* pParent, SvxLinguData_Impl& r
//fill language box
const Sequence< Locale >& rLoc = rLinguData.GetAllSupportedLocales();
- const Locale* pLocales = rLoc.getConstArray();
- for (int i = 0; i < rLoc.getLength(); ++i)
+ for (Locale const & locale : rLoc)
{
- LanguageType nLang = LanguageTag::convertToLanguageType( pLocales[i] );
+ LanguageType nLang = LanguageTag::convertToLanguageType( locale );
m_xLanguageLB->InsertLanguage(nLang);
}
LanguageType eSysLang = MsLangId::getSystemLanguage();
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 4e71fd62aa7b..2d6b104e1d9b 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1738,20 +1738,19 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
Reference< XNameAccess > xSet(
officecfg::Office::OptionsDialog::Nodes::get());
VectorOfNodes aNodeList;
- Sequence< OUString > seqNames = xSet->getElementNames();
+ const Sequence< OUString > seqNames = xSet->getElementNames();
- for ( int i = 0; i < seqNames.getLength(); ++i )
+ for ( OUString const & sGroupName : seqNames )
{
- OUString sGroupName( seqNames[i] );
Reference< XNameAccess > xNodeAccess;
- xSet->getByName( seqNames[i] ) >>= xNodeAccess;
+ xSet->getByName( sGroupName ) >>= xNodeAccess;
if ( xNodeAccess.is() )
{
OUString sNodeId, sLabel, sPageURL;
bool bAllModules = false;
- sNodeId = seqNames[i];
+ sNodeId = sGroupName;
xNodeAccess->getByName( "Label" ) >>= sLabel;
xNodeAccess->getByName( "OptionsPage" ) >>= sPageURL;
xNodeAccess->getByName( "AllModules" ) >>= bAllModules;
@@ -1772,11 +1771,11 @@ VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
xNodeAccess->getByName( "Leaves" ) >>= xLeavesSet;
if ( xLeavesSet.is() )
{
- Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
- for ( int j = 0; j < seqLeaves.getLength(); ++j )
+ const Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
+ for ( OUString const & leafName : seqLeaves )
{
Reference< XNameAccess > xLeaveAccess;
- xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
+ xLeavesSet->getByName( leafName ) >>= xLeaveAccess;
if ( xLeaveAccess.is() )
{
diff --git a/cui/source/options/webconninfo.cxx b/cui/source/options/webconninfo.cxx
index c06f085ccfa4..1d3abe82f860 100644
--- a/cui/source/options/webconninfo.cxx
+++ b/cui/source/options/webconninfo.cxx
@@ -86,14 +86,14 @@ void WebConnectionInfoDialog::FillPasswordList()
uno::Reference< task::XInteractionHandler > xInteractionHandler =
task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), nullptr);
- uno::Sequence< task::UrlRecord > aURLEntries = xMasterPasswd->getAllPersistent( xInteractionHandler );
+ const uno::Sequence< task::UrlRecord > aURLEntries = xMasterPasswd->getAllPersistent( xInteractionHandler );
sal_Int32 nCount = 0;
- for ( sal_Int32 nURLInd = 0; nURLInd < aURLEntries.getLength(); nURLInd++ )
+ for ( task::UrlRecord const & urlEntry : aURLEntries )
{
- for ( sal_Int32 nUserInd = 0; nUserInd < aURLEntries[nURLInd].UserList.getLength(); nUserInd++ )
+ for ( auto const & user : urlEntry.UserList )
{
- m_xPasswordsLB->append(OUString::number(nCount), aURLEntries[nURLInd].Url);
- m_xPasswordsLB->set_text(nCount, aURLEntries[nURLInd].UserList[nUserInd].UserName, 1);
+ m_xPasswordsLB->append(OUString::number(nCount), urlEntry.Url);
+ m_xPasswordsLB->set_text(nCount, user.UserName, 1);
++nCount;
}
}
@@ -101,12 +101,12 @@ void WebConnectionInfoDialog::FillPasswordList()
// remember pos of first url container entry.
m_nPos = nCount;
- uno::Sequence< OUString > aUrls
+ const uno::Sequence< OUString > aUrls
= xMasterPasswd->getUrls( true /* OnlyPersistent */ );
- for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
+ for ( OUString const & url : aUrls )
{
- m_xPasswordsLB->append(OUString::number(nCount), aUrls[nURLIdx]);
+ m_xPasswordsLB->append(OUString::number(nCount), url);
m_xPasswordsLB->set_text(nCount, "*");
++nCount;
}
@@ -157,10 +157,10 @@ IMPL_LINK_NOARG(WebConnectionInfoDialog, RemoveAllPasswordsHdl, weld::Button&, v
// should the master password be requested before?
xPasswdContainer->removeAllPersistent();
- uno::Sequence< OUString > aUrls
+ const uno::Sequence< OUString > aUrls
= xPasswdContainer->getUrls( true /* OnlyPersistent */ );
- for ( sal_Int32 nURLIdx = 0; nURLIdx < aUrls.getLength(); nURLIdx++ )
- xPasswdContainer->removeUrl( aUrls[ nURLIdx ] );
+ for ( OUString const & url : aUrls )
+ xPasswdContainer->removeUrl( url );
m_xPasswordsLB->clear();
}