diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2022-06-15 10:02:59 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-06-20 18:11:20 +0200 |
commit | 62e9828f97ac76fb6717fd50828d5da8375297b2 (patch) | |
tree | 866e5d5695bba8111b4636a921180078d5708d2f /vcl | |
parent | d497d1f1dbeb6de31a9f981da5b887f3114b1a5b (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mert Tumer <mert.tumer@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/jsdialog/executor.cxx | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 4e8324eb9379..2da2ab5b9608 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -216,13 +216,30 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM } else if (sAction == "textselection") { - // start;end int nSeparatorPos = rData["data"].indexOf(';'); if (nSeparatorPos <= 0) return true; + int nSeparator2Pos = rData["data"].indexOf(';', nSeparatorPos + 1); + int nSeparator3Pos = 0; + + if (nSeparator2Pos > 0) + { + // start;end;startPara;endPara + nSeparator3Pos = rData["data"].indexOf(';', nSeparator2Pos + 1); + if (nSeparator3Pos <= 0) + return true; + } + else + { + // start;end + nSeparator2Pos = 0; + nSeparator3Pos = 0; + } + std::u16string_view aStartPos = rData["data"].subView(0, nSeparatorPos); - std::u16string_view aEndPos = rData["data"].subView(nSeparatorPos + 1); + std::u16string_view aEndPos = rData["data"].subView( + nSeparatorPos + 1, nSeparator2Pos - nSeparatorPos + 1); if (aStartPos.empty() || aEndPos.empty()) return true; @@ -231,9 +248,33 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM OUStringToOString(aStartPos.data(), RTL_TEXTENCODING_ASCII_US).getStr()); int nEnd = std::atoi( OUStringToOString(aEndPos.data(), RTL_TEXTENCODING_ASCII_US).getStr()); + int nStartPara = 0; + int nEndPara = 0; + + // multiline case + if (nSeparator2Pos && nSeparator3Pos) + { + std::u16string_view aStartPara = rData["data"].subView( + nSeparator2Pos + 1, nSeparator3Pos - nSeparator2Pos + 1); + std::u16string_view aEndPara = rData["data"].subView(nSeparator3Pos + 1); + + if (aStartPara.empty() || aEndPara.empty()) + return true; + + nStartPara = std::atoi( + OUStringToOString(aStartPara.data(), RTL_TEXTENCODING_ASCII_US) + .getStr()); + nEndPara = std::atoi( + OUStringToOString(aEndPara.data(), RTL_TEXTENCODING_ASCII_US).getStr()); + } + + // 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; |