vcl/inc/salvtables.hxx | 20 +++++------------ vcl/source/app/salvtables.cxx | 49 ++++++++++++++---------------------------- 2 files changed, 23 insertions(+), 46 deletions(-)
New commits: commit 62050d49bdb2802894d2084ec8b5d1fe1c125cb3 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jan 21 14:35:19 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Jan 22 12:27:40 2026 +0100 vcl weld: Deduplicate TextWidget::{g,s}et_editable impls The SalInstanceTextView and SalInstanceEntry implementations implement the same logic. Deduplicate them by moving the logic to the shared SalInstanceTextWidget base class. Change-Id: Iefb63e93e486d1abd00e5ea2fb02138737f10ee8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197751 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 26b89fc81fee..0a10f18fca56 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -623,6 +623,9 @@ public: virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override; + virtual void set_editable(bool bEditable) override; + virtual bool get_editable() const override; + protected: virtual void do_set_text(const OUString& rText) override; virtual void do_set_position(int nCursorPos) override; @@ -649,10 +652,6 @@ public: virtual void set_max_length(int nChars) override; - virtual void set_editable(bool bEditable) override; - - virtual bool get_editable() const override; - virtual void set_visibility(bool bVisible) override; virtual void set_overwrite_mode(bool bOn) override; @@ -1434,8 +1433,6 @@ public: SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership); - virtual void set_editable(bool bEditable) override; - virtual bool get_editable() const override; virtual void set_max_length(int nChars) override; virtual void set_monospace(bool bMonospace) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 351cc4f8fb72..8bdb23eb628e 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3344,6 +3344,10 @@ void SalInstanceTextWidget::do_replace_selection(const OUString& rText) m_pEntry->ReplaceSelected(rText); } +void SalInstanceTextWidget::set_editable(bool bEditable) { m_pEntry->SetReadOnly(!bEditable); } + +bool SalInstanceTextWidget::get_editable() const { return !m_pEntry->IsReadOnly(); } + SalInstanceEntry::SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceTextWidget(pEntry, pBuilder, bTakeOwnership) , m_xEntry(pEntry) @@ -3360,10 +3364,6 @@ int SalInstanceEntry::get_width_chars() const { return m_xEntry->GetWidthInChars void SalInstanceEntry::set_max_length(int nChars) { m_xEntry->SetMaxTextLen(nChars); } -void SalInstanceEntry::set_editable(bool bEditable) { m_xEntry->SetReadOnly(!bEditable); } - -bool SalInstanceEntry::get_editable() const { return !m_xEntry->IsReadOnly(); } - void SalInstanceEntry::set_visibility(bool bVisible) { m_xEntry->set_property(u"visibility"_ustr, OUString::boolean(bVisible)); @@ -5622,8 +5622,6 @@ SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanc rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceTextView, VscrollHdl)); } -void SalInstanceTextView::set_editable(bool bEditable) { m_xTextView->SetReadOnly(!bEditable); } -bool SalInstanceTextView::get_editable() const { return !m_xTextView->IsReadOnly(); } void SalInstanceTextView::set_max_length(int nChars) { m_xTextView->SetMaxTextLen(nChars); } void SalInstanceTextView::set_monospace(bool bMonospace) commit 5675600c58da444163c4afc25578eb332cf55878 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jan 21 14:32:47 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Jan 22 12:27:33 2026 +0100 vcl weld: Deduplicate TextWidget::get_selection_bounds impls The SalInstanceTextView and SalInstanceEntry implementations implement the same logic. Deduplicate them by moving the logic to the shared SalInstanceTextWidget base class. Change-Id: I4d7137dc25792179048a8f31b8d3af9dd2361f8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197750 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 3166554b764e..26b89fc81fee 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -621,6 +621,8 @@ public: virtual int get_position() const override; + virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override; + protected: virtual void do_set_text(const OUString& rText) override; virtual void do_set_position(int nCursorPos) override; @@ -647,8 +649,6 @@ public: virtual void set_max_length(int nChars) override; - bool get_selection_bounds(int& rStartPos, int& rEndPos) override; - virtual void set_editable(bool bEditable) override; virtual bool get_editable() const override; @@ -1434,8 +1434,6 @@ public: SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership); - bool get_selection_bounds(int& rStartPos, int& rEndPos) override; - virtual void set_editable(bool bEditable) override; virtual bool get_editable() const override; virtual void set_max_length(int nChars) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 5d6cc7728db1..351cc4f8fb72 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3331,6 +3331,14 @@ void SalInstanceTextWidget::do_select_region(int nStartPos, int nEndPos) m_pEntry->SetSelection(Selection(nStart, nEnd)); } +bool SalInstanceTextWidget::get_selection_bounds(int& rStartPos, int& rEndPos) +{ + const Selection& rSelection = m_pEntry->GetSelection(); + rStartPos = rSelection.Min(); + rEndPos = rSelection.Max(); + return rSelection.Len(); +} + void SalInstanceTextWidget::do_replace_selection(const OUString& rText) { m_pEntry->ReplaceSelected(rText); @@ -3352,14 +3360,6 @@ int SalInstanceEntry::get_width_chars() const { return m_xEntry->GetWidthInChars void SalInstanceEntry::set_max_length(int nChars) { m_xEntry->SetMaxTextLen(nChars); } -bool SalInstanceEntry::get_selection_bounds(int& rStartPos, int& rEndPos) -{ - const Selection& rSelection = m_xEntry->GetSelection(); - rStartPos = rSelection.Min(); - rEndPos = rSelection.Max(); - return rSelection.Len(); -} - void SalInstanceEntry::set_editable(bool bEditable) { m_xEntry->SetReadOnly(!bEditable); } bool SalInstanceEntry::get_editable() const { return !m_xEntry->IsReadOnly(); } @@ -5622,14 +5622,6 @@ SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanc rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceTextView, VscrollHdl)); } -bool SalInstanceTextView::get_selection_bounds(int& rStartPos, int& rEndPos) -{ - const Selection& rSelection = m_xTextView->GetSelection(); - rStartPos = rSelection.Min(); - rEndPos = rSelection.Max(); - return rSelection.Len(); -} - void SalInstanceTextView::set_editable(bool bEditable) { m_xTextView->SetReadOnly(!bEditable); } bool SalInstanceTextView::get_editable() const { return !m_xTextView->IsReadOnly(); } void SalInstanceTextView::set_max_length(int nChars) { m_xTextView->SetMaxTextLen(nChars); } commit 22646c948d35ea0784944ede6fef882c9d16aacf Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jan 21 14:28:51 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Jan 22 12:27:27 2026 +0100 vcl weld: Deduplicate TextWidget::do_replace_selection impls The SalInstanceTextView and SalInstanceEntry implementations implement the same logic. Deduplicate them by moving the logic to the shared SalInstanceTextWidget base class. Change-Id: I5be21325d3e9dea04769660e8c0b5d80ea2b8fa4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197749 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 6a1a51a3f25d..3166554b764e 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -625,6 +625,7 @@ protected: virtual void do_set_text(const OUString& rText) override; virtual void do_set_position(int nCursorPos) override; virtual void do_select_region(int nStartPos, int nEndPos) override; + virtual void do_replace_selection(const OUString& rText) override; }; class SalInstanceEntry : public SalInstanceTextWidget, public virtual weld::Entry @@ -648,8 +649,6 @@ public: bool get_selection_bounds(int& rStartPos, int& rEndPos) override; - virtual void do_replace_selection(const OUString& rText) override; - virtual void set_editable(bool bEditable) override; virtual bool get_editable() const override; @@ -1435,8 +1434,6 @@ public: SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership); - virtual void do_replace_selection(const OUString& rText) override; - bool get_selection_bounds(int& rStartPos, int& rEndPos) override; virtual void set_editable(bool bEditable) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 203c923be127..5d6cc7728db1 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3331,6 +3331,11 @@ void SalInstanceTextWidget::do_select_region(int nStartPos, int nEndPos) m_pEntry->SetSelection(Selection(nStart, nEnd)); } +void SalInstanceTextWidget::do_replace_selection(const OUString& rText) +{ + m_pEntry->ReplaceSelected(rText); +} + SalInstanceEntry::SalInstanceEntry(Edit* pEntry, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceTextWidget(pEntry, pBuilder, bTakeOwnership) , m_xEntry(pEntry) @@ -3355,11 +3360,6 @@ bool SalInstanceEntry::get_selection_bounds(int& rStartPos, int& rEndPos) return rSelection.Len(); } -void SalInstanceEntry::do_replace_selection(const OUString& rText) -{ - m_xEntry->ReplaceSelected(rText); -} - void SalInstanceEntry::set_editable(bool bEditable) { m_xEntry->SetReadOnly(!bEditable); } bool SalInstanceEntry::get_editable() const { return !m_xEntry->IsReadOnly(); } @@ -5622,11 +5622,6 @@ SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit* pTextView, SalInstanc rVertScrollBar.SetScrollHdl(LINK(this, SalInstanceTextView, VscrollHdl)); } -void SalInstanceTextView::do_replace_selection(const OUString& rText) -{ - m_xTextView->ReplaceSelected(rText); -} - bool SalInstanceTextView::get_selection_bounds(int& rStartPos, int& rEndPos) { const Selection& rSelection = m_xTextView->GetSelection();
