summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-05-20 12:34:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-05-21 17:21:02 +0200
commit86618248683fa4048192d15356c7e6b430e8dbb9 (patch)
tree56e8bfbb202fc09539af38e2f273d56b24baecd5
parenta703b4d8842261f55f489c28352df1f53a9b070a (diff)
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: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--cui/source/inc/autocdlg.hxx1
-rw-r--r--cui/source/tabpages/autocdlg.cxx17
-rw-r--r--cui/uiconfig/ui/acorreplacepage.ui1
-rw-r--r--include/vcl/weld.hxx10
-rw-r--r--vcl/source/app/salvtables.cxx19
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx6
6 files changed, 42 insertions, 12 deletions
diff --git a/cui/source/inc/autocdlg.hxx b/cui/source/inc/autocdlg.hxx
index 346c6a1e556c..bcb283f154e6 100644
--- a/cui/source/inc/autocdlg.hxx
+++ b/cui/source/inc/autocdlg.hxx
@@ -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;
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 9e65e501740d..00c409916d42 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -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);
}
}
diff --git a/cui/uiconfig/ui/acorreplacepage.ui b/cui/uiconfig/ui/acorreplacepage.ui
index 326152eb2ca8..36808eb4ec4d 100644
--- a/cui/uiconfig/ui/acorreplacepage.ui
+++ b/cui/uiconfig/ui/acorreplacepage.ui
@@ -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">
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 8ba41b4e5851..71214ada80cf 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -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; }
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 3e375cd212ee..5c75d2f369a2 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -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;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index a39edc1abf07..fa8fbd554973 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -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