loleaflet/spec/loleaflet/control/PartsSpec.js |    4 +--
 loleaflet/spec/tilebench/TileBenchSpec.js     |    6 ++--
 loleaflet/src/control/Control.Search.js       |    2 -
 loleaflet/src/control/Parts.js                |   10 ++++----
 loleaflet/src/control/Permission.js           |    4 +--
 loleaflet/src/control/Search.js               |    4 +--
 loleaflet/src/control/Toolbar.js              |   16 ++++++-------
 loleaflet/src/core/Socket.js                  |   14 ++++-------
 loleaflet/src/layer/tile/CalcTileLayer.js     |   12 ++++-----
 loleaflet/src/layer/tile/GridLayer.js         |    4 +--
 loleaflet/src/layer/tile/ImpressTileLayer.js  |    8 +++---
 loleaflet/src/layer/tile/TileLayer.js         |   32 +++++++++++++-------------
 loleaflet/src/layer/tile/WriterTileLayer.js   |    6 ++--
 loleaflet/src/map/Map.js                      |    4 +--
 loleaflet/src/map/handler/Map.FileInserter.js |    4 +--
 loleaflet/src/map/handler/Map.Keyboard.js     |   18 +++++++-------
 16 files changed, 73 insertions(+), 75 deletions(-)

New commits:
commit aecc316409d11d97fefe9b0227a97ce5e3129025
Author: Jan Holesovsky <[email protected]>
Date:   Thu Jan 14 09:43:45 2016 +0100

    loleaflet: L.Socket should not be global.

diff --git a/loleaflet/spec/loleaflet/control/PartsSpec.js 
b/loleaflet/spec/loleaflet/control/PartsSpec.js
index c7438e5..f2edc1b 100644
--- a/loleaflet/spec/loleaflet/control/PartsSpec.js
+++ b/loleaflet/spec/loleaflet/control/PartsSpec.js
@@ -71,7 +71,7 @@ describe('Parts and Pages', function () {
                                        done();
                                }
                        });
-                       L.Socket.sendMessage('uno .uno:LeftPara');
+                       map._socket.sendMessage('uno .uno:LeftPara');
                });
 
                it('Remove the first preview', function (done) {
@@ -81,7 +81,7 @@ describe('Parts and Pages', function () {
                                done();
                        });
                        map.removePreviewUpdate(1);
-                       L.Socket.sendMessage('uno .uno:CenterPara');
+                       map._socket.sendMessage('uno .uno:CenterPara');
                });
        });
 
