diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-29 01:31:19 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-29 23:15:40 +0200 |
commit | 00e2762c664614a1b33f54dfc990ba29f0f81a07 (patch) | |
tree | 976d1d94d6d1e52812e128a5dfbcb3540ef9a42b /cui | |
parent | 8755c80018bec656e1b102da25edc450da4eee52 (diff) |
Drop uses of css::uno::Sequence::getConstArray in cppuhelper .. cui
where it was obsoleted by commits 2484de6728bd11bb7949003d112f1ece2223c7a1
(Remove non-const Sequence::begin()/end() in internal code, 2021-10-15) and
fb3c04bd1930eedacd406874e1a285d62bbf27d9 (Drop non-const Sequence::operator[]
in internal code 2021-11-05).
Change-Id: Ia2b60af973183bbe79656e67b5e37d7efa39a308
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166817
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/customize/cfgutil.cxx | 6 | ||||
-rw-r--r-- | cui/source/dialogs/AdditionsDialog.cxx | 8 | ||||
-rw-r--r-- | cui/source/dialogs/SpellDialog.cxx | 32 | ||||
-rw-r--r-- | cui/source/dialogs/cuifmsearch.cxx | 6 | ||||
-rw-r--r-- | cui/source/dialogs/hangulhanjadlg.cxx | 23 | ||||
-rw-r--r-- | cui/source/dialogs/hlmarkwn.cxx | 11 | ||||
-rw-r--r-- | cui/source/dialogs/hyphen.cxx | 40 | ||||
-rw-r--r-- | cui/source/dialogs/thesdlg.cxx | 19 | ||||
-rw-r--r-- | cui/source/options/connpoolconfig.cxx | 7 | ||||
-rw-r--r-- | cui/source/options/dbregisterednamesconfig.cxx | 20 | ||||
-rw-r--r-- | cui/source/options/optdict.cxx | 50 | ||||
-rw-r--r-- | cui/source/options/optgdlg.cxx | 25 | ||||
-rw-r--r-- | cui/source/options/optlingu.cxx | 104 | ||||
-rw-r--r-- | cui/source/options/optpath.cxx | 14 | ||||
-rw-r--r-- | cui/source/options/optsave.cxx | 19 | ||||
-rw-r--r-- | cui/source/tabpages/numpages.cxx | 34 |
16 files changed, 127 insertions, 291 deletions
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index 3a2cdbc1b05e..5875b977a434 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -742,13 +742,11 @@ OUString CuiConfigGroupListBox::GetImage( { throw RuntimeException("SFTreeListBox::Init: failed to get PropertyValue"); } - beans::PropertyValue const * pmoduleDescr = - moduleDescr.getConstArray(); for ( sal_Int32 pos = moduleDescr.getLength(); pos--; ) { - if ( pmoduleDescr[ pos ].Name == "ooSetupFactoryEmptyDocumentURL" ) + if (moduleDescr[pos].Name == "ooSetupFactoryEmptyDocumentURL") { - pmoduleDescr[ pos ].Value >>= factoryURL; + moduleDescr[pos].Value >>= factoryURL; SAL_INFO("cui.customize", "factory url for doc images is " << factoryURL); break; } diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx index 4d39ad937664..a0d2061e531c 100644 --- a/cui/source/dialogs/AdditionsDialog.cxx +++ b/cui/source/dialogs/AdditionsDialog.cxx @@ -821,15 +821,11 @@ void TmpRepositoryCommandEnv::handle(uno::Reference<task::XInteractionRequest> c bool approve = true; // select: - uno::Sequence<Reference<task::XInteractionContinuation>> conts(xRequest->getContinuations()); - Reference<task::XInteractionContinuation> const* pConts = conts.getConstArray(); - sal_Int32 len = conts.getLength(); - for (sal_Int32 pos = 0; pos < len; ++pos) + for (const auto& cont : xRequest->getContinuations()) { if (approve) { - uno::Reference<task::XInteractionApprove> xInteractionApprove(pConts[pos], - uno::UNO_QUERY); + uno::Reference<task::XInteractionApprove> xInteractionApprove(cont, uno::UNO_QUERY); if (xInteractionApprove.is()) { xInteractionApprove->select(); diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 9dd877f80cf9..bc45db96e25e 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -278,7 +278,6 @@ void SpellDialog::Init_Impl() void SpellDialog::UpdateBoxes_Impl(bool bCallFromSelectHdl) { - sal_Int32 i; m_xSuggestionLB->clear(); SpellErrorDescription aSpellErrorDescription; @@ -309,26 +308,20 @@ void SpellDialog::UpdateBoxes_Impl(bool bCallFromSelectHdl) int nDicts = InitUserDicts(); // enter alternatives - const OUString *pNewWords = aNewWords.getConstArray(); - const sal_Int32 nSize = aNewWords.getLength(); - for ( i = 0; i < nSize; ++i ) + for (auto& aTmp : aNewWords) { - OUString aTmp( pNewWords[i] ); if (m_xSuggestionLB->find_text(aTmp) == -1) m_xSuggestionLB->append_text(aTmp); } - if(!nSize) - m_xSuggestionLB->append_text(m_sNoSuggestionsST); - m_xAutoCorrPB->set_sensitive( nSize > 0 ); - - m_xSuggestionFT->set_sensitive(nSize > 0); - m_xSuggestionLB->set_sensitive(nSize > 0); - if( nSize ) - { + m_xSuggestionLB->set_sensitive(aNewWords.hasElements()); + if (aNewWords.hasElements()) m_xSuggestionLB->select(0); - } - m_xChangePB->set_sensitive( nSize > 0); - m_xChangeAllPB->set_sensitive(nSize > 0); + else + m_xSuggestionLB->append_text(m_sNoSuggestionsST); + m_xAutoCorrPB->set_sensitive(aNewWords.hasElements()); + m_xSuggestionFT->set_sensitive(aNewWords.hasElements()); + m_xChangePB->set_sensitive(aNewWords.hasElements()); + m_xChangeAllPB->set_sensitive(aNewWords.hasElements()); bool bShowChangeAll = !bIsGrammarError; m_xChangeAllPB->set_visible( bShowChangeAll ); m_xExplainFT->set_visible( !bShowChangeAll ); @@ -778,8 +771,6 @@ int SpellDialog::InitUserDicts() { const LanguageType nLang = m_xLanguageLB->get_active_id(); - const Reference< XDictionary > *pDic = nullptr; - // get list of dictionaries Reference< XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() ); if (xDicList.is()) @@ -798,13 +789,10 @@ int SpellDialog::InitUserDicts() // list suitable dictionaries bool bEnable = false; - const sal_Int32 nSize = pImpl->aDics.getLength(); - pDic = pImpl->aDics.getConstArray(); m_xAddToDictMB->clear(); sal_uInt16 nItemId = 1; // menu items should be enumerated from 1 and not 0 - for (sal_Int32 i = 0; i < nSize; ++i) + for (auto& xDicTmp : pImpl->aDics) { - uno::Reference< linguistic2::XDictionary > xDicTmp = pDic[i]; if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp) continue; diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx index eff48a747fe7..0a7eb06783ab 100644 --- a/cui/source/dialogs/cuifmsearch.cxx +++ b/cui/source/dialogs/cuifmsearch.cxx @@ -632,10 +632,8 @@ void FmSearchDialog::LoadParams() { FmSearchParams aParams(m_pConfig->getParams()); - const OUString* pHistory = aParams.aHistory.getConstArray(); - const OUString* pHistoryEnd = pHistory + aParams.aHistory.getLength(); - for (; pHistory != pHistoryEnd; ++pHistory) - m_pcmbSearchText->append_text( *pHistory ); + for (auto& historystr : aParams.aHistory) + m_pcmbSearchText->append_text(historystr); // I do the settings at my UI-elements and then I simply call the respective change-handler, // that way the data is handed on to the SearchEngine and all dependent settings are done diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index fb25df938e17..537918ecb779 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -729,15 +729,9 @@ namespace svx Reference< XNameContainer > xNameCont = m_xConversionDictionaryList->getDictionaryContainer(); if( xNameCont.is() ) { - Sequence< OUString > aDictNames( xNameCont->getElementNames() ); - - const OUString* pDic = aDictNames.getConstArray(); - sal_Int32 nCount = aDictNames.getLength(); - - sal_Int32 i; - for( i = 0 ; i < nCount ; ++i ) + for (auto& name : xNameCont->getElementNames()) { - Any aAny( xNameCont->getByName( pDic[ i ] ) ); + Any aAny(xNameCont->getByName(name)); Reference< XConversionDictionary > xDic; if( ( aAny >>= xDic ) && xDic.is() ) { @@ -1372,20 +1366,13 @@ namespace svx m_xSuggestions->Clear(); //fill found entries into boxes - sal_uInt32 nCnt = aEntries.getLength(); - if( nCnt ) + if (aEntries.hasElements()) { if( !m_xSuggestions ) m_xSuggestions.reset(new SuggestionList); - const OUString* pSugg = aEntries.getConstArray(); - sal_uInt32 n = 0; - while( nCnt ) - { - m_xSuggestions->Set( pSugg[ n ], sal_uInt16( n ) ); - ++n; - --nCnt; - } + for (sal_Int32 n = 0; n < aEntries.getLength(); ++n) + m_xSuggestions->Set(aEntries[n], n); } m_bModifiedSuggestions = false; } diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx index cf90450450ad..918fc7cab3f7 100644 --- a/cui/source/dialogs/hlmarkwn.cxx +++ b/cui/source/dialogs/hlmarkwn.cxx @@ -302,19 +302,14 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess > std::stack<std::pair<std::unique_ptr<weld::TreeIter>, const sal_Int32>> aHeadingsParentEntryStack; int nEntries=0; - const uno::Sequence< OUString > aNames( xLinks->getElementNames() ); - const sal_Int32 nLinks = aNames.getLength(); - const OUString* pNames = aNames.getConstArray(); static constexpr OUStringLiteral aProp_LinkDisplayName( u"LinkDisplayName" ); static constexpr OUStringLiteral aProp_LinkTarget( u"com.sun.star.document.LinkTarget" ); static constexpr OUStringLiteral aProp_LinkDisplayBitmap( u"LinkDisplayBitmap" ); - for( sal_Int32 i = 0; i < nLinks; i++ ) + for (auto& aLink : xLinks->getElementNames()) { uno::Any aAny; - OUString aLink( *pNames++ ); - bool bError = false; try { aAny = xLinks->getByName( aLink ); @@ -323,10 +318,8 @@ int SvxHlinkDlgMarkWnd::FillTree( const uno::Reference< container::XNameAccess > { // if the name of the target was invalid (like empty headings) // no object can be provided - bError = true; - } - if(bError) continue; + } uno::Reference< beans::XPropertySet > xTarget; diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx index 10ad1d9bba5b..c06ecab9661f 100644 --- a/cui/source/dialogs/hyphen.cxx +++ b/cui/source/dialogs/hyphen.cxx @@ -116,43 +116,28 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl() aTxt = m_xPossHyph->getPossibleHyphens(); m_nHyphenationPositionsOffset = 0; - uno::Sequence< sal_Int16 > aHyphenationPositions( - m_xPossHyph->getHyphenationPositions() ); - sal_Int32 nLen = aHyphenationPositions.getLength(); - const sal_Int16 *pHyphenationPos = aHyphenationPositions.getConstArray(); // find position nIdx after which all hyphen positions are unusable sal_Int32 nIdx = -1; - sal_Int32 nPos = 0, nPos1 = 0; - if (nLen) + for (sal_Int16 hyphenationPos : m_xPossHyph->getHyphenationPositions()) { - sal_Int32 nStart = 0; - for (sal_Int32 i = 0; i < nLen; ++i) + if (hyphenationPos > m_nMaxHyphenationPos) + break; + else { - if (pHyphenationPos[i] > m_nMaxHyphenationPos) + // find corresponding hyphen positions in string + nIdx = aTxt.indexOf(sal_Unicode(HYPH_POS_CHAR), nIdx + 1); + + if (nIdx == -1) break; - else - { - // find corresponding hyphen positions in string - nPos = aTxt.indexOf( sal_Unicode( HYPH_POS_CHAR ), nStart ); - - if (nPos == -1) - break; - else - { - nIdx = nPos; - nStart = nPos + 1; - } - } } } DBG_ASSERT(nIdx != -1, "no usable hyphenation position"); // 1) remove all not usable hyphenation positions from the end of the string - nPos = nIdx == -1 ? 0 : nIdx + 1; - nPos1 = nPos; //save for later use in 2) below + sal_Int32 nPos1 = nIdx + 1; //save for later use in 2) below const OUString aTmp( sal_Unicode( HYPH_POS_CHAR ) ); - while (nPos != -1) + for (sal_Int32 nPos = nPos1; nPos != -1;) { nPos++; aTxt = aTxt.replaceFirst( aTmp, "", &nPos); @@ -164,8 +149,7 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl() if (nPos2 != std::u16string_view::npos && nPos2 != 0) { OUString aLeft( aSearchRange.substr( 0, nPos2 ) ); - nPos = 0; - while (nPos != -1) + for (sal_Int32 nPos = 0; nPos != -1;) { nPos++; aLeft = aLeft.replaceFirst( aTmp, "", &nPos ); @@ -222,7 +206,7 @@ void SvxHyphenWordDialog::ContinueHyph_Impl( sal_Int32 nInsPos ) DBG_ASSERT(0 <= nIdxPos && nIdxPos < nLen, "index out of range"); if (nLen && 0 <= nIdxPos && nIdxPos < nLen) { - nInsPos = aSeq.getConstArray()[ nIdxPos ]; + nInsPos = aSeq[nIdxPos]; m_pHyphWrapper->InsertHyphen( nInsPos ); } } diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index ea98a44a3c9e..f1795ddd684d 100644 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -89,7 +89,6 @@ bool SvxThesaurusDialog::UpdateAlternativesBox_Impl() uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings = queryMeanings_Impl( aLookUpText, aLocale, uno::Sequence< beans::PropertyValue >() ); const sal_Int32 nMeanings = aMeanings.getLength(); - const uno::Reference< linguistic2::XMeaning > *pMeanings = aMeanings.getConstArray(); m_xAlternativesCT->freeze(); @@ -97,22 +96,20 @@ bool SvxThesaurusDialog::UpdateAlternativesBox_Impl() int nRow = 0; for (sal_Int32 i = 0; i < nMeanings; ++i) { - OUString rMeaningTxt = pMeanings[i]->getMeaning(); - uno::Sequence< OUString > aSynonyms( pMeanings[i]->querySynonyms() ); - const sal_Int32 nSynonyms = aSynonyms.getLength(); - const OUString *pSynonyms = aSynonyms.getConstArray(); + OUString rMeaningTxt = aMeanings[i]->getMeaning(); + uno::Sequence<OUString> aSynonyms(aMeanings[i]->querySynonyms()); DBG_ASSERT( !rMeaningTxt.isEmpty(), "meaning with empty text" ); - DBG_ASSERT( nSynonyms > 0, "meaning without synonym" ); + DBG_ASSERT(aSynonyms.hasElements(), "meaning without synonym"); OUString sHeading = OUString::number(i + 1) + ". " + rMeaningTxt; m_xAlternativesCT->append_text(sHeading); m_xAlternativesCT->set_text_emphasis(nRow, true, 0); ++nRow; - for (sal_Int32 k = 0; k < nSynonyms; ++k) + for (auto& synonym : aSynonyms) { // GetThesaurusReplaceText will strip the leading spaces - m_xAlternativesCT->append_text(" " + pSynonyms[k]); + m_xAlternativesCT->append_text(" " + synonym); m_xAlternativesCT->set_text_emphasis(nRow, false, 0); ++nRow; } @@ -287,13 +284,11 @@ SvxThesaurusDialog::SvxThesaurusDialog( uno::Sequence< lang::Locale > aLocales; if (xThesaurus.is()) aLocales = xThesaurus->getLocales(); - const sal_Int32 nLocales = aLocales.getLength(); - const lang::Locale *pLocales = aLocales.getConstArray(); m_xLangLB->clear(); std::vector< OUString > aLangVec; - for (sal_Int32 i = 0; i < nLocales; ++i) + for (auto& locale : aLocales) { - const LanguageType nLang = LanguageTag::convertToLanguageType( pLocales[i] ); + const LanguageType nLang = LanguageTag::convertToLanguageType(locale); DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" ); aLangVec.push_back( SvtLanguageTable::GetLanguageString( nLang ) ); } diff --git a/cui/source/options/connpoolconfig.cxx b/cui/source/options/connpoolconfig.cxx index 0d0f45be10b9..12aee9933f4e 100644 --- a/cui/source/options/connpoolconfig.cxx +++ b/cui/source/options/connpoolconfig.cxx @@ -67,13 +67,10 @@ namespace offapp // then look for which of them settings are stored in the configuration OConfigurationNode aDriverSettings = aConnectionPoolRoot.openNode(DRIVER_SETTINGS); - Sequence< OUString > aDriverKeys = aDriverSettings.getNodeNames(); - const OUString* pDriverKeys = aDriverKeys.getConstArray(); - const OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); - for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys) + for (auto& driverKey : aDriverSettings.getNodeNames()) { // the name of the driver in this round - OConfigurationNode aThisDriverSettings = aDriverSettings.openNode(*pDriverKeys); + OConfigurationNode aThisDriverSettings = aDriverSettings.openNode(driverKey); OUString sThisDriverName; aThisDriverSettings.getNodeValue(DRIVER_NAME) >>= sThisDriverName; diff --git a/cui/source/options/dbregisterednamesconfig.cxx b/cui/source/options/dbregisterednamesconfig.cxx index 6539506e9614..9c087d2823d0 100644 --- a/cui/source/options/dbregisterednamesconfig.cxx +++ b/cui/source/options/dbregisterednamesconfig.cxx @@ -43,14 +43,11 @@ namespace svx Reference< XDatabaseContext > xRegistrations( DatabaseContext::create(xContext) ); - Sequence< OUString > aRegistrationNames( xRegistrations->getRegistrationNames() ); - const OUString* pRegistrationName = aRegistrationNames.getConstArray(); - const OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength(); - for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) + for (auto& registrationName : xRegistrations->getRegistrationNames()) { - OUString sLocation( xRegistrations->getDatabaseLocation( *pRegistrationName ) ); - aSettings[ *pRegistrationName ] = - DatabaseRegistration( sLocation, xRegistrations->isDatabaseRegistrationReadOnly( *pRegistrationName ) ); + aSettings[registrationName] = DatabaseRegistration( + xRegistrations->getDatabaseLocation(registrationName), + xRegistrations->isDatabaseRegistrationReadOnly(registrationName)); } } catch( const Exception& ) @@ -99,13 +96,10 @@ namespace svx } // delete unused entries - Sequence< OUString > aRegistrationNames = xRegistrations->getRegistrationNames(); - const OUString* pRegistrationName = aRegistrationNames.getConstArray(); - const OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength(); - for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) + for (auto& registrationName : xRegistrations->getRegistrationNames()) { - if ( rNewRegistrations.find( *pRegistrationName ) == rNewRegistrations.end() ) - xRegistrations->revokeDatabaseLocation( *pRegistrationName ); + if (rNewRegistrations.find(registrationName) == rNewRegistrations.end()) + xRegistrations->revokeDatabaseLocation(registrationName); } } catch( const Exception& ) diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index dbe7f80e3d6b..a9f4720419a7 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -136,18 +136,6 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void) Reference< XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() ); - Sequence< Reference< XDictionary > > aDics; - if (xDicList.is()) - aDics = xDicList->getDictionaries(); - const Reference< XDictionary > *pDic = aDics.getConstArray(); - sal_Int32 nCount = aDics.getLength(); - - bool bFound = false; - sal_Int32 i; - for (i = 0; !bFound && i < nCount; ++i ) - if ( sDict.equalsIgnoreAsciiCase( pDic[i]->getName()) ) - bFound = true; - if ( sDict.indexOf("/") != -1 || sDict.indexOf("\\") != -1 ) { // Detected an invalid character. @@ -159,7 +147,12 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void) return; } - if ( bFound ) + Sequence< Reference< XDictionary > > aDics; + if (xDicList.is()) + aDics = xDicList->getDictionaries(); + + if (std::any_of(aDics.begin(), aDics.end(), + [&sDict](auto& d) { return sDict.equalsIgnoreAsciiCase(d->getName()); })) { // duplicate names? std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), @@ -276,13 +269,9 @@ SvxEditDictionaryDialog::SvxEditDictionaryDialog(weld::Window* pParent, std::u16 m_xReplaceED->connect_activate(LINK(this, SvxEditDictionaryDialog, NewDelActionHdl)); // fill listbox with all available WB's - const Reference< XDictionary > *pDic = aDics.getConstArray(); - sal_Int32 nCount = aDics.getLength(); - OUString aLookUpEntry; - for ( sal_Int32 i = 0; i < nCount; ++i ) + for (auto& xDic : aDics) { - Reference< XDictionary > xDic = pDic[i]; if (xDic.is()) { bool bNegative = xDic->getDictionaryType() == DictionaryType_NEGATIVE; @@ -298,7 +287,7 @@ SvxEditDictionaryDialog::SvxEditDictionaryDialog(weld::Window* pParent, std::u16 m_xLangLB->SetLanguageList( SvxLanguageListFlags::ALL, true, true ); - if ( nCount > 0 ) + if (aDics.hasElements()) { m_xAllDictsLB->set_active_text(aLookUpEntry); int nPos = m_xAllDictsLB->get_active(); @@ -396,7 +385,7 @@ void SvxEditDictionaryDialog::RemoveDictEntry(int nEntry) { OUString sTmpShort(m_pWordsLB->get_text(nEntry, 0)); - Reference<XDictionary> xDic = aDics.getConstArray()[nLBPos]; + Reference<XDictionary> xDic = aDics[nLBPos]; if (xDic->remove(sTmpShort)) // sal_True on success { m_pWordsLB->remove(nEntry); @@ -462,7 +451,7 @@ IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl, weld::ComboBox&, vo void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId ) { - Reference< XDictionary > xDic = aDics.getConstArray()[ nId ]; + Reference<XDictionary> xDic = aDics[nId]; weld::WaitObject aWait(m_xDialog.get()); @@ -512,16 +501,14 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId ) m_pWordsLB->clear(); Sequence< Reference< XDictionaryEntry > > aEntries( xDic->getEntries() ); - const Reference< XDictionaryEntry > *pEntry = aEntries.getConstArray(); - sal_Int32 nCount = aEntries.getLength(); std::vector<OUString> aSortedDicEntries; - aSortedDicEntries.reserve(nCount); - for (sal_Int32 i = 0; i < nCount; i++) + aSortedDicEntries.reserve(aEntries.getLength()); + for (auto& xDictionaryEntry : aEntries) { - OUString aStr = pEntry[i]->getDictionaryWord(); - if(!pEntry[i]->getReplacementText().isEmpty()) + OUString aStr = xDictionaryEntry->getDictionaryWord(); + if (!xDictionaryEntry->getReplacementText().isEmpty()) { - aStr += "\t" + pEntry[i]->getReplacementText(); + aStr += "\t" + xDictionaryEntry->getReplacementText(); } aSortedDicEntries.push_back(aStr); } @@ -540,10 +527,11 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId ) int nRow = 0; for (OUString const & rStr : aSortedDicEntries) { - m_pWordsLB->append_text(rStr.getToken(0, '\t')); - if (m_pWordsLB == m_xDoubleColumnLB.get()) + sal_Int32 index = 0; + m_pWordsLB->append_text(rStr.getToken(0, '\t', index)); + if (index != -1 && m_pWordsLB == m_xDoubleColumnLB.get()) { - OUString sReplace = rStr.getToken(1, '\t'); + OUString sReplace = rStr.getToken(0, '\t', index); m_pWordsLB->set_text(nRow, sReplace, 1); ++nRow; } diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 1b8e6f58fde7..c449bc4a652e 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -464,23 +464,18 @@ CanvasSettings::CanvasSettings() : Reference<XHierarchicalNameAccess> xHierarchicalNameAccess( xNameAccess, UNO_QUERY_THROW); - Sequence<OUString> serviceNames = xNameAccess->getElementNames(); - const OUString* pCurr = serviceNames.getConstArray(); - const OUString* const pEnd = pCurr + serviceNames.getLength(); - while( pCurr != pEnd ) + for (auto& serviceName : xNameAccess->getElementNames()) { Reference<XNameAccess> xEntryNameAccess( - xHierarchicalNameAccess->getByHierarchicalName(*pCurr), + xHierarchicalNameAccess->getByHierarchicalName(serviceName), UNO_QUERY ); if( xEntryNameAccess.is() ) { Sequence<OUString> preferredImplementations; if( xEntryNameAccess->getByName("PreferredImplementations") >>= preferredImplementations ) - maAvailableImplementations.emplace_back(*pCurr,preferredImplementations ); + maAvailableImplementations.emplace_back(serviceName, preferredImplementations); } - - ++pCurr; } } catch (const Exception&) @@ -500,15 +495,12 @@ bool CanvasSettings::IsHardwareAccelerationAvailable() const // implementation that presents the "HardwareAcceleration" property for (auto const& availableImpl : maAvailableImplementations) { - const OUString* pCurrImpl = availableImpl.second.getConstArray(); - const OUString* const pEndImpl = pCurrImpl + availableImpl.second.getLength(); - - while( pCurrImpl != pEndImpl ) + for (auto& currImpl : availableImpl.second) { try { Reference<XPropertySet> xPropSet( xFactory->createInstance( - pCurrImpl->trim() ), + currImpl.trim() ), UNO_QUERY_THROW ); bool bHasAccel(false); if( xPropSet->getPropertyValue("HardwareAcceleration") >>= bHasAccel ) @@ -521,8 +513,6 @@ bool CanvasSettings::IsHardwareAccelerationAvailable() const catch (const Exception&) { } - - ++pCurrImpl; } } } @@ -1144,10 +1134,9 @@ static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocal SAL_WARN_IF( !nPatterns, "cui.options", "No date acceptance pattern"); if (nPatterns) { - const OUString* pPatterns = aDateAcceptancePatterns.getConstArray(); - aBuf.append( pPatterns[0]); + aBuf.append(aDateAcceptancePatterns[0]); for (sal_Int32 i=1; i < nPatterns; ++i) - aBuf.append(";" + pPatterns[i]); + aBuf.append(";" + aDateAcceptancePatterns[i]); } return aBuf.makeStringAndClear(); } diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx index 4ec9bd987462..960fd62e1ebf 100644 --- a/cui/source/options/optlingu.cxx +++ b/cui/source/options/optlingu.cxx @@ -84,15 +84,8 @@ constexpr OUString cThes(SN_THESAURUS); static sal_Int32 lcl_SeqGetEntryPos( const Sequence< OUString > &rSeq, std::u16string_view rEntry ) { - sal_Int32 i; - sal_Int32 nLen = rSeq.getLength(); - const OUString *pItem = rSeq.getConstArray(); - for (i = 0; i < nLen; ++i) - { - if (rEntry == pItem[i]) - break; - } - return i < nLen ? i : -1; + 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 ) @@ -407,20 +400,6 @@ public: }; -static sal_Int32 lcl_SeqGetIndex( const Sequence< OUString > &rSeq, std::u16string_view rTxt ) -{ - sal_Int32 nRes = -1; - sal_Int32 nLen = rSeq.getLength(); - const OUString *pString = rSeq.getConstArray(); - for (sal_Int32 i = 0; i < nLen && nRes == -1; ++i) - { - if (pString[i] == rTxt) - nRes = i; - } - return nRes; -} - - Sequence< OUString > SvxLinguData_Impl::GetSortedImplNames( LanguageType nLang, sal_uInt8 nType ) { LangImplNameTable *pTable = nullptr; @@ -457,7 +436,7 @@ Sequence< OUString > SvxLinguData_Impl::GetSortedImplNames( LanguageType nLang, case TYPE_GRAMMAR : aImplName = rInfo.sGrammarImplName; break; } - if (!aImplName.isEmpty() && (lcl_SeqGetIndex( aRes, aImplName) == -1)) // name not yet added + if (!aImplName.isEmpty() && (lcl_SeqGetEntryPos( aRes, aImplName) == -1)) // name not yet added { DBG_ASSERT( nIdx < aRes.getLength(), "index out of range" ); if (nIdx < aRes.getLength()) @@ -745,20 +724,12 @@ void SvxLinguData_Impl::Reconfigure( std::u16string_view rDisplayName, bool bEna pInfo->bConfigured = bEnable; - Sequence< Locale > aLocales; - const Locale *pLocale = nullptr; - sal_Int32 nLocales = 0; - sal_Int32 i; - // update configured spellchecker entries if (pInfo->xSpell.is()) { - aLocales = pInfo->xSpell->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) + for (auto& locale : pInfo->xSpell->getLocales()) { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + LanguageType nLang = LanguageTag::convertToLanguageType(locale); if (!aCfgSpellTable.count( nLang ) && bEnable) aCfgSpellTable[ nLang ] = Sequence< OUString >(); if (aCfgSpellTable.count( nLang )) @@ -769,12 +740,9 @@ void SvxLinguData_Impl::Reconfigure( std::u16string_view rDisplayName, bool bEna // update configured grammar checker entries if (pInfo->xGrammar.is()) { - aLocales = pInfo->xGrammar->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) + for (auto& locale : pInfo->xGrammar->getLocales()) { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + LanguageType nLang = LanguageTag::convertToLanguageType(locale); if (!aCfgGrammarTable.count( nLang ) && bEnable) aCfgGrammarTable[ nLang ] = Sequence< OUString >(); if (aCfgGrammarTable.count( nLang )) @@ -785,12 +753,9 @@ void SvxLinguData_Impl::Reconfigure( std::u16string_view rDisplayName, bool bEna // update configured hyphenator entries if (pInfo->xHyph.is()) { - aLocales = pInfo->xHyph->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) + for (auto& locale : pInfo->xHyph->getLocales()) { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + LanguageType nLang = LanguageTag::convertToLanguageType(locale); if (!aCfgHyphTable.count( nLang ) && bEnable) aCfgHyphTable[ nLang ] = Sequence< OUString >(); if (aCfgHyphTable.count( nLang )) @@ -802,12 +767,9 @@ void SvxLinguData_Impl::Reconfigure( std::u16string_view rDisplayName, bool bEna if (!pInfo->xThes.is()) return; - aLocales = pInfo->xThes->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) + for (auto& locale : pInfo->xThes->getLocales()) { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + LanguageType nLang = LanguageTag::convertToLanguageType(locale); if (!aCfgThesTable.count( nLang ) && bEnable) aCfgThesTable[ nLang ] = Sequence< OUString >(); if (aCfgThesTable.count( nLang )) @@ -1017,7 +979,7 @@ bool SvxLinguTabPage::FillItemSet( SfxItemSet* rCoreSet ) if (aData.GetEntryId() < nDics) { bool bChecked = m_xLinguDicsCLB->get_toggle(i) == TRISTATE_TRUE; - uno::Reference< XDictionary > xDic( aDics.getConstArray()[ i ] ); + uno::Reference<XDictionary> xDic(aDics[i]); if (xDic.is()) { if (LinguMgr::GetIgnoreAllList() == xDic) @@ -1124,11 +1086,9 @@ void SvxLinguTabPage::UpdateDicBox_Impl() m_xLinguDicsCLB->freeze(); m_xLinguDicsCLB->clear(); - sal_Int32 nDics = aDics.getLength(); - const uno::Reference< XDictionary > *pDic = aDics.getConstArray(); - for (sal_Int32 i = 0; i < nDics; ++i) + for (sal_Int32 i = 0; i < aDics.getLength(); ++i) { - const uno::Reference< XDictionary > &rDic = pDic[i]; + const uno::Reference<XDictionary>& rDic = aDics[i]; if (rDic.is()) AddDicBoxEntry( rDic, static_cast<sal_uInt16>(i) ); } @@ -1373,7 +1333,7 @@ IMPL_LINK(SvxLinguTabPage, ModulesBoxCheckButtonHdl_Impl, const weld::TreeView:: IMPL_LINK(SvxLinguTabPage, DicsBoxCheckButtonHdl_Impl, const weld::TreeView::iter_col&, rRowCol, void) { - const uno::Reference<XDictionary> &rDic = aDics.getConstArray()[m_xLinguDicsCLB->get_iter_index_in_parent(rRowCol.first)]; + const uno::Reference<XDictionary> &rDic = aDics[m_xLinguDicsCLB->get_iter_index_in_parent(rRowCol.first)]; if (LinguMgr::GetIgnoreAllList() == rDic) m_xLinguDicsCLB->set_toggle(rRowCol.first, TRISTATE_TRUE); } @@ -1438,7 +1398,7 @@ IMPL_LINK(SvxLinguTabPage, ClickHdl_Impl, weld::Button&, rBtn, void) sal_Int32 nDics = aDics.getLength(); if (nDicPos < nDics) { - uno::Reference< XDictionary > xDic = aDics.getConstArray()[ nDicPos ]; + uno::Reference<XDictionary> xDic = aDics[nDicPos]; if (xDic.is()) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -1463,7 +1423,7 @@ IMPL_LINK(SvxLinguTabPage, ClickHdl_Impl, weld::Button&, rBtn, void) sal_Int32 nDics = aDics.getLength(); if (nDicPos < nDics) { - uno::Reference< XDictionary > xDic = aDics.getConstArray()[ nDicPos ]; + uno::Reference<XDictionary> xDic = aDics[nDicPos]; if (xDic.is()) { if (LinguMgr::GetIgnoreAllList() == xDic) @@ -1778,8 +1738,6 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) if (LANGUAGE_DONTKNOW != eCurLanguage) { - sal_Int32 n; - ServiceInfo_Impl* pInfo; bool bReadOnly = false; int nRow = 0; @@ -1802,16 +1760,13 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; } - Sequence< OUString > aNames( rLinguData.GetSortedImplNames( eCurLanguage, TYPE_SPELL ) ); - const OUString *pName = aNames.getConstArray(); - sal_Int32 nNames = aNames.getLength(); sal_Int32 nLocalIndex = 0; // index relative to parent - for (n = 0; n < nNames; ++n) + for (auto& name : rLinguData.GetSortedImplNames(eCurLanguage, TYPE_SPELL)) { OUString aImplName; bool bIsSuppLang = false; - pInfo = rLinguData.GetInfoByImplName( pName[n] ); + ServiceInfo_Impl* pInfo = rLinguData.GetInfoByImplName(name); if (pInfo) { bIsSuppLang = pInfo->xSpell.is() && @@ -1860,16 +1815,13 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; } - aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_GRAMMAR ); - pName = aNames.getConstArray(); - nNames = aNames.getLength(); nLocalIndex = 0; - for (n = 0; n < nNames; ++n) + for (auto& name : rLinguData.GetSortedImplNames(eCurLanguage, TYPE_GRAMMAR)) { OUString aImplName; bool bIsSuppLang = false; - pInfo = rLinguData.GetInfoByImplName( pName[n] ); + ServiceInfo_Impl* pInfo = rLinguData.GetInfoByImplName(name); if (pInfo) { bIsSuppLang = pInfo->xGrammar.is() && @@ -1919,16 +1871,13 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; } - aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_HYPH ); - pName = aNames.getConstArray(); - nNames = aNames.getLength(); nLocalIndex = 0; - for (n = 0; n < nNames; ++n) + for (auto& name : rLinguData.GetSortedImplNames(eCurLanguage, TYPE_HYPH)) { OUString aImplName; bool bIsSuppLang = false; - pInfo = rLinguData.GetInfoByImplName( pName[n] ); + ServiceInfo_Impl* pInfo = rLinguData.GetInfoByImplName(name); if (pInfo) { bIsSuppLang = pInfo->xHyph.is() && @@ -1977,16 +1926,13 @@ void SvxEditModulesDlg::LangSelectHdl_Impl(const SvxLanguageBox* pBox) bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0; } - aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_THES ); - pName = aNames.getConstArray(); - nNames = aNames.getLength(); nLocalIndex = 0; - for (n = 0; n < nNames; ++n) + for (auto& name : rLinguData.GetSortedImplNames(eCurLanguage, TYPE_THES)) { OUString aImplName; bool bIsSuppLang = false; - pInfo = rLinguData.GetInfoByImplName( pName[n] ); + ServiceInfo_Impl* pInfo = rLinguData.GetInfoByImplName(name); if (pInfo) { bIsSuppLang = pInfo->xThes.is() && diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index 4a410af07c4b..f75f354c9c6f 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -621,14 +621,11 @@ void SvxPathTabPage::GetPathList( Sequence< OUString > aPathSeq; if ( aAny >>= aPathSeq ) { - tools::Long i, nCount = aPathSeq.getLength(); - const OUString* pPaths = aPathSeq.getConstArray(); - - for ( i = 0; i < nCount; ++i ) + for (auto& path : aPathSeq) { if ( !_rInternalPath.isEmpty() ) _rInternalPath += ";"; - _rInternalPath += pPaths[i]; + _rInternalPath += path; } } // load user paths @@ -636,14 +633,11 @@ void SvxPathTabPage::GetPathList( sCfgName + POSTFIX_USER); if ( aAny >>= aPathSeq ) { - tools::Long i, nCount = aPathSeq.getLength(); - const OUString* pPaths = aPathSeq.getConstArray(); - - for ( i = 0; i < nCount; ++i ) + for (auto& path : aPathSeq) { if ( !_rUserPath.isEmpty() ) _rUserPath += ";"; - _rUserPath += pPaths[i]; + _rUserPath += path; } } // then the writable path diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index ecf23f377ec3..368a6d425186 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -576,29 +576,22 @@ IMPL_LINK_NOARG(SvxSaveTabPage, BackupClickHdl_Impl, weld::Toggleable&, void) static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties, std::u16string_view rExtension) { OUString sName; - const PropertyValue* pPropVal = rProperties.getConstArray(); - const PropertyValue* const pEnd = pPropVal + rProperties.getLength(); - for( ; pPropVal != pEnd; pPropVal++ ) + for (auto& propVal : rProperties) { - const OUString &rName = pPropVal->Name; + const OUString &rName = propVal.Name; if (rName == "UIName") { OUString sUIName; - if ( ( pPropVal->Value >>= sUIName ) && sUIName.getLength() ) + if ((propVal.Value >>= sUIName) && sUIName.getLength()) { if (!rExtension.empty()) - { - return sUIName + " (" + rExtension + ")"; - } - else - { - return sUIName; - } + sUIName += OUString::Concat(" (") + rExtension + ")"; + return sUIName; } } else if (rName == "Name") { - pPropVal->Value >>= sName; + propVal.Value >>= sName; } } diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index 2d084a1cd9af..05bd5822b5e0 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -98,26 +98,25 @@ static bool bLastRelative = false; static SvxNumSettings_Impl* lcl_CreateNumSettingsPtr(const Sequence<PropertyValue>& rLevelProps) { - const PropertyValue* pValues = rLevelProps.getConstArray(); SvxNumSettings_Impl* pNew = new SvxNumSettings_Impl; - for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++) + for (auto& prop : rLevelProps) { - if ( pValues[j].Name == "NumberingType" ) + if (prop.Name == "NumberingType") { sal_Int16 nTmp; - if (pValues[j].Value >>= nTmp) + if (prop.Value >>= nTmp) pNew->nNumberType = static_cast<SvxNumType>(nTmp); } - else if ( pValues[j].Name == "Prefix" ) - pValues[j].Value >>= pNew->sPrefix; - else if ( pValues[j].Name == "Suffix" ) - pValues[j].Value >>= pNew->sSuffix; - else if ( pValues[j].Name == "ParentNumbering" ) - pValues[j].Value >>= pNew->nParentNumbering; - else if ( pValues[j].Name == "BulletChar" ) - pValues[j].Value >>= pNew->sBulletChar; - else if ( pValues[j].Name == "BulletFontName" ) - pValues[j].Value >>= pNew->sBulletFont; + else if (prop.Name == "Prefix") + prop.Value >>= pNew->sPrefix; + else if (prop.Name == "Suffix") + prop.Value >>= pNew->sSuffix; + else if (prop.Name == "ParentNumbering") + prop.Value >>= pNew->nParentNumbering; + else if (prop.Name == "BulletChar") + prop.Value >>= pNew->sBulletChar; + else if (prop.Name == "BulletFontName") + prop.Value >>= pNew->sBulletFont; } return pNew; } @@ -176,13 +175,10 @@ SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(weld::Container* pPage, weld::D aNumberings = xDefNum->getDefaultContinuousNumberingLevels( rLocale ); - sal_Int32 nLength = std::min<sal_Int32>(aNumberings.getLength(), NUM_VALUSET_COUNT); - - const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray(); for(sal_Int32 i = 0; i < nLength; i++) { - SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]); + SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aNumberings[i]); aNumSettingsArr.push_back(std::unique_ptr<SvxNumSettings_Impl>(pNew)); } } @@ -501,7 +497,7 @@ SvxNumPickTabPage::SvxNumPickTabPage(weld::Container* pPage, weld::DialogControl { SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ]; - Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem]; + Reference<XIndexAccess> xLevel = aOutlineAccess[nItem]; for(sal_Int32 nLevel = 0; nLevel < SVX_MAX_NUM; nLevel++) { // use the last locale-defined level for all remaining levels. |