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 47b07f1894ca5e603fb165f5d9571651729640a2 Author: Skyler Grey <[email protected]> AuthorDate: Tue Jun 24 09:12:11 2025 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Thu Jul 3 06:18:52 2025 +0200 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]> diff --git a/include/vcl/jsdialog/executor.hxx b/include/vcl/jsdialog/executor.hxx index be24997d4409..d2af7a124a10 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_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 67afbc73ec82..a9a8b4243ef9 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 067da05f8985..97db9d8749b1 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> @@ -97,6 +98,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)
