[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - 2 commits - kit/ChildSession.cpp kit/ChildSession.hpp kit/Kit.cpp loleaflet/css loleaflet/src test/WhiteBoxTests.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 18 20:29:49 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 | 27 +++++++++++++++++++-------
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, 79 insertions(+), 23 deletions(-)
New commits:
commit 9f6d41dced553f80f95c0e26e643aaa338e86459
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Fri Nov 23 01:36:17 2018 -0500
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Oct 18 22:29:46 2019 +0200
leaflet: support reordering slides to first position
Change-Id: I23fba5d7e10d861ec482974cf355c9fb1ae13a64
Reviewed-on: https://gerrit.libreoffice.org/69637
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
(cherry picked from commit 685f10a287c23e22ad77468f10cfc0f2dac5955e)
Reviewed-on: https://gerrit.libreoffice.org/80580
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/control/Control.PartsPreview.js b/loleaflet/src/control/Control.PartsPreview.js
index 23ef831d2..1492f03ab 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -66,7 +66,7 @@ L.Control.PartsPreview = L.Control.extend({
this._map.on('click', function() {
this.partsFocused = false;
}, this);
-
+
this._map.on('keydown', function(e) {
if (this.partsFocused === true) {
switch (e.originalEvent.keyCode) {
@@ -82,6 +82,12 @@ L.Control.PartsPreview = L.Control.extend({
this._scrollContainer = $('#slide-sorter .mCSB_container').get(0);
+ // Add a special frame just as a drop-site for reordering.
+ var frame = L.DomUtil.create('div', 'preview-frame', this._scrollContainer);
+ this._addDnDHandlers(frame);
+ frame.setAttribute('draggable', false);
+ L.DomUtil.setStyle(frame, 'height', '12px');
+
// Create the preview parts
for (var i = 0; i < parts; i++) {
this._previewTiles.push(this._createPreview(i, e.partNames[i], bottomBound));
@@ -189,12 +195,12 @@ L.Control.PartsPreview = L.Control.extend({
$('#slide-sorter').mCustomScrollbar('scrollTo', nodePos-(sliderHeight-nodeHeight-nodeHeight/2));
}, 50);
}
- }
+ }
return;
}
var part = $('#slide-sorter .mCSB_container .preview-frame').index(e.target.parentNode);
if (part !== null) {
- var partId = parseInt(part);
+ var partId = parseInt(part) - 1; // The first part is just a drop-site for reordering.
if (e.ctrlKey) {
this._map.selectPart(partId, 2, false); // Toggle selection on ctrl+click.
@@ -381,7 +387,9 @@ L.Control.PartsPreview = L.Control.extend({
var part = $('#slide-sorter .mCSB_container .preview-frame').index(e.target.parentNode);
if (part !== null) {
- var partId = parseInt(part);
+ var partId = parseInt(part) - 1; // First frame is a drop-site for reordering.
+ if (partId < 0)
+ partId = -1; // First item is -1.
this.partsPreview._map._socket.sendMessage('moveselectedclientparts position=' + partId);
}
commit 02570ef535fd9d9c77144b3682ecdd9366c2d064
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Sep 17 06:31:36 2018 -0400
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Oct 18 22:29:31 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>
(cherry picked from commit cee3fb4d6e0e1b0fbeaebf7cfbad76743ac958c8)
Reviewed-on: https://gerrit.libreoffice.org/80579
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 1e4a81953..fdccb6ae4 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1818,6 +1818,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
{
@@ -1845,10 +1850,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 2f33e8c63..f6bcf60a7 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 7bfe2dd96..ad0df946e 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1510,6 +1510,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
{
@@ -1559,10 +1568,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 19a23b1c2..ffe478d81 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -1001,10 +1001,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 3552af21d..51297c17b 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