summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-24 14:56:23 +0000
committerMichael Stahl <michael.stahl@cib.de>2020-01-27 11:24:50 +0100
commitf1e14f99179ea2169750340d184ca92ce36b3125 (patch)
tree1fe6ff8934208050d1bbda130cf312189f1cde56 /cui
parent59edd056643125978483e7292bfb4b7be707cf3d (diff)
Resolves: tdf#130143 crash in sorted font replacement table
it was always sorted historically, just without showing the sort indicator. Fix that inconsistency which led to the error causing the crash, and use iterators when appending to the sorted list instead of indexes which is the crashing part. Change-Id: I4ea3028a334129bdeb8e1a1aa79f4ead8a0243e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87344 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/options/fontsubs.cxx41
-rw-r--r--cui/source/options/fontsubs.hxx1
2 files changed, 19 insertions, 23 deletions
diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx
index 4cedb534c6f9..8db43110dadd 100644
--- a/cui/source/options/fontsubs.cxx
+++ b/cui/source/options/fontsubs.cxx
@@ -35,7 +35,6 @@
SvxFontSubstTabPage::SvxFontSubstTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
: SfxTabPage(pPage, pController, "cui/ui/optfontspage.ui", "OptFontsPage", &rSet)
, m_xConfig(new SvtFontSubstConfig)
- , m_bSorted(false)
, m_xUseTableCB(m_xBuilder->weld_check_button("usetable"))
, m_xFont1CB(m_xBuilder->weld_combo_box("font1"))
, m_xFont2CB(m_xBuilder->weld_combo_box("font2"))
@@ -57,7 +56,6 @@ SvxFontSubstTabPage::SvxFontSubstTabPage(weld::Container* pPage, weld::DialogCon
m_xCheckLB->get_height_rows(10));
m_xCheckLB->set_help_id(HID_OFA_FONT_SUBST_CLB);
m_xCheckLB->set_selection_mode(SelectionMode::Multiple);
- m_xCheckLB->set_sort_column(3);
setColSizes();
@@ -92,12 +90,6 @@ SvxFontSubstTabPage::SvxFontSubstTabPage(weld::Container* pPage, weld::DialogCon
IMPL_LINK(SvxFontSubstTabPage, HeaderBarClick, int, nColumn, void)
{
- if (!m_bSorted)
- {
- m_xCheckLB->make_sorted();
- m_bSorted = true;
- }
-
bool bSortAtoZ = m_xCheckLB->get_sort_order();
//set new arrow positions in headerbar
@@ -204,18 +196,23 @@ void SvxFontSubstTabPage::Reset( const SfxItemSet* )
if (nCount)
m_xUseTableCB->set_active(m_xConfig->IsEnabled());
+ std::unique_ptr<weld::TreeIter> xIter(m_xCheckLB->make_iterator());
for (sal_Int32 i = 0; i < nCount; ++i)
{
- m_xCheckLB->append();
+ m_xCheckLB->append(xIter.get());
const SubstitutionStruct* pSubs = m_xConfig->GetSubstitution(i);
- m_xCheckLB->set_toggle(i, pSubs->bReplaceAlways ? TRISTATE_TRUE : TRISTATE_FALSE, 1);
- m_xCheckLB->set_toggle(i, pSubs->bReplaceOnScreenOnly ? TRISTATE_TRUE : TRISTATE_FALSE, 2);
- m_xCheckLB->set_text(i, pSubs->sFont, 3);
- m_xCheckLB->set_text(i, pSubs->sReplaceBy, 4);
+ m_xCheckLB->set_toggle(*xIter, pSubs->bReplaceAlways ? TRISTATE_TRUE : TRISTATE_FALSE, 1);
+ m_xCheckLB->set_toggle(*xIter, pSubs->bReplaceOnScreenOnly ? TRISTATE_TRUE : TRISTATE_FALSE, 2);
+ m_xCheckLB->set_text(*xIter, pSubs->sFont, 3);
+ m_xCheckLB->set_text(*xIter, pSubs->sReplaceBy, 4);
}
m_xCheckLB->thaw();
+ m_xCheckLB->make_sorted();
+ m_xCheckLB->set_sort_column(3);
+ m_xCheckLB->set_sort_indicator(TRISTATE_TRUE, 3);
+
CheckEnable();
//fill font name box first
@@ -282,10 +279,12 @@ void SvxFontSubstTabPage::SelectHdl(const weld::Widget* pWin)
int nPos = findText(*m_xCheckLB, m_xFont1CB->get_active_text());
if (pWin == m_xApply.get())
{
+ m_xCheckLB->unselect_all();
if (nPos != -1)
{
// change entry
m_xCheckLB->set_text(nPos, m_xFont2CB->get_active_text(), 4);
+ m_xCheckLB->select(nPos);
}
else
{
@@ -293,16 +292,14 @@ void SvxFontSubstTabPage::SelectHdl(const weld::Widget* pWin)
OUString sFont1 = m_xFont1CB->get_active_text();
OUString sFont2 = m_xFont2CB->get_active_text();
- nPos = m_xCheckLB->n_children();
- m_xCheckLB->append();
- m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 1);
- m_xCheckLB->set_toggle(nPos, TRISTATE_FALSE, 2);
- m_xCheckLB->set_text(nPos, sFont1, 3);
- m_xCheckLB->set_text(nPos, sFont2, 4);
-
+ std::unique_ptr<weld::TreeIter> xIter(m_xCheckLB->make_iterator());
+ m_xCheckLB->append(xIter.get());
+ m_xCheckLB->set_toggle(*xIter, TRISTATE_FALSE, 1);
+ m_xCheckLB->set_toggle(*xIter, TRISTATE_FALSE, 2);
+ m_xCheckLB->set_text(*xIter, sFont1, 3);
+ m_xCheckLB->set_text(*xIter, sFont2, 4);
+ m_xCheckLB->select(*xIter);
}
- m_xCheckLB->unselect_all();
- m_xCheckLB->select(nPos);
}
else if (pWin == m_xDelete.get())
{
diff --git a/cui/source/options/fontsubs.hxx b/cui/source/options/fontsubs.hxx
index 880c11675858..b7fed8b8162c 100644
--- a/cui/source/options/fontsubs.hxx
+++ b/cui/source/options/fontsubs.hxx
@@ -27,7 +27,6 @@ class SvxFontSubstTabPage : public SfxTabPage
{
OUString m_sAutomatic;
std::unique_ptr<SvtFontSubstConfig> m_xConfig;
- bool m_bSorted;
std::unique_ptr<weld::CheckButton> m_xUseTableCB;
std::unique_ptr<weld::ComboBox> m_xFont1CB;