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 +++++ 7 files changed, 98 insertions(+), 2 deletions(-)
New commits: commit 9408633f9c82c64fc57dd29a9c8f36f6b84b35c2 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Tue Sep 11 19:30:55 2018 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Fri Oct 18 22:27:53 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 <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit 66930b7232c366968099d5e98ffa574425a52f04) Reviewed-on: https://gerrit.libreoffice.org/80574 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h index 850e544c6..4f9d668c4 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -564,6 +564,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 4a2d0e642..5bec45b48 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); @@ -1791,6 +1795,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 f40110b15..ed272f225 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -262,6 +262,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 c26c804a7..4014a3e58 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -163,6 +163,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" && @@ -320,6 +321,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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits