From b6dc3ce75d05148555bfea4be390bfed1ecdc44f Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 24 Apr 2026 13:17:15 +0200 Subject: [PATCH] vcl: Also pass the item in treeview callback when entry edited So far, the callback called when a SvTreeListBox entry was edited contained the SvTreeListEntry and the new text of the entry. Pass also the entry's item (SvLBoxItem) in addition, so the handler can take that into account. This will be used in an upcoming commit to extend weld::TreeView::signal_editing_done to also pass the index of the edited column. Change-Id: Iad2866d8fcc710d82f4f0dc0661a3b1f0bebaeab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204303 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- include/vcl/toolkit/svtabbx.hxx | 9 +++++---- include/vcl/toolkit/treelistbox.hxx | 18 ++++++++++++++++-- .../source/controls/tree/treecontrolpeer.cxx | 6 ++++-- vcl/inc/salvtables.hxx | 2 +- vcl/inc/treeglue.hxx | 9 +++++---- vcl/source/app/salvtables.cxx | 6 +++--- vcl/source/treelist/treelistbox.cxx | 7 +++++-- 7 files changed, 39 insertions(+), 18 deletions(-) diff --git a/include/vcl/toolkit/svtabbx.hxx b/include/vcl/toolkit/svtabbx.hxx index ca5727f9bc02..ed0f29108031 100644 --- a/include/vcl/toolkit/svtabbx.hxx +++ b/include/vcl/toolkit/svtabbx.hxx @@ -111,7 +111,7 @@ private: std::vector> m_aAccessibleChildren; Link m_aEditingEntryHdl; - Link m_aEditedEntryHdl; + Link m_aEditedEntryHdl; DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTreeListBox*, void ); DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar*, void ); @@ -223,7 +223,7 @@ public: m_aEditingEntryHdl = rLink; } - void SetEditedEntryHdl(const Link& rLink) + void SetEditedEntryHdl(const Link& rLink) { m_aEditedEntryHdl = rLink; } @@ -239,9 +239,10 @@ public: return m_aEditingEntryHdl.Call(pEntry); } - virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) override + virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem, + const OUString& rNewText) override { - return m_aEditedEntryHdl.Call(IterString(rEntry, rNewText)); + return m_aEditedEntryHdl.Call(EntryItemText(rEntry, pItem, rNewText)); } }; diff --git a/include/vcl/toolkit/treelistbox.hxx b/include/vcl/toolkit/treelistbox.hxx index e56d6023e983..90a3a71a132d 100644 --- a/include/vcl/toolkit/treelistbox.hxx +++ b/include/vcl/toolkit/treelistbox.hxx @@ -176,7 +176,20 @@ struct SvTreeListBoxImpl; typedef std::pair svtree_measure_args; typedef std::tuple svtree_render_args; -typedef std::pair IterString; + +struct EntryItemText +{ + SvTreeListEntry& m_rEntry; + const SvLBoxItem* m_pItem; + OUString m_sText; + + EntryItemText(SvTreeListEntry& rEntry, const SvLBoxItem* pItem, const OUString& rText) + : m_rEntry(rEntry) + , m_pItem(pItem) + , m_sText(rText) + { + } +}; class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListBox : public Control, public DropTargetHelper, @@ -669,7 +682,8 @@ public: // Edits the Entry's first StringItem, 0 == Cursor void EditEntry( SvTreeListEntry* pEntry ); virtual bool EditingEntry( SvTreeListEntry* pEntry ); - virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText); + virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem, + const OUString& rNewText); virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; diff --git a/toolkit/source/controls/tree/treecontrolpeer.cxx b/toolkit/source/controls/tree/treecontrolpeer.cxx index 80f42e1bfddf..86093fb57042 100644 --- a/toolkit/source/controls/tree/treecontrolpeer.cxx +++ b/toolkit/source/controls/tree/treecontrolpeer.cxx @@ -99,7 +99,8 @@ public: virtual void RequestingChildren( SvTreeListEntry* pParent ) override; virtual bool EditingEntry( SvTreeListEntry* pEntry ) override; - virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) override; + virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem, + const OUString& rNewText) override; DECL_LINK(OnSelectionChangeHdl, SvTreeListBox*, void); DECL_LINK(OnExpandingHdl, SvTreeListBox*, bool); @@ -1485,7 +1486,8 @@ bool UnoTreeListBoxImpl::EditingEntry( SvTreeListEntry* pEntry ) return mxPeer.is() && mxPeer->onEditingEntry( dynamic_cast< UnoTreeListEntry* >( pEntry ) ); } -bool UnoTreeListBoxImpl::EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) +bool UnoTreeListBoxImpl::EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem*, + const OUString& rNewText) { return mxPeer.is() && mxPeer->onEditedEntry(dynamic_cast(&rEntry), rNewText); } diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 2ba2796ec998..f0a63fd3c295 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1567,7 +1567,7 @@ protected: DECL_LINK(StartDragHdl, SvTreeListBox*, bool); DECL_STATIC_LINK(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void); DECL_LINK(EditingEntryHdl, SvTreeListEntry*, bool); - DECL_LINK(EditedEntryHdl, const IterString&, bool); + DECL_LINK(EditedEntryHdl, const EntryItemText&, bool); DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void); DECL_LINK(CompareHdl, const SvSortData&, sal_Int32); DECL_LINK(TooltipHdl, SvTreeListEntry*, OUString); diff --git a/vcl/inc/treeglue.hxx b/vcl/inc/treeglue.hxx index 40521fc6627b..87830295c8e7 100644 --- a/vcl/inc/treeglue.hxx +++ b/vcl/inc/treeglue.hxx @@ -21,7 +21,7 @@ class LclTabListBox final : public SvTabListBox Link m_aStartDragHdl; Link m_aEndDragHdl; Link m_aEditingEntryHdl; - Link m_aEditedEntryHdl; + Link m_aEditedEntryHdl; public: LclTabListBox(vcl::Window* pParent, WinBits nWinStyle) @@ -36,7 +36,7 @@ public: { m_aEditingEntryHdl = rLink; } - void SetEditedEntryHdl(const Link& rLink) + void SetEditedEntryHdl(const Link& rLink) { m_aEditedEntryHdl = rLink; } @@ -127,9 +127,10 @@ public: return m_aEditingEntryHdl.Call(pEntry); } - virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) override + virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem, + const OUString& rNewText) override { - return m_aEditedEntryHdl.Call(IterString(rEntry, rNewText)); + return m_aEditedEntryHdl.Call(EntryItemText(rEntry, pItem, rNewText)); } }; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 5ba5181de04b..32a9fa9fd858 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5083,10 +5083,10 @@ IMPL_LINK(SalInstanceTreeView, EditingEntryHdl, SvTreeListEntry*, pEntry, bool) return signal_editing_started(SalInstanceTreeIter(*this, pEntry)); } -IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const IterString&, rIterString, bool) +IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const EntryItemText&, rEntryItemString, bool) { - return signal_editing_done( - iter_string(SalInstanceTreeIter(*this, &rIterString.first), rIterString.second)); + return signal_editing_done(iter_string(SalInstanceTreeIter(*this, &rEntryItemString.m_rEntry), + rEntryItemString.m_sText)); } SalInstanceIconView::SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder, diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index ae9ce123fd96..2950af695b77 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -2131,7 +2131,10 @@ bool SvTreeListBox::EditingEntry( SvTreeListEntry* ) return true; } -bool SvTreeListBox::EditedEntry(SvTreeListEntry&, const OUString&) { return true; } +bool SvTreeListBox::EditedEntry(SvTreeListEntry&, const SvLBoxItem*, const OUString&) +{ + return true; +} void SvTreeListBox::EnableInplaceEditing( bool bOn ) { @@ -2774,7 +2777,7 @@ void SvTreeListBox::EditedText( const OUString& rStr ) { if (m_pEdEntry) // we have to check if this entry is null that means that it is removed while editing { - if (EditedEntry(*m_pEdEntry, rStr)) + if (EditedEntry(*m_pEdEntry, m_pEdItem, rStr)) { m_pEdItem->SetText(rStr); m_pModel->InvalidateEntry(m_pEdEntry);