vcl/jsdialog/executor.cxx |   36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

New commits:
commit 61f5c991a97de8990badfed6ef840941b5aa8c7f
Author:     Szymon Kłos <[email protected]>
AuthorDate: Wed Jun 1 14:52:33 2022 +0200
Commit:     Szymon Kłos <[email protected]>
CommitDate: Wed Jun 29 07:27:52 2022 +0200

    jsdialog: correctly parse click position for drawingarea
    
    Change-Id: I8f0739cea8d2a3472926682f205bc5f5227bdc4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135241
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Mert Tumer <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136593
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 58ec87cf0197..0145c91f8eee 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -175,27 +175,29 @@ bool ExecuteAction(const std::string& nWindowId, const 
OString& rWidget, StringM
                 if (sAction == "click")
                 {
                     OUString sClickData = rData["data"];
-                    int separatorPos = sClickData.indexOf(';');
-                    if (separatorPos > 0)
+                    int nSeparatorPos = sClickData.indexOf(';');
+                    if (nSeparatorPos > 0)
                     {
                         // x;y
-                        std::u16string_view clickPosX = sClickData.subView(0, 
separatorPos);
-                        std::u16string_view clickPosY = 
sClickData.subView(separatorPos + 1);
-                        if (!clickPosX.empty() && !clickPosY.empty())
-                        {
-                            double posX = o3tl::toDouble(clickPosX);
-                            double posY = o3tl::toDouble(clickPosY);
-                            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 = sClickData.subView(0, 
nSeparatorPos);
+                        std::u16string_view nClickPosY = 
sClickData.subView(nSeparatorPos + 1);
+
+                        if (nClickPosX.empty() || nClickPosY.empty())
                             return true;
-                        }
+
+                        double posX = o3tl::toDouble(nClickPosX);
+                        double posY = o3tl::toDouble(nClickPosY);
+                        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;
                 }

Reply via email to