[Libreoffice-commits] core.git: Branch 'feature/eszka' - 4 commits - include/vcl sc/source vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 11 17:47:31 UTC 2020


 include/vcl/salvtables.hxx           |    4 +
 include/vcl/treelist.hxx             |    1 
 include/vcl/weld.hxx                 |    1 
 sc/source/ui/cctrl/checklistmenu.cxx |   16 ++--
 vcl/source/app/salvtables.cxx        |  126 ++++++++++++++++-------------------
 vcl/unx/gtk3/gtk3gtkinst.cxx         |   20 +++++
 6 files changed, 95 insertions(+), 73 deletions(-)

New commits:
commit ad72de8693eb7cefae06b433be01196e679d6e3f
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Mar 22 20:21:09 2020 +0000
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 11 18:43:38 2020 +0100

    always set ForceMakeVisible
    
    Change-Id: Icb0b4f34b5f230b6e1cb99debba278e4a9c8dd96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90893
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index dd07cd7a5979..98533945d6da 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3475,6 +3475,7 @@ SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBui
     , m_nSortColumn(-1)
 {
     m_xTreeView->SetNodeDefaultImages();
+    m_xTreeView->SetForceMakeVisible(true);
     m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
     m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl));
     m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, DoubleClickHdl));
commit fd6542107db59eca054f5ea1442302d9f3aba742
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 10 09:33:39 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 11 18:43:38 2020 +0100

    tdf#131581 inhibit updates during all_foreach
    
    Change-Id: I8494b4c9175e427bfb89696d49c2da7607af37ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102371
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx
index c53669e32c35..ee55bb9fa081 100644
--- a/include/vcl/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -1151,6 +1151,8 @@ protected:
 
     void update_checkbutton_column_width(SvTreeListEntry* pEntry);
 
+    void InvalidateModelEntry(SvTreeListEntry* pEntry);
+
     void do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col);
 
     static TriState do_get_toggle(SvTreeListEntry* pEntry, int col);
diff --git a/include/vcl/treelist.hxx b/include/vcl/treelist.hxx
index 20045cb21804..ffb359a4e8f8 100644
--- a/include/vcl/treelist.hxx
+++ b/include/vcl/treelist.hxx
@@ -133,6 +133,7 @@ public:
                         );
 
     void                EnableInvalidate( bool bEnable );
+    bool                IsEnableInvalidate() const { return mbEnableInvalidate; }
 
     // Notify all Listeners
     void                InvalidateEntry( SvTreeListEntry* );
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index b0e33be5cf6f..dd07cd7a5979 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3237,6 +3237,37 @@ int SalInstanceTreeView::to_external_model(int col) const
     return col;
 }
 
+namespace
+{
+    class UpdateGuard
+    {
+    private:
+        SvTabListBox& m_rTreeView;
+        bool m_bOrigUpdate;
+        bool m_bOrigEnableInvalidate;
+
+    public:
+        UpdateGuard(SvTabListBox& rTreeView)
+            : m_rTreeView(rTreeView)
+            , m_bOrigUpdate(m_rTreeView.IsUpdateMode())
+            , m_bOrigEnableInvalidate(m_rTreeView.GetModel()->IsEnableInvalidate())
+        {
+            if (m_bOrigUpdate)
+                m_rTreeView.SetUpdateMode(false);
+            if (m_bOrigEnableInvalidate)
+                m_rTreeView.GetModel()->EnableInvalidate(false);
+        }
+
+        ~UpdateGuard()
+        {
+            if (m_bOrigUpdate)
+                m_rTreeView.SetUpdateMode(true);
+            if (m_bOrigEnableInvalidate)
+                m_rTreeView.GetModel()->EnableInvalidate(true);
+        }
+    };
+}
+
 bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry* pEntry) const
 {
     return m_xTreeView->GetEntryText(pEntry).trim() == "<dummy>";
@@ -3337,6 +3368,13 @@ void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry* pEntr
     m_xTreeView->CheckBoxInserted(pEntry);
 }
 
