Blame SOURCES/0264-lok-Introduce-LOK_CALLBACK_UNO_COMMAND_RESULT-callba.patch

f325b2
From 1c5b0b2f4a2e883f5da3a4afb3cadaf695d58fac Mon Sep 17 00:00:00 2001
f325b2
From: Jan Holesovsky <kendy@collabora.com>
f325b2
Date: Tue, 3 Nov 2015 13:20:06 +0100
f325b2
Subject: [PATCH 264/398] lok: Introduce LOK_CALLBACK_UNO_COMMAND_RESULT
f325b2
 callback.
f325b2
f325b2
Posting of the .uno:Something commands is asynchronous.  To be able to find
f325b2
out when eg. .uno:Save finished, this commit introduces a callback that fires
f325b2
when that happens.
f325b2
f325b2
To be able to receive such a notification, the appropriate postUnoCommand()
f325b2
must be called with 'true' as the parameter for bNotifyWhenFinished (defaults
f325b2
to 'false').
f325b2
f325b2
Change-Id: I254939ebc8ea5f309ae39686dcaaeddd5148b0c9
f325b2
(cherry picked from commit 8c987fababbddb6e4f81b0cd717b59b9a9ff9be0)
f325b2
---
f325b2
 comphelper/source/misc/dispatchcommand.cxx         |  9 ++-
f325b2
 desktop/inc/lib/init.hxx                           |  2 +
f325b2
 desktop/source/lib/init.cxx                        | 74 ++++++++++++++++++++--
f325b2
 include/LibreOfficeKit/LibreOfficeKit.h            |  8 ++-
f325b2
 include/LibreOfficeKit/LibreOfficeKit.hxx          |  4 +-
f325b2
 include/LibreOfficeKit/LibreOfficeKitEnums.h       | 17 ++++-
f325b2
 include/LibreOfficeKit/LibreOfficeKitGtk.h         |  4 +-
f325b2
 include/comphelper/dispatchcommand.hxx             |  5 +-
f325b2
 .../qa/gtktiledviewer/gtktiledviewer.cxx           | 15 ++++-
f325b2
 libreofficekit/source/gtk/lokdocview.cxx           | 34 +++++++++-
f325b2
 libreofficekit/source/gtk/tilebuffer.hxx           |  2 +
f325b2
 11 files changed, 157 insertions(+), 17 deletions(-)
f325b2
f325b2
diff --git a/comphelper/source/misc/dispatchcommand.cxx b/comphelper/source/misc/dispatchcommand.cxx
f325b2
index 5de05542dbb4..a5a6dde0885d 100644
f325b2
--- a/comphelper/source/misc/dispatchcommand.cxx
f325b2
+++ b/comphelper/source/misc/dispatchcommand.cxx
f325b2
@@ -23,6 +23,7 @@
f325b2
 #include <com/sun/star/frame/Desktop.hpp>
f325b2
 #include <com/sun/star/frame/XDispatch.hpp>
f325b2
 #include <com/sun/star/frame/XDispatchProvider.hpp>
f325b2
+#include <com/sun/star/frame/XNotifyingDispatch.hpp>
f325b2
 #include <com/sun/star/util/URL.hpp>
f325b2
 #include <com/sun/star/util/URLTransformer.hpp>
f325b2
 
f325b2
@@ -30,7 +31,7 @@ using namespace css;
f325b2
 
f325b2
 namespace comphelper {
f325b2
 
f325b2
-bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
f325b2
+bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArguments, uno::Reference<css::frame::XDispatchResultListener> aListener)
f325b2
 {
f325b2
     // Target where we will execute the .uno: command
f325b2
     uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
f325b2
@@ -54,7 +55,11 @@ bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence
f325b2
         return false;
f325b2
 
f325b2
     // And do the work...
f325b2
-    xDisp->dispatch(aCommandURL, rArguments);
f325b2
+    uno::Reference<frame::XNotifyingDispatch> xNotifyingDisp(xDisp, uno::UNO_QUERY);
f325b2
+    if (xNotifyingDisp.is())
f325b2
+        xNotifyingDisp->dispatchWithNotification(aCommandURL, rArguments, aListener);
f325b2
+    else
f325b2
+        xNotifyingDisp->dispatch(aCommandURL, rArguments);
f325b2
 
f325b2
     return true;
f325b2
 }
