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 a74bbebc520ad7073e6bbe5a4420825ddbdc7a3f
Author:     Gökay Şatır <[email protected]>
AuthorDate: Mon Sep 1 17:04:12 2025 +0300
Commit:     Gökay ŞATIR <[email protected]>
CommitDate: Thu Feb 26 07:05:37 2026 +0100

    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 <[email protected]>
    Change-Id: I3ed6cea3ffe81769c7f95da95636ad6d630059ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190487
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200290
    Reviewed-by: Gökay ŞATIR <[email protected]>
    Tested-by: Jenkins

diff --git a/forms/source/component/FormComponent.cxx 
b/forms/source/component/FormComponent.cxx
index 8ccec384f410..7cef8b5c588f 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -56,6 +56,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 7ee2c87a9521..74e2992bef07 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -192,7 +192,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 be1dfa7f6f3c..5d2dc0d9f9b5 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -425,7 +425,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 aaa17cd7991c..64f9ed984d73 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -41,7 +41,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 d228230135bf..7afde6b855bc 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1346,7 +1346,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 7a2bee572052..d3778bb66753 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1076,6 +1076,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 68e102c96afe..e4084220e4bd 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -737,12 +737,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 8af5f1837e6e..3e696e834974 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -3590,9 +3590,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 cd7899e3515f..09e911db9d6d 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -343,7 +343,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 052bc81fdf13..5af45eddd0ac 100644
--- a/vcl/source/window/cursor.cxx
+++ b/vcl/source/window/cursor.cxx
@@ -322,7 +322,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 cfc2674d1e21..c4c6fd96cffb 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3168,6 +3168,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
@@ -3178,9 +3181,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++;
@@ -3190,6 +3190,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);
@@ -3362,6 +3373,7 @@ void Window::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
     rJsonWriter.put("text", GetText());
     rJsonWriter.put("enabled", IsEnabled());
     rJsonWriter.put("canFocus", bool(GetStyle() & WB_TABSTOP));
+    rJsonWriter.put("lokWindowId", GetLOKWindowId());
     if (!IsVisible())
         rJsonWriter.put("visible", false);
 

Reply via email to