[Libreoffice-commits] online.git: bundled/include kit/ChildSession.cpp kit/ChildSession.hpp loleaflet/src wsd/ClientSession.cpp

Szymon Kłos (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 14 17:19:15 UTC 2019


 bundled/include/LibreOfficeKit/LibreOfficeKit.h   |    5 ++++
 bundled/include/LibreOfficeKit/LibreOfficeKit.hxx |   11 +++++++++
 kit/ChildSession.cpp                              |   25 +++++++++++++++++++++-
 kit/ChildSession.hpp                              |    1 
 loleaflet/src/control/Control.JSDialogBuilder.js  |    4 ++-
 loleaflet/src/control/Control.LokDialog.js        |    2 +
 wsd/ClientSession.cpp                             |    7 +++++-
 7 files changed, 52 insertions(+), 3 deletions(-)

New commits:
commit 80ecaa60f62aa41584ef1ab8b040806f8d92a0a7
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Oct 14 18:02:28 2019 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Oct 14 19:18:07 2019 +0200

    jsdialogs: send events to the core
    
    Change-Id: I23a5a14b93bda205c9c276a697e58d1dc4147f0c

diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index 6060b015b..2e846c7fa 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -199,6 +199,11 @@ struct _LibreOfficeKitDocumentClass
                             int nButtons,
                             int nModifier);
 
+    /// @see lok::Document::sendDialogEvent
+    void (*sendDialogEvent) (LibreOfficeKitDocument* pThis,
+                            unsigned nLOKWindowId,
+                            const char* pArguments);
+
     /// @see lok::Document::postUnoCommand
     void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
                             const char* pCommand,
diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
index a695c4113..26093f387 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -303,6 +303,17 @@ public:
     }
 
     /**
+     * Posts a dialog event for the window with given id
+     *
+     * @param nWindowId id of the window to notify
+     * @param pArguments arguments of the event.
+     */
+    void sendDialogEvent(unsigned nWindowId, const char* pArguments = NULL)
+    {
+        mpDoc->pClass->sendDialogEvent(mpDoc, nWindowId, pArguments);
+    }
+
+    /**
      * Posts an UNO command to the document.
      *
      * Example argument string:
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index cd38ec7a7..05c9ba772 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -42,6 +42,7 @@
 #include <Util.hpp>
 #include <Unit.hpp>
 #include <Clipboard.hpp>
+#include <string>
 
 using Poco::JSON::Object;
 using Poco::JSON::Parser;
@@ -295,7 +296,8 @@ bool ChildSession::_handleInput(const char *buffer, int length)
                tokens[0] == "uploadsigneddocument" ||
                tokens[0] == "exportsignanduploaddocument" ||
                tokens[0] == "rendershapeselection" ||
-               tokens[0] == "removetextcontext");
+               tokens[0] == "removetextcontext" ||
+               tokens[0] == "dialogevent");
 
         if (tokens[0] == "clientzoom")
         {
@@ -419,6 +421,10 @@ bool ChildSession::_handleInput(const char *buffer, int length)
         {
             return removeTextContext(buffer, length, tokens);
         }
+        else if (tokens[0] == "dialogevent")
+        {
+            return dialogEvent(buffer, length, tokens);
+        }
         else
         {
             assert(false && "Unknown command token.");
@@ -1375,6 +1381,23 @@ bool ChildSession::mouseEvent(const char* /*buffer*/, int /*length*/,
     return true;
 }
 
+bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
+{
+    if (tokens.size() <= 2)
+    {
+        sendTextFrame("error: cmd=dialogevent kind=syntax");
+        return false;
+    }
+
+    getLOKitDocument()->setView(_viewId);
+
+    unsigned nLOKWindowId = std::stoi(tokens[1].c_str());
+    getLOKitDocument()->sendDialogEvent(nLOKWindowId,
+        Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str());
+
+    return true;
+}
+
 bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
 {
     if (tokens.size() <= 1)
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 88166a0c4..971b4158b 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -259,6 +259,7 @@ private:
     bool dialogKeyEvent(const char* buffer, int length, const std::vector<std::string>& tokens);
     bool mouseEvent(const char* buffer, int length, const std::vector<std::string>& tokens, const LokEventTargetEnum target);
     bool gestureEvent(const char* buffer, int length, const std::vector<std::string>& tokens);
+    bool dialogEvent(const char* buffer, int length, const std::vector<std::string>& tokens);
     bool unoCommand(const char* buffer, int length, const std::vector<std::string>& tokens);
     bool selectText(const char* buffer, int length, const std::vector<std::string>& tokens);
     bool selectGraphic(const char* buffer, int length, const std::vector<std::string>& tokens);
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index aee7a23f5..a94fbc778 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -91,10 +91,12 @@ L.Control.JSDialogBuilder = L.Control.extend({
 
 	// by default send new state to the core
 	_defaultCallbackHandler: function(objectType, eventType, object, data, builder) {
-		console.debug('control: \'' + objectType + '\' event: \'' + eventType + '\' state: \'' + data + '\'');
+		console.debug('control: \'' + objectType + '\' id:\'' + object.id + '\' event: \'' + eventType + '\' state: \'' + data + '\'');
 
 		if (objectType == 'toolbutton' && eventType == 'click') {
 			builder.map.sendUnoCommand(data);
+		} else {
+			builder.map._socket.sendMessage('dialogevent ' + window.sidebarId + ' ' + object.id);
 		}
 	},
 
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index b346eb3f2..1c1c88eae 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -263,6 +263,8 @@ L.Control.LokDialog = L.Control.extend({
 			} else if (e.winType === 'deck') {
 				if (!window.mode.isMobile()) {
 					this._launchSidebar(e.id, width, height);
+				} else {
+					window.sidebarId = e.id;
 				}
 			} else if (e.winType === 'child') {
 				var parentId = parseInt(e.parentId);
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 9e30fe65b..996273218 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -427,7 +427,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
              tokens[0] != "removesession" &&
              tokens[0] != "renamefile" &&
              tokens[0] != "resizewindow" &&
-             tokens[0] != "removetextcontext")
+             tokens[0] != "removetextcontext" &&
+             tokens[0] != "dialogevent")
     {
         LOG_ERR("Session [" << getId() << "] got unknown command [" << tokens[0] << "].");
         sendTextFrame("error: cmd=" + tokens[0] + " kind=unknown");
@@ -696,6 +697,10 @@ bool ClientSession::_handleInput(const char *buffer, int length)
         docBroker->saveAsToStorage(getId(), "", wopiFilename, true);
         return true;
     }
+    else if (tokens[0] == "dialogevent")
+    {
+        return forwardToChild(firstLine, docBroker);
+    }
     else
     {
         if (tokens[0] == "key")


More information about the Libreoffice-commits mailing list