+void SalInstanceTreeView::InvalidateModelEntry(SvTreeListEntry* pEntry)
+{
+    if (!m_xTreeView->GetModel()->IsEnableInvalidate())
+        return;
+    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+}
+
 void SalInstanceTreeView::do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col)
 {
     assert(col >= 0 && static_cast<unsigned>(col) < pEntry->ItemCount());
@@ -3363,7 +3401,7 @@ void SalInstanceTreeView::do_set_toggle(SvTreeListEntry* pEntry, TriState eState
             break;
     }
 
-    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    InvalidateModelEntry(pEntry);
 }
 
 TriState SalInstanceTreeView::do_get_toggle(SvTreeListEntry* pEntry, int col)
@@ -3802,7 +3840,7 @@ void SalInstanceTreeView::set_text(SvTreeListEntry* pEntry, const OUString& rTex
         assert(dynamic_cast<SvLBoxString*>(&rItem));
         static_cast<SvLBoxString&>(rItem).SetText(rText);
     }
-    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    InvalidateModelEntry(pEntry);
 }
 
 void SalInstanceTreeView::set_text(int pos, const OUString& rText, int col)
@@ -3822,8 +3860,7 @@ void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive
             if (rItem.GetType() == SvLBoxItemType::String)
             {
                 rItem.Enable(bSensitive);
-                m_xTreeView->ModelHasEntryInvalidated(pEntry);
-                break;
+                InvalidateModelEntry(pEntry);
             }
         }
         return;
@@ -3835,7 +3872,7 @@ void SalInstanceTreeView::set_sensitive(SvTreeListEntry* pEntry, bool bSensitive
     SvLBoxItem& rItem = pEntry->GetItem(col);
     rItem.Enable(bSensitive);
 
-    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    InvalidateModelEntry(pEntry);
 }
 
 void SalInstanceTreeView::set_sensitive(int pos, bool bSensitive, int col)
@@ -3894,7 +3931,7 @@ void SalInstanceTreeView::set_text_emphasis(SvTreeListEntry* pEntry, bool bOn, i
     assert(dynamic_cast<SvLBoxString*>(&rItem));
     static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
 
-    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    InvalidateModelEntry(pEntry);
 }
 
 void SalInstanceTreeView::set_text_emphasis(const weld::TreeIter& rIter, bool bOn, int col)
@@ -3930,7 +3967,7 @@ void SalInstanceTreeView::set_text_align(SvTreeListEntry* pEntry, double fAlign,
     assert(dynamic_cast<SvLBoxString*>(&rItem));
     static_cast<SvLBoxString&>(rItem).Align(fAlign);
 
-    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    InvalidateModelEntry(pEntry);
 }
 
 void SalInstanceTreeView::set_text_align(const weld::TreeIter& rIter, double fAlign, int col)
@@ -3995,7 +4032,7 @@ void SalInstanceTreeView::set_image(SvTreeListEntry* pEntry, const Image& rImage
     }
 
     m_xTreeView->SetEntryHeight(pEntry);
-    m_xTreeView->ModelHasEntryInvalidated(pEntry);
+    InvalidateModelEntry(pEntry);
 }
 
 void SalInstanceTreeView::set_image(int pos, const OUString& rImage, int col)