f325b2
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
f325b2
index d3a42fb10bde..4f878d26c007 100644
f325b2
--- a/desktop/inc/lib/init.hxx
f325b2
+++ b/desktop/inc/lib/init.hxx
f325b2
@@ -20,6 +20,8 @@ namespace desktop {
f325b2
     {
f325b2
         uno::Reference<css::lang::XComponent> mxComponent;
f325b2
         std::shared_ptr< LibreOfficeKitDocumentClass > m_pDocumentClass;
f325b2
+        LibreOfficeKitCallback mpCallback;
f325b2
+        void *mpCallbackData;
f325b2
 
f325b2
         explicit LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent);
f325b2
         ~LibLODocument_Impl();
f325b2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
f325b2
index 98747ea62e3a..9ba26c414d8c 100644
f325b2
--- a/desktop/source/lib/init.cxx
f325b2
+++ b/desktop/source/lib/init.cxx
f325b2
@@ -35,6 +35,8 @@
f325b2
 #include <com/sun/star/beans/XPropertySet.hpp>
f325b2
 #include <com/sun/star/container/XNameAccess.hpp>
f325b2
 #include <com/sun/star/frame/Desktop.hpp>
f325b2
+#include <com/sun/star/frame/DispatchResultEvent.hpp>
f325b2
+#include <com/sun/star/frame/DispatchResultState.hpp>
f325b2
 #include <com/sun/star/frame/XStorable.hpp>
f325b2
 #include <com/sun/star/lang/Locale.hpp>
f325b2
 #include <com/sun/star/lang/XComponent.hpp>
f325b2
@@ -240,7 +242,8 @@ static void doc_postMouseEvent (LibreOfficeKitDocument* pThis,
f325b2
                                 int nModifier);
f325b2
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis,
f325b2
                                const char* pCommand,
f325b2
-                               const char* pArguments);
f325b2
+                               const char* pArguments,
f325b2
+                               bool bNotifyWhenFinished);
f325b2
 static void doc_setTextSelection (LibreOfficeKitDocument* pThis,
f325b2
                                   int nType,
f325b2
                                   int nX,
f325b2
@@ -883,9 +886,14 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis)
f325b2
 }
f325b2
 
