include/vcl/weld/TreeView.hxx | 10 ++++++---- vcl/inc/qt5/QtInstanceTreeView.hxx | 2 -- vcl/inc/salvtables.hxx | 4 ---- vcl/qt5/QtInstanceTreeView.cxx | 10 ---------- vcl/source/app/salvtables.cxx | 12 ------------ vcl/source/weld/TreeView.cxx | 12 ++++++++++++ vcl/unx/gtk3/gtkinst.cxx | 20 -------------------- 7 files changed, 18 insertions(+), 52 deletions(-)
New commits: commit 66056389ee91b335bb51b83625b895ffdc00d7f5 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Dec 22 22:35:45 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Dec 23 10:12:46 2025 +0100 weld: Deduplicate TreeView::get_font_color implementations The variant taking an int param can be implemented using the variant taking a weld::TreeIter param. Do so once in the abstract weld::TreeView base class, and drop the toolkit-specific implementations. Also move the method declarations of both methods next to each other. Change-Id: Ic6eb95577d891689f082e911e11ce69f7c67d2d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196138 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/weld/TreeView.hxx b/include/vcl/weld/TreeView.hxx index a21783d2df6e..0fc4e09195f4 100644 --- a/include/vcl/weld/TreeView.hxx +++ b/include/vcl/weld/TreeView.hxx @@ -269,7 +269,9 @@ public: virtual void swap(int pos1, int pos2) = 0; virtual std::vector<int> get_selected_rows() const = 0; - virtual void set_font_color(int pos, const Color& rColor) = 0; + + void set_font_color(int pos, const Color& rColor); + virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0; // scroll to make 'row' visible, this will also expand all parent rows of 'row' as necessary to // make 'row' visible @@ -347,7 +349,6 @@ public: //visually indent this row as if it was at get_iter_depth() + nIndentLevel virtual void set_extra_row_indent(const TreeIter& rIter, int nIndentLevel) = 0; - virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0; // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to // make rIter visible diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx b/vcl/inc/qt5/QtInstanceTreeView.hxx index 490712b6a739..dca83bfed8fa 100644 --- a/vcl/inc/qt5/QtInstanceTreeView.hxx +++ b/vcl/inc/qt5/QtInstanceTreeView.hxx @@ -54,7 +54,6 @@ public: virtual void swap(int nPos1, int nPos2) override; virtual std::vector<int> get_selected_rows() const override; - virtual void set_font_color(int nPos, const Color& rColor) override; virtual void do_scroll_to_row(int nRow) override; virtual bool is_selected(int nPos) const override; using QtInstanceItemView::do_set_cursor; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 24b850736d99..cce28c543c31 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1651,8 +1651,6 @@ public: const weld::TreeIter* pParent = nullptr, const std::vector<int>* pFixedWidths = nullptr, bool bGoingToSetText = false) override; - virtual void set_font_color(int pos, const Color& rColor) override; - virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override; virtual int find_text(const OUString& rText) const override; diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 057b460a0c07..ea75bf778516 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -150,11 +150,6 @@ std::vector<int> QtInstanceTreeView::get_selected_rows() const return aSelectedRows; } -void QtInstanceTreeView::set_font_color(int nPos, const Color& rColor) -{ - set_font_color(treeIter(nPos), rColor); -} - void QtInstanceTreeView::do_scroll_to_row(int nRow) { scroll_to_row(treeIter(nRow)); } bool QtInstanceTreeView::is_selected(int nPos) const { return is_selected(treeIter(nPos)); } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index ffdc8bfbd225..d3d7dcd05a3a 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -4145,12 +4145,6 @@ void SalInstanceTreeView::bulk_insert_for_each( thaw(); } -void SalInstanceTreeView::set_font_color(int pos, const Color& rColor) -{ - SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); - set_font_color(pEntry, rColor); -} - void SalInstanceTreeView::set_font_color(const weld::TreeIter& rIter, const Color& rColor) { const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter); diff --git a/vcl/source/weld/TreeView.cxx b/vcl/source/weld/TreeView.cxx index 807045277dab..a405a14d5c82 100644 --- a/vcl/source/weld/TreeView.cxx +++ b/vcl/source/weld/TreeView.cxx @@ -99,6 +99,12 @@ void weld::TreeView::set_text_align(int row, TxtAlign eAlign, int col) if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(row)) set_text_align(*pIter, eAlign, col); } + +void weld::TreeView::set_font_color(int pos, const Color& rColor) +{ + if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(pos)) + set_font_color(*pIter, rColor); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 1b20a4198fa9..577384b19905 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -14951,13 +14951,6 @@ public: enable_notify_events(); } - virtual void set_font_color(int pos, const Color& rColor) override - { - GtkTreeIter iter; - gtk_tree_model_iter_nth_child(m_pTreeModel, &iter, nullptr, pos); - set_font_color(iter, rColor); - } - virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override { const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter); commit 068afa2644175328442c7de38960f0bef599c9f5 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Dec 22 22:32:15 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Dec 23 10:12:37 2025 +0100 weld: Deduplicate TreeView::set_text_align implementations The variant taking an int param can be implemented using the variant taking a weld::TreeIter param. Do so once in the abstract weld::TreeView base class, and drop the toolkit-specific implementations. Also move the method declarations of both methods next to each other. Change-Id: I3f27c227fc66bc44de93901d1b00a35430139ae2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196137 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/include/vcl/weld/TreeView.hxx b/include/vcl/weld/TreeView.hxx index 8e4fc29b0b5b..a21783d2df6e 100644 --- a/include/vcl/weld/TreeView.hxx +++ b/include/vcl/weld/TreeView.hxx @@ -264,7 +264,9 @@ public: bool get_text_emphasis(int row, int col) const; virtual bool get_text_emphasis(const TreeIter& rIter, int col) const = 0; - virtual void set_text_align(int row, TxtAlign eAlign, int col) = 0; + void set_text_align(int row, TxtAlign eAlign, int col); + virtual void set_text_align(const TreeIter& rIter, TxtAlign eAlign, int col) = 0; + virtual void swap(int pos1, int pos2) = 0; virtual std::vector<int> get_selected_rows() const = 0; virtual void set_font_color(int pos, const Color& rColor) = 0; @@ -345,7 +347,6 @@ public: //visually indent this row as if it was at get_iter_depth() + nIndentLevel virtual void set_extra_row_indent(const TreeIter& rIter, int nIndentLevel) = 0; - virtual void set_text_align(const TreeIter& rIter, TxtAlign eAlign, int col) = 0; virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0; // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx b/vcl/inc/qt5/QtInstanceTreeView.hxx index 9706de73d9ef..490712b6a739 100644 --- a/vcl/inc/qt5/QtInstanceTreeView.hxx +++ b/vcl/inc/qt5/QtInstanceTreeView.hxx @@ -52,7 +52,6 @@ public: virtual void set_clicks_to_toggle(int nToggleBehavior) override; - virtual void set_text_align(int nRow, TxtAlign eAlign, int nCol) override; virtual void swap(int nPos1, int nPos2) override; virtual std::vector<int> get_selected_rows() const override; virtual void set_font_color(int nPos, const Color& rColor) override; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 6ffad9b8abf9..24b850736d99 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1706,8 +1706,6 @@ public: virtual void set_text_align(const weld::TreeIter& rIter, TxtAlign eAlign, int col) override; - virtual void set_text_align(int pos, TxtAlign eAlign, int col) override; - virtual void connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink, const Link<const iter_string&, bool>& rEndLink) override; diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index be09d133a64e..057b460a0c07 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -109,11 +109,6 @@ void QtInstanceTreeView::enable_toggle_buttons(weld::ColumnToggleType) void QtInstanceTreeView::set_clicks_to_toggle(int) { assert(false && "Not implemented yet"); } -void QtInstanceTreeView::set_text_align(int nRow, TxtAlign eAlign, int nCol) -{ - return set_text_align(treeIter(nRow), eAlign, nCol); -} - void QtInstanceTreeView::swap(int nPos1, int nPos2) { SolarMutexGuard g; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 8fb32e20659b..ffdc8bfbd225 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -4430,12 +4430,6 @@ void SalInstanceTreeView::set_text_align(const weld::TreeIter& rIter, TxtAlign e set_text_align(rVclIter.iter, eAlign, col); } -void SalInstanceTreeView::set_text_align(int pos, TxtAlign eAlign, int col) -{ - SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); - set_text_align(pEntry, eAlign, col); -} - void SalInstanceTreeView::connect_editing(const Link<const weld::TreeIter&, bool>& rStartLink, const Link<const iter_string&, bool>& rEndLink) { diff --git a/vcl/source/weld/TreeView.cxx b/vcl/source/weld/TreeView.cxx index 4232fb9d7191..807045277dab 100644 --- a/vcl/source/weld/TreeView.cxx +++ b/vcl/source/weld/TreeView.cxx @@ -93,6 +93,12 @@ bool weld::TreeView::get_text_emphasis(int row, int col) const return false; } + +void weld::TreeView::set_text_align(int row, TxtAlign eAlign, int col) +{ + if (std::unique_ptr<weld::TreeIter> pIter = get_iterator(row)) + set_text_align(*pIter, eAlign, col); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 62ff930a7d27..1b20a4198fa9 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -14142,13 +14142,6 @@ private: m_Setter(m_pTreeModel, const_cast<GtkTreeIter*>(&iter), col, fValue, -1); } - void set(int pos, int col, double fValue) - { - GtkTreeIter iter; - if (gtk_tree_model_iter_nth_child(m_pTreeModel, &iter, nullptr, pos)) - set(iter, col, fValue); - } - static gboolean signalTestExpandRow(GtkTreeView*, GtkTreeIter* iter, GtkTreePath*, gpointer widget) { GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget); @@ -15390,12 +15383,6 @@ public: set(rGtkIter.iter, m_aAlignMap[col], toGtkTextAlignValue(eAlign)); } - virtual void set_text_align(int pos, TxtAlign eAlign, int col) override - { - col = to_internal_model(col); - set(pos, m_aAlignMap[col], toGtkTextAlignValue(eAlign)); - } - using GtkInstanceWidget::set_sensitive; using GtkInstanceWidget::get_sensitive;