@@ -4272,6 +4309,8 @@ void SalInstanceTreeView::set_selection_mode(SelectionMode eMode)
 
 void SalInstanceTreeView::all_foreach(const std::function<bool(weld::TreeIter&)>& func)
 {
+    UpdateGuard aGuard(*m_xTreeView);
+
     SalInstanceTreeIter aVclIter(m_xTreeView->First());
     while (aVclIter.iter)
     {
commit 85237ad225d84428f128fd1be09d60d1535d7cfb
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 30 15:03:31 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 11 18:43:30 2020 +0100

    tdf#134270 rearrange so we know the final treeview width
    
    so we can unconditionally use the treeview width as the optimized
    pre-calculated row width hint and then fix up the gen fixed column
    settings to take account of the auto CHK_BTN mode
    
    Change-Id: I2e1eaf4b1121d5e705eb7db3464f123c038db246
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97532
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 8e63bea9c344..b0e33be5cf6f 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3334,8 +3334,7 @@ void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry* pEntr
 {
     SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
     m_xTreeView->InitViewData(pViewData, pEntry);
-    if (!m_bDisableCheckBoxAutoWidth)
-        m_xTreeView->CheckBoxInserted(pEntry);
+    m_xTreeView->CheckBoxInserted(pEntry);
 }
 
 void SalInstanceTreeView::do_set_toggle(SvTreeListEntry* pEntry, TriState eState, int col)
@@ -3434,7 +3433,6 @@ SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBui
     , m_xTreeView(pTreeView)
     , m_aCheckButtonData(pTreeView, false)
     , m_aRadioButtonData(pTreeView, true)
-    , m_bDisableCheckBoxAutoWidth(false)
     , m_bTogglesAsRadio(false)
     , m_nSortColumn(-1)
 {
@@ -3499,7 +3497,6 @@ void SalInstanceTreeView::thaw()
 
 void SalInstanceTreeView::set_column_fixed_widths(const std::vector<int>& rWidths)
 {
-    m_bDisableCheckBoxAutoWidth = true;
     std::vector<long> aTabPositions;
     aTabPositions.push_back(0);
     for (size_t i = 0; i < rWidths.size(); ++i)
@@ -3569,57 +3566,8 @@ void SalInstanceTreeView::insert(const weld::TreeIter* pParent, int pos, const O
                     const OUString* pIconName, VirtualDevice* pImageSurface,
                     const OUString* pExpanderName, bool bChildrenOnDemand, weld::TreeIter* pRet)
 {
-    disable_notify_events();
-    const SalInstanceTreeIter* pVclIter = static_cast<const SalInstanceTreeIter*>(pParent);
-    SvTreeListEntry* iter = pVclIter ? pVclIter->iter : nullptr;
-    auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos;
-    void* pUserData;
-    if (pId)
-    {
-        m_aUserData.emplace_back(std::make_unique<OUString>(*pId));
-        pUserData = m_aUserData.back().get();
-    }
-    else
-        pUserData = nullptr;
-
-    SvTreeListEntry* pEntry = new SvTreeListEntry;
-
-    if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
-        AddStringItem(pEntry, "", -1);
-
-    if (pIconName || pImageSurface)
-    {
-        Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
-        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
-    }
-    else
-    {
-        Image aDummy;
-        pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
-    }
-    if (pStr)
-        pEntry->AddItem(std::make_unique<SvLBoxString>(*pStr));
-    pEntry->SetUserData(pUserData);
-    m_xTreeView->Insert(pEntry, iter, nInsertPos);
-
-    if (pExpanderName)
-    {
-        Image aImage(createImage(*pExpanderName));
-        m_xTreeView->SetExpandedEntryBmp(pEntry, aImage);
-        m_xTreeView->SetCollapsedEntryBmp(pEntry, aImage);
-    }
-
-    if (pRet)
-    {
-        SalInstanceTreeIter* pVclRetIter = static_cast<SalInstanceTreeIter*>(pRet);
-        pVclRetIter->iter = pEntry;
-    }
-
-    if (bChildrenOnDemand)
-    {
-        m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr);
-    }
-    enable_notify_events();
+    do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface,
+                  bChildrenOnDemand, pRet, false);
 }
 
 void SalInstanceTreeView::bulk_insert_for_each(int nSourceCount,
@@ -3635,11 +3583,14 @@ void SalInstanceTreeView::bulk_insert_for_each(int nSourceCount,
     if (pFixedWidths)
         set_column_fixed_widths(*pFixedWidths);
 
+    bool bHasAutoCheckButton(m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN);
+        size_t nExtraCols = bHasAutoCheckButton ? 2 : 1;
+
     Image aDummy;
     for (int i = 0; i < nSourceCount; ++i)
     {
         aVclIter.iter = new SvTreeListEntry;
-        if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN)
+        if (bHasAutoCheckButton)
             AddStringItem(aVclIter.iter, "", -1);
         aVclIter.iter->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false));
         m_xTreeView->Insert(aVclIter.iter, nullptr, TREELIST_APPEND);
@@ -3651,7 +3602,7 @@ void SalInstanceTreeView::bulk_insert_for_each(int nSourceCount,
         size_t nFixedWidths = std::min(pFixedWidths->size(), aVclIter.iter->ItemCount());
         for (size_t j = 0; j < nFixedWidths; ++j)
         {
-            SvLBoxItem& rItem = aVclIter.iter->GetItem(j);
+            SvLBoxItem& rItem = aVclIter.iter->GetItem(j + nExtraCols);
             SvViewDataItem* pViewDataItem = m_xTreeView->GetViewDataItem(aVclIter.iter, &rItem);
             pViewDataItem->mnWidth = (*pFixedWidths)[j];
         }
commit 62108d8885119a5dc01ffe4d7aed9277359d71b0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Jan 19 17:52:36 2020 +0000
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Nov 11 18:04:14 2020 +0100

    add get_row_area for TreeView
    
    Change-Id: I0fa8e3666f6731abb831d0ba62f128614eae261c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87048
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx
index a1a8eabfe0fd..c53669e32c35 100644
--- a/include/vcl/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -1402,6 +1402,8 @@ public:
 
     virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult) override;
 
+    virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const override;
+
     virtual TreeView* get_drag_source() const override;
 
     void set_show_expanders(bool bShow) override;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 351d39b5224b..6dcd91c97ccb 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1026,6 +1026,7 @@ public:
 
     // for dnd
     virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult) = 0;
+    virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const = 0;
     // for dragging and dropping between TreeViews, return the active source
     virtual TreeView* get_drag_source() const = 0;
 
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 493400ea3efb..313409a6fce0 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -279,14 +279,14 @@ void ScCheckListMenuControl::launchSubMenu(bool bSetMenuPos)
     if (!mxMenu->get_selected(mxScratchIter.get()))
         return;
 
-    // tools::Rectangle aRect = mxMenu->get_row_area(*mxScratchIter);
-    // ScCheckListMenuControl& rSubMenuControl = pSubMenu->get_widget();
-    // rSubMenuControl.StartPopupMode(aRect, (FloatWinPopupFlags::Right | FloatWinPopupFlags::GrabFocus));
-    // if (bSetMenuPos)
-    //     rSubMenuControl.setSelectedMenuItem(0, false, false); // select menu item after the popup becomes fully visible.
-
-    // mxMenu->select(*mxScratchIter);
-    // rSubMenuControl.GrabFocus();
+    tools::Rectangle aRect = mxMenu->get_row_area(*mxScratchIter);
+    ScCheckListMenuControl& rSubMenuControl = pSubMenu->get_widget();
+    rSubMenuControl.StartPopupMode(aRect, (FloatWinPopupFlags::Right | FloatWinPopupFlags::GrabFocus));
+    if (bSetMenuPos)
+        rSubMenuControl.setSelectedMenuItem(0, false); // select menu item after the popup becomes fully visible.
+
+    mxMenu->select(*mxScratchIter);
+    rSubMenuControl.GrabFocus();
 }
 
 IMPL_LINK_NOARG(ScCheckListMenuControl, PostPopdownHdl, void*, void)
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 822871242a42..8e63bea9c344 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4527,6 +4527,11 @@ bool SalInstanceTreeView::get_dest_row_at_pos(const Point &rPos, weld::TreeIter*
     return pTarget != nullptr;
 }
 
