wsd: leaflet: track multi-selection
Change-Id: I17c092e950fb4d7a0cb4129c537d60a8e5edd06a Reviewed-on: https://gerrit.libreoffice.org/69636 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/71100
This commit is contained in:
parent
2eab5cea76
commit
d45ecd586c
9 changed files with 65 additions and 19 deletions
|
@ -1959,6 +1959,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
|
||||
{
|
||||
|
@ -1984,10 +1989,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
|
||||
{
|
||||
|
|
|
@ -59,6 +59,9 @@ public:
|
|||
/// Access to the document instance.
|
||||
virtual std::shared_ptr<lok::Document> getLOKitDocument() = 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;
|
||||
|
|
10
kit/Kit.cpp
10
kit/Kit.cpp
|
@ -1594,6 +1594,13 @@ private:
|
|||
return _editorId;
|
||||
}
|
||||
|
||||
/// Notify all views with the given message
|
||||
bool notifyAll(const std::string& msg) override
|
||||
{
|
||||
// Broadcast updated viewinfo to all clients.
|
||||
return sendTextFrame("client-all " + msg);
|
||||
}
|
||||
|
||||
/// Notify all views of viewId and their associated usernames
|
||||
void notifyViewInfo() override
|
||||
{
|
||||
|
@ -1641,10 +1648,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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,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;
|
||||
|
@ -65,7 +66,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
|
||||
|
@ -76,9 +77,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');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -977,10 +977,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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -633,6 +633,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) {
|
||||
|
@ -644,6 +645,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
|
||||
|
|
|
@ -520,6 +520,11 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool notifyAll(const std::string&) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void notifyViewInfo() override
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue