[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-3' - kit/ChildSession.cpp kit/ChildSession.hpp loleaflet/src wsd/ClientSession.cpp
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sun May 10 15:17:40 UTC 2020
kit/ChildSession.cpp | 24 +++++++++++++++++++++++-
kit/ChildSession.hpp | 1 +
loleaflet/src/layer/FormFieldButtonLayer.js | 22 ++++++++++++++++++----
loleaflet/src/layer/tile/TileLayer.js | 1 -
wsd/ClientSession.cpp | 7 ++++++-
5 files changed, 48 insertions(+), 7 deletions(-)
New commits:
commit a41ca9fc3d18ea4445c9de1183861a7d5e2958b9
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed May 6 13:59:03 2020 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun May 10 17:17:22 2020 +0200
MSForms: send item selection event to core.
Change-Id: I10fceb66a4f8cd777c43411ddace3456a315b5a2
(cherry picked from commit 75dc61da7e6305a2f6b6e8e9a45e016ae1fc2e7d)
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93887
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index e70cfde2e..ba8bdf8ee 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -301,7 +301,8 @@ bool ChildSession::_handleInput(const char *buffer, int length)
tokens.equals(0, "rendershapeselection") ||
tokens.equals(0, "removetextcontext") ||
tokens.equals(0, "dialogevent") ||
- tokens.equals(0, "completefunction"));
+ tokens.equals(0, "completefunction")||
+ tokens.equals(0, "formfieldevent"));
if (tokens.equals(0, "clientzoom"))
{
@@ -446,6 +447,10 @@ bool ChildSession::_handleInput(const char *buffer, int length)
{
return completeFunction(buffer, length, tokens);
}
+ else if (tokens.equals(0, "formfieldevent"))
+ {
+ return formFieldEvent(buffer, length, tokens);
+ }
else
{
assert(false && "Unknown command token.");
@@ -1426,6 +1431,23 @@ bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const Str
return true;
}
+bool ChildSession::formFieldEvent(const char* buffer, int length, const StringVector& /*tokens*/)
+{
+ std::string sFirstLine = getFirstLine(buffer, length);
+ std::string sArguments = sFirstLine.substr(std::string("formfieldevent ").size());
+
+ if (sArguments.empty())
+ {
+ sendTextFrameAndLogError("error: cmd=formfieldevent kind=syntax");
+ return false;
+ }
+
+ getLOKitDocument()->setView(_viewId);
+ getLOKitDocument()->sendFormFieldEvent(sArguments.c_str());
+
+ return true;
+}
+
bool ChildSession::completeFunction(const char* /*buffer*/, int /*length*/, const StringVector& tokens)
{
std::string functionName;
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index fad3061aa..4c4dbb2ec 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -291,6 +291,7 @@ private:
bool removeTextContext(const char* /*buffer*/, int /*length*/, const StringVector& tokens);
void rememberEventsForInactiveUser(const int type, const std::string& payload);
+ bool formFieldEvent(const char* buffer, int length, const StringVector& tokens);
virtual void disconnect() override;
virtual bool _handleInput(const char* buffer, int length) override;
diff --git a/loleaflet/src/layer/FormFieldButtonLayer.js b/loleaflet/src/layer/FormFieldButtonLayer.js
index 4cd837ffe..33c6b561c 100644
--- a/loleaflet/src/layer/FormFieldButtonLayer.js
+++ b/loleaflet/src/layer/FormFieldButtonLayer.js
@@ -15,6 +15,7 @@ L.FormFieldButton = L.Layer.extend({
},
onAdd: function (map) {
+ this.map = map;
this._clearButton();
this._buildFormButton(map);
},
@@ -102,7 +103,10 @@ L.FormFieldButton = L.Layer.extend({
for (var i = 0; i < itemList.length; ++i) {
var option = L.DomUtil.create('div', 'drop-down-field-list-item', dropDownList);
option.innerHTML = itemList[i];
+
option.addEventListener('click', this._onListItemSelect);
+ option.map = this.map;
+
// Stop propagation to the main document
option.addEventListener('mouseup', function(event) {event.stopPropagation();});
option.addEventListener('mousedown', function(event) {event.stopPropagation();});
@@ -116,17 +120,27 @@ L.FormFieldButton = L.Layer.extend({
this._clearButton();
},
- _onClickDropDown: function() {
+ _onClickDropDown: function(event) {
$('.drop-down-field-list').show();
+ event.stopPropagation();
},
_onListItemSelect: function(event) {
+ $('.drop-down-field-list').hide();
$('.drop-down-field-list-item.selected').removeClass('selected');
event.target.classList.add('selected');
- // TODO: send back
- $('.drop-down-field-list').hide();
+
event.stopPropagation();
- console.warn(event.target.textContent);
+
+ // Find item index
+ var index = $(event.target).index();
+
+ var message = 'formfieldevent {\"type\": \"drop-down\",' +
+ '\"cmd\": \"selected\",' +
+ '\"data\":\"' + index.toString() + '\"}';
+
+ // Apply selection in the document.
+ this.map._socket.sendMessage(message);
},
_clearButton: function() {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6deb6808f..ded1b572c 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -728,7 +728,6 @@ L.TileLayer = L.GridLayer.extend({
}
else if (textMsg.startsWith('formfieldbutton:')) {
this._onFormFieldButtonMsg(textMsg);
- console.error(textMsg);
}
},
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 64ae23deb..e985b2a7a 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -440,7 +440,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
tokens[0] != "resizewindow" &&
tokens[0] != "removetextcontext" &&
tokens[0] != "dialogevent" &&
- tokens[0] != "completefunction")
+ tokens[0] != "completefunction" &&
+ tokens[0] != "formfieldevent")
{
LOG_ERR("Session [" << getId() << "] got unknown command [" << tokens[0] << "].");
sendTextFrameAndLogError("error: cmd=" + tokens[0] + " kind=unknown");
@@ -722,6 +723,10 @@ bool ClientSession::_handleInput(const char *buffer, int length)
{
return forwardToChild(std::string(buffer, length), docBroker);
}
+ else if (tokens.equals(0, "formfieldevent"))
+ {
+ return forwardToChild(firstLine, docBroker);
+ }
else
{
if (tokens.equals(0, "key"))
More information about the Libreoffice-commits
mailing list