f325b2
 static void doc_registerCallback(LibreOfficeKitDocument* pThis,
f325b2
-                                LibreOfficeKitCallback pCallback,
f325b2
-                                void* pData)
f325b2
+                                 LibreOfficeKitCallback pCallback,
f325b2
+                                 void* pData)
f325b2
 {
f325b2
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
f325b2
+
f325b2
+    pDocument->mpCallback = pCallback;
f325b2
+    pDocument->mpCallbackData = pData;
f325b2
+
f325b2
     if (comphelper::LibreOfficeKit::isViewCallback())
f325b2
     {
f325b2
         if (SfxViewShell* pViewShell = SfxViewFrame::Current()->GetViewShell())
f325b2
@@ -950,13 +958,69 @@ static void jsonToPropertyValues(const char* pJSON, uno::Sequence
f325b2
     rPropertyValues = comphelper::containerToSequence(aArguments);
f325b2
 }
f325b2
 
f325b2
-static void doc_postUnoCommand(LibreOfficeKitDocument* /*pThis*/, const char* pCommand, const char* pArguments)
f325b2
+/** Class to react on finishing of a dispatched command.
f325b2
+
f325b2
+    This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was
f325b2
+    called with the parameter requesting the notification.
f325b2
+
f325b2
+    @see LibreOfficeKitCallbackType::LOK_CALLBACK_UNO_COMMAND_RESULT.
f325b2
+*/
f325b2
+class DispatchResultListener : public cppu::WeakImplHelper<css::frame::XDispatchResultListener>
f325b2
+{
f325b2
+    OString maCommand;                 ///< Command for which this is the result.
f325b2
+    LibreOfficeKitCallback mpCallback; ///< Callback to call.
f325b2
+    void* mpCallbackData;              ///< The callback's data.
f325b2
+
f325b2
+public:
f325b2
+    DispatchResultListener(const char* pCommand, LibreOfficeKitCallback pCallback, void* pCallbackData)
f325b2
+        : maCommand(pCommand)
f325b2
+        , mpCallback(pCallback)
f325b2
+        , mpCallbackData(pCallbackData)
f325b2
+    {
f325b2
+        assert(mpCallback);
f325b2
+    }
f325b2
+
f325b2
+    virtual void SAL_CALL dispatchFinished(const css::frame::DispatchResultEvent& rEvent) throw(css::uno::RuntimeException, std::exception) override
f325b2
+    {
f325b2
+        boost::property_tree::ptree aTree;
f325b2
+        aTree.put("commandName", maCommand.getStr());
f325b2
+
f325b2
+        if (rEvent.State != frame::DispatchResultState::DONTKNOW)
f325b2
+        {
f325b2
+            bool bSuccess = (rEvent.State == frame::DispatchResultState::SUCCESS);
f325b2
+            aTree.put("success", bSuccess);
f325b2
+        }
f325b2
+
f325b2
+        // TODO UNO Any rEvent.Result -> JSON
f325b2
+        // aTree.put("result": "...");
f325b2
+
f325b2
+        std::stringstream aStream;
f325b2
+        boost::property_tree::write_json(aStream, aTree);
f325b2
+        mpCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, strdup(aStream.str().c_str()), mpCallbackData);
f325b2
+    }
f325b2
+
f325b2
+    virtual void SAL_CALL disposing(const css::lang::EventObject&) throw (css::uno::RuntimeException, std::exception) override {}
f325b2
+};
f325b2
+
f325b2
+static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished)
f325b2
 {
f325b2
     OUString aCommand(pCommand, strlen(pCommand), RTL_TEXTENCODING_UTF8);
f325b2
 
f325b2
     uno::Sequence<beans::PropertyValue> aPropertyValues;
f325b2
     jsonToPropertyValues(pArguments, aPropertyValues);
f325b2
-    if (!comphelper::dispatchCommand(aCommand, aPropertyValues))
f325b2
+    bool bResult = false;
f325b2
+
f325b2
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
f325b2
+
f325b2
+    if (bNotifyWhenFinished && pDocument->mpCallback)
f325b2
+    {
f325b2
+        bResult = comphelper::dispatchCommand(aCommand, aPropertyValues,
f325b2
+                new DispatchResultListener(pCommand, pDocument->mpCallback, pDocument->mpCallbackData));
f325b2
+    }
f325b2
+    else
f325b2
+        bResult = comphelper::dispatchCommand(aCommand, aPropertyValues);
f325b2
+
f325b2
+    if (!bResult)
f325b2
     {
f325b2
         gImpl->maLastExceptionMsg = "Failed to dispatch the .uno: command";
f325b2
     }
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
index d83717b4a809..c887f5f64b8a 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
@@ -12,6 +12,11 @@
f325b2
 
f325b2
 #include <stddef.h>
f325b2
 
f325b2
+#ifdef LOK_USE_UNSTABLE_API
f325b2
+// the unstable API needs C99's bool
f325b2
+#include <stdbool.h>
f325b2
+#endif
f325b2
+
f325b2
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
f325b2
 
f325b2
 #ifdef __cplusplus
f325b2
@@ -144,7 +149,8 @@ struct _LibreOfficeKitDocumentClass
f325b2
     /// @see lok::Document::postUnoCommand
f325b2
     void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
f325b2
                             const char* pCommand,
f325b2
-                            const char* pArguments);
f325b2
+                            const char* pArguments,
f325b2
+                            bool bNotifyWhenFinished);
f325b2
 
f325b2
     /// @see lok::Document::setTextSelection
