[Libreoffice-commits] online.git: loleaflet/src
Dennis Francis (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 13 10:11:02 UTC 2020
loleaflet/src/control/Parts.js | 11 +++++-----
loleaflet/src/layer/tile/CalcTileLayer.js | 32 +++++++++++++++++++++---------
2 files changed, 29 insertions(+), 14 deletions(-)
New commits:
commit e6814552df0f4a7a8910e898013b8ca3b112df35
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Mon Jul 13 13:57:53 2020 +0530
Commit: Dennis Francis <dennis.francis at collabora.com>
CommitDate: Mon Jul 13 12:10:43 2020 +0200
request sheet-geometry data just after sending setclientpart to core...
instead of doing it on getting a 'setpart' back from core.
This is helpful in the following respects:
1. On new sheet insert, setpart is not sent by the core.
2. On sheet-switch, new sheet's messages (cursor) can arrive before we
get sheet-geometry-data because it is requested only after setpart
which is too late.
3. save almost all of the round-trip time for sheet-geometry data.
Change-Id: Id6464be72c2ff6e8dce006d8e7ba3141b8d6cf1b
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98621
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Dennis Francis <dennis.francis at collabora.com>
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index d112557f7..3fc5c0961 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -32,6 +32,12 @@ L.Map.include({
this._socket.sendMessage('resetselection');
}
+ // If this wasn't triggered from the server,
+ // then notify the server of the change.
+ if (!external) {
+ this._socket.sendMessage('setclientpart part=' + docLayer._selectedPart);
+ }
+
this.fire('updateparts', {
selectedPart: docLayer._selectedPart,
selectedParts: docLayer._selectedParts,
@@ -39,11 +45,6 @@ L.Map.include({
docType: docLayer._docType
});
- // If this wasn't triggered from the server,
- // then notify the server of the change.
- if (!external) {
- this._socket.sendMessage('setclientpart part=' + docLayer._selectedPart);
- }
docLayer.eachView(docLayer._viewCursors, docLayer._onUpdateViewCursor, docLayer);
docLayer.eachView(docLayer._cellViewCursors, docLayer._onUpdateCellViewCursor, docLayer);
docLayer.eachView(docLayer._graphicViewMarkers, docLayer._onUpdateGraphicViewSelection, docLayer);
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index dfe2fd9e2..36d8d43af 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -234,6 +234,9 @@ L.CalcTileLayer = (L.Browser.mobile ? L.TileLayer : L.CanvasTileLayer).extend({
_onUpdateParts: function (e) {
if (typeof this._prevSelectedPart === 'number' && !e.source) {
+ this._clearMsgReplayStore();
+ this.refreshViewData(undefined, false /* compatDataSrcOnly */, true /* sheetGeometryChanged */);
+ this._switchSplitPanesContext();
this.hideAnnotations(this._prevSelectedPart);
this.showAnnotations();
}
@@ -445,9 +448,7 @@ L.CalcTileLayer = (L.Browser.mobile ? L.TileLayer : L.CanvasTileLayer).extend({
_onSetPartMsg: function (textMsg) {
var part = parseInt(textMsg.match(/\d+/g)[0]);
if (!this.isHiddenPart(part)) {
- this._clearMsgReplayStore();
- this._switchSplitPanesContext();
- this.refreshViewData(undefined, false /* compatDataSrcOnly */, true /* sheetGeometryChanged */);
+ this.refreshViewData(undefined, true /* compatDataSrcOnly */, false /* sheetGeometryChanged */);
}
},
@@ -723,10 +724,10 @@ L.CalcTileLayer = (L.Browser.mobile ? L.TileLayer : L.CanvasTileLayer).extend({
this._sheetGeomFirstWait = false;
this.sheetGeometry = new L.SheetGeometry(jsonMsgObj,
this._tileWidthTwips, this._tileHeightTwips,
- this._tileSize, this._tilePixelScale);
+ this._tileSize, this._tilePixelScale, this._selectedPart);
}
else {
- this.sheetGeometry.update(jsonMsgObj);
+ this.sheetGeometry.update(jsonMsgObj, /* checkCompleteness */ false, this._selectedPart);
}
this._replayPrintTwipsMsgs();
@@ -1073,17 +1074,19 @@ L.SheetGeometry = L.Class.extend({
// all flags (ie 'columns', 'rows', 'sizes', 'hidden', 'filtered',
// 'groups') enabled.
initialize: function (sheetGeomJSON, tileWidthTwips, tileHeightTwips,
- tileSizeCSSPixels, dpiScale) {
+ tileSizeCSSPixels, dpiScale, part) {
if (typeof sheetGeomJSON !== 'object' ||
typeof tileWidthTwips !== 'number' ||
typeof tileHeightTwips !== 'number' ||
typeof tileSizeCSSPixels !== 'number' ||
- typeof dpiScale !== 'number') {
+ typeof dpiScale !== 'number' ||
+ typeof part !== 'number') {
console.error('Incorrect constructor argument types or missing required arguments');
return;
}
+ this._part = -1;
this._columns = new L.SheetDimension();
this._rows = new L.SheetDimension();
this._unoCommand = '.uno:SheetGeometryData';
@@ -1092,10 +1095,10 @@ L.SheetGeometry = L.Class.extend({
this.setTileGeometryData(tileWidthTwips, tileHeightTwips, tileSizeCSSPixels,
dpiScale, false /* update position info ?*/);
- this.update(sheetGeomJSON, /* checkCompleteness */ true);
+ this.update(sheetGeomJSON, /* checkCompleteness */ true, part);
},
- update: function (sheetGeomJSON, checkCompleteness) {
+ update: function (sheetGeomJSON, checkCompleteness, part) {
if (!this._testValidity(sheetGeomJSON, checkCompleteness)) {
return false;
@@ -1116,12 +1119,23 @@ L.SheetGeometry = L.Class.extend({
}
}
+ if (updateOK) {
+ console.assert(typeof part === 'number', 'part must be a number');
+ if (part !== this._part) {
+ this._part = part;
+ }
+ }
+
this._columns.setMaxIndex(+sheetGeomJSON.maxtiledcolumn);
this._rows.setMaxIndex(+sheetGeomJSON.maxtiledrow);
return updateOK;
},
+ getPart: function () {
+ return this._part;
+ },
+
setTileGeometryData: function (tileWidthTwips, tileHeightTwips, tileSizeCSSPixels,
dpiScale, updatePositions) {
this._columns.setTileGeometryData(tileWidthTwips, tileSizeCSSPixels, dpiScale, updatePositions);
More information about the Libreoffice-commits
mailing list