From 1e0deae3df1e1a36c986983908be6180993292a1 Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Wed, 19 Apr 2017 23:09:19 +0200 Subject: [PATCH] Calc: changed the way header are updated on row/col insertion/deletion Now when a row/col is inserted/removed or resized is the core to notify the client that current header is no more valid and a new header should be requested by the client to core. In this way core can notify the header invalidation to all views. Change-Id: Ia3c1872b73cfb3458cd0d35907291a9fc9eebd11 Reviewed-on: https://gerrit.libreoffice.org/36729 Reviewed-by: Jan Holesovsky Tested-by: Jan Holesovsky --- bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 10 +++++++++- kit/ChildSession.cpp | 6 +++++- kit/KitHelper.hpp | 4 +++- loleaflet/src/control/Control.RowHeader.js | 5 ----- loleaflet/src/layer/tile/CalcTileLayer.js | 4 ++++ tools/KitClient.cpp | 1 + 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h index 8a59b4cc8a..dffc728eb6 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -492,7 +492,15 @@ typedef enum * - 'action' can be 'Add', 'Remove' or 'Modify' depending on whether * comment has been added, removed or modified. */ - LOK_CALLBACK_COMMENT = 32 + LOK_CALLBACK_COMMENT = 32, + + /** + * The column/row header is no more valid because of a column/row insertion + * or a similar event. Clients must query a new column/row header set. + * + * The payload says if we are invalidating a row or column header. + */ + LOK_CALLBACK_INVALIDATE_HEADER = 33 } LibreOfficeKitCallbackType; diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index e3aaa5dde7..97a384a7be 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -979,7 +979,8 @@ void ChildSession::rememberEventsForInactiveUser(const int type, const std::stri type == LOK_CALLBACK_CELL_FORMULA || type == LOK_CALLBACK_CELL_CURSOR || type == LOK_CALLBACK_GRAPHIC_SELECTION || - type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED) + type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED || + type == LOK_CALLBACK_INVALIDATE_HEADER) { auto lock(getLock()); _stateRecorder.recordEvent(type, payload); @@ -1199,6 +1200,9 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) case LOK_CALLBACK_COMMENT: sendTextFrame("comment: " + payload); break; + case LOK_CALLBACK_INVALIDATE_HEADER: + sendTextFrame("invalidateheader: " + payload); + break; default: LOG_ERR("Unknown callback event (" << type << "): " << payload); } diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp index 19c36f3bcb..63040a1ed8 100644 --- a/kit/KitHelper.hpp +++ b/kit/KitHelper.hpp @@ -109,7 +109,9 @@ namespace LOKitHelper return "VIEW_LOCK"; case LOK_CALLBACK_COMMENT: return "COMMENT"; - } + case LOK_CALLBACK_INVALIDATE_HEADER: + return "INVALIDATE_HEADER"; + } return std::to_string(type); } diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js index 9ca3395da4..d5f702a1e7 100644 --- a/loleaflet/src/control/Control.RowHeader.js +++ b/loleaflet/src/control/Control.RowHeader.js @@ -93,7 +93,6 @@ L.Control.RowHeader = L.Control.Header.extend({ this._selectRow(row, 0); } this._map.sendUnoCommand('.uno:InsertRows'); - this._updateRowHeader(); }, deleteRow: function(row) { @@ -101,7 +100,6 @@ L.Control.RowHeader = L.Control.Header.extend({ this._selectRow(row, 0); } this._map.sendUnoCommand('.uno:DeleteRows'); - this._updateRowHeader(); }, hideRow: function(row) { @@ -109,7 +107,6 @@ L.Control.RowHeader = L.Control.Header.extend({ this._selectRow(row, 0); } this._map.sendUnoCommand('.uno:HideRow'); - this._updateRowHeader(); }, showRow: function(row) { @@ -117,7 +114,6 @@ L.Control.RowHeader = L.Control.Header.extend({ this._selectRow(row, 0); } this._map.sendUnoCommand('.uno:ShowRow'); - this._updateRowHeader(); }, setScrollPosition: function (e) { @@ -286,7 +282,6 @@ L.Control.RowHeader = L.Control.Header.extend({ }; this._map.sendUnoCommand('.uno:RowHeight', command); - this._updateRowHeader(); } this._map.removeLayer(this._horzLine); diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js index 80c009d414..8db36a7a92 100644 --- a/loleaflet/src/layer/tile/CalcTileLayer.js +++ b/loleaflet/src/layer/tile/CalcTileLayer.js @@ -211,6 +211,10 @@ L.CalcTileLayer = L.TileLayer.extend({ modified.setLatLngBounds(obj.comment.cellPos); } } + } else if (textMsg.startsWith('invalidateheader: column')) { + this._map.fire('updaterowcolumnheaders', {x: this._map._getTopLeftPoint().x, y: 0, offset: {x: undefined, y: 0}}); + } else if (textMsg.startsWith('invalidateheader: row')) { + this._map.fire('updaterowcolumnheaders', {x: 0, y: this._map._getTopLeftPoint().y, offset: {x: 0, y: undefined}}); } else { L.TileLayer.prototype._onMessage.call(this, textMsg, img); } diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index bff3384e10..95597b352c 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -76,6 +76,7 @@ extern "C" CASE(REDLINE_TABLE_SIZE_CHANGED); CASE(REDLINE_TABLE_ENTRY_MODIFIED); CASE(COMMENT); + CASE(INVALIDATE_HEADER); #undef CASE } std::cout << " payload: " << payload << std::endl;