diff options
author | Bayram Çiçek <bayram.cicek@collabora.com> | 2024-05-28 09:05:40 +0300 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2024-05-28 14:07:09 +0200 |
commit | 42c044dbdfd6351d8d1f795837c5733183a26dea (patch) | |
tree | 350594b682d3a1ab04abe2f0dfbfb1117b902cc3 | |
parent | remove isAutoFillFromOnMouseUp and add LOK callback (diff) | |
download | online-42c044dbdfd6351d8d1f795837c5733183a26dea.tar.gz online-42c044dbdfd6351d8d1f795837c5733183a26dea.zip |
add AutoFill contextmenu items
- remove Control.AutoFillOptions.ts & cleanup
- added AutoFill contextmenu items
- Copy Cells
- Fill Series
- add 'AutoFill':{spreadsheet:{menu:_('Auto Fill'),},}
- remove LOK_CALLBACK_CELL_ACTIONS
Signed-off-by: Bayram Çiçek <bayram.cicek@collabora.com>
Change-Id: Ib64f6078ec50c994da3ed188910cba258adfe3fa
-rw-r--r-- | browser/Makefile.am | 1 | ||||
-rw-r--r-- | browser/src/control/Control.AutoFillOptions.ts | 116 | ||||
-rw-r--r-- | browser/src/control/Control.ContextMenu.js | 34 | ||||
-rw-r--r-- | browser/src/control/Control.JSDialog.js | 9 | ||||
-rw-r--r-- | browser/src/control/Control.Tabs.js | 1 | ||||
-rw-r--r-- | browser/src/control/Control.UIManager.js | 1 | ||||
-rw-r--r-- | browser/src/layer/marker/TextInput.js | 6 | ||||
-rw-r--r-- | browser/src/layer/tile/CalcTileLayer.js | 1 | ||||
-rw-r--r-- | browser/src/layer/tile/CanvasTileLayer.js | 9 | ||||
-rw-r--r-- | browser/src/unocommands.js | 1 | ||||
-rw-r--r-- | kit/ChildSession.cpp | 3 |
11 files changed, 34 insertions, 148 deletions
diff --git a/browser/Makefile.am b/browser/Makefile.am index c7e17f82c2..fe7d3bfa69 100644 --- a/browser/Makefile.am +++ b/browser/Makefile.am @@ -394,7 +394,6 @@ COOL_JS_LST =\ src/control/Control.Mention.ts \ src/control/Control.FormulaUsagePopup.ts \ src/control/Control.FormulaAutoCompletePopup.ts \ - src/control/Control.AutoFillOptions.ts \ src/control/Control.Zotero.js \ src/control/Search.js \ src/control/Permission.js \ diff --git a/browser/src/control/Control.AutoFillOptions.ts b/browser/src/control/Control.AutoFillOptions.ts deleted file mode 100644 index 15a58a802b..0000000000 --- a/browser/src/control/Control.AutoFillOptions.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- js-indent-level: 8 -*- */ -/* - * Copyright the Collabora Online contributors. - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -/* - * Control.AutoFillOptions - class for auto fill popup - * - * Auto fill popup can be seen right after dragging the auto fill marker box. - * There are two options for auto fill popup: - * - Copy cells (copies the selected cells to the marked area) - * - Fill series (increases/decreases the values of selected cells and fills them to the marked area) - */ - -/* global app */ - -class AutoFillOptions extends L.Control.AutoCompletePopup { - map: ReturnType<typeof L.map>; - newPopupData: PopupData; - firstChar: string; - users: any; - itemList: Array<any>; - data: MessageEvent<any>; - - constructor(map: ReturnType<typeof L.map>) { - super('autoFillPopup', map); - } - - onAdd() { - this.newPopupData.isAutoCompletePopup = true; - this.map.on('openautofillpopup', this.openAutoFillPopup, this); - this.map.on('closeautofillpopup', this.closeMentionPopup, this); - this.map.on('sendautofilllocation', this.sendAutoFillLocation, this); - this.firstChar = null; - this.users = null; - this.itemList = null; - } - - getAutoFillRectanglePosition(ev: FireEvent): Point { - var currPos = ev.data; - var origin = this.map.getPixelOrigin(); - var panePos = this.map._getMapPanePos(); - return new L.Point( - Math.round(currPos.x + panePos.x - origin.x), - Math.round(currPos.y + panePos.y - origin.y), - ); - } - - sendAutoFillLocation(ev: FireEvent) { - this.openAutoFillPopup({ data: ev.data }); - } - - getPopupEntries(): any[] { - const entries: any[] = [ - { text: 'copy', columns: [{ text: _('Copy cells') }], row: '0' }, - { text: 'fill', columns: [{ text: _('Fill series') }], row: '1' }, - ]; - return entries; - } - - openAutoFillPopup(ev: FireEvent): void { - const framePos = this.getAutoFillRectanglePosition(ev); // bottom-right position - const entries = this.getPopupEntries(); - let data: PopupData; - - if (entries.length > 0) { - const control = this.getTreeJSON(); - - if (L.DomUtil.get(this.popupId)) - this.closeMentionPopup({ typingMention: true } as CloseMessageEvent); - data = this.newPopupData; - data.children[0].children[0] = control; - (data.children[0].children[0] as TreeWidget).entries = entries; - } - - // add position - data.posx = framePos.x; - data.posy = framePos.y; - this.sendJSON(data); - } - - closeMentionPopup(ev: CloseMessageEvent) { - super.closePopup(); - if (!ev.typingMention) { - this.map._docLayer._typingMention = false; - this.map._docLayer._mentionText = []; - } - } - - callback(objectType: any, eventType: any, object: any, index: number) { - if (eventType === 'close') { - this.closeMentionPopup({ typingMention: false } as CloseMessageEvent); - } else if (eventType === 'select' || eventType === 'activate') { - this.map.fire('closeautofillpopup'); - - if (index == 0) { - // Copy cells - this.map.sendUnoCommand('.uno:AutoFill?Copy:bool=true'); - } else if (index == 1) { - // Fill series - this.map.sendUnoCommand('.uno:AutoFill?Copy:bool=false'); - } - } else { - return super.callback(objectType, eventType, object, index); - } - return false; - } -} -L.control.autofilloptions = function (map: any) { - return new AutoFillOptions(map); -}; diff --git a/browser/src/control/Control.ContextMenu.js b/browser/src/control/Control.ContextMenu.js index 0393416ad1..28595d996b 100644 --- a/browser/src/control/Control.ContextMenu.js +++ b/browser/src/control/Control.ContextMenu.js @@ -66,7 +66,7 @@ L.Control.ContextMenu = L.Control.extend({ 'RecalcPivotTable', 'DataDataPilotRun', 'DeletePivotTable', 'FormatCellDialog', 'DeleteNote', 'SetAnchorToCell', 'SetAnchorToCellResize', 'FormatSparklineMenu', 'InsertSparkline', 'DeleteSparkline', 'DeleteSparklineGroup', - 'EditSparklineGroup', 'EditSparkline', 'GroupSparklines', 'UngroupSparklines'], + 'EditSparklineGroup', 'EditSparkline', 'GroupSparklines', 'UngroupSparklines', 'AutoFill'], presentation: ['SetDefault'], drawing: [] @@ -97,7 +97,7 @@ L.Control.ContextMenu = L.Control.extend({ 'SpellingAndGrammarDialog', 'FontDialog', 'FontDialogForParagraph', // spreadsheet 'FormatCellDialog', 'DataDataPilotRun', - 'GroupSparklines', 'UngroupSparklines' + 'GroupSparklines', 'UngroupSparklines', 'AutoFill' ] }, @@ -109,6 +109,7 @@ L.Control.ContextMenu = L.Control.extend({ map._contextMenu = this; map.on('locontextmenu', this._onContextMenu, this); map.on('mousedown', this._onMouseDown, this); + map.on('mouseup', this._onMouseUp, this); map.on('keydown', this._onKeyDown, this); map.on('closepopups', this._onClosePopup, this); }, @@ -124,6 +125,10 @@ L.Control.ContextMenu = L.Control.extend({ this._onClosePopup(); }, + _onMouseUp: function (e) { + this._currMousePos = { x: e.originalEvent.pageX, y: e.originalEvent.pageY }; + }, + _onKeyDown: function(e) { if (e.originalEvent.keyCode === 27 /* ESC */) { $.contextMenu('destroy', '.leaflet-layer'); @@ -144,10 +149,14 @@ L.Control.ContextMenu = L.Control.extend({ var contextMenu = this._createContextMenuStructure(obj); var spellingContextMenu = false; + var autoFillContextMenu = false; for (var menuItem in contextMenu) { if (menuItem.indexOf('.uno:SpellCheckIgnore') !== -1) { spellingContextMenu = true; break; + } else if (menuItem.indexOf('.uno:AutoFill') !== -1) { + autoFillContextMenu = true; + break; } } if (window.mode.isMobile()) { @@ -178,7 +187,10 @@ L.Control.ContextMenu = L.Control.extend({ } }); - $('.leaflet-layer').contextMenu(this._prevMousePos); + if (autoFillContextMenu) + $('.leaflet-layer').contextMenu(this._currMousePos); + else + $('.leaflet-layer').contextMenu(this._prevMousePos); this.hasContextMenu = true; } }, @@ -221,6 +233,22 @@ L.Control.ContextMenu = L.Control.extend({ item.menu = undefined; } + if (item.type === 'command' && item.text.replace('~', '') === 'Copy Cells' + && item.menu && item.menu.length) { + item.text = _('Copy Cells'); + item.command = '.uno:AutoFill?Copy:bool=true'; + item.type = item.menu[0].type; + item.menu = undefined; + } + + if (item.type === 'command' && item.text.replace('~', '') === 'Fill Series' + && item.menu && item.menu.length) { + item.text = _('Fill Series'); + item.command = '.uno:AutoFill?Copy:bool=false'; + item.type = item.menu[0].type; + item.menu = undefined; + } + if (item.type === 'separator') { if (isLastItemText) { contextMenu['sep' + sepIdx++] = this.options.SEPARATOR; diff --git a/browser/src/control/Control.JSDialog.js b/browser/src/control/Control.JSDialog.js index a794921d8e..223a5c1fb5 100644 --- a/browser/src/control/Control.JSDialog.js +++ b/browser/src/control/Control.JSDialog.js @@ -604,9 +604,6 @@ L.Control.JSDialog = L.Control.extend({ // Call this.close(key, true) for the current dialog this.close(autoFilterDialogId, true); } - - if (dialog.isAutoFillPopup) - this.close(autoFilterDialogId); } }, @@ -640,8 +637,7 @@ L.Control.JSDialog = L.Control.extend({ instance.isDocumentAreaPopup = instance.popupParent === '_POPOVER_' && instance.posx !== undefined && instance.posy !== undefined; instance.isPopup = instance.isModalPopUp || instance.isDocumentAreaPopup || instance.isSnackbar; instance.containerParent = instance.isDocumentAreaPopup ? document.getElementById('document-container'): document.body; - instance.isAutoFillPopup = instance.id === 'autoFillPopup'; - instance.isAutofilter = instance.isDocumentAreaPopup && this.map._docLayer.isCalc() && !instance.isAutoFillPopup; + instance.isAutofilter = instance.isDocumentAreaPopup && this.map._docLayer.isCalc(); instance.haveTitlebar = (!instance.isModalPopUp && !instance.isSnackbar) || (instance.hasClose && instance.title && instance.title !== ''); instance.nonModal = !instance.isModalPopUp && !instance.isDocumentAreaPopup && !instance.isSnackbar; @@ -711,9 +707,6 @@ L.Control.JSDialog = L.Control.extend({ if (instance.isAutofilter) this.calculateAutoFilterPosition(instance); - if (instance.isAutoFillPopup) - this.calculateAutoFilterPosition(instance); - this.dialogs[instance.id] = instance; if (instance.isSnackbar && instance.snackbarTimeout > 0) { diff --git a/browser/src/control/Control.Tabs.js b/browser/src/control/Control.Tabs.js index 8413004627..2212f5a691 100644 --- a/browser/src/control/Control.Tabs.js +++ b/browser/src/control/Control.Tabs.js @@ -272,6 +272,7 @@ L.Control.Tabs = L.Control.extend({ if (part === selectedPart) { // close auto filter popups on sheet tab selected this._map.fire('closeAutoFilterDialog'); + this._map.fire('closepopups'); L.DomUtil.addClass(this._spreadsheetTabs[key], 'spreadsheet-tab-selected'); } } diff --git a/browser/src/control/Control.UIManager.js b/browser/src/control/Control.UIManager.js index d3344d7c59..41f600e1bd 100644 --- a/browser/src/control/Control.UIManager.js +++ b/browser/src/control/Control.UIManager.js @@ -217,7 +217,6 @@ L.Control.UIManager = L.Control.extend({ this.map.mention = L.control.mention(this.map); this.map.formulaautocomplete = L.control.formulaautocomplete(this.map); this.map.formulausage = L.control.formulausage(this.map); - this.map.autofilloptions = L.control.autofilloptions(this.map); } this.map.jsdialog = L.control.jsDialog(); diff --git a/browser/src/layer/marker/TextInput.js b/browser/src/layer/marker/TextInput.js index 7f462f923d..7df2464f55 100644 --- a/browser/src/layer/marker/TextInput.js +++ b/browser/src/layer/marker/TextInput.js @@ -978,11 +978,6 @@ L.TextInput = L.Layer.extend({ this._map.fire('closementionpopup', { 'typingMention': false }); else if (id === 'formulaautocompletePopup') this._map.fire('closeformulapopup'); - else if (id === 'autoFillPopup') - this._map.fire('closeautofillpopup'); - - } else if (ev.key === ' ' && id === 'autoFillPopup') { // special case for autoFillPopup, close if SPACE button pressed. - this._map.fire('closeautofillpopup'); } } }, @@ -1135,7 +1130,6 @@ L.TextInput = L.Layer.extend({ this._handleKeyDownForPopup(ev, 'mentionPopup'); this._handleKeyDownForPopup(ev, 'formulaautocompletePopup'); - this._handleKeyDownForPopup(ev, 'autoFillPopup'); }, // Check arrow keys on 'keyup' event; using 'ArrowLeft' or 'ArrowRight' diff --git a/browser/src/layer/tile/CalcTileLayer.js b/browser/src/layer/tile/CalcTileLayer.js index 6e8910a14b..a21570b039 100644 --- a/browser/src/layer/tile/CalcTileLayer.js +++ b/browser/src/layer/tile/CalcTileLayer.js @@ -88,7 +88,6 @@ L.CalcTileLayer = L.CanvasTileLayer.extend({ app.sectionContainer.addSection(new app.definitions.AutoFillMarkerSection()); this.insertMode = false; - this.autoFillLocation = {}; this._resetInternalState(); this._sheetSwitch = new L.SheetSwitchViewRestore(map); this._sheetGrid = true; diff --git a/browser/src/layer/tile/CanvasTileLayer.js b/browser/src/layer/tile/CanvasTileLayer.js index 1664be7e60..9cc6dbbd6c 100644 --- a/browser/src/layer/tile/CanvasTileLayer.js +++ b/browser/src/layer/tile/CanvasTileLayer.js @@ -1440,9 +1440,6 @@ L.CanvasTileLayer = L.Layer.extend({ else if (textMsg.startsWith('cellautofillarea:')) { this._onCellAutoFillAreaMsg(textMsg); } - else if (textMsg.startsWith('cellactions:')) { - this._onCellActionsMsg(); - } else if (textMsg.startsWith('complexselection:')) { if (this._map._clip) this._map._clip.onComplexSelection(textMsg.substr('complexselection:'.length)); @@ -3219,18 +3216,12 @@ L.CanvasTileLayer = L.Layer.extend({ var topLeftPixels = this._twipsToCorePixels(topLeftTwips); var offsetPixels = this._twipsToCorePixels(offset); this._cellAutoFillAreaPixels = L.LOUtil.createRectangle(topLeftPixels.x, topLeftPixels.y, offsetPixels.x, offsetPixels.y); - this._map._docLayer.autoFillLocation = { data: topLeftPixels }; } else { this._cellAutoFillAreaPixels = null; } }, - _onCellActionsMsg: function () { - // TODO: don't open AutoFill popup if empty cells are selected - this._map.fire('sendautofilllocation', this._map._docLayer.autoFillLocation); - }, - _onDialogPaintMsg: function(textMsg, img) { var command = app.socket.parseServerCmd(textMsg); diff --git a/browser/src/unocommands.js b/browser/src/unocommands.js index b9b077dafa..c6e04a2824 100644 --- a/browser/src/unocommands.js +++ b/browser/src/unocommands.js @@ -23,6 +23,7 @@ var unoCommandsArray = { 'AnchorMenu':{global:{menu:_('Anc~hor'),},}, 'ArrangeFrameMenu':{text:{menu:_('Arrange'),},}, 'ArrangeMenu':{global:{menu:_('A~rrange'),},presentation:{menu:_('~Arrange'),},}, + 'AutoFill':{spreadsheet:{menu:_('Auto Fill'),},}, 'AutoFormatMenu':{text:{menu:_('AutoCorr~ect'),},}, 'BackColor':{text:{menu:_('Character Highlighting Color'),},}, 'BackgroundColor':{global:{menu:_('Background Color'),},}, diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 67855796ad..8bf2492069 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -3191,9 +3191,6 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) case LOK_CALLBACK_CELL_AUTO_FILL_AREA: sendTextFrame("cellautofillarea: " + payload); break; - case LOK_CALLBACK_CELL_ACTIONS: - sendTextFrame("cellactions: " + payload); - break; case LOK_CALLBACK_TABLE_SELECTED: sendTextFrame("tableselected: " + payload); break; |