calc: Enable sheet protection

Require LOKit change Ib8e8209225d027472c1f2eef57839df5784acf30
https://gerrit.libreoffice.org/c/core/+/163205

Signed-off-by: Hubert Figuière <hub@collabora.com>
Change-Id: Ie54b355ad794a0e34fabbd8e56b4a17a936686f7
This commit is contained in:
Hubert Figuière 2024-02-09 14:57:41 -05:00 committed by Michael Meeks
parent f76333da3b
commit dece121bf2

View file

@ -74,6 +74,10 @@ L.Control.Tabs = L.Control.extend({
'.uno:Name': {name: _UNO('.uno:RenameTable', 'spreadsheet', true),
callback: (this._renameSheet).bind(this)
},
'.uno:Protect': {
name: _UNO('.uno:Protect', 'spreadsheet', true),
callback: (this._protectSheet).bind(this),
},
'.uno:Show': {
name: _UNO('.uno:Show', 'spreadsheet', true),
callback: (this._showSheet).bind(this),
@ -291,16 +295,21 @@ L.Control.Tabs = L.Control.extend({
}
},
_setPart: function (e) {
// Set the part by index. Return true if cancelled.
_setPartIndex: function(index) {
if (cool.Comment.isAnyEdit()) {
cool.CommentSection.showCommentEditingWarning();
return;
return true;
}
this._map._docLayer._clearReferences();
this._map.setPart(index, /*external:*/ false, /*calledFromSetPartHandler:*/ true);
},
_setPart: function (e) {
var part = e.target.id.match(/\d+/g)[0];
if (part !== null) {
this._map._docLayer._clearReferences();
this._map.setPart(parseInt(part), /*external:*/ false, /*calledFromSetPartHandler:*/ true);
this._setPartIndex(parseInt(part));
}
},
@ -370,6 +379,14 @@ L.Control.Tabs = L.Control.extend({
});
},
// Trigger sheet protection. It seems that it does it for the current sheet
// so we select it first.
_protectSheet: function() {
if (!this._setPartIndex(this._tabForContextMenu)) {
this._map.sendUnoCommand('.uno:Protect');
}
},
_showSheet: function() {
this._map.showPage();
},