diff --git a/loleaflet/spec/tilebench/TileBenchSpec.js 
b/loleaflet/spec/tilebench/TileBenchSpec.js
index 9724d57..87874e8 100644
--- a/loleaflet/spec/tilebench/TileBenchSpec.js
+++ b/loleaflet/spec/tilebench/TileBenchSpec.js
@@ -36,14 +36,14 @@ describe('TileBench', function () {
 
                // add a timestamp to tile messages so we can identify
                // the response
-               L.Socket.sendMessage = L.bind(function (msg, coords) {
+               map._socket.sendMessage = L.bind(function (msg, coords) {
                        var now = Date.now();
                        if (msg.startsWith('tile')) {
                                msg += ' timestamp=' + now;
                        }
                        L.Log.log(msg, L.OUTGOING, coords, now);
                        this.socket.send(msg);
-               }, L.Socket);
+               }, map._socket);
        });
 
        afterEach(function () {
@@ -100,7 +100,7 @@ describe('TileBench', function () {
 
                        for (var i = 0; i < keyInput.length; i++) {
                                setTimeout(L.bind(function () {
-                                       L.Socket.sendMessage(keyInput[this][1]);
+                                       
map._socket.sendMessage(keyInput[this][1]);
                                }, i), keyInput[i][0]);
                        }
                });
diff --git a/loleaflet/src/control/Control.Search.js 
b/loleaflet/src/control/Control.Search.js
index 3dc46b5..57b662d 100644
--- a/loleaflet/src/control/Control.Search.js
+++ b/loleaflet/src/control/Control.Search.js
@@ -47,7 +47,7 @@ L.Control.Search = L.Control.extend({
                        this._refocusOnMap();
                }
                else {
-                       L.Socket.sendMessage('requestloksession');
+                       this._map._socket.sendMessage('requestloksession');
                }
        },
 
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 88585bf..2c9a59c 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -23,14 +23,14 @@ L.Map.include({
                }
                if (docLayer._isCursorOverlayVisible) {
                        // a click outside the slide to clear any selection
-                       L.Socket.sendMessage('resetselection');
+                       this._socket.sendMessage('resetselection');
                }
                this.fire('updateparts', {
                        selectedPart: docLayer._selectedPart,
                        parts: docLayer._parts,
                        docType: docLayer._docType
                });
-               L.Socket.sendMessage('setclientpart part=' + 
docLayer._selectedPart);
+               this._socket.sendMessage('setclientpart part=' + 
docLayer._selectedPart);
                docLayer._clearSelections();
                docLayer._update();
                docLayer._pruneTiles();
@@ -74,7 +74,7 @@ L.Map.include({
                else {
                        maxHeight = Math.round(tileHeight * maxWidth / 
tileWidth);
                }
-               L.Socket.sendMessage('tile ' +
+               this._socket.sendMessage('tile ' +
                                                        'part=' + part + ' ' +
                                                        'width=' + maxWidth + ' 
' +
                                                        'height=' + maxHeight + 
' ' +
@@ -92,7 +92,7 @@ L.Map.include({
                var autoUpdate = options ? options.autoUpdate : false;
                this._docPreviews[id] = {id: id, part: part, width: width, 
height: height, tilePosX: tilePosX,
                        tilePosY: tilePosY, tileWidth: tileWidth, tileHeight: 
tileHeight, autoUpdate: autoUpdate};
-               L.Socket.sendMessage('tile ' +
+               this._socket.sendMessage('tile ' +
                                                        'part=' + part + ' ' +
                                                        'width=' + width + ' ' +
                                                        'height=' + height + ' 
' +
@@ -135,7 +135,7 @@ L.Map.include({
                        this.scrollLeft(pos.x, {update: true});
                }
                else {
-                       L.Socket.sendMessage('setpage page=' + 
docLayer._currentPage);
+                       this._socket.sendMessage('setpage page=' + 
docLayer._currentPage);
                }
                this.fire('pagenumberchanged', {
                        currentPage: docLayer._currentPage,
diff --git a/loleaflet/src/control/Permission.js 
b/loleaflet/src/control/Permission.js
index b0689e5..b282ac3 100644
--- a/loleaflet/src/control/Permission.js
+++ b/loleaflet/src/control/Permission.js
@@ -5,7 +5,7 @@ L.Map.include({
        setPermission: function (perm) {
                this._docLayer._permission = perm;
                if (perm === 'edit') {
-                       L.Socket.sendMessage('requestloksession');
+                       this._socket.sendMessage('requestloksession');
                        this.dragging.disable();
                }
                else if (perm === 'view' || perm === 'readonly') {
@@ -22,7 +22,7 @@ L.Map.include({
                if (this._docLayer._permission === 'edit') {
                        return;
                }
-               L.Socket.sendMessage('requestloksession');
+               this._socket.sendMessage('requestloksession');
                this.dragging.disable();
        },
 
diff --git a/loleaflet/src/control/Search.js b/loleaflet/src/control/Search.js
index e08d1c4..bf14a13 100644
--- a/loleaflet/src/control/Search.js
+++ b/loleaflet/src/control/Search.js
@@ -35,7 +35,7 @@ L.Map.include({
                searchCmd['SearchItem.Command'] = {};
                searchCmd['SearchItem.Command'].type = 'long';
                searchCmd['SearchItem.Command'].value = all;
-               L.Socket.sendMessage('uno .uno:ExecuteSearch ' + 
JSON.stringify(searchCmd));
+               this._socket.sendMessage('uno .uno:ExecuteSearch ' + 
JSON.stringify(searchCmd));
        },
 
        searchAll: function (text, backward) {
@@ -43,6 +43,6 @@ L.Map.include({
        },
 
        resetSelection: function () {
-               L.Socket.sendMessage('resetselection');
+               this._socket.sendMessage('resetselection');
        }
 });
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 4f05b43..2a95bc7 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -14,7 +14,7 @@ L.Map.include({
                        var msg = 'uno .uno:CharFontName {' +
                                '"CharFontName.FamilyName": ' +
                                        '{"type": "string", "value": "' + 
fontName + '"}}';
-                       L.Socket.sendMessage(msg);
+                       this._socket.sendMessage(msg);
                }
        },
 
@@ -23,7 +23,7 @@ L.Map.include({
                        var msg = 'uno .uno:FontHeight {' +
                                '"FontHeight.Height": ' +
                                '{"type": "float", "value": "' + fontSize + 
'"}}';
-                       L.Socket.sendMessage(msg);
+                       this._socket.sendMessage(msg);
                }
        },
 
@@ -39,7 +39,7 @@ L.Map.include({
                        options = '';
                }
                id = id || -1; // not a special download
-               L.Socket.sendMessage('downloadas ' +
+               this._socket.sendMessage('downloadas ' +
                        'name=' + name + ' ' +
                        'id=' + id + ' ' +
                        'format=' + format + ' ' +
@@ -57,7 +57,7 @@ L.Map.include({
                if (options === undefined || options === null) {
                        options = '';
                }
-               L.Socket.sendMessage('saveas ' +
+               this._socket.sendMessage('saveas ' +
                        'url=' + url + ' ' +
                        'format=' + format + ' ' +
                        'options=' + options);
@@ -73,13 +73,13 @@ L.Map.include({
                                        '"Style":{"type":"string", "value": "' 
+ style + '"},' +
                                        '"FamilyName":{"type":"string", 
"value":"' + familyName + '"}' +
                                        '}';
-                       L.Socket.sendMessage(msg);
+                       this._socket.sendMessage(msg);
                }
        },
 
        sendUnoCommand: function (command, json) {
                if (this._docLayer._permission === 'edit') {
-                       L.Socket.sendMessage('uno ' + command + (json ? ' ' + 
JSON.stringify(json) : ''));
+                       this._socket.sendMessage('uno ' + command + (json ? ' ' 
+ JSON.stringify(json) : ''));
                }
        },
 
@@ -103,10 +103,10 @@ L.Map.include({
                                value: string
                        }
                };
-               L.Socket.sendMessage('uno .uno:EnterString ' + 
JSON.stringify(command));
+               this._socket.sendMessage('uno .uno:EnterString ' + 
JSON.stringify(command));
        },
 
        renderFont: function (fontName) {
-               L.Socket.sendMessage('renderfont font=' + 
window.encodeURIComponent(fontName));
+               this._socket.sendMessage('renderfont font=' + 
window.encodeURIComponent(fontName));
        }
 });
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index e8d34ef..716fe00 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -2,8 +2,8 @@
  * L.Socket contains methods for the communication with the server
  */
 
-L.Socket = {
-       connect: function (map) {
+L.Socket = L.Class.extend({
+       initialize: function (map) {
                try {
                        this.socket = new WebSocket(map.options.server);
                } catch (e) {
@@ -245,10 +245,8 @@ L.Socket = {
                }
                return command;
        }
-};
+});
 
-if (typeof String.prototype.startsWith !== 'function') {
-       String.prototype.startsWith = function (str) {
-               return this.slice(0, str.length) === str;
-       };
-}
+L.socket = function (map) {
+    return new L.Socket(map);
+};
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js 
b/loleaflet/src/layer/tile/CalcTileLayer.js
index 58303f3..8196c23 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -11,7 +11,7 @@ L.CalcTileLayer = L.TileLayer.extend({
        },
 
        _onInvalidateTilesMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                if (command.x === undefined || command.y === undefined || 
command.part === undefined) {
                        var strTwips = textMsg.match(/\d+/g);
                        command.x = parseInt(strTwips[0]);
@@ -76,7 +76,7 @@ L.CalcTileLayer = L.TileLayer.extend({
                                'tilewidth=' + this._tileWidthTwips + ' ' +
                                'tileheight=' + this._tileHeightTwips;
 
-                       L.Socket.sendMessage(message, "");
+                       this._map._socket.sendMessage(message, "");
                }
 
                for (key in this._tileCache) {
@@ -117,10 +117,10 @@ L.CalcTileLayer = L.TileLayer.extend({
        _onZoomRowColumns: function () {
                this._updateClientZoom();
                if (this._clientZoom) {
-                       L.Socket.sendMessage('clientzoom ' + this._clientZoom);
+                       this._map._socket.sendMessage('clientzoom ' + 
this._clientZoom);
                        this._clientZoom = null;
                }
-               L.Socket.sendMessage('commandvalues 
command=.uno:ViewRowColumnHeaders');
+               this._map._socket.sendMessage('commandvalues 
command=.uno:ViewRowColumnHeaders');
        },
 
        _onUpdateViewPort: function () {
@@ -139,7 +139,7 @@ L.CalcTileLayer = L.TileLayer.extend({
        },
 
        _onStatusMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                if (command.width && command.height && this._documentInfo !== 
textMsg) {
                        this._docWidthTwips = command.width;
                        this._docHeightTwips = command.height;
@@ -148,7 +148,7 @@ L.CalcTileLayer = L.TileLayer.extend({
                        this._documentInfo = textMsg;
                        this._parts = command.parts;
                        this._selectedPart = command.selectedPart;
-                       L.Socket.sendMessage('setclientpart part=' + 
this._selectedPart);
+                       this._map._socket.sendMessage('setclientpart part=' + 
this._selectedPart);
                        var partNames = textMsg.match(/[^\r\n]+/g);
                        // only get the last matches
                        partNames = partNames.slice(partNames.length - 
this._parts);
diff --git a/loleaflet/src/layer/tile/GridLayer.js 
b/loleaflet/src/layer/tile/GridLayer.js
index ed9211c..8e3be8f 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -532,7 +532,7 @@ L.GridLayer = L.Layer.extend({
                        if (newView) {
                                // we know that a new set of tiles that cover 
the whole view has been requested
                                // so we're able to cancel the previous 
requests that are being processed
-                               L.Socket.sendMessage('canceltiles');
+                               this._map._socket.sendMessage('canceltiles');
                                for (key in this._tiles) {
                                        if (!this._tiles[key].loaded) {
                                                
L.DomUtil.remove(this._tiles[key].el);
@@ -694,7 +694,7 @@ L.GridLayer = L.Layer.extend({
                        if (coords.part !== this._selectedPart) {
                                msg += ' prefetch=true';
                        }
-                       L.Socket.sendMessage(msg, key);
+                       this._map._socket.sendMessage(msg, key);
                }
                else {
                        tile.src = this._tileCache[key];
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js 
b/loleaflet/src/layer/tile/ImpressTileLayer.js
index ec7b27c..de3cf4f 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -5,7 +5,7 @@
 L.ImpressTileLayer = L.TileLayer.extend({
 
        _onInvalidateTilesMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                if (command.x === undefined || command.y === undefined || 
command.part === undefined) {
                        var strTwips = textMsg.match(/\d+/g);
                        command.x = parseInt(strTwips[0]);
@@ -67,7 +67,7 @@ L.ImpressTileLayer = L.TileLayer.extend({
                                'tilewidth=' + this._tileWidthTwips + ' ' +
                                'tileheight=' + this._tileHeightTwips;
 
-                       L.Socket.sendMessage(message, "");
+                       this._map._socket.sendMessage(message, "");
                }
 
                for (key in this._tileCache) {
@@ -111,7 +111,7 @@ L.ImpressTileLayer = L.TileLayer.extend({
        },
 
        _onStatusMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                if (command.width && command.height && this._documentInfo !== 
textMsg) {
                        this._docWidthTwips = command.width;
                        this._docHeightTwips = command.height;
@@ -120,7 +120,7 @@ L.ImpressTileLayer = L.TileLayer.extend({
                        this._documentInfo = textMsg;
                        this._parts = command.parts;
                        this._selectedPart = command.selectedPart;
-                       L.Socket.sendMessage('setclientpart part=' + 
this._selectedPart);
+                       this._map._socket.sendMessage('setclientpart part=' + 
this._selectedPart);
                        var partNames = textMsg.match(/[^\r\n]+/g);
                        // only get the last matches
                        partNames = partNames.slice(partNames.length - 
this._parts);
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index bc05cac..04fe59c 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -208,7 +208,7 @@ L.TileLayer = L.GridLayer.extend({
        _getToolbarCommandsValues: function() {
                for (var i = 0; i < this._map.unoToolbarCommands.length; i++) {
                        var command = this._map.unoToolbarCommands[i];
-                       L.Socket.sendMessage('commandvalues command=' + 
command);
+                       this._map._socket.sendMessage('commandvalues command=' 
+ command);
                }
        },
 
@@ -328,7 +328,7 @@ L.TileLayer = L.GridLayer.extend({
        },
 
        _onDownloadAsMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                var parser = document.createElement('a');
                parser.href = this._map.options.server;
                var url = this._map.options.webserver + '/' +
@@ -353,12 +353,12 @@ L.TileLayer = L.GridLayer.extend({
        },
 
        _onErrorMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                this._map.fire('error', {cmd: command.errorCmd, kind: 
command.errorKind});
        },
 
        _onGetChildIdMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                this._map.fire('childid', {id: command.id});
        },
 
@@ -451,7 +451,7 @@ L.TileLayer = L.GridLayer.extend({
        },
 
        _onRenderFontMsg: function (textMsg, img) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                this._map.fire('renderfont', {
                        font: command.font,
                        img: img
@@ -549,7 +549,7 @@ L.TileLayer = L.GridLayer.extend({
                                clearTimeout(this._selectionContentRequest);
                        }
                        this._selectionContentRequest = 
setTimeout(L.bind(function () {
-                               L.Socket.sendMessage('gettextselection 
mimetype=text/plain;charset=utf-8');}, this), 100);
+                               this._map._socket.sendMessage('gettextselection 
mimetype=text/plain;charset=utf-8');}, this), 100);
                }
                this._onUpdateTextSelection();
        },
@@ -590,7 +590,7 @@ L.TileLayer = L.GridLayer.extend({
        },
 
        _onTileMsg: function (textMsg, img) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                var coords = this._twipsToCoords(command);
                coords.z = command.zoom;
                coords.part = command.part;
@@ -665,10 +665,10 @@ L.TileLayer = L.GridLayer.extend({
        _postMouseEvent: function(type, x, y, count, buttons, modifier) {
                if (this._clientZoom) {
                        // the zoom level has changed
-                       L.Socket.sendMessage('clientzoom ' + this._clientZoom);
+                       this._map._socket.sendMessage('clientzoom ' + 
this._clientZoom);
                        this._clientZoom = null;
                }
-               L.Socket.sendMessage('mouse type=' + type +
+               this._map._socket.sendMessage('mouse type=' + type +
                                ' x=' + x + ' y=' + y + ' count=' + count +
                                ' buttons=' + buttons + ' modifier=' + 
modifier);
        },
@@ -676,20 +676,20 @@ L.TileLayer = L.GridLayer.extend({
        _postKeyboardEvent: function(type, charcode, keycode) {
                if (this._clientZoom) {
                        // the zoom level has changed
-                       L.Socket.sendMessage('clientzoom ' + this._clientZoom);
+                       this._map._socket.sendMessage('clientzoom ' + 
this._clientZoom);
                        this._clientZoom = null;
                }
-               L.Socket.sendMessage('key type=' + type +
+               this._map._socket.sendMessage('key type=' + type +
                                ' char=' + charcode + ' key=' + keycode);
        },
 
        _postSelectGraphicEvent: function(type, x, y) {
-               L.Socket.sendMessage('selectgraphic type=' + type +
+               this._map._socket.sendMessage('selectgraphic type=' + type +
                                ' x=' + x + ' y=' + y);
        },
 
        _postSelectTextEvent: function(type, x, y) {
-               L.Socket.sendMessage('selecttext type=' + type +
+               this._map._socket.sendMessage('selecttext type=' + type +
                                ' x=' + x + ' y=' + y);
        },
 
@@ -921,7 +921,7 @@ L.TileLayer = L.GridLayer.extend({
        _onPaste: function (e) {
                e = e.originalEvent;
                e.preventDefault();
-               L.Socket.sendMessage('paste mimetype=text/plain;charset=utf-8 
data=' + e.clipboardData.getData('text/plain'));
+               this._map._socket.sendMessage('paste 
mimetype=text/plain;charset=utf-8 data=' + 
e.clipboardData.getData('text/plain'));
        },
 
        _onDragStart: function () {
@@ -929,7 +929,7 @@ L.TileLayer = L.GridLayer.extend({
        },
 
        _onRequestLOKSession: function () {
-               L.Socket.sendMessage('requestloksession');
+               this._map._socket.sendMessage('requestloksession');
        },
 
        _fitWidthZoom: function (e, maxZoom) {
@@ -991,7 +991,7 @@ L.TileLayer = L.GridLayer.extend({
        // hence we need to request an updated cell cursor position for this 
level.
        _onCellCursorShift: function (force) {
                if (this._cellCursorMarker || force) {
-                       L.Socket.sendMessage('commandvalues 
command=.uno:CellCursor'
+                       this._map._socket.sendMessage('commandvalues 
command=.uno:CellCursor'
                                             + '?outputHeight=' + this._tileSize
                                             + '&outputWidth=' + this._tileSize
                                             + '&tileHeight=' + 
this._tileWidthTwips
diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js 
b/loleaflet/src/layer/tile/WriterTileLayer.js
index 71aeb4a..3c0ad8f 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -5,7 +5,7 @@
 L.WriterTileLayer = L.TileLayer.extend({
 
        _onInvalidateTilesMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                if (command.x === undefined || command.y === undefined || 
command.part === undefined) {
                        var strTwips = textMsg.match(/\d+/g);
                        command.x = parseInt(strTwips[0]);
@@ -68,7 +68,7 @@ L.WriterTileLayer = L.TileLayer.extend({
                                'tilewidth=' + this._tileWidthTwips + ' ' +
                                'tileheight=' + this._tileHeightTwips;
 
-                       L.Socket.sendMessage(message, "");
+                       this._map._socket.sendMessage(message, "");
                }
 
                for (key in this._tileCache) {
@@ -105,7 +105,7 @@ L.WriterTileLayer = L.TileLayer.extend({
        },
 
        _onStatusMsg: function (textMsg) {
-               var command = L.Socket.parseServerCmd(textMsg);
+               var command = this._map._socket.parseServerCmd(textMsg);
                if (command.width && command.height && this._documentInfo !== 
textMsg) {
                        this._docWidthTwips = command.width;
                        this._docHeightTwips = command.height;
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index f7c93c8..a4c5aea 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -67,7 +67,7 @@ L.Map = L.Evented.extend({
                        L.Icon.Default.imagePath = this.options.imagePath;
                }
                this._addLayers(this.options.layers);
-               L.Socket.connect(this);
+               this._socket = L.socket(this);
 
                // Inhibit the context menu - the browser thinks that the 
document
                // is just a bunch of images, hence the context menu is useless 
(tdf#94599)
@@ -273,7 +273,7 @@ L.Map = L.Evented.extend({
                        this.removeLayer(this._docLayer);
                }
                this.removeControls();
-               L.Socket.close();
+               this._socket.close();
                return this;
        },
 
diff --git a/loleaflet/src/map/handler/Map.FileInserter.js 
b/loleaflet/src/map/handler/Map.FileInserter.js
index e95050d..0dd6aee 100644
--- a/loleaflet/src/map/handler/Map.FileInserter.js
+++ b/loleaflet/src/map/handler/Map.FileInserter.js
@@ -29,7 +29,7 @@ L.Map.FileInserter = L.Handler.extend({
 
        _onInsertFile: function (e) {
                if (!this._childId) {
-                       L.Socket.sendMessage('getchildid');
+                       this._map._socket.sendMessage('getchildid');
                        this._toInsert[Date.now()] = e.file;
                }
                else {
@@ -50,7 +50,7 @@ L.Map.FileInserter = L.Handler.extend({
                var xmlHttp = new XMLHttpRequest();
                xmlHttp.onreadystatechange = function () {
                        if (xmlHttp.readyState === 4 && xmlHttp.status === 200) 
{
-                               L.Socket.sendMessage('insertfile name=' + name 
+ ' type=graphic');
+                               this._map._socket.sendMessage('insertfile 
name=' + name + ' type=graphic');
                        }
                };
                xmlHttp.open('POST', url, true);
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js 
b/loleaflet/src/map/handler/Map.Keyboard.js
index 2956493..bb07c75 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -311,17 +311,17 @@ L.Map.Keyboard = L.Handler.extend({
                        if (!e.originalEvent.shiftKey) {
                                switch (e.originalEvent.keyCode) {
                                        case 53: // 5
-                                               L.Socket.sendMessage('uno 
.uno:Strikeout');
+                                               
this._map._socket.sendMessage('uno .uno:Strikeout');
                                                return true;
                                        case 70: // f
-                                               L.Socket.sendMessage('uno 
.uno:InsertFootnote');
+                                               
this._map._socket.sendMessage('uno .uno:InsertFootnote');
                                                return true;
                                        case 67: // c
                                        case 77: // m
-                                               L.Socket.sendMessage('uno 
.uno:InsertAnnotation');
+                                               
this._map._socket.sendMessage('uno .uno:InsertAnnotation');
                                                return true;
                                        case 68: // d
-                                               L.Socket.sendMessage('uno 
.uno:InsertEndnote');
+                                               
this._map._socket.sendMessage('uno .uno:InsertEndnote');
                                                return true;
                                }
                        }
@@ -332,14 +332,14 @@ L.Map.Keyboard = L.Handler.extend({
                switch (e.originalEvent.keyCode) {
                        case 51: // 3
                                if (this._map.getDocType() === 'spreadsheet') {
-                                       L.Socket.sendMessage('uno 
.uno:SetOptimalColumnWidthDirect');
-                                       L.Socket.sendMessage('commandvalues 
command=.uno:ViewRowColumnHeaders');
+                                       this._map._socket.sendMessage('uno 
.uno:SetOptimalColumnWidthDirect');
+                                       
this._map._socket.sendMessage('commandvalues 
command=.uno:ViewRowColumnHeaders');
                                        return true;
                                }
                                return false;
                        case 53: // 5
                                if (this._map.getDocType() === 'spreadsheet') {
-                                       L.Socket.sendMessage('uno 
.uno:Strikeout');
+                                       this._map._socket.sendMessage('uno 
.uno:Strikeout');
                                        return true;
                                }
                                return false;
@@ -355,10 +355,10 @@ L.Map.Keyboard = L.Handler.extend({
                        case 86: // v
                                return true;
                        case 188: // ,
-                               L.Socket.sendMessage('uno .uno:SubScript');
+                               this._map._socket.sendMessage('uno 
.uno:SubScript');
                                return true;
                        case 190: // .
-                               L.Socket.sendMessage('uno .uno:SuperScript');
+                               this._map._socket.sendMessage('uno 
.uno:SuperScript');
                                return true;
                }
                if (e.type === 'keypress' && e.originalEvent.key === 'c' && 
e.originalEvent.ctrlKey) {
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to