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

New commits:
commit ea6534827d708f24d4b9d7e176dee738e5d24598
Author:     Caolán McNamara <[email protected]>
AuthorDate: Fri Jan 9 09:59:46 2026 +0000
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Jan 12 08:48:30 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]>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index cd8bb23071ab..cbe9b82baf7e 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -255,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 7debc336138e..a9616855337d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -66,6 +66,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>
@@ -1452,6 +1453,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)
@@ -5654,6 +5672,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