f325b2
     void (*setTextSelection) (LibreOfficeKitDocument* pThis,
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
index 6673cd731eb7..c51339fa3ba8 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
@@ -220,9 +220,9 @@ public:
f325b2
      * @param pCommand uno command to be posted to the document, like ".uno:Bold"
f325b2
      * @param pArguments arguments of the uno command.
f325b2
      */
f325b2
-    inline void postUnoCommand(const char* pCommand, const char* pArguments = 0)
f325b2
+    inline void postUnoCommand(const char* pCommand, const char* pArguments = 0, bool bNotifyWhenFinished = false)
f325b2
     {
f325b2
-        mpDoc->pClass->postUnoCommand(mpDoc, pCommand, pArguments);
f325b2
+        mpDoc->pClass->postUnoCommand(mpDoc, pCommand, pArguments, bNotifyWhenFinished);
f325b2
     }
f325b2
 
f325b2
     /**
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
f325b2
index 459da5d196f4..86d9e6bfd873 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
f325b2
@@ -180,7 +180,22 @@ typedef enum
f325b2
      * - searchResultSelection is an array of part-number and rectangle list
f325b2
      *   pairs, in LOK_CALLBACK_SET_PART / LOK_CALLBACK_TEXT_SELECTION format.
f325b2
      */
f325b2
-    LOK_CALLBACK_SEARCH_RESULT_SELECTION
f325b2
+    LOK_CALLBACK_SEARCH_RESULT_SELECTION,
f325b2
+
f325b2
+    /**
f325b2
+     * Result of the UNO command execution when bNotifyWhenFinished was set
f325b2
+     * to 'true' during the postUnoCommand() call.
f325b2
+     *
f325b2
+     * The result returns a success / failure state, and potentially
f325b2
+     * additional data:
f325b2
+     *
f325b2
+     * {
f325b2
+     *     "commandName": "...",    // the command for which this is the result
f325b2
+     *     "success": true/false,   // when the result is "don't know", this is missing
f325b2
+     *     // TODO "result": "..."  // UNO Any converted to JSON (not implemented yet)
f325b2
+     * }
f325b2
+     */
f325b2
+    LOK_CALLBACK_UNO_COMMAND_RESULT
f325b2
 }
f325b2
 LibreOfficeKitCallbackType;
f325b2
 
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
f325b2
index 81f42105d374..32cb66963220 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
f325b2
@@ -184,12 +184,14 @@ gboolean                       lok_doc_view_get_edit               (LOKDocView*
f325b2
  * @pDocView: the #LOKDocView instance
f325b2
  * @pCommand: the command to issue to LO core
f325b2
  * @pArguments: the arguments to the given command
f325b2
+ * @bNotifyWhenFinished: normally false, but it may be useful for eg. .uno:Save
f325b2
  *
f325b2
  * Posts the .uno: command to the LibreOfficeKit.
f325b2
  */
f325b2
 void                           lok_doc_view_post_command           (LOKDocView* pDocView,
f325b2
                                                                     const gchar* pCommand,
f325b2
-                                                                    const gchar* pArguments);
f325b2
+                                                                    const gchar* pArguments,
f325b2
+                                                                    gboolean bNotifyWhenFinished);
f325b2
 
f325b2
 /**
f325b2
  * lok_doc_view_pixel_to_twip:
f325b2
diff --git a/include/comphelper/dispatchcommand.hxx b/include/comphelper/dispatchcommand.hxx
f325b2
index 58aa0b940f4e..7b76bd5a0310 100644
f325b2
--- a/include/comphelper/dispatchcommand.hxx
f325b2
+++ b/include/comphelper/dispatchcommand.hxx
f325b2
@@ -14,6 +14,7 @@
f325b2
 #include <rtl/ustring.hxx>
f325b2
 #include <com/sun/star/uno/Sequence.hxx>
f325b2
 #include <com/sun/star/beans/PropertyValue.hpp>
f325b2
+#include <com/sun/star/frame/XDispatchResultListener.hpp>
f325b2
 
f325b2
 namespace comphelper
f325b2
 {
f325b2
@@ -24,7 +25,9 @@ namespace comphelper
f325b2
 
f325b2
     @return true on success.
f325b2
 */
f325b2
-COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rArguments);
f325b2
+COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
f325b2
+        const css::uno::Sequence<css::beans::PropertyValue>& rArguments,
f325b2
+        css::uno::Reference<css::frame::XDispatchResultListener> aListener = css::uno::Reference<css::frame::XDispatchResultListener>());
f325b2
 
f325b2
 }
f325b2
 
