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 <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
This commit is contained in:
Marco Cecchetti
2017-04-19 23:09:19 +02:00
committed by Jan Holesovsky
parent 9c7cbab615
commit 1e0deae3df
6 changed files with 22 additions and 8 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;