diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-17 13:26:55 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-20 14:53:59 +0200 |
commit | 40e8402585ffed9a3fca46241e392b8101d7c18b (patch) | |
tree | 52c4ea79d29016dc59dc94c419c34cf7748e0a0e /cui/source/tabpages | |
parent | 50588a1583e3cc5dc647a35889e50478c7bfd033 (diff) |
use iterators for large aurocorr handling
Change-Id: Id63bd371d4665cb15fb684e0d5e962855a12b2e2
Reviewed-on: https://gerrit.libreoffice.org/72489
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source/tabpages')
-rw-r--r-- | cui/source/tabpages/autocdlg.cxx | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 861f2a70396f..9e65e501740d 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -1080,7 +1080,8 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) { - int nFirstSel = m_xReplaceTLB->get_selected_index(); + std::unique_ptr<weld::TreeIter> xFirstSel(m_xReplaceTLB->make_iterator()); + bool bFirstSelIterSet = m_xReplaceTLB->get_selected(xFirstSel.get()); bool bShort = &rEdt == m_xShortED.get(); const OUString rEntry = rEdt.get_text(); const OUString rRepString = m_xReplaceED->get_text(); @@ -1093,37 +1094,36 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) bool bFound = false; bool bTmpSelEntry=false; - int nCount = m_xReplaceTLB->n_children(); - for (int i = 0; i < nCount; ++i) - { - int nEntry = i; - OUString aTestStr = m_xReplaceTLB->get_text(i, 0); + m_xReplaceTLB->all_foreach([this, &rEntry, &rRepString, &bFound, + &bTmpSelEntry, &bFirstSelIterSet, + &xFirstSel, &aWordStr](weld::TreeIter& rIter){ + OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0); if( pCompareClass->compareString(rEntry, aTestStr ) == 0 ) { - if( !rRepString.isEmpty() ) - { + if (!rRepString.isEmpty()) bFirstSelect = true; - } - m_xReplaceTLB->set_cursor(nEntry); - nFirstSel = i; + m_xReplaceTLB->set_cursor(rIter); + m_xReplaceTLB->copy_iterator(rIter, *xFirstSel); + bFirstSelIterSet = true; m_xNewReplacePB->set_label(sModify); bFound = true; - break; + return true; } else { aTestStr = pCharClass->lowercase( aTestStr ); if( aTestStr.startsWith(aWordStr) && !bTmpSelEntry ) { - m_xReplaceTLB->scroll_to_row(nEntry); + m_xReplaceTLB->scroll_to_row(rIter); bTmpSelEntry = true; } } - } + return false; + }); if( !bFound ) { m_xReplaceTLB->select(-1); - nFirstSel = -1; + bFirstSelIterSet = false; m_xNewReplacePB->set_label(sNew); if( bReplaceEditChanged ) m_xTextOnlyCB->set_sensitive(false); @@ -1139,7 +1139,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) else if( !bShort ) { bReplaceEditChanged = true; - if (nFirstSel != -1) + if (bFirstSelIterSet) { m_xNewReplacePB->set_label(sModify); } @@ -1149,8 +1149,8 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) bool bEnableNew = !rShortTxt.isEmpty() && ( !rRepString.isEmpty() || ( bHasSelectionText && bSWriter )) && - ( nFirstSel == -1 || rRepString != - m_xReplaceTLB->get_text(nFirstSel, 1) ); + ( !bFirstSelIterSet || rRepString != + m_xReplaceTLB->get_text(*xFirstSel, 1) ); if( bEnableNew ) { for (auto const& elem : aFormatText) |