[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-0' - 3 commits - loleaflet/dist loleaflet/src loolwsd/MasterProcessSession.cpp
Pranav Kant
pranavk at collabora.co.uk
Fri Oct 21 10:51:54 UTC 2016
loleaflet/dist/toolbar/toolbar.js | 13 ++++++++-
loleaflet/src/layer/tile/TileLayer.js | 47 +++++++++++++++++++++++++++++++++-
loolwsd/MasterProcessSession.cpp | 7 +++++
3 files changed, 65 insertions(+), 2 deletions(-)
New commits:
commit e9bcd9a25df78b2ce6d24aa03940e358f282e26c
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Oct 21 15:32:38 2016 +0530
Click to jump to user cursor
Change-Id: If46abca58a1b401c1accc30192cb9c163b14005b
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 44ba7b0..54eaf65 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1331,8 +1331,19 @@ map.on('statusindicator', function (e) {
}
});
+function onUseritemClicked(e) {
+ var viewId = parseInt(e.currentTarget.id.replace('user-', ''));
+ if (map._docLayer) {
+ if (map.getDocType() === 'spreadsheet') {
+ map._docLayer.goToCellCursor(viewId);
+ } else if (map.getDocType() === 'text') {
+ map._docLayer.goToCursor(viewId);
+ }
+ }
+}
+
function getUserItem(viewId, userName) {
- var html = '<tr class="useritem" id="user-' + viewId + '">' +
+ var html = '<tr class="useritem" id="user-' + viewId + '" onclick=onUseritemClicked(event)>' +
'<td class="username">' + userName + '</td>' +
'<td class="lock"></td>' +
'</tr>';
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 1f3d7f8..fb0017c 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -910,6 +910,18 @@ L.TileLayer = L.GridLayer.extend({
}
},
+ goToCursor: function() {
+ if (this._isCursorVisible && !this._map.getBounds().contains(this._visibleCursor)) {
+ var cursorPos = this._visibleCursor.getNorthWest();
+ var center = this._map.project(cursorPos);
+ center = center.subtract(this._map.getSize().divideBy(2));
+ center.x = Math.round(center.x < 0 ? 0 : center.x);
+ center.y = Math.round(center.y < 0 ? 0 : center.y);
+
+ this._map.fire('scrollto', {x: center.x, y: center.y});
+ }
+ },
+
// Update dragged graphics selection resize.
_onGraphicEdit: function (e) {
if (!e.handle) { return; }
@@ -1041,6 +1053,39 @@ L.TileLayer = L.GridLayer.extend({
}
},
+ goToCellCursor: function() {
+ // TODO: Lots of common code with onUpdateCellCursor. Factor out
+ var mapBounds = this._map.getBounds();
+ if (this._cellCursor && !this._isEmptyRectangle(this._cellCursor) && !mapBounds.contains(this._cellCursor)) {
+ var scrollX = 0;
+ var scrollY = 0;
+
+ var spacingX = Math.abs(this._cellCursor.getEast() - this._cellCursor.getWest()) / 4.0;
+ var spacingY = Math.abs((this._cellCursor.getSouth() - this._cellCursor.getNorth())) / 4.0;
+ if (this._cellCursor.getWest() < mapBounds.getWest()) {
+ scrollX = this._cellCursor.getWest() - mapBounds.getWest() - spacingX;
+ } else if (this._cellCursor.getEast() > mapBounds.getEast()) {
+ scrollX = this._cellCursor.getEast() - mapBounds.getEast() + spacingX;
+ }
+ if (this._cellCursor.getNorth() > mapBounds.getNorth()) {
+ scrollY = this._cellCursor.getNorth() - mapBounds.getNorth() + spacingY;
+ } else if (this._cellCursor.getSouth() < mapBounds.getSouth()) {
+ scrollY = this._cellCursor.getSouth() - mapBounds.getSouth() - spacingY;
+ }
+
+ if (scrollX !== 0 || scrollY !== 0) {
+ var newCenter = mapBounds.getCenter();
+ newCenter.lng += scrollX;
+ newCenter.lat += scrollY;
+ var center = this._map.project(newCenter);
+ center = center.subtract(this._map.getSize().divideBy(2));
+ center.x = Math.round(center.x < 0 ? 0 : center.x);
+ center.y = Math.round(center.y < 0 ? 0 : center.y);
+ this._map.fire('scrollto', {x: center.x, y: center.y});
+ }
+ }
+ },
+
// Update text selection handlers.
_onUpdateTextSelection: function () {
var startMarker, endMarker;
commit 2a2055e4079be208d0f73d22ed8ef6de52353f76
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Fri Oct 21 14:53:21 2016 +0530
loolwsd: Inform about editlock here too
This was accidentally removed in
0a9a94dacd7b12228fda7ff5690fdeb8c9425ac2 but its needed for new
views to know about their editlock state.
Change-Id: I4b02424ea143c0c5617ff74b0cde3edbc0e908b6
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index f312ed8..19822c2 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -221,6 +221,13 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length)
// Forward the status response to the client.
forwardToPeer(buffer, length);
+
+ // And let clients know if they hold the edit lock.
+ std::string message = "editlock: ";
+ message += std::to_string(peer->isEditLocked());
+ Log::debug("Forwarding [" + message + "] in response to status.");
+ forwardToPeer(message.c_str(), message.size());
+
return true;
}
else if (tokens[0] == "commandvalues:")
commit db18481dd24eacddd7a5168f8c65ee35446c4c17
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Oct 20 15:22:46 2016 +0530
lolefalet: Show cursor for 'view' sessions too
Change-Id: Ib1f234b6405ec7f5758ed636264b381262b2e17f
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 46f4265..1f3d7f8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -893,7 +893,7 @@ L.TileLayer = L.GridLayer.extend({
var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
var cursorPos = this._visibleCursor.getNorthWest();
- if (this._map._permission === 'edit' && this._isCursorVisible && this._isCursorOverlayVisible
+ if (this._map._permission !== 'readonly' && this._isCursorVisible && this._isCursorOverlayVisible
&& !this._isEmptyRectangle(this._visibleCursor)) {
if (this._cursorMarker) {
this._map.removeLayer(this._cursorMarker);
More information about the Libreoffice-commits
mailing list