summaryrefslogtreecommitdiff
path: root/vcl/jsdialog/executor.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-06-01 14:52:33 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2022-06-02 09:37:16 +0200
commit802571046793dd1090c94b598a085ac4b69c90df (patch)
tree2cd46fb76016d010f90e01c5a36a009ba6d64f0b /vcl/jsdialog/executor.cxx
parent3c8376a00636091b1c90970b4bd8a2a2eae9da52 (diff)
jsdialog: correctly parse click position for drawingarea
Change-Id: I8f0739cea8d2a3472926682f205bc5f5227bdc4c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135241 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mert Tumer <mert.tumer@collabora.com>
Diffstat (limited to 'vcl/jsdialog/executor.cxx')
-rw-r--r--vcl/jsdialog/executor.cxx42
1 files changed, 23 insertions, 19 deletions
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 130c48453815..4e8324eb9379 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -174,29 +174,33 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM
{
if (sAction == "click")
{
- int separatorPos = rData["data"].indexOf(';');
- if (separatorPos > 0)
+ int nSeparatorPos = rData["data"].indexOf(';');
+ if (nSeparatorPos > 0)
{
// x;y
- std::string_view clickPosX = OUStringToOString(
- rData["data"].subView(0, separatorPos), RTL_TEXTENCODING_ASCII_US);
- std::string_view clickPosY = OUStringToOString(
- rData["data"].subView(separatorPos + 1), RTL_TEXTENCODING_ASCII_US);
- if (!clickPosX.empty() && !clickPosY.empty())
- {
- double posX = std::atof(clickPosX.data());
- double posY = std::atof(clickPosY.data());
- OutputDevice& rRefDevice = pArea->get_ref_device();
- // We send OutPutSize for the drawing area bitmap
- // get_size_request is not necessarily updated
- // therefore it may be incorrect.
- Size size = rRefDevice.GetOutputSize();
- posX = posX * size.Width();
- posY = posY * size.Height();
- LOKTrigger::trigger_click(*pArea, Point(posX, posY));
+ std::u16string_view nClickPosX = rData["data"].subView(0, nSeparatorPos);
+ std::u16string_view nClickPosY = rData["data"].subView(nSeparatorPos + 1);
+
+ if (nClickPosX.empty() || nClickPosY.empty())
return true;
- }
+
+ double posX = std::atof(
+ OUStringToOString(nClickPosX.data(), RTL_TEXTENCODING_ASCII_US)
+ .getStr());
+ double posY = std::atof(
+ OUStringToOString(nClickPosY.data(), RTL_TEXTENCODING_ASCII_US)
+ .getStr());
+ OutputDevice& rRefDevice = pArea->get_ref_device();
+ // We send OutPutSize for the drawing area bitmap
+ // get_size_request is not necessarily updated
+ // therefore it may be incorrect.
+ Size size = rRefDevice.GetOutputSize();
+ posX = posX * size.Width();
+ posY = posY * size.Height();
+ LOKTrigger::trigger_click(*pArea, Point(posX, posY));
+ return true;
}
+
LOKTrigger::trigger_click(*pArea, Point(10, 10));
return true;
}