vcl/source/app/salvtables.cxx |   20 ++++++++++++++++----
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   30 +++++++++++++++++++++++++-----
 2 files changed, 41 insertions(+), 9 deletions(-)

New commits:
commit bbb9500ebf9ce5522b3c2c8e07e7fa227620dc40
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Mar 2 19:49:10 2020 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Mar 3 13:02:16 2020 +0100

    deem placeholders entries currently expanding as logically still 
placeholders
    
    Change-Id: I87ebc1d7e095f465c76fcd9b76c01749fe6b57df
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89871
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e4aafd793bba..f42448890b11 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -19,7 +19,7 @@
 
 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
 #include <com/sun/star/awt/XWindow.hpp>
-#include <o3tl/safeint.hxx>
+#include <o3tl/sorted_vector.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <iconview.hxx>
 #include <salframe.hxx>
@@ -3251,6 +3251,9 @@ private:
     VclPtr<SvTabListBox> m_xTreeView;
     SvLBoxButtonData m_aCheckButtonData;
     SvLBoxButtonData m_aRadioButtonData;
+    // currently expanding parent that logically, but not currently physically,
+    // contain placeholders
+    o3tl::sorted_vector<SvTreeListEntry*> m_aExpandingPlaceHolderParents;
     bool m_bDisableCheckBoxAutoWidth;
     int m_nSortColumn;
 
@@ -4197,6 +4200,8 @@ public:
     virtual bool get_children_on_demand(const weld::TreeIter& rIter) const 
override
     {
         const SalInstanceTreeIter& rVclIter = static_cast<const 
SalInstanceTreeIter&>(rIter);
+        if (m_aExpandingPlaceHolderParents.count(rVclIter.iter))
+            return true;
         return GetPlaceHolderChild(rVclIter.iter) != nullptr;
     }
 
@@ -4690,14 +4695,21 @@ IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, 
SvTreeListBox*, bool)
     // potentially expandable in the first place, now we remove it
     SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(pEntry);
     if (pPlaceHolder)
+    {
+        m_aExpandingPlaceHolderParents.insert(pEntry);
         m_xTreeView->RemoveEntry(pPlaceHolder);
+    }
 
     bool bRet = signal_expanding(aIter);
 
-    //expand disallowed, restore placeholder
-    if (!bRet && pPlaceHolder)
+    if (pPlaceHolder)
     {
-        m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr);
+        //expand disallowed, restore placeholder
+        if (!bRet)
+        {
+            m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr);
+        }
+        m_aExpandingPlaceHolderParents.erase(pEntry);
     }
 
     return bRet;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 0720a6833b57..b298bc2940cb 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8575,6 +8575,14 @@ static GtkInstanceTreeView* g_DragSource;
 
 namespace {
 
+struct CompareGtkTreeIter
+{
+    bool operator()(const GtkTreeIter& lhs, const GtkTreeIter& rhs) const
+    {
+        return memcmp(&lhs, &rhs, sizeof(GtkTreeIter)) < 0;
+    }
+};
+
 class GtkInstanceTreeView : public GtkInstanceContainer, public virtual 
weld::TreeView
 {
 private:
@@ -8591,6 +8599,9 @@ private:
     std::map<int, int> m_aWeightMap;
     // map from text column to sensitive column
     std::map<int, int> m_aSensitiveMap;
+    // currently expanding parent that logically, but not currently physically,
+    // contain placeholders
+    o3tl::sorted_vector<GtkTreeIter, CompareGtkTreeIter> 
m_aExpandingPlaceHolderParents;
     std::vector<GtkSortType> m_aSavedSortTypes;
     std::vector<int> m_aSavedSortColumns;
     std::vector<int> m_aViewColToModelCol;
@@ -8810,6 +8821,8 @@ private:
 
     bool child_is_placeholder(GtkInstanceTreeIter& rGtkIter) const
     {
+        if (m_aExpandingPlaceHolderParents.count(rGtkIter.iter))
+            return true;
         bool bPlaceHolder = false;
         GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
         GtkTreeIter tmp;
@@ -8833,17 +8846,24 @@ private:
         GtkInstanceTreeIter aIter(iter);
         bool bPlaceHolder = child_is_placeholder(aIter);
         if (bPlaceHolder)
+        {
             gtk_tree_store_remove(m_pTreeStore, &aIter.iter);
+            m_aExpandingPlaceHolderParents.insert(iter);
+        }
 
         aIter.iter = iter;
         bool bRet = signal_expanding(aIter);
 
-        //expand disallowed, restore placeholder
-        if (!bRet && bPlaceHolder)
+        if (bPlaceHolder)
         {
-            GtkTreeIter subiter;
-            OUString sDummy("<dummy>");
-            insert_row(subiter, &iter, -1, nullptr, &sDummy, nullptr, nullptr, 
nullptr);
+            //expand disallowed, restore placeholder
+            if (!bRet)
+            {
+                GtkTreeIter subiter;
+                OUString sDummy("<dummy>");
+                insert_row(subiter, &iter, -1, nullptr, &sDummy, nullptr, 
nullptr, nullptr);
+            }
+            m_aExpandingPlaceHolderParents.erase(iter);
         }
 
         enable_notify_events();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to