Skip to content

Commit

Permalink
leaflet: provide easy way to rearrange calc sheet
Browse files Browse the repository at this point in the history
new options added:
move sheet left
move sheet right
move/copy dialog (desktop online)

Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Idd4857b9b36b09d549909330bd75dd385daeaaf3
  • Loading branch information
lpranam committed Nov 26, 2020
1 parent 94c7c23 commit 4f01c11
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
38 changes: 36 additions & 2 deletions loleaflet/src/control/Control.Tabs.js
Expand Up @@ -63,10 +63,24 @@ L.Control.Tabs = L.Control.extend({
'.uno:Hide': {
name: _UNO('.uno:Hide', 'spreadsheet', true),
callback: (this._hideSheet).bind(this)
},
'movesheetleft': {
name: _('Move Sheet Left'),
callback: (this._moveSheetLeft).bind(this)
},
'movesheetright': {
name: _('Move Sheet Right'),
callback: (this._moveSheetRight).bind(this)
}
};

if (!window.mode.isMobile()) {

// no blacklisting available for this context menu so only add when needed
this._menuItem['.uno:Move'] = {
name: _UNO('.uno:Move', 'spreadsheet', true),
callback: function() {this._map.sendUnoCommand('.uno:Move');}.bind(this)
};
L.installContextMenu({
selector: '.spreadsheet-tab',
className: 'loleaflet-font',
Expand Down Expand Up @@ -127,16 +141,18 @@ L.Control.Tabs = L.Control.extend({
if (window.mode.isMobile()) {
(new Hammer(tab, {recognizers: [[Hammer.Press]]}))
.on('press', function (j) {
return function() {
return function(e) {
this._tabForContextMenu = j;
this._setPart(e);
window.contextMenuWizard = true;
if (!this._map.isPermissionReadOnly()) this._map.fire('mobilewizard', menuData);
};
}(i).bind(this));
} else {
L.DomEvent.on(tab, 'contextmenu', function(j) {
return function() {
return function(e) {
this._tabForContextMenu = j;
this._setPart(e);
};
}(i).bind(this));
}
Expand Down Expand Up @@ -182,6 +198,24 @@ L.Control.Tabs = L.Control.extend({
}
},

//selected sheet is moved to new index
_moveSheet: function (newIndex) {
this._map.sendUnoCommand('.uno:Move?Copy:bool=false&UseCurrentDocument:bool=true&Index=' + newIndex);
},

_moveSheetLeft: function () {
var targetIndex = this._map._docLayer._partNames.indexOf(this._map._docLayer._partNames[this._map._docLayer._selectedPart]);
//core handles sheet with 1 base indexing
// 0 index means last sheet
if (targetIndex <= 0) return;
this._moveSheet(targetIndex);
},

_moveSheetRight: function () {
var targetIndex = this._map._docLayer._partNames.indexOf(this._map._docLayer._partNames[this._map._docLayer._selectedPart]) + 3;
this._moveSheet(targetIndex);
},

_insertSheetBefore: function() {
this._map.insertPage(this._tabForContextMenu);
},
Expand Down
1 change: 1 addition & 0 deletions loleaflet/src/unocommands.js
Expand Up @@ -233,6 +233,7 @@ var unoCommandsArray = {
MasterSlidesPanel:{presentation:{menu:_('Master Slides'),},},
MergeCells:{presentation:{menu:_('Merge Cells'),},spreadsheet:{menu:_('Merge Cells'),},text:{menu:_('Merge Cells'),},},
ModifyPage:{presentation:{menu:_('Slide ~Layout'),},},
Move:{spreadsheet:{menu:_('~Move or Copy Sheet...'),},},
MoveDown:{text:{menu:_('Move Down'),},},
MoveDownSubItems:{text:{menu:_('Move Down with Subpoints'),},},
MoveUp:{text:{menu:_('Move Up'),},},
Expand Down

0 comments on commit 4f01c11

Please sign in to comment.