desktop/inc/lib/init.hxx    |   13 +++++++++++++
 desktop/source/lib/init.cxx |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

New commits:
commit 516e2915e72d83d3f9a7c1b0540757843c2bf7eb
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Jan 9 09:59:46 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Jan 12 15:52:06 2026 +0100

    add something to report to kit when core is idle
    
    Change-Id: Idf5e1659d111a9351e4833114d4f1cb899cc6f17
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196911
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    (cherry picked from commit ea6534827d708f24d4b9d7e176dee738e5d24598)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197075
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index f556dbf5515a..54e6a1b27535 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -30,6 +30,7 @@
 #include <tools/gen.hxx>
 #include <sfx2/lokcallback.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <vcl/idle.hxx>
 
 #include <desktop/dllapi.h>
 
@@ -254,12 +255,24 @@ namespace desktop {
         DECL_LINK(FlushQueue, void*, void);
     };
 
+    struct WaitUntilIdle
+    {
+        WaitUntilIdle();
+
+        Idle maIdle;
+        OUString msIdleId;
+        std::shared_ptr<CallbackFlushHandler> mpCallbackFlushHandler;
+
+        DECL_LINK(IdleHdl, Timer*, void);
+    };
+
     struct DESKTOP_DLLPUBLIC LibLODocument_Impl : public LibreOfficeKitDocument
     {
         css::uno::Reference<css::lang::XComponent> mxComponent;
         std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass;
         std::map<size_t, std::shared_ptr<CallbackFlushHandler>> 
mpCallbackFlushHandlers;
         const int mnDocumentId;
+        WaitUntilIdle maIdleHelper;
         std::set<OUString> maFontsMissing;
 
         explicit LibLODocument_Impl(css::uno::Reference<css::lang::XComponent> 
xComponent,
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3e0a82ac43b9..2c265ffb7040 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -67,6 +67,7 @@
 #include <utility>
 #include <vcl/commandinfoprovider.hxx>
 #include <vcl/errinf.hxx>
+#include <vcl/idletask.hxx>
 #include <vcl/lok.hxx>
 #include <o3tl/any.hxx>
 #include <o3tl/unit_conversion.hxx>
@@ -1450,6 +1451,23 @@ int getDocumentType (LibreOfficeKitDocument* pThis)
 
 } // anonymous namespace
 
+WaitUntilIdle::WaitUntilIdle()
+    : maIdle{"LibLODocument IdleTask"}
+{
+    maIdle.SetPriority(TaskPriority::TOOLKIT_DEBUG);
+    maIdle.SetInvokeHandler(LINK(this, WaitUntilIdle, IdleHdl));
+}
+
+IMPL_LINK_NOARG(WaitUntilIdle, IdleHdl, Timer*, void)
+{
+    tools::JsonWriter aJson;
+    aJson.put("commandName", ".uno:ReportWhenIdle");
+    aJson.put("idleID", msIdleId);
+    mpCallbackFlushHandler->queue(LOK_CALLBACK_UNO_COMMAND_RESULT, 
aJson.finishAndGetAsOString());
+    mpCallbackFlushHandler.reset();
+    msIdleId.clear();
+}
+
 LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> 
xComponent, int nDocumentId)
     : mxComponent(std::move(xComponent))
     , mnDocumentId(nDocumentId)
@@ -5647,6 +5665,24 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* 
pThis, const char* pComma
 
         return;
     }
+    else if (gImpl && aCommand == ".uno:ReportWhenIdle")
+    {
+        assert(pDocument->maIdleHelper.msIdleId.isEmpty() && "idle id should 
be uset");
+        pDocument->maIdleHelper.mpCallbackFlushHandler = 
pDocument->mpCallbackFlushHandlers[nView];
+
+        for (const beans::PropertyValue& rPropValue : aPropertyValuesVector)
+        {
+            if (rPropValue.Name == "idleID")
+            {
+                rPropValue.Value >>= pDocument->maIdleHelper.msIdleId;
+            }
+        }
+
+        assert(!pDocument->maIdleHelper.msIdleId.isEmpty() && "idle id should 
be set");
+
+        pDocument->maIdleHelper.maIdle.Start();
+        return;
+    }
 
     if (aCommand != ".uno:Save")
     {

Reply via email to