cui/source/options/optlingu.cxx | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
New commits: commit c122b85b99d4177103da6a840c084ca52828692a Author: Mike Kaganski <[email protected]> AuthorDate: Wed Oct 8 11:26:37 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Wed Oct 8 09:46:46 2025 +0200 Replace an ad-hoc function with comphelper::findValue Change-Id: I2203924ed2c3cd36de2fc426cfde7dafe5a2038b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192056 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx index 2a34e669508c..286591d4cb94 100644 --- a/cui/source/options/optlingu.cxx +++ b/cui/source/options/optlingu.cxx @@ -36,6 +36,7 @@ #include <comphelper/diagnose_ex.hxx> #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> #include <com/sun/star/configuration/ReadWriteAccess.hpp> #include <com/sun/star/linguistic2/LinguServiceManager.hpp> #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> @@ -80,13 +81,6 @@ constexpr OUString cThes(SN_THESAURUS); // static ---------------------------------------------------------------- -static sal_Int32 lcl_SeqGetEntryPos( - const Sequence< OUString > &rSeq, std::u16string_view rEntry ) -{ - auto it = std::find(rSeq.begin(), rSeq.end(), rEntry); - return it == rSeq.end() ? -1 : std::distance(rSeq.begin(), it); -} - static bool KillFile_Impl( const OUString& rURL ) { bool bRet = true; @@ -435,7 +429,7 @@ Sequence< OUString > SvxLinguData_Impl::GetSortedImplNames( LanguageType nLang, case TYPE_GRAMMAR : aImplName = rInfo.sGrammarImplName; break; } - if (!aImplName.isEmpty() && (lcl_SeqGetEntryPos( aRes, aImplName) == -1)) // name not yet added + if (!aImplName.isEmpty() && (comphelper::findValue(aRes, aImplName) == -1)) // name not yet added { DBG_ASSERT( nIdx < aRes.getLength(), "index out of range" ); if (nIdx < aRes.getLength()) @@ -682,7 +676,7 @@ bool SvxLinguData_Impl::AddRemove( bool bRet = false; // modified? sal_Int32 nEntries = rConfigured.getLength(); - sal_Int32 nPos = lcl_SeqGetEntryPos(rConfigured, rImplName); + sal_Int32 nPos = comphelper::findValue(rConfigured, rImplName); if (bAdd && nPos < 0) // add new entry { rConfigured.realloc( ++nEntries ); @@ -1778,7 +1772,7 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) { SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported } - const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; + const bool bCheck = bHasLang && comphelper::findValue( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_SPELL, static_cast<sal_uInt8>(nLocalIndex++) ); sId = weld::toId(pUserData); @@ -1833,7 +1827,7 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) { SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported } - const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; + const bool bCheck = bHasLang && comphelper::findValue( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_GRAMMAR, static_cast<sal_uInt8>(nLocalIndex++) ); @@ -1889,7 +1883,7 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) { SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported } - const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; + const bool bCheck = bHasLang && comphelper::findValue( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_HYPH, static_cast<sal_uInt8>(nLocalIndex++) ); sId = weld::toId(pUserData); @@ -1944,7 +1938,7 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) { SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported } - const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0; + const bool bCheck = bHasLang && comphelper::findValue( rTable[ eCurLanguage ], aImplName ) >= 0; pUserData = new ModuleUserData_Impl( aImplName, false, bCheck, TYPE_THES, static_cast<sal_uInt8>(nLocalIndex++) ); sId = weld::toId(pUserData);
