summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2020-12-17 11:02:40 -0400
committerHenry Castro <hcastro@collabora.com>2021-01-19 02:47:26 +0100
commit9d5201aefffb4636c5e3612013424da4ca701612 (patch)
tree23e68c4313000de6f4c0cbb5f5ad04531ec6513c
parenta8de3a3f83615cdbb113f7713227a64621e937d8 (diff)
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@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109204 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--include/vcl/salvtables.hxx2
-rw-r--r--vcl/jsdialog/executor.cxx20
-rw-r--r--vcl/source/app/salvtables.cxx7
3 files changed, 22 insertions, 7 deletions
diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx
index d63d8b00dd36..c46f1a0668f1 100644
--- a/include/vcl/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -1339,6 +1339,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_next(weld::TreeIter& rIter) const override;
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 1a66fe36520a..f4bcc817a461 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -206,7 +206,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")
@@ -238,6 +238,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
@@ -245,17 +255,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 c4275fefb8be..844e36775ea8 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4158,6 +4158,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);