f325b2
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
index 795fb4ed7ff7..96a69fcf64f8 100644
f325b2
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
f325b2
@@ -595,7 +595,7 @@ static void doSearch(GtkWidget* pButton, bool bBackwards)
f325b2
     std::stringstream aStream;
f325b2
     boost::property_tree::write_json(aStream, aTree);
f325b2
 
f325b2
-    lok_doc_view_post_command(pLOKDocView, ".uno:ExecuteSearch", aStream.str().c_str());
f325b2
+    lok_doc_view_post_command(pLOKDocView, ".uno:ExecuteSearch", aStream.str().c_str(), false);
f325b2
 }
f325b2
 
f325b2
 /// Click handler for the search next button.
f325b2
@@ -671,6 +671,12 @@ static void signalCommand(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pD
f325b2
     }
f325b2
 }
f325b2
 
f325b2
+/// LOKDocView command finished -> just write it to the console, not that useful for the viewer.
f325b2
+static void signalCommandResult(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer /*pData*/)
f325b2
+{
f325b2
+    fprintf(stderr, "Command finished: %s\n", pPayload);
f325b2
+}
f325b2
+
f325b2
 static void loadChanged(LOKDocView* /*pLOKDocView*/, gdouble fValue, gpointer pData)
f325b2
 {
f325b2
     GtkWidget* pProgressBar = GTK_WIDGET (pData);
f325b2
@@ -773,7 +779,11 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
f325b2
         GtkToolItem* pItem = GTK_TOOL_ITEM(pWidget);
f325b2
         const std::string& rString = rWindow.m_aToolItemCommandNames[pItem];
f325b2
         g_info("toggleToolItem: lok_doc_view_post_command('%s')", rString.c_str());
f325b2
-        lok_doc_view_post_command(pLOKDocView, rString.c_str(), 0);
f325b2
+
f325b2
+        // notify about the finished Save
f325b2
+        gboolean bNotify = (rString == ".uno:Save");
f325b2
+
f325b2
+        lok_doc_view_post_command(pLOKDocView, rString.c_str(), 0, bNotify);
f325b2
     }
f325b2
 }
f325b2
 
f325b2
@@ -1171,6 +1181,7 @@ static void setupDocView(GtkWidget* pDocView)
f325b2
 #endif
f325b2
     g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
f325b2
     g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
f325b2
+    g_signal_connect(pDocView, "command-result", G_CALLBACK(signalCommandResult), NULL);
f325b2
     g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
f325b2
     g_signal_connect(pDocView, "search-result-count", G_CALLBACK(signalSearchResultCount), NULL);
f325b2
     g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
f325b2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
index 49d5ecc54f65..bcb1d136b749 100644
f325b2
--- a/libreofficekit/source/gtk/lokdocview.cxx
f325b2
+++ b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
@@ -180,6 +180,7 @@ enum
f325b2
     HYPERLINK_CLICKED,
f325b2
     CURSOR_CHANGED,
f325b2
     SEARCH_RESULT_COUNT,
f325b2
+    COMMAND_RESULT,
f325b2
 
f325b2
     LAST_SIGNAL
f325b2
 };
f325b2
@@ -461,6 +462,11 @@ static void searchResultCount(LOKDocView* pDocView, const std::string& rString)
f325b2
     g_signal_emit(pDocView, doc_view_signals[SEARCH_RESULT_COUNT], 0, rString.c_str());
f325b2
 }
f325b2
 
f325b2
+static void commandResult(LOKDocView* pDocView, const std::string& rString)
f325b2
+{
f325b2
+    g_signal_emit(pDocView, doc_view_signals[COMMAND_RESULT], 0, rString.c_str());
f325b2
+}
f325b2
+
f325b2
 static void
f325b2
 setPart(LOKDocView* pDocView, const std::string& rString)
f325b2
 {
f325b2
@@ -752,6 +758,11 @@ callback (gpointer pData)
f325b2
         searchResultCount(pDocView, std::to_string(nCount));
f325b2
     }
f325b2
     break;
f325b2
+    case LOK_CALLBACK_UNO_COMMAND_RESULT:
f325b2
+    {
f325b2
+        commandResult(pDocView, pCallback->m_aPayload);
f325b2
+    }
f325b2
+    break;
f325b2
     default:
f325b2
         g_assert(false);
