[Libreoffice-commits] online.git: 2 commits - loolwsd/bundled loolwsd/LOKitClient.cpp loolwsd/LOOLSession.cpp

Jan Holesovsky kendy at collabora.com
Tue Nov 3 10:30:22 PST 2015


 loolwsd/LOKitClient.cpp                                      |    1 
 loolwsd/LOOLSession.cpp                                      |   12 +++++--
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h      |    8 ++++-
 loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h |   17 ++++++++++-
 4 files changed, 33 insertions(+), 5 deletions(-)

New commits:
commit db38aaff1c38cfcc90b36515f23b8ddd162a79a2
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 3 19:28:46 2015 +0100

    loolwsd: Handle LOK_CALLBACK_UNO_COMMAND_RESULT.
    
    Also update according to the API change, and trigger the notification when
    calling .uno:Save.

diff --git a/loolwsd/LOKitClient.cpp b/loolwsd/LOKitClient.cpp
index d8ea3f0..1e912af 100644
--- a/loolwsd/LOKitClient.cpp
+++ b/loolwsd/LOKitClient.cpp
@@ -60,6 +60,7 @@ extern "C"
             CASE(SEARCH_RESULT_SELECTION);
             CASE(DOCUMENT_SIZE_CHANGED);
             CASE(SET_PART);
+            CASE(UNO_COMMAND_RESULT);
 #undef CASE
         }
         std::cout << " payload: " << pPayload << std::endl;
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 12c75f4..36b6a92 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -891,6 +891,9 @@ extern "C"
         case LOK_CALLBACK_SET_PART:
             srv->sendTextFrame("setpart: " + std::string(pPayload));
             break;
+        case LOK_CALLBACK_UNO_COMMAND_RESULT:
+            srv->sendTextFrame("unocommandresult: " + std::string(pPayload));
+            break;
         }
     }
 }
@@ -1151,7 +1154,7 @@ bool ChildProcessSession::insertFile(const char* /*buffer*/, int /*length*/, Str
                 "\"type\":\"string\","
                 "\"value\":\"" + fileName + "\""
             "}}";
-        _loKitDocument->pClass->postUnoCommand(_loKitDocument, command.c_str(), arguments.c_str());
+        _loKitDocument->pClass->postUnoCommand(_loKitDocument, command.c_str(), arguments.c_str(), false);
     }
 
     return true;
@@ -1210,13 +1213,16 @@ bool ChildProcessSession::unoCommand(const char* /*buffer*/, int /*length*/, Str
         return false;
     }
 
+    // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
+    bool bNotify = (tokens[1] == ".uno:Save");
+
     if (tokens.count() == 2)
     {
-        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), 0);
+        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), 0, bNotify);
     }
     else
     {
-        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str());
+        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(), bNotify);
     }
 
     return true;
commit 9f75fbd2fc37f3f7f80b1c57afa9ab9851cfc361
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 3 14:53:19 2015 +0100

    loolwsd: Update the bundled LOK to contain LOK_CALLBACK_UNO_COMMAND_RESULT.

diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index d83717b..c887f5f 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -12,6 +12,11 @@
 
 #include <stddef.h>
 
+#ifdef LOK_USE_UNSTABLE_API
+// the unstable API needs C99's bool
+#include <stdbool.h>
+#endif
+
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
 
 #ifdef __cplusplus
@@ -144,7 +149,8 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::postUnoCommand
     void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
                             const char* pCommand,
-                            const char* pArguments);
+                            const char* pArguments,
+                            bool bNotifyWhenFinished);
 
     /// @see lok::Document::setTextSelection
     void (*setTextSelection) (LibreOfficeKitDocument* pThis,
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 459da5d..86d9e6b 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -180,7 +180,22 @@ typedef enum
      * - searchResultSelection is an array of part-number and rectangle list
      *   pairs, in LOK_CALLBACK_SET_PART / LOK_CALLBACK_TEXT_SELECTION format.
      */
-    LOK_CALLBACK_SEARCH_RESULT_SELECTION
+    LOK_CALLBACK_SEARCH_RESULT_SELECTION,
+
+    /**
+     * Result of the UNO command execution when bNotifyWhenFinished was set
+     * to 'true' during the postUnoCommand() call.
+     *
+     * The result returns a success / failure state, and potentially
+     * additional data:
+     *
+     * {
+     *     "commandName": "...",    // the command for which this is the result
+     *     "success": true/false,   // when the result is "don't know", this is missing
+     *     // TODO "result": "..."  // UNO Any converted to JSON (not implemented yet)
+     * }
+     */
+    LOK_CALLBACK_UNO_COMMAND_RESULT
 }
 LibreOfficeKitCallbackType;
 


More information about the Libreoffice-commits mailing list