vcl/inc/jsdialog/jsdialogbuilder.hxx | 1 + vcl/jsdialog/executor.cxx | 22 ++++++++++++++++++++++ vcl/jsdialog/jsdialogbuilder.cxx | 6 ++++++ 3 files changed, 29 insertions(+)
New commits: commit aaf35ab8b093924055b6c3adb6446842639babf8 Author: Szymon Kłos <[email protected]> AuthorDate: Fri Mar 3 17:01:55 2023 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Wed Mar 8 10:40:11 2023 +0000 jsdialog: textselection action for text view Change-Id: I11e41b5be897c4341ed0e2baf9fc6772ad0163b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148247 Tested-by: Szymon Kłos <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 5f62191ffe71..19458a938c02 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -666,6 +666,7 @@ public: JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership); virtual void set_text(const OUString& rText) override; + virtual void replace_selection(const OUString& rText) override; }; class JSTreeView final : public JSWidget<SalInstanceTreeView, ::SvTabListBox> diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index be17d4ef353c..017f2a8eb522 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -370,6 +370,28 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM LOKTrigger::trigger_changed(*pTextView); return true; } + else if (sAction == "textselection") + { + // start;end + OUString sTextData = rData["data"]; + int nSeparatorPos = sTextData.indexOf(';'); + if (nSeparatorPos <= 0) + return true; + + std::u16string_view aStartPos = sTextData.subView(0, nSeparatorPos); + std::u16string_view aEndPos = sTextData.subView(nSeparatorPos + 1); + + if (aStartPos.empty() || aEndPos.empty()) + return true; + + sal_Int32 nStart = o3tl::toInt32(aStartPos); + sal_Int32 nEnd = o3tl::toInt32(aEndPos); + + pTextView->select_region(nStart, nEnd); + LOKTrigger::trigger_changed(*pTextView); + + return true; + } } } else if (sControlType == "treeview") diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 2bf0ad8e9e4e..2d73c26613da 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1752,6 +1752,12 @@ void JSTextView::set_text(const OUString& rText) sendUpdate(); } +void JSTextView::replace_selection(const OUString& rText) +{ + SalInstanceTextView::replace_selection(rText); + sendUpdate(); +} + JSTreeView::JSTreeView(JSDialogSender* pSender, ::SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceTreeView, ::SvTabListBox>(pSender, pTreeView, pBuilder, bTakeOwnership)
