[Libreoffice-commits] core.git: vcl/inc vcl/jsdialog vcl/source

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 22 12:05:34 UTC 2020


 vcl/inc/salvtables.hxx        |    2 ++
 vcl/jsdialog/executor.cxx     |   20 +++++++++++++-------
 vcl/source/app/salvtables.cxx |    7 +++++++
 3 files changed, 22 insertions(+), 7 deletions(-)

New commits:
commit 07ba7227104f5c30a6dbaa88314cf62aac28b7c5
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Dec 17 11:02:40 2020 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Dec 22 13:04:47 2020 +0100

    jsdialog: add the "expand" action
    
    to the tree list view control
    
    Change-Id: I69f1b06748053fdfe9164c52e889629e51f91409
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107914
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 47afc48903f2..c435230653c5 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1566,6 +1566,8 @@ public:
 
     virtual bool get_iter_first(weld::TreeIter& rIter) const override;
 
+    virtual bool get_iter_abs_pos(weld::TreeIter& rIter, int nPos) const;
+
     virtual bool iter_next_sibling(weld::TreeIter& rIter) const override;
 
     virtual bool iter_previous_sibling(weld::TreeIter& rIter) const override;
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index b2103fbe865f..0ff259e7bfd4 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -179,7 +179,7 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
         }
         else if (sControlType == "treeview")
         {
-            auto pTreeView = dynamic_cast<weld::TreeView*>(pWidget);
+            auto pTreeView = dynamic_cast<JSTreeView*>(pWidget);
             if (pTreeView)
             {
                 if (sAction == "change")
@@ -209,6 +209,16 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
                     LOKTrigger::trigger_row_activated(*pTreeView);
                     return true;
                 }
+                else if (sAction == "expand")
+                {
+                    OString nRowString
+                        = OUStringToOString(rData["data"], RTL_TEXTENCODING_ASCII_US);
+                    int nAbsPos = std::atoi(nRowString.getStr());
+                    std::unique_ptr<weld::TreeIter> itEntry(pTreeView->make_iterator());
+                    pTreeView->get_iter_abs_pos(*itEntry, nAbsPos);
+                    pTreeView->expand_row(*itEntry);
+                    return true;
+                }
                 else if (sAction == "dragstart")
                 {
                     OString nRowString
@@ -216,17 +226,13 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
                     int nRow = std::atoi(nRowString.getStr());
 
                     pTreeView->select(nRow);
+                    pTreeView->drag_start();
 
-                    JSTreeView* pJSTreeView = dynamic_cast<JSTreeView*>(pTreeView);
-                    if (pJSTreeView)
-                        pJSTreeView->drag_start();
                     return true;
                 }
                 else if (sAction == "dragend")
                 {
-                    JSTreeView* pJSTreeView = dynamic_cast<JSTreeView*>(pTreeView);
-                    if (pJSTreeView)
-                        pJSTreeView->drag_end();
+                    pTreeView->drag_end();
                     return true;
                 }
             }
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e2e322e725fa..47563271e05b 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4329,6 +4329,13 @@ bool SalInstanceTreeView::get_iter_first(weld::TreeIter& rIter) const
     return rVclIter.iter != nullptr;
 }
 
+bool SalInstanceTreeView::get_iter_abs_pos(weld::TreeIter& rIter, int nAbsPos) const
+{
+    SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);
+    rVclIter.iter = m_xTreeView->GetEntryAtAbsPos(nAbsPos);
+    return rVclIter.iter != nullptr;
+}
+
 bool SalInstanceTreeView::iter_next_sibling(weld::TreeIter& rIter) const
 {
     SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter);


More information about the Libreoffice-commits mailing list