+tools::Rectangle SalInstanceTreeView::get_row_area(const weld::TreeIter& rIter) const
+{
+    return m_xTreeView->GetBoundingRect(static_cast<const SalInstanceTreeIter&>(rIter).iter);
+}
+
 weld::TreeView* SalInstanceTreeView::get_drag_source() const
 {
     return g_DragSource;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index c3e019b1d048..7729d0ab082b 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -10232,6 +10232,26 @@ public:
         return ret;
     }
 
+    virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const override
+    {
+        tools::Rectangle aRet;
+
+        const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter);
+        GtkTreePath* pPath = gtk_tree_model_get_path(m_pTreeModel, const_cast<GtkTreeIter*>(&rGtkIter.iter));
+
+        GdkRectangle aRect;
+        for (GList* pEntry = g_list_last(m_pColumns); pEntry; pEntry = g_list_previous(pEntry))
+        {
+            GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(pEntry->data);
+            gtk_tree_view_get_cell_area(m_pTreeView, pPath, pColumn, &aRect);
+            aRet.Union(tools::Rectangle(aRect.x, aRect.y, aRect.x + aRect.width, aRect.y + aRect.height));
+        }
+
+        gtk_tree_path_free(pPath);
+
+        return aRet;
+    }
+
     virtual void start_editing(const weld::TreeIter& rIter) override
     {
         GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, m_nTextView));


More information about the Libreoffice-commits mailing list