[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - kit/ChildSession.cpp kit/ChildSession.hpp kit/Kit.cpp loleaflet/css loleaflet/src test/WhiteBoxTests.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Apr 15 03:02:32 UTC 2019
kit/ChildSession.cpp | 9 +++++++--
kit/ChildSession.hpp | 3 +++
kit/Kit.cpp | 12 ++++++++++--
loleaflet/css/partsPreviewControl.css | 13 +++++++++++--
loleaflet/src/control/Control.PartsPreview.js | 11 ++++++++---
loleaflet/src/control/Parts.js | 23 +++++++++++++++++------
loleaflet/src/core/Socket.js | 8 ++++----
loleaflet/src/layer/tile/ImpressTileLayer.js | 2 ++
test/WhiteBoxTests.cpp | 5 +++++
9 files changed, 67 insertions(+), 19 deletions(-)
New commits:
commit cee3fb4d6e0e1b0fbeaebf7cfbad76743ac958c8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Sep 17 06:31:36 2018 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Mon Apr 15 05:02:11 2019 +0200
wsd: leaflet: track multi-selection
Change-Id: I17c092e950fb4d7a0cb4129c537d60a8e5edd06a
Reviewed-on: https://gerrit.libreoffice.org/69636
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index ea39697bb..1e3e00413 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1847,6 +1847,11 @@ bool ChildSession::selectClientPart(const char* /*buffer*/, int /*length*/, cons
if (getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT && nPart != getLOKitDocument()->getPart())
{
getLOKitDocument()->selectPart(nPart, nSelect);
+
+ // Notify the client of the selection update.
+ const std::string status = LOKitHelper::documentStatus(getLOKitDocument()->get());
+ if (!status.empty())
+ return sendTextFrame("statusupdate: " + status);
}
else
{
@@ -1874,10 +1879,10 @@ bool ChildSession::moveSelectedClientParts(const char* /*buffer*/, int /*length*
{
getLOKitDocument()->moveSelectedParts(nPosition, false); // Move, don't duplicate.
- // Get the status to recreate the previews and correctly order parts.
+ // Get the status to notify clients of the reordering and selection change.
const std::string status = LOKitHelper::documentStatus(getLOKitDocument()->get());
if (!status.empty())
- return sendTextFrame("statusupdate: " + status);
+ return _docManager.notifyAll("statusupdate: " + status);
}
else
{
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 2cddff005..4e5f75297 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -58,6 +58,9 @@ public:
/// Access to the office instance.
virtual std::shared_ptr<lok::Office> getLOKit() = 0;
+ /// Send msg to all active sessions.
+ virtual bool notifyAll(const std::string& msg) = 0;
+
/// Send updated view info to all active sessions.
virtual void notifyViewInfo() = 0;
virtual void updateEditorSpeeds(int id, int speed) = 0;
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 019a061cb..76e41b4b3 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1491,6 +1491,15 @@ private:
return _editorId;
}
+ /// Notify all views with the given message
+ bool notifyAll(const std::string& msg) override
+ {
+ Util::assertIsLocked(_documentMutex);
+
+ // Broadcast updated viewinfo to all clients.
+ return sendTextFrame("client-all " + msg);
+ }
+
/// Notify all views of viewId and their associated usernames
void notifyViewInfo() override
{
@@ -1540,10 +1549,9 @@ private:
oss.seekp(-1, std::ios_base::cur); // Remove last comma.
oss << "]";
- const std::string msg = oss.str();
// Broadcast updated viewinfo to all clients.
- sendTextFrame("client-all " + msg);
+ notifyAll(oss.str());
}
void updateEditorSpeeds(int id, int speed) override
diff --git a/loleaflet/css/partsPreviewControl.css b/loleaflet/css/partsPreviewControl.css
index 66e47c9bb..39bba0121 100644
--- a/loleaflet/css/partsPreviewControl.css
+++ b/loleaflet/css/partsPreviewControl.css
@@ -27,10 +27,19 @@
border: 2px solid #dfdfdf;
}
-.preview-img-selected {
- border-color: #000000;
+/* The current part the user is on. */
+.preview-img-currentpart {
+ border-color: #000000;
+ border-style: solid;
}
+/* One of (potentially many) selected parts, but not the current. */
+.preview-img-selectedpart {
+ border-color: #000000;
+ border-style: dotted;
+}
+
+/* Highlight where a slide can be dropped when reordering by drag-and-drop. */
.preview-img-dropsite {
border-bottom: 2px solid red;
}
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index 78834a6d8..23ef831d2 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -26,6 +26,7 @@ L.Control.PartsPreview = L.Control.extend({
_updateDisabled: function (e) {
var parts = e.parts;
var selectedPart = e.selectedPart;
+ var selectedParts = e.selectedParts;
var docType = e.docType;
if (docType === 'text') {
return;
@@ -85,7 +86,7 @@ L.Control.PartsPreview = L.Control.extend({
for (var i = 0; i < parts; i++) {
this._previewTiles.push(this._createPreview(i, e.partNames[i], bottomBound));
}
- L.DomUtil.addClass(this._previewTiles[selectedPart], 'preview-img-selected');
+ L.DomUtil.addClass(this._previewTiles[selectedPart], 'preview-img-currentpart');
this._previewInitialized = true;
}
else
@@ -96,9 +97,13 @@ L.Control.PartsPreview = L.Control.extend({
// change the border style of the selected preview.
for (var j = 0; j < parts; j++) {
- L.DomUtil.removeClass(this._previewTiles[j], 'preview-img-selected');
+ L.DomUtil.removeClass(this._previewTiles[j], 'preview-img-currentpart');
+ L.DomUtil.removeClass(this._previewTiles[j], 'preview-img-selectedpart');
+ if (j === selectedPart)
+ L.DomUtil.addClass(this._previewTiles[j], 'preview-img-currentpart');
+ else if (selectedParts.indexOf(j) >= 0)
+ L.DomUtil.addClass(this._previewTiles[j], 'preview-img-selectedpart');
}
- L.DomUtil.addClass(this._previewTiles[selectedPart], 'preview-img-selected');
}
}
},
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 24e57ba55..95e5bc2a0 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -6,6 +6,7 @@ L.Map.include({
setPart: function (part, external, calledFromSetPartHandler) {
var docLayer = this._docLayer;
docLayer._prevSelectedPart = docLayer._selectedPart;
+ docLayer._selectedParts = [];
if (part === 'prev') {
if (docLayer._selectedPart > 0) {
docLayer._selectedPart -= 1;
@@ -22,12 +23,17 @@ L.Map.include({
else {
return;
}
+
+ docLayer._selectedParts.push(docLayer._selectedPart);
+
if (docLayer.isCursorVisible()) {
// a click outside the slide to clear any selection
this._socket.sendMessage('resetselection');
}
+
this.fire('updateparts', {
selectedPart: docLayer._selectedPart,
+ selectedParts: docLayer._selectedParts,
parts: docLayer._parts,
docType: docLayer._docType
});
@@ -57,16 +63,21 @@ 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) {
- //TODO: Update/track selected parts.
+ //TODO: Update/track selected parts(?).
var docLayer = this._docLayer;
- if (typeof (part) === 'number' && part >= 0 && part < docLayer._parts) {
- var selectedPart = part;
+ var index = docLayer._selectedParts.indexOf(part);
+ if (index >= 0 && how != 1) {
+ // Remove (i.e. deselect)
+ docLayer._selectedParts.splice(index, 1);
}
- else {
- return;
+ else if (how != 0) {
+ // Add (i.e. select)
+ docLayer._selectedParts.push(part);
}
+
this.fire('updateparts', {
selectedPart: docLayer._selectedPart,
+ selectedParts: docLayer._selectedParts,
parts: docLayer._parts,
docType: docLayer._docType
});
@@ -74,7 +85,7 @@ L.Map.include({
// 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);
+ this._socket.sendMessage('selectclientpart part=' + part + ' how=' + how);
}
},
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 4e3ee7547..db0c1e6bf 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -997,10 +997,10 @@ L.Socket = L.Class.extend({
});
}
else if (tokens[i].startsWith('selectedparts=')) {
- var selectedparts = tokens[i].substring(14).split(',');
- command.selectedparts = [];
- selectedparts.forEach(function (item) {
- command.selectedparts.push(parseInt(item));
+ var selectedParts = tokens[i].substring(14).split(',');
+ command.selectedParts = [];
+ selectedParts.forEach(function (item) {
+ command.selectedParts.push(parseInt(item));
});
}
}
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js
index 5240e3b89..b19fdd0c0 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -476,6 +476,7 @@ L.ImpressTileLayer = L.TileLayer.extend({
this._parts = command.parts;
this._viewId = parseInt(command.viewid);
this._selectedPart = command.selectedPart;
+ this._selectedParts = command.selectedParts || [command.selectedPart];
this._resetPreFetching(true);
this._update();
if (this._preFetchPart !== this._selectedPart) {
@@ -487,6 +488,7 @@ L.ImpressTileLayer = L.TileLayer.extend({
this._partHashes = partMatch.slice(partMatch.length - this._parts);
this._map.fire('updateparts', {
selectedPart: this._selectedPart,
+ selectedParts: this._selectedParts,
parts: this._parts,
docType: this._docType,
partNames: this._partHashes
diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp
index 801402e87..58ded5276 100644
--- a/test/WhiteBoxTests.cpp
+++ b/test/WhiteBoxTests.cpp
@@ -521,6 +521,11 @@ public:
return nullptr;
}
+ bool notifyAll(const std::string&) override
+ {
+ return true;
+ }
+
void notifyViewInfo() override
{
}
More information about the Libreoffice-commits
mailing list