introduce _getCursorRectangle() and _parseRectangle()...
and move the parsing/rectangle calculation code there. Change-Id: Ia24cd5d6931cf970336e3acdcd4a07a6da044068 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98146 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
This commit is contained in:
parent
4527f5587a
commit
844a9431c8
1 changed files with 33 additions and 6 deletions
|
@ -1249,13 +1249,10 @@ L.TileLayer = L.GridLayer.extend({
|
|||
var obj = JSON.parse(textMsg);
|
||||
var modifierViewId = parseInt(obj.viewId);
|
||||
this._cursorAtMispelledWord = obj.mispelledWord ? Boolean(parseInt(obj.mispelledWord)).valueOf() : false;
|
||||
var strTwips = obj.rectangle.match(/\d+/g);
|
||||
var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
|
||||
var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
|
||||
var bottomRightTwips = topLeftTwips.add(offset);
|
||||
var rectangle = this._getCursorRectangle(obj);
|
||||
this._visibleCursor = new L.LatLngBounds(
|
||||
this._twipsToLatLng(topLeftTwips, this._map.getZoom()),
|
||||
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
|
||||
this._twipsToLatLng(rectangle.getTopLeft(), this._map.getZoom()),
|
||||
this._twipsToLatLng(rectangle.getBottomRight(), this._map.getZoom()));
|
||||
var cursorPos = this._visibleCursor.getNorthWest();
|
||||
var docLayer = this._map._docLayer;
|
||||
if ((docLayer._followEditor || docLayer._followUser) && this._map.lastActionByUser) {
|
||||
|
@ -3402,6 +3399,36 @@ L.TileLayer = L.GridLayer.extend({
|
|||
return this.sheetGeometry.getTileTwipsSheetAreaFromPrint(rectangle);
|
||||
},
|
||||
|
||||
_getCursorRectangle: function (msgObj) {
|
||||
|
||||
if (typeof msgObj !== 'object' || !msgObj.hasOwnProperty('rectangle')) {
|
||||
console.error('invalid cursor message');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this._parseRectangle(msgObj.rectangle);
|
||||
},
|
||||
|
||||
_parseRectangle: function (rectString) {
|
||||
|
||||
if (typeof rectString !== 'string') {
|
||||
console.error('invalid rectangle string');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var strTwips = rectString.match(/\d+/g);
|
||||
if (strTwips.length < 4) {
|
||||
console.error('incomplete rectangle');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
|
||||
var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
|
||||
var bottomRightTwips = topLeftTwips.add(offset);
|
||||
|
||||
return new L.Bounds(topLeftTwips, bottomRightTwips);
|
||||
},
|
||||
|
||||
_debugGetTimeArray: function() {
|
||||
return {count: 0, ms: 0, best: Number.MAX_SAFE_INTEGER, worst: 0, date: 0};
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue