forms/source/component/FormComponent.cxx |    5 +++++
 include/sfx2/lokhelper.hxx               |    2 +-
 include/sfx2/viewsh.hxx                  |    2 +-
 include/vcl/IDialogRenderable.hxx        |    2 +-
 include/vcl/svapp.hxx                    |    2 +-
 include/vcl/window.hxx                   |    3 +++
 sfx2/source/view/lokhelper.cxx           |    6 ++++--
 sfx2/source/view/viewsh.cxx              |    4 ++--
 vcl/source/app/svapp.cxx                 |    2 +-
 vcl/source/window/cursor.cxx             |    6 +++++-
 vcl/source/window/window.cxx             |   18 +++++++++++++++---
 11 files changed, 39 insertions(+), 13 deletions(-)

New commits:
commit 8ec50498c5b9c1c51ce22e81cb1ce1189f6c85a8
Author:     Gökay Şatır <gokaysa...@gmail.com>
AuthorDate: Mon Sep 1 17:04:12 2025 +0300
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Sep 12 15:24:40 2025 +0200

    Add windowId to "notifyCursorInvalidation".
    
    Online side has special handling for backspace and delete chars.
    Online side calls a function for these chars along with windowId.
    We need to know the windowIds of the form controls when calling 
removeTextContent function.
    
    Signed-off-by: Gökay Şatır <gokaysa...@gmail.com>
    Change-Id: I3ed6cea3ffe81769c7f95da95636ad6d630059ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190487
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/forms/source/component/FormComponent.cxx 
b/forms/source/component/FormComponent.cxx
index 557f914e5d5d..a3b3632187dd 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -55,6 +55,8 @@
 #include <algorithm>
 #include <vcl/window.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
+
+#include <comphelper/lok.hxx>
 namespace frm
 {
 using namespace ::com::sun::star::uno;
@@ -275,6 +277,9 @@ void SAL_CALL OControl::createPeer(const 
Reference<XToolkit>& _rxToolkit, const
 
         VclPtr<vcl::Window> pVclPeer = VCLUnoHelper::GetWindow(getPeer());
         pVclPeer->SetFormControl(true);
+
+        if (comphelper::LibreOfficeKit::isActive())
+            pVclPeer->SetLOKWindowId();
     }
 }
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 0ebd4e1d1dd2..099c45025328 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -188,7 +188,7 @@ public:
     /// Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same 
document with the same part
     static void notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, int 
nPart);
     /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR
-    static void notifyCursorInvalidation(SfxViewShell const* pThisView, 
tools::Rectangle const * pRect, bool bControlEvent);
+    static void notifyCursorInvalidation(SfxViewShell const* pThisView, 
tools::Rectangle const * pRect, bool bControlEvent, int windowID);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to 
setOptionalFeatures() if needed.
     static void notifyInvalidation(SfxViewShell const* pThisView, int nPart, 
tools::Rectangle const *);
     /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to 
setOptionalFeatures() if needed
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index dc2f5f525ee0..a4815690ad62 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -439,7 +439,7 @@ public:
     /// ILibreOfficeKitNotifier. Emits a LOK_CALLBACK_INVALIDATE_TILES.
     virtual void notifyInvalidation(tools::Rectangle const *) const override;
     /// ILibreOfficeKitNotifier.
-    virtual void notifyCursorInvalidation(tools::Rectangle const *, bool 
bControlEvent) const override;
+    virtual void notifyCursorInvalidation(tools::Rectangle const *, bool 
bControlEvent, int windowID) const override;
 
     /// See OutlinerViewShell::NotifyOtherViews().
     void NotifyOtherViews(int nType, const OString& rKey, const OString& 
rPayload) override;
diff --git a/include/vcl/IDialogRenderable.hxx 
b/include/vcl/IDialogRenderable.hxx
index baaf6358d372..ff2f1e70f3bd 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -43,7 +43,7 @@ public:
     virtual void notifyInvalidation(tools::Rectangle const *) const = 0;
 
     /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR.
-    virtual void notifyCursorInvalidation(tools::Rectangle const *, bool 
bControlEvent) const = 0;
+    virtual void notifyCursorInvalidation(tools::Rectangle const *, bool 
bControlEvent, int windowID) const = 0;
 
     /// Debugging
     virtual OString dumpNotifyState() const = 0;
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index b5dab8ab07ef..8f8a86f7e67b 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1329,7 +1329,7 @@ public:
                               const std::vector<vcl::LOKPayloadItem>& rPayload 
= std::vector<vcl::LOKPayloadItem>()) const override;
     virtual void libreOfficeKitViewCallback(int nType, const OString& 
pPayload) const override;
     virtual void notifyInvalidation(tools::Rectangle const* pRect) const 
override;
-    virtual void notifyCursorInvalidation(tools::Rectangle const* pRect, bool 
bControlEvent) const override;
+    virtual void notifyCursorInvalidation(tools::Rectangle const* pRect, bool 
bControlEvent, int windowID) const override;
     virtual OString dumpNotifyState() const override;
 
 private:
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index b8e28ff92901..d74424b98b5e 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1106,6 +1106,9 @@ public:
     const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const;
     vcl::LOKWindowId                    GetLOKWindowId() const;
 
+    /// This sets the lokWindowId without setting a notifier.
+    void                                SetLOKWindowId();
+
     /// Find the nearest parent with LOK Notifier; can be itself if this 
Window has LOK notifier set.
     VclPtr<vcl::Window>                 GetParentWithLOKNotifier();
 
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index bdcd49d196ed..f554ae32daad 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -740,12 +740,14 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* 
pThisView,
     pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, s);
 }
 
-void SfxLokHelper::notifyCursorInvalidation(SfxViewShell const* pThisView, 
tools::Rectangle const* pRect, bool bControlEvent)
+void SfxLokHelper::notifyCursorInvalidation(SfxViewShell const* pThisView, 
tools::Rectangle const* pRect, bool bControlEvent, int windowID)
 {
     int nViewId = SfxLokHelper::getView(*pThisView);
     OString sPayload = OString::Concat("{ \"viewId\": \"") + 
OString::number(nViewId) + "\", \"rectangle\": \"" + pRect->toString();
     if (bControlEvent)
-        sPayload += "\", \"controlEvent\": true";
+    {
+        sPayload += "\", \"controlEvent\": true, \"windowId\": \"" + 
OString::number(windowID) + "\"";
+    }
     sPayload += " }";
     
pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, 
sPayload);
 }
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 9e29bde9e9b8..23004089e82b 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -3560,9 +3560,9 @@ void SfxViewShell::notifyInvalidation(tools::Rectangle 
const* pRect) const
     SfxLokHelper::notifyInvalidation(this, pRect);
 }
 
-void SfxViewShell::notifyCursorInvalidation(tools::Rectangle const* pRect, 
bool bControlEvent) const
+void SfxViewShell::notifyCursorInvalidation(tools::Rectangle const* pRect, 
bool bControlEvent, int windowID) const
 {
-    SfxLokHelper::notifyCursorInvalidation(this, pRect, bControlEvent);
+    SfxLokHelper::notifyCursorInvalidation(this, pRect, bControlEvent, 
windowID);
 }
 
 void SfxViewShell::NotifyOtherViews(int nType, const OString& rKey, const 
OString& rPayload)
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index fa258d7f0613..c97f7fadeb43 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -341,7 +341,7 @@ void Application::notifyInvalidation(tools::Rectangle 
const* /*pRect*/) const
 {
 }
 
-void Application::notifyCursorInvalidation(tools::Rectangle const* /*pRect*/, 
bool /*bControlEvent*/) const
+void Application::notifyCursorInvalidation(tools::Rectangle const* /*pRect*/, 
bool /*bControlEvent*/, int /*windowID*/) const
 {
 }
 
diff --git a/vcl/source/window/cursor.cxx b/vcl/source/window/cursor.cxx
index 2437fc321348..535a0bde2a46 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -296,7 +296,11 @@ void vcl::Cursor::LOKNotify(vcl::Window* pWindow, const 
OUString& rAction)
 
             OutputDevice* pDevice = mpData->mpWindow->GetOutDev();
             const tools::Rectangle aRectTwip = pDevice->PixelToLogic(aRect, 
MapMode(MapUnit::MapTwip));
-            pNotifier->notifyCursorInvalidation(&aRectTwip, true);
+
+            if (pWindow->IsFormControl())
+                pNotifier->notifyCursorInvalidation(&aRectTwip, true, 
pWindow->GetLOKWindowId());
+            else
+                pNotifier->notifyCursorInvalidation(&aRectTwip, true, 
pWindow->GetParent()->GetLOKWindowId());
         }
     }
     else
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 23df41fa50ce..0366f5ba5e75 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3174,6 +3174,9 @@ LOKWindowsMap& GetLOKWindowsMap()
 
 }
 
+// Counter to be able to have unique id's for each window.
+static vcl::LOKWindowId sLastLOKWindowId = 1;
+
 void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, 
bool bParent)
 {
     // don't allow setting this twice
@@ -3184,9 +3187,6 @@ void Window::SetLOKNotifier(const 
vcl::ILibreOfficeKitNotifier* pNotifier, bool
 
     if (!bParent)
     {
-        // Counter to be able to have unique id's for each window.
-        static vcl::LOKWindowId sLastLOKWindowId = 1;
-
         // assign the LOK window id
         assert(mpWindowImpl->mnLOKWindowId == 0);
         mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
@@ -3196,6 +3196,17 @@ void Window::SetLOKNotifier(const 
vcl::ILibreOfficeKitNotifier* pNotifier, bool
     mpWindowImpl->mpLOKNotifier = pNotifier;
 }
 
+void Window::SetLOKWindowId()
+{
+    // never use this in the desktop case
+    assert(comphelper::LibreOfficeKit::isActive());
+
+    // assign the LOK window id
+    assert(mpWindowImpl->mnLOKWindowId == 0);
+    mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
+    GetLOKWindowsMap().emplace(mpWindowImpl->mnLOKWindowId, this);
+}
+
 VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId)
 {
     const auto it = GetLOKWindowsMap().find(nWindowId);
@@ -3363,6 +3374,7 @@ void Window::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
     rJsonWriter.put("type", windowTypeName(GetType()));
     rJsonWriter.put("text", GetText());
     rJsonWriter.put("enabled", IsEnabled());
+    rJsonWriter.put("lokWindowId", GetLOKWindowId());
     if (!IsVisible())
         rJsonWriter.put("visible", false);
 

Reply via email to