include/vcl/jsdialog/executor.hxx | 6 ++++++ vcl/jsdialog/executor.cxx | 22 ++++++++++++++++++++++ vcl/source/treelist/svtabbx.cxx | 6 ++++++ 3 files changed, 34 insertions(+)
New commits: commit d0f4e06750e1bc6b13497d2c36924b04880efa2b Author: Skyler Grey <[email protected]> AuthorDate: Tue Jun 24 09:12:11 2025 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Fri Nov 14 07:17:49 2025 +0100 feat(jsdialog): allow editing treeview items There are some dialogs which we need to edit items in, for example the bookmarks dialog. This isn't hooked up to any existing editing functions - the client won't recieve events that say we intend to edit, say. Instead, the client should implement its own way to edit an editable item. This requires the client to know whether a given cell is editable so we will send that to the client. If the client allows editing non-editable cells it will cause strange effects (such as editing the document with text from a different cell in the case of the bookmark dialog). Additionally, the client needs a way to tell us that it has edited a cell. Signed-off-by: Skyler Grey <[email protected]> Change-Id: Icd510aab1ce236609e84ed672210d68c4d0c6583 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187193 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193851 Tested-by: Jenkins diff --git a/include/vcl/jsdialog/executor.hxx b/include/vcl/jsdialog/executor.hxx index 3b31aa711eb0..6c632e99918c 100644 --- a/include/vcl/jsdialog/executor.hxx +++ b/include/vcl/jsdialog/executor.hxx @@ -25,6 +25,12 @@ public: static void trigger_changed(weld::TreeView& rTreeView) { rTreeView.signal_selection_changed(); } + static void trigger_editing_done(weld::TreeView& rTreeView, + const weld::TreeView::iter_string& rIterText) + { + rTreeView.signal_editing_done(rIterText); + } + static void trigger_changed(weld::IconView& rIconView) { rIconView.signal_selection_changed(); } static void trigger_scrollv(weld::ScrolledWindow& rScrolledWindow) diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index a629101a84e9..fb04f3c20f62 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -17,6 +17,8 @@ #include <sal/log.hxx> #include <string_view> #include <vcl/jsdialog/executor.hxx> +#include <vcl/toolkit/treelistentry.hxx> +#include <vcl/weld.hxx> /// returns true if execution was successful using JSWidgetExecutor = bool (*)(weld::Widget&, const StringMap&); @@ -648,6 +650,26 @@ bool ExecuteAction(const OUString& nWindowId, const OUString& rWidget, const Str << " in treeview"); return true; } + else if (sAction == "editend") + { + OUString sDataJSON = rtl::Uri::decode( + rData.at(u"data"_ustr), rtl_UriDecodeMechanism::rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8); + StringMap aMap(jsonToStringMap( + OUStringToOString(sDataJSON, RTL_TEXTENCODING_ASCII_US).getStr())); + + sal_Int32 nRow = o3tl::toInt32(aMap[u"row"_ustr]); + sal_Int32 nColumn = o3tl::toInt32(aMap[u"column"_ustr]); + OUString sValue = aMap[u"value"_ustr]; + + pTreeView->set_text(nRow, sValue, nColumn); + + SalInstanceTreeIter pEntry = pTreeView->getTreeView().GetEntry(nRow); + LOKTrigger::trigger_editing_done(*pTreeView, + weld::TreeView::iter_string(pEntry, sValue)); + + return true; + } } } else if (sControlType == "iconview") diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx index ebed8e79ac8e..6ad788c16eda 100644 --- a/vcl/source/treelist/svtabbx.cxx +++ b/vcl/source/treelist/svtabbx.cxx @@ -23,6 +23,7 @@ #include <vcl/toolkit/svtabbx.hxx> #include <vcl/headbar.hxx> #include <vcl/toolkit/svlbitm.hxx> +#include <vcl/toolkit/treelistbox.hxx> #include <vcl/toolkit/treelistentry.hxx> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> @@ -98,6 +99,11 @@ static void lcl_DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, { auto aColumn = rJsonWriter.startStruct(); rJsonWriter.put("text", pStringItem->GetText()); + + SvLBoxTab* pTab = pTabListBox->GetTab( pEntry, &rItem ); + if ( pTab ) { + rJsonWriter.put("editable", pTab->IsEditable()); + } } } else if (rItem.GetType() == SvLBoxItemType::ContextBmp)
