include/vcl/weld/TextWidget.hxx | 4 ++-- vcl/inc/qt5/QtInstanceEntry.hxx | 3 --- vcl/inc/qt5/QtInstanceTextView.hxx | 3 --- vcl/qt5/QtInstanceEntry.cxx | 4 ---- vcl/qt5/QtInstanceTextView.cxx | 4 ---- vcl/source/weld/TextWidget.cxx | 16 ++++++++++++++++ 6 files changed, 18 insertions(+), 16 deletions(-)
New commits: commit 19f1dac15327f341385181852281134ffde919b2 Author: Michael Weghorn <[email protected]> AuthorDate: Sat Jan 3 16:09:39 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sun Jan 4 15:04:40 2026 +0100 tdf#130857 weld: Implement TextWidget::paste_clipboard in base Add an implementation of TextWidget::paste_clipboard right in the abstract base class, as it provides all relevant API to do that. Drop the QtInstanceEntry and QtInstanceTextView overrides that would so far only trigger an assert. For now, leave the GTK and vcl implementations/overrides in place. Change-Id: Ia41cad18204781ee7982e06bb2b51afdeeb5fbd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196455 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/vcl/weld/TextWidget.hxx b/include/vcl/weld/TextWidget.hxx index 977abf6824fa..b51d33b41172 100644 --- a/include/vcl/weld/TextWidget.hxx +++ b/include/vcl/weld/TextWidget.hxx @@ -55,7 +55,7 @@ public: virtual void cut_clipboard(); virtual void copy_clipboard(); - virtual void paste_clipboard() = 0; + virtual void paste_clipboard(); void save_value() { m_sSavedValue = get_text(); } OUString const& get_saved_value() const { return m_sSavedValue; } diff --git a/vcl/inc/qt5/QtInstanceEntry.hxx b/vcl/inc/qt5/QtInstanceEntry.hxx index 230a8583e5a8..f57d2c27be8a 100644 --- a/vcl/inc/qt5/QtInstanceEntry.hxx +++ b/vcl/inc/qt5/QtInstanceEntry.hxx @@ -46,8 +46,6 @@ public: virtual void set_font(const vcl::Font& rFont) override; virtual void set_font_color(const Color& rColor) override; - virtual void paste_clipboard() override; - virtual void set_alignment(TxtAlign eXAlign) override; static void setMessageType(QLineEdit& rLineEdit, weld::EntryMessageType eType); diff --git a/vcl/inc/qt5/QtInstanceTextView.hxx b/vcl/inc/qt5/QtInstanceTextView.hxx index 5dd6c29f6a48..b9c068cd8f7f 100644 --- a/vcl/inc/qt5/QtInstanceTextView.hxx +++ b/vcl/inc/qt5/QtInstanceTextView.hxx @@ -40,8 +40,6 @@ public: virtual bool can_move_cursor_with_up() const override; virtual bool can_move_cursor_with_down() const override; - virtual void paste_clipboard() override; - virtual void set_alignment(TxtAlign eXAlign) override; virtual int vadjustment_get_value() const override; diff --git a/vcl/qt5/QtInstanceEntry.cxx b/vcl/qt5/QtInstanceEntry.cxx index d0f0698ada56..e15619a59583 100644 --- a/vcl/qt5/QtInstanceEntry.cxx +++ b/vcl/qt5/QtInstanceEntry.cxx @@ -180,8 +180,6 @@ void QtInstanceEntry::set_font(const vcl::Font& rFont) { setFont(rFont); } void QtInstanceEntry::set_font_color(const Color& rColor) { setFontColor(rColor); } -void QtInstanceEntry::paste_clipboard() { assert(false && "Not implemented yet"); } - void QtInstanceEntry::set_alignment(TxtAlign eXAlign) { SolarMutexGuard g; diff --git a/vcl/qt5/QtInstanceTextView.cxx b/vcl/qt5/QtInstanceTextView.cxx index e394afd6cc20..ce4cd83d9408 100644 --- a/vcl/qt5/QtInstanceTextView.cxx +++ b/vcl/qt5/QtInstanceTextView.cxx @@ -124,8 +124,6 @@ bool QtInstanceTextView::can_move_cursor_with_down() const return false; } -void QtInstanceTextView::paste_clipboard() { assert(false && "Not implemented yet"); } - void QtInstanceTextView::set_alignment(TxtAlign) { assert(false && "Not implemented yet"); } int QtInstanceTextView::vadjustment_get_value() const diff --git a/vcl/source/weld/TextWidget.cxx b/vcl/source/weld/TextWidget.cxx index 0a68adeb85d5..0546fd66cd3d 100644 --- a/vcl/source/weld/TextWidget.cxx +++ b/vcl/source/weld/TextWidget.cxx @@ -8,6 +8,7 @@ */ #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <vcl/transfer.hxx> #include <vcl/unohelp2.hxx> #include <vcl/weld/TextWidget.hxx> @@ -54,6 +55,15 @@ void TextWidget::copy_clipboard() std::abs(nSelectionEnd - nSelectionStart)); vcl::unohelper::TextDataObject::CopyStringTo(sSelectedText, get_clipboard()); } + +void TextWidget::paste_clipboard() +{ + TransferableDataHelper aDataHelper + = TransferableDataHelper::CreateFromClipboard(get_clipboard()); + OUString sText; + if (aDataHelper.GetString(SotClipboardFormatId::STRING, sText)) + replace_selection(sText); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ commit 8b03089f4f986b4938246b15988b9ce1ec718176 Author: Michael Weghorn <[email protected]> AuthorDate: Sat Jan 3 15:52:22 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Sun Jan 4 15:04:31 2026 +0100 tdf#130857 weld: Implement TextWidget::cut_clipboard in base Add an implementation of TextWidget::cut_clipboard right in the abstract base class, as it provides all relevant API to do that. Drop the QtInstanceEntry and QtInstanceTextView overrides that would so far only trigger an assert. For now, leave the GTK and vcl implementations/overrides in place. While it's probably not relevant in practice, those might be more efficient than operating on the whole text of the widget to extract the relevant substring to copy/cut. Change-Id: I9b4f70daa3f3fa7af2fb16cfc0d840d9da6551a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196454 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/vcl/weld/TextWidget.hxx b/include/vcl/weld/TextWidget.hxx index e9e6976912dc..977abf6824fa 100644 --- a/include/vcl/weld/TextWidget.hxx +++ b/include/vcl/weld/TextWidget.hxx @@ -53,7 +53,7 @@ public: */ virtual void set_font_color(const Color& rColor) = 0; - virtual void cut_clipboard() = 0; + virtual void cut_clipboard(); virtual void copy_clipboard(); virtual void paste_clipboard() = 0; diff --git a/vcl/inc/qt5/QtInstanceEntry.hxx b/vcl/inc/qt5/QtInstanceEntry.hxx index e4a1b1d7e9bc..230a8583e5a8 100644 --- a/vcl/inc/qt5/QtInstanceEntry.hxx +++ b/vcl/inc/qt5/QtInstanceEntry.hxx @@ -46,7 +46,6 @@ public: virtual void set_font(const vcl::Font& rFont) override; virtual void set_font_color(const Color& rColor) override; - virtual void cut_clipboard() override; virtual void paste_clipboard() override; virtual void set_alignment(TxtAlign eXAlign) override; diff --git a/vcl/inc/qt5/QtInstanceTextView.hxx b/vcl/inc/qt5/QtInstanceTextView.hxx index 3b20370b7508..5dd6c29f6a48 100644 --- a/vcl/inc/qt5/QtInstanceTextView.hxx +++ b/vcl/inc/qt5/QtInstanceTextView.hxx @@ -40,7 +40,6 @@ public: virtual bool can_move_cursor_with_up() const override; virtual bool can_move_cursor_with_down() const override; - virtual void cut_clipboard() override; virtual void paste_clipboard() override; virtual void set_alignment(TxtAlign eXAlign) override; diff --git a/vcl/qt5/QtInstanceEntry.cxx b/vcl/qt5/QtInstanceEntry.cxx index 822720a1feee..d0f0698ada56 100644 --- a/vcl/qt5/QtInstanceEntry.cxx +++ b/vcl/qt5/QtInstanceEntry.cxx @@ -180,8 +180,6 @@ void QtInstanceEntry::set_font(const vcl::Font& rFont) { setFont(rFont); } void QtInstanceEntry::set_font_color(const Color& rColor) { setFontColor(rColor); } -void QtInstanceEntry::cut_clipboard() { assert(false && "Not implemented yet"); } - void QtInstanceEntry::paste_clipboard() { assert(false && "Not implemented yet"); } void QtInstanceEntry::set_alignment(TxtAlign eXAlign) diff --git a/vcl/qt5/QtInstanceTextView.cxx b/vcl/qt5/QtInstanceTextView.cxx index ce449f19b087..e394afd6cc20 100644 --- a/vcl/qt5/QtInstanceTextView.cxx +++ b/vcl/qt5/QtInstanceTextView.cxx @@ -124,8 +124,6 @@ bool QtInstanceTextView::can_move_cursor_with_down() const return false; } -void QtInstanceTextView::cut_clipboard() { assert(false && "Not implemented yet"); } - void QtInstanceTextView::paste_clipboard() { assert(false && "Not implemented yet"); } void QtInstanceTextView::set_alignment(TxtAlign) { assert(false && "Not implemented yet"); } diff --git a/vcl/source/weld/TextWidget.cxx b/vcl/source/weld/TextWidget.cxx index 0590d9cd4804..0a68adeb85d5 100644 --- a/vcl/source/weld/TextWidget.cxx +++ b/vcl/source/weld/TextWidget.cxx @@ -34,6 +34,12 @@ void TextWidget::replace_selection(const OUString& rText) enable_notify_events(); } +void TextWidget::cut_clipboard() +{ + copy_clipboard(); + replace_selection(u""_ustr); +} + void TextWidget::copy_clipboard() { int nSelectionStart = 0;