f325b2
         break;
f325b2
@@ -1520,7 +1531,7 @@ postCommandInThread (gpointer data)
f325b2
     std::stringstream ss;
f325b2
     ss << "lok::Document::postUnoCommand(" << pLOEvent->m_pCommand << ", " << pLOEvent->m_pArguments << ")";
f325b2
     g_info(ss.str().c_str());
f325b2
-    priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, pLOEvent->m_pCommand, pLOEvent->m_pArguments);
f325b2
+    priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, pLOEvent->m_pCommand, pLOEvent->m_pArguments, pLOEvent->m_bNotifyWhenFinished);
f325b2
 }
f325b2
 
f325b2
 static void
f325b2
@@ -2077,6 +2088,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
f325b2
                      G_TYPE_NONE, 4,
f325b2
                      G_TYPE_INT, G_TYPE_INT,
f325b2
                      G_TYPE_INT, G_TYPE_INT);
f325b2
+
f325b2
     /**
f325b2
      * LOKDocView::search-result-count:
f325b2
      * @pDocView: the #LOKDocView on which the signal is emitted
f325b2
@@ -2092,6 +2104,22 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
f325b2
                      G_TYPE_NONE, 1,
f325b2
                      G_TYPE_STRING);
f325b2
 
f325b2
+    /**
f325b2
+     * LOKDocView::command-result:
f325b2
+     * @pDocView: the #LOKDocView on which the signal is emitted
f325b2
+     * @aCommand: JSON containing the info about the command that finished,
f325b2
+     * and its success status.
f325b2
+     */
f325b2
+    doc_view_signals[COMMAND_RESULT] =
f325b2
+        g_signal_new("command-result",
f325b2
+                     G_TYPE_FROM_CLASS(pGObjectClass),
f325b2
+                     G_SIGNAL_RUN_FIRST,
f325b2
+                     0,
f325b2
+                     NULL, NULL,
f325b2
+                     g_cclosure_marshal_VOID__STRING,
f325b2
+                     G_TYPE_NONE, 1,
f325b2
+                     G_TYPE_STRING);
f325b2
+
f325b2
 }
f325b2
 
f325b2
 SAL_DLLPUBLIC_EXPORT GtkWidget*
f325b2
@@ -2326,7 +2354,8 @@ lok_doc_view_get_edit (LOKDocView* pDocView)
f325b2
 SAL_DLLPUBLIC_EXPORT void
f325b2
 lok_doc_view_post_command (LOKDocView* pDocView,
f325b2
                            const gchar* pCommand,
f325b2
-                           const gchar* pArguments)
f325b2
+                           const gchar* pArguments,
f325b2
+                           gboolean bNotifyWhenFinished)
f325b2
 {
f325b2
     LOKDocViewPrivate& priv = getPrivate(pDocView);
f325b2
     GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
f325b2
@@ -2334,6 +2363,7 @@ lok_doc_view_post_command (LOKDocView* pDocView,
f325b2
     GError* error = NULL;
f325b2
     pLOEvent->m_pCommand = pCommand;
f325b2
     pLOEvent->m_pArguments  = g_strdup(pArguments);
f325b2
+    pLOEvent->m_bNotifyWhenFinished = bNotifyWhenFinished;
f325b2
 
f325b2
     g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
f325b2
     g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error);
f325b2
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
index 5e1ea1a27049..8a8569eeb306 100644
f325b2
--- a/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
f325b2
@@ -171,6 +171,7 @@ struct LOEvent
f325b2
     ///@{
f325b2
     const gchar* m_pCommand;
f325b2
     gchar* m_pArguments;
f325b2
+    gboolean m_bNotifyWhenFinished;
f325b2
     ///@}
f325b2
 
f325b2
     /// @name open_document parameter
f325b2
@@ -223,6 +224,7 @@ struct LOEvent
f325b2
         : m_nType(type)
f325b2
         , m_pCommand(0)
f325b2
         , m_pArguments(0)
f325b2
+        , m_bNotifyWhenFinished(false)
f325b2
         , m_pPath(0)
f325b2
         , m_bEdit(false)
f325b2
         , m_nPartMode(0)
f325b2
-- 
f325b2
2.12.0
f325b2