[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - bundled/include kit/ChildSession.cpp kit/ChildSession.hpp loleaflet/src wsd/ClientSession.cpp wsd/protocol.txt
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Apr 15 00:49:50 UTC 2019
bundled/include/LibreOfficeKit/LibreOfficeKit.h | 3 +
bundled/include/LibreOfficeKit/LibreOfficeKit.hxx | 7 ++++
bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 1
kit/ChildSession.cpp | 32 +++++++++++++++++++
kit/ChildSession.hpp | 1
loleaflet/src/control/Control.PartsPreview.js | 12 ++++++-
loleaflet/src/control/Parts.js | 25 ++++++++++++++
wsd/ClientSession.cpp | 20 +++++++++++
wsd/protocol.txt | 9 +++++
9 files changed, 108 insertions(+), 2 deletions(-)
New commits:
commit 66930b7232c366968099d5e98ffa574425a52f04
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Tue Sep 11 19:30:55 2018 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Mon Apr 15 02:49:31 2019 +0200
wsd: loleaflet: select multiple parts
Primarily support for selecting multiple slides
to edit their properties together.
Change-Id: I96c7ec048668494b5b769677db6874df91cbb42d
Reviewed-on: https://gerrit.libreoffice.org/69631
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index b694dc522..763e5311e 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.h
@@ -372,6 +372,9 @@ struct _LibreOfficeKitDocumentClass
int nY,
int nOffset);
+ /// @see lok::Document::selectPart().
+ void (*selectPart) (LibreOfficeKitDocument* pThis, int nPart, int nSelect);
+
#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 f2163cd1f..36052cd64 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -649,6 +649,13 @@ public:
return mpDoc->pClass->postWindowGestureEvent(mpDoc, nWindowId, pType, nX, nY, nOffset);
}
+ /// Set a part's selection mode.
+ /// nSelect is 0 to deselect, 1 to select, and 2 to toggle.
+ void selectPart(int nPart, int nSelect)
+ {
+ mpDoc->pClass->selectPart(mpDoc, nPart, nSelect);
+ }
+
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 1d55ce858..26fb2ab74 100644
--- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -563,6 +563,7 @@ typedef enum
* "type" tells the type of the window the action is associated with
* - "dialog" - window is a dialog
* - "child" - window is a floating window (combo boxes, etc.)
+ * - "panel" - window is a docked panel (i.e. in the sidebar)
*
* "action" can take following values:
* - "created" - window is created in the backend, client can render it now
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 31e978894..ddf7dee8a 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -223,6 +223,10 @@ bool ChildSession::_handleInput(const char *buffer, int length)
{
return setClientPart(buffer, length, tokens);
}
+ else if (tokens[0] == "selectclientpart")
+ {
+ return selectClientPart(buffer, length, tokens);
+ }
else if (tokens[0] == "setpage")
{
return setPage(buffer, length, tokens);
@@ -1820,6 +1824,34 @@ bool ChildSession::setClientPart(const char* /*buffer*/, int /*length*/, const s
return true;
}
+bool ChildSession::selectClientPart(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
+{
+ int nPart;
+ int nSelect;
+ if (tokens.size() < 3 ||
+ !getTokenInteger(tokens[1], "part", nPart) ||
+ !getTokenInteger(tokens[2], "how", nSelect))
+ {
+ sendTextFrame("error: cmd=selectclientpart kind=invalid");
+ return false;
+ }
+
+ std::unique_lock<std::mutex> lock(_docManager.getDocumentMutex());
+
+ getLOKitDocument()->setView(_viewId);
+
+ if (getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT && nPart != getLOKitDocument()->getPart())
+ {
+ getLOKitDocument()->selectPart(nPart, nSelect);
+ }
+ else
+ {
+ LOG_WRN("ChildSession::selectClientPart[" << getName() << "]: error selecting part on text documents.");
+ }
+
+ return true;
+}
+
bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens)
{
int page;
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 597002336..d37ab14a5 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -263,6 +263,7 @@ private:
bool resetSelection(const char* buffer, int length, const std::vector<std::string>& tokens);
bool saveAs(const char* buffer, int length, const std::vector<std::string>& tokens);
bool setClientPart(const char* buffer, int length, const std::vector<std::string>& tokens);
+ bool selectClientPart(const char* buffer, int length, const std::vector<std::string>& tokens);
bool setPage(const char* buffer, int length, const std::vector<std::string>& tokens);
bool sendWindowCommand(const char* buffer, int length, const std::vector<std::string>& tokens);
bool signDocumentContent(const char* buffer, int length, const std::vector<std::string>& tokens);
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index eae8149d3..dc978f39f 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -188,7 +188,17 @@ L.Control.PartsPreview = L.Control.extend({
}
var part = $('#slide-sorter .mCSB_container .preview-frame').index(e.target.parentNode);
if (part !== null) {
- this._map.setPart(parseInt(part));
+ var partId = parseInt(part);
+
+ if (e.ctrlKey) {
+ this._map.selectPart(partId, 2, false); // Toggle selection on ctrl+click.
+ } else if (e.altKey) {
+ console.log('alt');
+ } else if (e.shiftKey) {
+ console.log('shift');
+ } else {
+ this._map.setPart(partId);
+ }
}
},
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 1b309146c..49a8de3ec 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -1,6 +1,6 @@
/* -*- js-indent-level: 8 -*- */
/*
- * Document parts switching handler
+ * Document parts switching and selecting handler
*/
L.Map.include({
setPart: function (part, external, calledFromSetPartHandler) {
@@ -54,6 +54,29 @@ L.Map.include({
}
},
+ // part is the part index/id
+ // how is 0 to deselect, 1 to select, and 2 to toggle selection
+ selectPart: function (part, how, external) {
+ var docLayer = this._docLayer;
+ if (typeof (part) === 'number' && part >= 0 && part < docLayer._parts) {
+ var selectedPart = part;
+ }
+ else {
+ return;
+ }
+ this.fire('updateparts', {
+ selectedPart: docLayer._selectedPart,
+ parts: docLayer._parts,
+ docType: docLayer._docType
+ });
+
+ // If this wasn't triggered from the server,
+ // then notify the server of the change.
+ if (!external) {
+ this._socket.sendMessage('selectclientpart part=' + selectedPart + ' how=' + how);
+ }
+ },
+
getPreview: function (id, index, maxWidth, maxHeight, options) {
if (!this._docPreviews) {
this._docPreviews = {};
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index efbac7dab..f9b8739f5 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -164,6 +164,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
tokens[0] != "selectgraphic" &&
tokens[0] != "selecttext" &&
tokens[0] != "setclientpart" &&
+ tokens[0] != "selectclientpart" &&
tokens[0] != "setpage" &&
tokens[0] != "status" &&
tokens[0] != "tile" &&
@@ -318,6 +319,25 @@ bool ClientSession::_handleInput(const char *buffer, int length)
}
}
}
+ else if (tokens[0] == "selectclientpart")
+ {
+ if(!_isTextDocument)
+ {
+ int part;
+ int how;
+ if (tokens.size() != 3 ||
+ !getTokenInteger(tokens[1], "part", part) ||
+ !getTokenInteger(tokens[2], "how", how))
+ {
+ sendTextFrame("error: cmd=selectclientpart kind=syntax");
+ return false;
+ }
+ else
+ {
+ return forwardToChild(std::string(buffer, length), docBroker);
+ }
+ }
+ }
else if (tokens[0] == "clientzoom")
{
int tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight;
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index 047cbead5..a4631c912 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -138,6 +138,15 @@ setclientpart part=<partNumber>
Informs the server that the client changed to part <partNumber>.
+selectclientpart part=<partNumber>
+
+ Informs the server that the client changed the selection state of <partNumber>.
+
+setpage page=<pageNumber>
+
+ Valid only for text documents.
+ Informs the server that the client changed to page <pageNumber>.
+
status
styles
More information about the Libreoffice-commits
mailing list