Kaydet (Commit) 40e84025 authored tarafından Caolán McNamara's avatar Caolán McNamara

use iterators for large aurocorr handling

Change-Id: Id63bd371d4665cb15fb684e0d5e962855a12b2e2
Reviewed-on: https://gerrit.libreoffice.org/72489
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 50588a15
...@@ -1080,7 +1080,8 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) ...@@ -1080,7 +1080,8 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn)
IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) 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(); bool bShort = &rEdt == m_xShortED.get();
const OUString rEntry = rEdt.get_text(); const OUString rEntry = rEdt.get_text();
const OUString rRepString = m_xReplaceED->get_text(); const OUString rRepString = m_xReplaceED->get_text();
...@@ -1093,37 +1094,36 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) ...@@ -1093,37 +1094,36 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void)
bool bFound = false; bool bFound = false;
bool bTmpSelEntry=false; bool bTmpSelEntry=false;
int nCount = m_xReplaceTLB->n_children(); m_xReplaceTLB->all_foreach([this, &rEntry, &rRepString, &bFound,
for (int i = 0; i < nCount; ++i) &bTmpSelEntry, &bFirstSelIterSet,
{ &xFirstSel, &aWordStr](weld::TreeIter& rIter){
int nEntry = i; OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0);
OUString aTestStr = m_xReplaceTLB->get_text(i, 0);
if( pCompareClass->compareString(rEntry, aTestStr ) == 0 ) if( pCompareClass->compareString(rEntry, aTestStr ) == 0 )
{ {
if( !rRepString.isEmpty() ) if (!rRepString.isEmpty())
{
bFirstSelect = true; bFirstSelect = true;
} m_xReplaceTLB->set_cursor(rIter);
m_xReplaceTLB->set_cursor(nEntry); m_xReplaceTLB->copy_iterator(rIter, *xFirstSel);
nFirstSel = i; bFirstSelIterSet = true;
m_xNewReplacePB->set_label(sModify); m_xNewReplacePB->set_label(sModify);
bFound = true; bFound = true;
break; return true;
} }
else else
{ {
aTestStr = pCharClass->lowercase( aTestStr ); aTestStr = pCharClass->lowercase( aTestStr );
if( aTestStr.startsWith(aWordStr) && !bTmpSelEntry ) if( aTestStr.startsWith(aWordStr) && !bTmpSelEntry )
{ {
m_xReplaceTLB->scroll_to_row(nEntry); m_xReplaceTLB->scroll_to_row(rIter);
bTmpSelEntry = true; bTmpSelEntry = true;
} }
} }
} return false;
});
if( !bFound ) if( !bFound )
{ {
m_xReplaceTLB->select(-1); m_xReplaceTLB->select(-1);
nFirstSel = -1; bFirstSelIterSet = false;
m_xNewReplacePB->set_label(sNew); m_xNewReplacePB->set_label(sNew);
if( bReplaceEditChanged ) if( bReplaceEditChanged )
m_xTextOnlyCB->set_sensitive(false); m_xTextOnlyCB->set_sensitive(false);
...@@ -1139,7 +1139,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) ...@@ -1139,7 +1139,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void)
else if( !bShort ) else if( !bShort )
{ {
bReplaceEditChanged = true; bReplaceEditChanged = true;
if (nFirstSel != -1) if (bFirstSelIterSet)
{ {
m_xNewReplacePB->set_label(sModify); m_xNewReplacePB->set_label(sModify);
} }
...@@ -1149,8 +1149,8 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) ...@@ -1149,8 +1149,8 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void)
bool bEnableNew = !rShortTxt.isEmpty() && bool bEnableNew = !rShortTxt.isEmpty() &&
( !rRepString.isEmpty() || ( !rRepString.isEmpty() ||
( bHasSelectionText && bSWriter )) && ( bHasSelectionText && bSWriter )) &&
( nFirstSel == -1 || rRepString != ( !bFirstSelIterSet || rRepString !=
m_xReplaceTLB->get_text(nFirstSel, 1) ); m_xReplaceTLB->get_text(*xFirstSel, 1) );
if( bEnableNew ) if( bEnableNew )
{ {
for (auto const& elem : aFormatText) for (auto const& elem : aFormatText)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment