sc/source/ui/app/inputwin.cxx | 9 ++++++-- vcl/jsdialog/executor.cxx | 44 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-)
New commits: commit 850b7a567c9d0812dc612ba21ee804d8bafb6fe1 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Jun 15 10:02:59 2022 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Jun 29 10:40:01 2022 +0200 jsdialog: formulabar: handle multiline selection it uses format: "start;end;startPara;endPara" Change-Id: If3d36550f5e4a35fc04c72114c7719119b10da61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135866 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mert Tumer <mert.tu...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136597 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 817a68dc044f..395499a683d7 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1774,9 +1774,14 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt ) if (!m_xEditView) return true; + // information about paragraph is in additional data + // information about position in a paragraph in a Mouse Pos + // see vcl/jsdialog/executor.cxx "textselection" event + const Point* pParaPoint = static_cast<const Point*>(rCEvt.GetEventData()); Point aSelectionStartEnd = rCEvt.GetMousePosPixel(); - m_xEditView->SetSelection(ESelection(0, aSelectionStartEnd.X(), - 0, aSelectionStartEnd.Y())); + m_xEditView->SetSelection( + ESelection((pParaPoint ? pParaPoint->X() : 0), aSelectionStartEnd.X(), + (pParaPoint ? pParaPoint->Y() : 0), aSelectionStartEnd.Y())); SC_MOD()->InputSelection( m_xEditView.get() ); diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 0145c91f8eee..4489949a91b5 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -210,23 +210,61 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM } else if (sAction == "textselection") { - // start;end OUString sTextData = rData["data"]; int nSeparatorPos = sTextData.indexOf(';'); if (nSeparatorPos <= 0) return true; + int nSeparator2Pos = sTextData.indexOf(';', nSeparatorPos + 1); + int nSeparator3Pos = 0; + + if (nSeparator2Pos > 0) + { + // start;end;startPara;endPara + nSeparator3Pos = sTextData.indexOf(';', nSeparator2Pos + 1); + if (nSeparator3Pos <= 0) + return true; + } + else + { + // start;end + nSeparator2Pos = 0; + nSeparator3Pos = 0; + } + std::u16string_view aStartPos = sTextData.subView(0, nSeparatorPos); - std::u16string_view aEndPos = sTextData.subView(nSeparatorPos + 1); + std::u16string_view aEndPos + = sTextData.subView(nSeparatorPos + 1, nSeparator2Pos - nSeparatorPos + 1); if (aStartPos.empty() || aEndPos.empty()) return true; sal_Int32 nStart = o3tl::toInt32(aStartPos); sal_Int32 nEnd = o3tl::toInt32(aEndPos); + sal_Int32 nStartPara = 0; + sal_Int32 nEndPara = 0; + + // multiline case + if (nSeparator2Pos && nSeparator3Pos) + { + std::u16string_view aStartPara = sTextData.subView( + nSeparator2Pos + 1, nSeparator3Pos - nSeparator2Pos + 1); + std::u16string_view aEndPara = sTextData.subView(nSeparator3Pos + 1); + + if (aStartPara.empty() || aEndPara.empty()) + return true; + + nStartPara = o3tl::toInt32(aStartPara); + nEndPara = o3tl::toInt32(aEndPara); + } + + // pass information about paragraph number in the additional data + // handled in sc/source/ui/app/inputwin.cxx + Point* pParaPoint = new Point(nStartPara, nEndPara); + const void* pCmdData = pParaPoint; Point aPos(nStart, nEnd); - CommandEvent aCEvt(aPos, CommandEventId::CursorPos); + CommandEvent aCEvt(aPos, CommandEventId::CursorPos, false, pCmdData); LOKTrigger::command(*pArea, aCEvt); return true;