[Libreoffice-commits] core.git: cui/source cui/uiconfig include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 21 15:23:04 UTC 2019


 cui/source/inc/autocdlg.hxx        |    1 +
 cui/source/tabpages/autocdlg.cxx   |   17 +++++++++--------
 cui/uiconfig/ui/acorreplacepage.ui |    1 +
 include/vcl/weld.hxx               |   10 ++++++++--
 vcl/source/app/salvtables.cxx      |   19 ++++++++++++++++++-
 vcl/unx/gtk3/gtk3gtkinst.cxx       |    6 +++++-
 6 files changed, 42 insertions(+), 12 deletions(-)

New commits:
commit 86618248683fa4048192d15356c7e6b430e8dbb9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 20 12:34:52 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 21 17:21:02 2019 +0200

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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


More information about the Libreoffice-commits mailing list