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

tdf#109158 short-circuit text width measuring with fixed width columns

Change-Id: Id050bfa8b4dae70e2a3a45b2501bb071d82d14e5
Reviewed-on: https://gerrit.libreoffice.org/72601
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a703b4d8
......@@ -180,6 +180,7 @@ private:
bool bReplaceEditChanged:1;
bool bSWriter:1;
std::vector<int> m_aReplaceFixedWidths;
std::unique_ptr<weld::CheckButton> m_xTextOnlyCB;
std::unique_ptr<weld::Entry> m_xShortED;
std::unique_ptr<weld::Entry> m_xReplaceED;
......
......@@ -680,9 +680,9 @@ OfaAutocorrReplacePage::OfaAutocorrReplacePage(TabPageParent pParent,
pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 );
pCharClass.reset( new CharClass( aLanguageTag ) );
std::vector<int> aWidths;
aWidths.push_back(m_xReplaceTLB->get_approximate_digit_width() * 32);
m_xReplaceTLB->set_column_fixed_widths(aWidths);
auto nColWidth = m_xReplaceTLB->get_approximate_digit_width() * 32;
m_aReplaceFixedWidths.push_back(nColWidth);
m_aReplaceFixedWidths.push_back(nColWidth);
m_xReplaceTLB->connect_changed( LINK(this, OfaAutocorrReplacePage, SelectHdl) );
m_xNewReplacePB->connect_clicked( LINK(this, OfaAutocorrReplacePage, NewDelButtonHdl) );
......@@ -827,7 +827,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset,
{
aFormatText.insert(rDouble.sShort);
}
});
}, &m_aReplaceFixedWidths);
}
else
{
......@@ -853,7 +853,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset,
{
aFormatText.insert(elem->GetShort());
}
});
}, &m_aReplaceFixedWidths);
m_xNewReplacePB->set_sensitive(false);
m_xDeleteReplacePB->set_sensitive(false);
}
......@@ -999,12 +999,13 @@ IMPL_LINK(OfaAutocorrReplacePage, NewDelActionHdl, weld::Entry&, rEdit, bool)
IMPL_LINK_NOARG(OfaAutocorrReplacePage, EntrySizeAllocHdl, const Size&, void)
{
std::vector<int> aWidths;
m_aReplaceFixedWidths.clear();
int x, y, width, height;
if (m_xReplaceED->get_extents_relative_to(*m_xReplaceTLB, x, y, width, height))
{
aWidths.push_back(x);
m_xReplaceTLB->set_column_fixed_widths(aWidths);
m_aReplaceFixedWidths.push_back(x);
m_aReplaceFixedWidths.push_back(width - 1);
m_xReplaceTLB->set_column_fixed_widths(m_aReplaceFixedWidths);
}
}
......
......@@ -85,6 +85,7 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="tabview">
......
......@@ -775,9 +775,15 @@ public:
// inserted with an arg of the index that this row will be when bulk insert
// ends.
//
// this enables inserting the entries backwards in models where that is faster
// this enables inserting the entries backwards in models where that is faster,
//
// pFixedWidths is optional, when present each matching entry col text
// width will not be measured, and the fixed width used instead. Use
// sparingly because wider text than the fixed width is clipped and cannot
// be scrolled into view horizontally.
virtual void bulk_insert_for_each(int nSourceCount,
const std::function<void(TreeIter&, int nSourceIndex)>& func)
const std::function<void(TreeIter&, int nSourceIndex)>& func,
const std::vector<int>* pFixedWidths = nullptr)
= 0;
void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; }
......
......@@ -61,6 +61,7 @@
#include <vcl/toolkit/unowrap.hxx>
#include <vcl/weld.hxx>
#include <vcl/vclmedit.hxx>
#include <vcl/viewdataentry.hxx>
#include <vcl/virdev.hxx>
#include <bitmaps.hlst>
......@@ -2768,7 +2769,9 @@ public:
enable_notify_events();
}
virtual void bulk_insert_for_each(int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func) override
virtual void bulk_insert_for_each(int nSourceCount,
const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
const std::vector<int>* pFixedWidths) override
{
freeze();
clear();
......@@ -2776,11 +2779,25 @@ public:
m_xTreeView->nTreeFlags |= SvTreeFlags::MANINS;
if (pFixedWidths)
set_column_fixed_widths(*pFixedWidths);
for (int i = 0; i < nSourceCount; ++i)
{
aVclIter.iter = new SvTreeListEntry;
m_xTreeView->Insert(aVclIter.iter, nullptr, TREELIST_APPEND);
func(aVclIter, i);
if (!pFixedWidths)
continue;
size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount());
for (size_t j = 0; j < nFixedWidths; ++j)
{
SvLBoxItem& rItem = aVclIter.iter->GetItem(j);
SvViewDataItem* pViewDataItem = m_xTreeView->GetViewDataItem(aVclIter.iter, &rItem);
pViewDataItem->mnWidth = (*pFixedWidths)[j];
}
}
m_xTreeView->nTreeFlags &= ~SvTreeFlags::MANINS;
......
......@@ -6710,12 +6710,16 @@ public:
return aSearch.index;
}
virtual void bulk_insert_for_each(int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func) override
virtual void bulk_insert_for_each(int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func,
const std::vector<int>* pFixedWidths) override
{
freeze();
clear();
GtkInstanceTreeIter aGtkIter(nullptr);
if (pFixedWidths)
set_column_fixed_widths(*pFixedWidths);
while (nSourceCount)
{
// tdf#125241 inserting backwards is massively faster
......
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