loleaflet/src/control/Ruler.js         |   47 ++++++++++++++++++++++-----------
 loleaflet/src/map/Map.js               |    3 +-
 loleaflet/src/map/handler/Map.Mouse.js |    2 -
 3 files changed, 35 insertions(+), 17 deletions(-)

New commits:
commit 415bb2a9bf8d22c94b8bfd86daadeb390dbc89b6
Author: Aditya Dewan <[email protected]>
Date:   Fri Dec 8 01:49:52 2017 +0530

    no text selection when ruler interactions are happening
    
    Change-Id: Id3628f407067506ddf6ce2e2dd2587bd2e35ddbc
    Reviewed-on: https://gerrit.libreoffice.org/46040
    Reviewed-by: pranavk <[email protected]>
    Tested-by: pranavk <[email protected]>
    (cherry picked from commit 3d23119399b7e673f2c1d52b1ad1e9ad7e8eff77)
    Reviewed-on: https://gerrit.libreoffice.org/46102

diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index 68ccbfd0..d13e3cbd 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -162,6 +162,7 @@ L.Control.Ruler = L.Control.extend({
        },
 
        _initiateDrag: function(e) {
+               this._map.rulerActive = true;
 
                var dragableElem = e.srcElement || e.target;
                L.DomEvent.on(this._rFace, 'mousemove', this._moveMargin, this);
@@ -200,6 +201,8 @@ L.Control.Ruler = L.Control.extend({
 
 
        _endDrag: function(e) {
+               this._map.rulerActive = false;
+
                var posChange = e.originalEvent.clientX - this._initialposition;
                var unoObj = {}, marginType, fact;
 
diff --git a/loleaflet/src/map/handler/Map.Mouse.js 
b/loleaflet/src/map/handler/Map.Mouse.js
index 78229005..f196adbe 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -38,7 +38,7 @@ L.Map.Mouse = L.Handler.extend({
 
        _onMouseEvent: function (e) {
                var docLayer = this._map._docLayer;
-               if (!docLayer || (this._map.slideShow && 
this._map.slideShow.fullscreen)) {
+               if (!docLayer || (this._map.slideShow && 
this._map.slideShow.fullscreen) || this._map.rulerActive) {
                        return;
                }
                if (docLayer._graphicMarker) {
commit 09e4e7fd3f569dc8f063eabaa47276b66752b5fb
Author: Aditya Dewan <[email protected]>
Date:   Wed Dec 6 20:05:44 2017 +0530

    Disable interactive ruler for readonly docs
    
    Change-Id: I7982387d5dd913dd5e4ca5ff5d188ad0eed00fa6
    Reviewed-on: https://gerrit.libreoffice.org/45962
    Reviewed-by: pranavk <[email protected]>
    Tested-by: pranavk <[email protected]>
    (cherry picked from commit a508d5b490fa246174ed9754cb93ecaef3880452)
    Reviewed-on: https://gerrit.libreoffice.org/46101

diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index 22453cee..68ccbfd0 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -24,6 +24,7 @@ L.Control.Ruler = L.Control.extend({
                map.on('rulerupdate', this._updateOptions, this);
                map.on('docsize', this._updatePaintTimer, this);
                map.on('scrolloffset resize', this._fixOffset, this);
+               map.on('updatepermission', this._changeInteractions, this);
                this._map = map;
 
                return this._initLayout();
@@ -34,6 +35,22 @@ L.Control.Ruler = L.Control.extend({
                this.options.timer = setTimeout(L.bind(this._updateBreakPoints, 
this), 300);
        },
 
+       _changeInteractions: function(e) {
+               if (e.perm === 'edit') {
+                       this._lMarginDrag.style.cursor = 'e-resize';
+                       this._rMarginDrag.style.cursor = 'w-resize';
+
+                       L.DomEvent.on(this._rMarginDrag, 'mousedown', 
this._initiateDrag, this);
+                       L.DomEvent.on(this._lMarginDrag, 'mousedown', 
this._initiateDrag, this);
+               }
+               else {
+                       this._lMarginDrag.style.cursor = 'default';
+                       this._rMarginDrag.style.cursor = 'default';
+
+                       L.DomEvent.off(this._rMarginDrag, 'mousedown', 
this._initiateDrag, this);
+                       L.DomEvent.off(this._lMarginDrag, 'mousedown', 
this._initiateDrag, this);
+               }
+       },
 
        _initLayout: function() {
                this._rWrapper = L.DomUtil.create('div', 'loleaflet-ruler 
leaflet-bar leaflet-control leaflet-control-custom');
@@ -112,28 +129,25 @@ L.Control.Ruler = L.Control.extend({
                        this._lMarginMarker = L.DomUtil.create('div', 
classMargin + ' ' + leftComp, this._rFace);
                        this._rMarginMarker =  L.DomUtil.create('div', 
classMargin + ' ' + rightComp, this._rFace);
 
-                       if (this.options.interactive) {
-                               this._lMarginDrag = L.DomUtil.create('div', 
classDraggable + ' ' + leftComp, this._rMarginWrapper);
-                               this._lToolTip = L.DomUtil.create('div', 
lToolTip, this._lMarginDrag)
-                               this._rMarginDrag = L.DomUtil.create('div', 
classDraggable + ' ' + rightComp, this._rMarginWrapper);
-                               this._rToolTip = L.DomUtil.create('div', 
rToolTip, this._rMarginDrag)
-                               this._lMarginDrag.style.cursor = 'e-resize';
-                               this._rMarginDrag.style.cursor = 'w-resize';
-                               this._lMarginDrag.title = leftMarginStr;
-                               this._rMarginDrag.title = rightMarginStr;
-                       }
+                       this._lMarginDrag = L.DomUtil.create('div', 
classDraggable + ' ' + leftComp, this._rMarginWrapper);
+                       this._lToolTip = L.DomUtil.create('div', lToolTip, 
this._lMarginDrag)
+                       this._rMarginDrag = L.DomUtil.create('div', 
classDraggable + ' ' + rightComp, this._rMarginWrapper);
+                       this._rToolTip = L.DomUtil.create('div', rToolTip, 
this._rMarginDrag)
+                       this._lMarginDrag.title = leftMarginStr;
+                       this._rMarginDrag.title = rightMarginStr;
                }
 
                this._lMarginMarker.style.width = 
(DraggableConvertRatio*lMargin) + 'px';
                this._rMarginMarker.style.width = 
(DraggableConvertRatio*rMargin) + 'px';
+               this._lMarginDrag.style.width = (DraggableConvertRatio*lMargin) 
+ 'px';
+               this._rMarginDrag.style.width = (DraggableConvertRatio*rMargin) 
+ 'px';
 
                if (this.options.interactive) {
-                       this._lMarginDrag.style.width = 
(DraggableConvertRatio*lMargin) + 'px';
-                       this._rMarginDrag.style.width = 
(DraggableConvertRatio*rMargin) + 'px';
+                       this._changeInteractions({perm:'edit'});
+               }
+               else {
+                       this._changeInteractions({perm:'readonly'});
                }
-
-               L.DomEvent.on(this._rMarginDrag, 'mousedown', 
this._initiateDrag, this);
-               L.DomEvent.on(this._lMarginDrag, 'mousedown', 
this._initiateDrag, this);
        },
 
        _fixOffset: function() {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index f4696cb9..6c5d8f71 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -119,7 +119,8 @@ L.Map = L.Evented.extend({
                                this._fireInitComplete('doclayerinit');
                        }
                        if (this._docLayer._docType == 'text') {
-                               
L.control.ruler({position:'topleft'}).addTo(this);
+                               var interactiveRuler = this._permission === 
'edit' ? true : false;
+                               L.control.ruler({position:'topleft', 
interactive:interactiveRuler}).addTo(this);
                        }
                });
                this.on('updatetoolbarcommandvalues', function(e) {
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to