[Libreoffice-commits] online.git: loleaflet/dist loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Mon Oct 10 12:34:24 UTC 2016
loleaflet/dist/toolbar/toolbar.js | 2 +-
loleaflet/src/core/LOUtil.js | 20 ++++++++++++++++++++
loleaflet/src/map/Map.js | 6 +++++-
3 files changed, 26 insertions(+), 2 deletions(-)
New commits:
commit a01d2fc91dfd6ea4ce365d30641fa251d45c8b04
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Oct 10 18:00:38 2016 +0530
loleaflet: Restore old coloring algorithm for non-text documents
.uno:TrackedChangeAuthors doesn't give correct colors for
documents other than writer, lets use our old algorithm for color
assignment for these documents.
Change-Id: If865788154a80da2637aad84183a0e947bb4b7e8
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 9003281..11281f5 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1346,7 +1346,7 @@ map.on('addview', function(e) {
}, 3000);
var username = e.username;
- var color = L.LOUtil.rgbToHex(e.color);
+ var color = L.LOUtil.rgbToHex(map.getViewColor(e.viewId));
if (e.viewId === map._docLayer._viewId) {
username = _('You');
color = '#000';
diff --git a/loleaflet/src/core/LOUtil.js b/loleaflet/src/core/LOUtil.js
index 4ebb9d1..ed6b718 100644
--- a/loleaflet/src/core/LOUtil.js
+++ b/loleaflet/src/core/LOUtil.js
@@ -3,6 +3,21 @@
*/
L.LOUtil = {
+ // Based on core.git's colordata.hxx: COL_AUTHOR1_DARK...COL_AUTHOR9_DARK
+ // consisting of arrays of RGB values
+ // Maybe move the color logic to separate file when it becomes complex
+ darkColors: [
+ [198, 146, 0],
+ [6, 70, 162],
+ [87, 157, 28],
+ [105, 43, 157],
+ [197, 0, 11],
+ [0, 128, 128],
+ [140, 132, 0],
+ [53, 85, 107],
+ [209, 118, 0]
+ ],
+
startSpinner: function (spinnerCanvas, spinnerSpeed) {
var spinnerInterval;
spinnerCanvas.width = 50;
@@ -28,6 +43,11 @@ L.LOUtil = {
return spinnerInterval;
},
+ getViewIdHexColor: function(viewId) {
+ var color = this.darkColors[(viewId + 1) % this.darkColors.length];
+ return (color[2] | (color[1] << 8) | (color[0] << 16));
+ },
+
rgbToHex: function(color) {
return '#' + ('000000' + color.toString(16)).slice(-6);
}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index c6d2f71..70fc83b 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -130,7 +130,7 @@ L.Map = L.Evented.extend({
addView: function(viewid, username, color) {
this._viewInfo[viewid] = {'username': username, 'color': color};
- this.fire('addview', {viewId: viewid, username: username, color: color});
+ this.fire('addview', {viewId: viewid, username: username});
},
removeView: function(viewid) {
@@ -144,6 +144,10 @@ L.Map = L.Evented.extend({
},
getViewColor: function(viewid) {
+ if (this._docLayer._docType !== 'text') {
+ return L.LOUtil.getViewIdHexColor(viewid);
+ }
+
return this._viewInfo[viewid].color;
},
More information about the Libreoffice-commits
mailing list