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

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 2 16:34:32 UTC 2019


 bundled/include/LibreOfficeKit/LibreOfficeKit.h   |    4 +++
 bundled/include/LibreOfficeKit/LibreOfficeKit.hxx |   10 +++++++++
 kit/ChildSession.cpp                              |   24 +++++++++++++++++++++-
 kit/ChildSession.hpp                              |    1 
 loleaflet/src/control/Control.JSDialogBuilder.js  |    4 +++
 loleaflet/src/layer/tile/TileLayer.js             |    4 +--
 wsd/ClientSession.cpp                             |   17 ++++++++++++++-
 7 files changed, 60 insertions(+), 4 deletions(-)

New commits:
commit 836ce7d636e8a2d0fec1e9c9801c3125df1c5d65
Author:     Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Wed Nov 27 22:56:50 2019 +0100
Commit:     Marco Cecchetti <marco.cecchetti at collabora.com>
CommitDate: Mon Dec 2 17:34:13 2019 +0100

    formula bar: function complete
    
    lok clients can request to complete a function name partially typed in
    the formula input box.
    
    Change-Id: If8e4485c5ed9f91a594dfcec04e0c0b10becdcd0
    Reviewed-on: https://gerrit.libreoffice.org/83985
    Reviewed-by: Marco Cecchetti <marco.cecchetti at collabora.com>
    Tested-by: Marco Cecchetti <marco.cecchetti at collabora.com>

diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index a486886c1..4c9e6c66b 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -436,6 +436,10 @@ struct _LibreOfficeKitDocumentClass
                                 const double dpiscale,
                                 int viewId);
 
+    /// @see lok::Document::completeFunction
+    void (*completeFunction) (LibreOfficeKitDocument* pThis,
+                              int nIndex);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
index ae17e4e71..d50ef4823 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -757,6 +757,16 @@ public:
         mpDoc->pClass->removeTextContext(mpDoc, nWindowId, nBefore, nAfter);
     }
 
+    /**
+     * Select the Calc function to be pasted into the formula input box
+     *
+     * @param nIndex is the index of the selected function
+     */
+    void completeFunction(int nIndex)
+    {
+        mpDoc->pClass->completeFunction(mpDoc, nIndex);
+    }
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index d07125a5c..7e8c1f70c 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -296,7 +296,8 @@ bool ChildSession::_handleInput(const char *buffer, int length)
                tokens[0] == "exportsignanduploaddocument" ||
                tokens[0] == "rendershapeselection" ||
                tokens[0] == "removetextcontext" ||
-               tokens[0] == "dialogevent");
+               tokens[0] == "dialogevent" ||
+               tokens[0] == "completefunction");
 
         if (tokens[0] == "clientzoom")
         {
@@ -432,6 +433,10 @@ bool ChildSession::_handleInput(const char *buffer, int length)
         {
             return dialogEvent(buffer, length, tokens);
         }
+        else if (tokens[0] == "completefunction")
+        {
+            return completeFunction(buffer, length, tokens);
+        }
         else
         {
             assert(false && "Unknown command token.");
@@ -1405,6 +1410,23 @@ bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const std
     return true;
 }
 
+bool ChildSession::completeFunction(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
+{
+    int index;
+
+    if (tokens.size() != 2 ||
+        !getTokenInteger(tokens[1], "index", index))
+    {
+        sendTextFrame("error: cmd=completefunction kind=syntax");
+        return false;
+    }
+
+    getLOKitDocument()->setView(_viewId);
+
+    getLOKitDocument()->completeFunction(index);
+    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 88e445671..8404bcddc 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -262,6 +262,7 @@ private:
     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 completeFunction(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 4a8bd352b..b7e3bfa9e 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -320,11 +320,15 @@ L.Control.JSDialogBuilder = L.Control.extend({
 
 		$(contentDiv).hide();
 		if (builder.wizard) {
+			var that = this;
 			$(rightDiv).click(function() {
 				builder.wizard.goLevelDown(contentDiv);
 				if (contentNode.onshow)
 					contentNode.onshow();
 			});
+			$(leftDiv).click(function() {
+				that.map._socket.sendMessage('completefunction index=' + data.index);
+			});
 		} else {
 			console.debug('Builder used outside of mobile wizard: please implement the click handler');
 		}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index a84bed916..d2bee6cf1 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -751,7 +751,6 @@ L.TileLayer = L.GridLayer.extend({
 	},
 
 	_onCalcFunctionListMsg: function (textMsg) {
-		console.log('_onCalcFunctionList: textMsg: ' + textMsg);
 		var funcList = JSON.parse(textMsg);
 		this._closeMobileWizard();
 
@@ -764,13 +763,14 @@ L.TileLayer = L.GridLayer.extend({
 		};
 
 		var entries = data.children;
-		for (var idx in funcList) {
+		for (var idx = 0; idx < funcList.length; ++idx) {
 			var func =  funcList[idx];
 			var name = func.signature.split('(')[0];
 			var entry = {
 				id: '',
 				type: 'calcfuncpanel',
 				text: name,
+				index: idx,
 				enabled: true,
 				children: []
 			}
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 51ec92ef5..43bc0ecbb 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -427,7 +427,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
              tokens[0] != "renamefile" &&
              tokens[0] != "resizewindow" &&
              tokens[0] != "removetextcontext" &&
-             tokens[0] != "dialogevent")
+             tokens[0] != "dialogevent" &&
+             tokens[0] != "completefunction")
     {
         LOG_ERR("Session [" << getId() << "] got unknown command [" << tokens[0] << "].");
         sendTextFrame("error: cmd=" + tokens[0] + " kind=unknown");
@@ -705,6 +706,20 @@ bool ClientSession::_handleInput(const char *buffer, int length)
     {
         return forwardToChild(firstLine, docBroker);
     }
+    else if (tokens[0] == "completefunction")
+    {
+        int temp;
+        if (tokens.size() != 2 ||
+            !getTokenInteger(tokens[1], "index", temp))
+        {
+            LOG_WRN("Invalid syntax for '" << tokens[0] << "' message: [" << firstLine << "].");
+            return true;
+        }
+        else
+        {
+            return forwardToChild(std::string(buffer, length), docBroker);
+        }
+    }
     else
     {
         if (tokens[0] == "key")


More information about the Libreoffice-commits mailing list