From 299239648262b0167beb514e8c23d32628c6c4bb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 10 Mar 2022 19:21:29 +0300 Subject: [PATCH 01/10] [DE] Edit ole objects --- .../main/lib/controller/ExternalOleEditor.js | 260 ++++++++++++++++++ .../common/main/lib/view/ExternalOleEditor.js | 164 +++++++++++ apps/documenteditor/main/app.js | 2 + .../main/app/controller/DocumentHolder.js | 21 ++ .../main/app/controller/Main.js | 1 + .../main/app/view/DocumentHolder.js | 12 + apps/documenteditor/main/app_dev.js | 2 + .../main/app/controller/Main.js | 20 ++ 8 files changed, 482 insertions(+) create mode 100644 apps/common/main/lib/controller/ExternalOleEditor.js create mode 100644 apps/common/main/lib/view/ExternalOleEditor.js diff --git a/apps/common/main/lib/controller/ExternalOleEditor.js b/apps/common/main/lib/controller/ExternalOleEditor.js new file mode 100644 index 000000000..91393ea99 --- /dev/null +++ b/apps/common/main/lib/controller/ExternalOleEditor.js @@ -0,0 +1,260 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2022 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * ExternalOleEditor.js + * + * Created by Julia Radzhabova on 3/10/22 + * Copyright (c) 2022 Ascensio System SIA. All rights reserved. + * + */ + +if (Common === undefined) + var Common = {}; + +Common.Controllers = Common.Controllers || {}; + +define([ + 'core', + 'common/main/lib/view/ExternalOleEditor' +], function () { 'use strict'; + Common.Controllers.ExternalOleEditor = Backbone.Controller.extend(_.extend((function() { + var appLang = '{{DEFAULT_LANG}}', + customization = undefined, + targetApp = '', + externalEditor = null, + isAppFirstOpened = true; + + + var createExternalEditor = function() { + !!customization && (customization.uiTheme = Common.localStorage.getItem("ui-theme-id", "theme-light")); + externalEditor = new DocsAPI.DocEditor('id-ole-editor-placeholder', { + width : '100%', + height : '100%', + documentType: 'cell', + document : { + url : '_chart_', + permissions : { + edit : true, + download: false + } + }, + editorConfig: { + // mode : 'editole', + mode : 'editdiagram', + targetApp : targetApp, + lang : appLang, + canCoAuthoring : false, + canBackToFolder : false, + canCreateNew : false, + customization : customization, + user : {id: ('uid-'+Date.now())} + }, + events: { + 'onAppReady' : function() {}, + 'onDocumentStateChange' : function() {}, + 'onError' : function() {}, + 'onInternalMessage' : _.bind(this.onInternalMessage, this) + } + }); + Common.Gateway.on('processmouse', _.bind(this.onProcessMouse, this)); + }; + + return { + views: ['Common.Views.ExternalOleEditor'], + + initialize: function() { + this.addListeners({ + 'Common.Views.ExternalOleEditor': { + 'setoledata': _.bind(this.setOleData, this), + 'drag': _.bind(function(o, state){ + externalEditor && externalEditor.serviceCommand('window:drag', state == 'start'); + },this), + 'show': _.bind(function(cmp){ + var h = this.oleEditorView.getHeight(), + innerHeight = Common.Utils.innerHeight() - Common.Utils.InternalSettings.get('window-inactive-area-top'); + if (innerHeight>h && h<700 || innerHeight', + '
', + '', + '
', + '' + ].join(''); + + _options.tpl = _.template(this.template)(_options); + + this.handler = _options.handler; + this._oleData = null; + this._isNewOle = true; + Common.UI.Window.prototype.initialize.call(this, _options); + }, + + render: function() { + Common.UI.Window.prototype.render.call(this); + + this.btnSave = new Common.UI.Button({ + el: $('#id-btn-ole-editor-apply'), + disabled: true + }); + this.btnCancel = new Common.UI.Button({ + el: $('#id-btn-ole-editor-cancel') + }); + + this.$window.find('.dlg-btn').on('click', _.bind(this.onDlgBtnClick, this)); + }, + + show: function() { + this.setPlaceholder(); + Common.UI.Window.prototype.show.apply(this, arguments); + }, + + setOleData: function(data) { + this._oleData = data; + if (this._isExternalDocReady) + this.fireEvent('setoledata', this); + }, + + setEditMode: function(mode) { + this._isNewOle = !mode; + }, + + isEditMode: function() { + return !this._isNewOle; + }, + + setControlsDisabled: function(disable) { + this.btnSave.setDisabled(disable); + this.btnCancel.setDisabled(disable); + (disable) ? this.$window.find('.tool.close').addClass('disabled') : this.$window.find('.tool.close').removeClass('disabled'); + }, + + onDlgBtnClick: function(event) { + if ( this.handler ) { + this.handler.call(this, event.currentTarget.attributes['result'].value); + return; + } + this.hide(); + }, + + onToolClose: function() { + if ( this.handler ) { + this.handler.call(this, 'cancel'); + return; + } + this.hide(); + }, + + setHeight: function(height) { + if (height >= 0) { + var min = parseInt(this.$window.css('min-height')); + height < min && (height = min); + this.$window.height(height); + + var header_height = (this.initConfig.header) ? parseInt(this.$window.find('> .header').css('height')) : 0; + + this.$window.find('> .body').css('height', height-header_height); + this.$window.find('> .body > .box').css('height', height-85); + + var top = (Common.Utils.innerHeight() - Common.Utils.InternalSettings.get('window-inactive-area-top') - parseInt(height)) / 2; + var left = (Common.Utils.innerWidth() - parseInt(this.initConfig.width)) / 2; + + this.$window.css('left',left); + this.$window.css('top', Common.Utils.InternalSettings.get('window-inactive-area-top') + top); + } + }, + + setPlaceholder: function(placeholder) { + this._placeholder = placeholder; + }, + + getPlaceholder: function() { + return this._placeholder; + }, + + textSave: 'Save & Exit', + textClose: 'Close', + textTitle: 'Spreadsheet Editor' + }, Common.Views.ExternalOleEditor || {})); +}); diff --git a/apps/documenteditor/main/app.js b/apps/documenteditor/main/app.js index 3e2a27386..c8fffa7c4 100644 --- a/apps/documenteditor/main/app.js +++ b/apps/documenteditor/main/app.js @@ -167,6 +167,7 @@ require([ ,'Common.Controllers.Plugins' ,'Common.Controllers.ExternalDiagramEditor' ,'Common.Controllers.ExternalMergeEditor' + ,'Common.Controllers.ExternalOleEditor' ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ] @@ -207,6 +208,7 @@ require([ ,'documenteditor/main/app/view/ChartSettings' ,'common/main/lib/controller/ExternalDiagramEditor' ,'common/main/lib/controller/ExternalMergeEditor' + ,'common/main/lib/controller/ExternalOleEditor' ,'common/main/lib/controller/ReviewChanges' ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Themes' diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index 55f341fba..012df13e6 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -163,6 +163,27 @@ define([ }, 10); }, this)); } + + var oleEditor = this.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); + if (oleEditor) { + diagramEditor.on('internalmessage', _.bind(function(cmp, message) { + var command = message.data.command; + var data = message.data.data; + if (this.api) { + if (oleEditor.isEditMode()) + this.api.asc_editTableOleObject(data); + } + }, this)); + diagramEditor.on('hide', _.bind(function(cmp, message) { + if (this.api) { + this.api.asc_enableKeyEvents(true); + } + var me = this; + setTimeout(function(){ + me.documentHolder.fireEvent('editcomplete', me.documentHolder); + }, 10); + }, this)); + } }, getView: function (name) { diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 93d5356e0..cdbbbdbb6 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1234,6 +1234,7 @@ define([ chatController.setApi(this.api).setMode(this.appOptions); application.getController('Common.Controllers.ExternalDiagramEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); application.getController('Common.Controllers.ExternalMergeEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); + application.getController('Common.Controllers.ExternalOleEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); pluginsController.setApi(me.api); diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index a654d9f8d..9092fe7fc 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -802,6 +802,17 @@ define([ } } }; + + var onDoubleClickOnTableOleObject = function(chart) { + if (me.mode.isEdit && !me._isDisabled) { + var oleEditor = DE.getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); + if (oleEditor && chart) { + oleEditor.setEditMode(true); + oleEditor.show(); + oleEditor.setOleData(Asc.asc_putBinaryDataToFrameFromTableOleObject(chart)); + } + } + }; var onCoAuthoringDisconnect= function() { me.mode.isEdit = false; @@ -1596,6 +1607,7 @@ define([ this.api.asc_registerCallback('asc_onImgWrapStyleChanged', _.bind(this.onImgWrapStyleChanged, this)); this.api.asc_registerCallback('asc_onDialogAddHyperlink', onDialogAddHyperlink); this.api.asc_registerCallback('asc_doubleClickOnChart', onDoubleClickOnChart); + this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', onDoubleClickOnTableOleObject); this.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, this)); this.api.asc_registerCallback('asc_onRulerDblClick', _.bind(this.onRulerDblClick, this)); this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this)); diff --git a/apps/documenteditor/main/app_dev.js b/apps/documenteditor/main/app_dev.js index cb8cdd5a4..a43f32677 100644 --- a/apps/documenteditor/main/app_dev.js +++ b/apps/documenteditor/main/app_dev.js @@ -157,6 +157,7 @@ require([ ,'Common.Controllers.Plugins' ,'Common.Controllers.ExternalDiagramEditor' ,'Common.Controllers.ExternalMergeEditor' + ,'Common.Controllers.ExternalOleEditor' ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ] @@ -197,6 +198,7 @@ require([ ,'documenteditor/main/app/view/ChartSettings' ,'common/main/lib/controller/ExternalDiagramEditor' ,'common/main/lib/controller/ExternalMergeEditor' + ,'common/main/lib/controller/ExternalOleEditor' ,'common/main/lib/controller/ReviewChanges' ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Themes' diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 6a093031b..a9f113ee4 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2491,6 +2491,8 @@ define([ case 'clearChartData': this.clearChartData(); break; case 'setMergeData': this.setMergeData(data.data); break; case 'getMergeData': this.getMergeData(); break; + case 'setOleData': this.setOleData(data.data); break; + case 'getOleData': this.getOleData(); break; case 'setAppDisabled': if (this.isAppDisabled===undefined && !data.data) { // first editor opening Common.NotificationCenter.trigger('layout:changed', 'main'); @@ -2545,6 +2547,24 @@ define([ this.api && this.api.asc_closeCellEditor(); }, + setOleData: function(obj) { + if (typeof obj === 'object' && this.api) { + this.api.asc_addTableOleObject(obj); + this.isFrameClosed = false; + } + }, + + getOleData: function() { + if (this.api) { + var oleData = this.api.asc_getBinaryInfoOleObject(); + if (typeof oleData === 'object') { + Common.Gateway.internalMessage('oleData', { + data: oleData + }); + } + } + }, + setMergeData: function(merge) { if (typeof merge === 'object' && this.api) { this.api.asc_setData(merge); From 45186d4a0c4a505f0a411b9ce78aa0b8b1899224 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 11 Mar 2022 13:04:30 +0300 Subject: [PATCH 02/10] [DE] Refactoring --- apps/documenteditor/main/app/controller/DocumentHolder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index 012df13e6..2e221d0ff 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -166,7 +166,7 @@ define([ var oleEditor = this.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); if (oleEditor) { - diagramEditor.on('internalmessage', _.bind(function(cmp, message) { + oleEditor.on('internalmessage', _.bind(function(cmp, message) { var command = message.data.command; var data = message.data.data; if (this.api) { @@ -174,7 +174,7 @@ define([ this.api.asc_editTableOleObject(data); } }, this)); - diagramEditor.on('hide', _.bind(function(cmp, message) { + oleEditor.on('hide', _.bind(function(cmp, message) { if (this.api) { this.api.asc_enableKeyEvents(true); } From fab188cb2364d06889f44ed09ee24f0b4f85ad84 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 11 Mar 2022 13:58:15 +0300 Subject: [PATCH 03/10] [SSE] Add mode 'editole' for ole objects --- apps/api/documents/api.js | 4 +- apps/common/main/lib/controller/Chat.js | 2 +- .../main/lib/controller/ExternalOleEditor.js | 3 +- apps/common/main/lib/controller/Plugins.js | 2 +- .../main/app/controller/CellEditor.js | 8 +- .../main/app/controller/DataTab.js | 2 +- .../main/app/controller/DocumentHolder.js | 12 ++- .../main/app/controller/LeftMenu.js | 10 +- .../main/app/controller/Main.js | 56 +++++----- .../main/app/controller/Statusbar.js | 4 +- .../main/app/controller/Toolbar.js | 102 +++++++++++++++--- .../main/app/controller/ViewTab.js | 2 +- .../main/app/controller/Viewport.js | 6 +- .../main/app/template/ToolbarAnother.template | 35 ++++++ .../main/app/view/Statusbar.js | 8 +- .../main/app/view/Toolbar.js | 10 +- 16 files changed, 189 insertions(+), 77 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index f0f72168d..bd8ed790e 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -913,7 +913,7 @@ if ( typeof(customization) == 'object' && ( customization.toolbarNoTabs || (config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) { index = "/index_loader.html"; - } else if (config.editorConfig.mode === 'editdiagram' || config.editorConfig.mode === 'editmerge') + } else if (config.editorConfig.mode === 'editdiagram' || config.editorConfig.mode === 'editmerge' || config.editorConfig.mode === 'editole') index = "/index_internal.html"; } @@ -947,7 +947,7 @@ } } - if (config.editorConfig && (config.editorConfig.mode == 'editdiagram' || config.editorConfig.mode == 'editmerge')) + if (config.editorConfig && (config.editorConfig.mode == 'editdiagram' || config.editorConfig.mode == 'editmerge' || config.editorConfig.mode == 'editole')) params += "&internal=true"; if (config.frameEditorId) diff --git a/apps/common/main/lib/controller/Chat.js b/apps/common/main/lib/controller/Chat.js index 002c178cc..04d8474df 100644 --- a/apps/common/main/lib/controller/Chat.js +++ b/apps/common/main/lib/controller/Chat.js @@ -95,7 +95,7 @@ define([ if (this.mode.canCoAuthoring && this.mode.canChat) this.api.asc_registerCallback('asc_onCoAuthoringChatReceiveMessage', _.bind(this.onReceiveMessage, this)); - if ( !this.mode.isEditDiagram && !this.mode.isEditMailMerge ) { + if ( !this.mode.isEditDiagram && !this.mode.isEditMailMerge && !this.mode.isEditOle ) { this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this)); this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this)); this.api.asc_coAuthoringGetUsers(); diff --git a/apps/common/main/lib/controller/ExternalOleEditor.js b/apps/common/main/lib/controller/ExternalOleEditor.js index 91393ea99..35de11350 100644 --- a/apps/common/main/lib/controller/ExternalOleEditor.js +++ b/apps/common/main/lib/controller/ExternalOleEditor.js @@ -69,8 +69,7 @@ define([ } }, editorConfig: { - // mode : 'editole', - mode : 'editdiagram', + mode : 'editole', targetApp : targetApp, lang : appLang, canCoAuthoring : false, diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 98d3f0c56..9632e386e 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -63,7 +63,7 @@ define([ 'render:before' : function (toolbar) { var appOptions = me.getApplication().getController('Main').appOptions; - if ( !appOptions.isEditMailMerge && !appOptions.isEditDiagram ) { + if ( !appOptions.isEditMailMerge && !appOptions.isEditDiagram && !appOptions.isEditOle ) { var tab = {action: 'plugins', caption: me.panelPlugins.groupCaption, dataHintTitle: 'E', layoutname: 'toolbar-plugins'}; me.$toolbarPanelPlugins = me.panelPlugins.getPanel(); diff --git a/apps/spreadsheeteditor/main/app/controller/CellEditor.js b/apps/spreadsheeteditor/main/app/controller/CellEditor.js index 7462d143d..b79e41345 100644 --- a/apps/spreadsheeteditor/main/app/controller/CellEditor.js +++ b/apps/spreadsheeteditor/main/app/controller/CellEditor.js @@ -97,7 +97,7 @@ define([ this.mode = mode; this.editor.$btnfunc[this.mode.isEdit?'removeClass':'addClass']('disabled'); - this.editor.btnNamedRanges.setVisible(this.mode.isEdit && !this.mode.isEditDiagram && !this.mode.isEditMailMerge); + this.editor.btnNamedRanges.setVisible(this.mode.isEdit && !this.mode.isEditDiagram && !this.mode.isEditMailMerge && !this.mode.isEditOle); if ( this.mode.isEdit ) { this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); @@ -156,7 +156,7 @@ define([ if (this.viewmode) return; // signed file var seltype = info.asc_getSelectionType(), - coauth_disable = (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) ? (info.asc_getLocked() === true || info.asc_getLockedTable() === true || info.asc_getLockedPivotTable()===true) : false; + coauth_disable = (!this.mode.isEditMailMerge && !this.mode.isEditDiagram && !this.mode.isEditOle) ? (info.asc_getLocked() === true || info.asc_getLockedTable() === true || info.asc_getLockedPivotTable()===true) : false; var is_chart_text = seltype == Asc.c_oAscSelectionType.RangeChartText, is_chart = seltype == Asc.c_oAscSelectionType.RangeChart, @@ -326,14 +326,14 @@ define([ SetDisabled: function(disabled) { this.editor.$btnfunc[!disabled && this.mode.isEdit ?'removeClass':'addClass']('disabled'); - this.editor.btnNamedRanges.setVisible(!disabled && this.mode.isEdit && !this.mode.isEditDiagram && !this.mode.isEditMailMerge); + this.editor.btnNamedRanges.setVisible(!disabled && this.mode.isEdit && !this.mode.isEditDiagram && !this.mode.isEditMailMerge && !this.mode.isEditOle); }, setPreviewMode: function(mode) { if (this.viewmode === mode) return; this.viewmode = mode; this.editor.$btnfunc[!mode && this.mode.isEdit?'removeClass':'addClass']('disabled'); - this.editor.cellNameDisabled(mode && !(this.mode.isEdit && !this.mode.isEditDiagram && !this.mode.isEditMailMerge)); + this.editor.cellNameDisabled(mode && !(this.mode.isEdit && !this.mode.isEditDiagram && !this.mode.isEditMailMerge && !this.mode.isEditOle)); } }); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index dd21ed81c..de94aa22f 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -440,7 +440,7 @@ define([ }, onApiSheetChanged: function() { - if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return; + if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge || this.toolbar.mode.isEditOle) return; var currentSheet = this.api.asc_getActiveWorksheetIndex(); this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index ff6f867fe..6113b60b6 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1832,7 +1832,7 @@ define([ isPivotLocked = cellinfo.asc_getLockedPivotTable()===true, isObjLocked = false, commentsController = this.getApplication().getController('Common.Controllers.Comments'), - internaleditor = this.permissions.isEditMailMerge || this.permissions.isEditDiagram, + internaleditor = this.permissions.isEditMailMerge || this.permissions.isEditDiagram || this.permissions.isEditOle, xfs = cellinfo.asc_getXfs(), isSmartArt = false, isSmartArtInternal = false; @@ -2059,8 +2059,10 @@ define([ if (showMenu) this.showPopupMenu(documentHolder.textInShapeMenu, {}, event); documentHolder.menuParagraphBullets.setDisabled(isSmartArt || isSmartArtInternal); - } else if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram || (seltype !== Asc.c_oAscSelectionType.RangeImage && seltype !== Asc.c_oAscSelectionType.RangeShape && - seltype !== Asc.c_oAscSelectionType.RangeChart && seltype !== Asc.c_oAscSelectionType.RangeChartText && seltype !== Asc.c_oAscSelectionType.RangeShapeText && seltype !== Asc.c_oAscSelectionType.RangeSlicer)) { + } else if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle || + (seltype !== Asc.c_oAscSelectionType.RangeImage && seltype !== Asc.c_oAscSelectionType.RangeShape && + seltype !== Asc.c_oAscSelectionType.RangeChart && seltype !== Asc.c_oAscSelectionType.RangeChartText && + seltype !== Asc.c_oAscSelectionType.RangeShapeText && seltype !== Asc.c_oAscSelectionType.RangeSlicer)) { if (!documentHolder.ssMenu || !showMenu && !documentHolder.ssMenu.isVisible()) return; var iscelledit = this.api.isCellEdited, @@ -2213,9 +2215,9 @@ define([ isCellLocked = cellinfo.asc_getLocked(), isTableLocked = cellinfo.asc_getLockedTable()===true, commentsController = this.getApplication().getController('Common.Controllers.Comments'), - iscellmenu = (seltype==Asc.c_oAscSelectionType.RangeCells) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram, + iscellmenu = (seltype==Asc.c_oAscSelectionType.RangeCells) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle, iscelledit = this.api.isCellEdited, - isimagemenu = (seltype==Asc.c_oAscSelectionType.RangeShape || seltype==Asc.c_oAscSelectionType.RangeImage) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram, + isimagemenu = (seltype==Asc.c_oAscSelectionType.RangeShape || seltype==Asc.c_oAscSelectionType.RangeImage) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle, signGuid; if (!documentHolder.viewModeMenu) diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 6c691cf16..fb1f2b32d 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -176,7 +176,7 @@ define([ } } /** coauthoring end **/ - if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) + if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram && !this.mode.isEditOle) this.api.asc_registerCallback('asc_onEditCell', _.bind(this.onApiEditCell, this)); this.leftMenu.getMenu('file').setApi(api); if (this.mode.canUseHistory) @@ -249,7 +249,7 @@ define([ (this.mode.trialMode || this.mode.isBeta) && this.leftMenu.setDeveloperMode(this.mode.trialMode, this.mode.isBeta, this.mode.buildVersion); /** coauthoring end **/ Common.util.Shortcuts.resumeEvents(); - if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) + if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram && !this.mode.isEditOle) Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this)); return this; }, @@ -867,6 +867,7 @@ define([ if (this.mode.isEditDiagram && s!='escape') return false; if (this.mode.isEditMailMerge && s!='escape' && s!='search') return false; + if (this.mode.isEditOle && s!='escape' && s!='search') return false; switch (s) { case 'replace': @@ -877,7 +878,8 @@ define([ this.leftMenu.btnSearch.toggle(true,true); this.leftMenu.btnAbout.toggle(false); - this.leftMenu.menuFile.hide(); + if ( this.leftMenu.menuFile.isVisible() ) + this.leftMenu.menuFile.hide(); } return false; case 'save': @@ -931,7 +933,7 @@ define([ } return false; } - if (this.mode.isEditDiagram || this.mode.isEditMailMerge) { + if (this.mode.isEditDiagram || this.mode.isEditMailMerge || this.mode.isEditOle) { menu_opened = $(document.body).find('.open > .dropdown-menu'); if (!this.api.isCellEdited && !menu_opened.length) { Common.Gateway.internalMessage('shortcut', {key:'escape'}); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a9f113ee4..9e6f9796e 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -398,6 +398,7 @@ define([ this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl; this.appOptions.isEditDiagram = this.editorConfig.mode == 'editdiagram'; this.appOptions.isEditMailMerge = this.editorConfig.mode == 'editmerge'; + this.appOptions.isEditOle = this.editorConfig.mode == 'editole'; this.appOptions.canRequestClose = this.editorConfig.canRequestClose; this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object') && (!_.isEmpty(this.editorConfig.customization.goback.url) || this.editorConfig.customization.goback.requestClose && this.appOptions.canRequestClose); @@ -414,7 +415,7 @@ define([ this.appOptions.canFeaturePivot = true; this.appOptions.canFeatureViews = true; - if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge) + if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle) Common.NotificationCenter.on('user:rename', _.bind(this.showRenameUserDialog, this)); this.headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header'); @@ -464,7 +465,7 @@ define([ this.appOptions.wopi = this.editorConfig.wopi; - this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge); + this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); Common.Controllers.Desktop.init(this.appOptions); if (this.appOptions.isEditDiagram) { @@ -852,7 +853,7 @@ define([ me.hidePreloader(); me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); - value = (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram) ? 100 : Common.localStorage.getItem("sse-settings-zoom"); + value = (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram || this.appOptions.isEditOle) ? 100 : Common.localStorage.getItem("sse-settings-zoom"); Common.Utils.InternalSettings.set("sse-settings-zoom", value); var zf = (value!==null) ? parseInt(value)/100 : (this.appOptions.customization && this.appOptions.customization.zoom ? parseInt(this.appOptions.customization.zoom)/100 : 1); this.api.asc_setZoom(zf>0 ? zf : 1); @@ -908,14 +909,14 @@ define([ leftMenuView.getMenu('file').loadDocument({doc:me.appOptions.spreadsheet}); leftmenuController.setMode(me.appOptions).createDelayedElements().setApi(me.api); - if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { + if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && !me.appOptions.isEditOle) { pluginsController.setApi(me.api); this.api && this.api.asc_setFrozenPaneBorderType(Common.localStorage.getBool('sse-freeze-shadow', true) ? Asc.c_oAscFrozenPaneBorderType.shadow : Asc.c_oAscFrozenPaneBorderType.line); } leftMenuView.disableMenu('all',false); - if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && me.appOptions.canBranding) { + if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && !me.appOptions.isEditOle && me.appOptions.canBranding) { me.getApplication().getController('LeftMenu').leftMenu.getMenu('about').setLicInfo(me.editorConfig.customization); } @@ -952,7 +953,7 @@ define([ } var timer_sl = setInterval(function(){ - if (window.styles_loaded || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) { + if (window.styles_loaded || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge || me.appOptions.isEditOle) { clearInterval(timer_sl); Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + me.api.asc_getActiveWorksheetId()]); @@ -961,7 +962,7 @@ define([ toolbarController.createDelayedElements(); me.setLanguages(); - if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { + if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && !me.appOptions.isEditOle) { var shapes = me.api.asc_getPropertyEditorShapes(); if (shapes) me.fillAutoShapes(shapes[0], shapes[1]); @@ -994,7 +995,7 @@ define([ me.applyLicense(); } // TODO bug 43960 - if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { + if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && !me.appOptions.isEditOle) { var dummyClass = ~~(1e6*Math.random()); $('.toolbar').prepend(Common.Utils.String.format('
', dummyClass)); setTimeout(function() { $(Common.Utils.String.format('.toolbar .lazy-{0}', dummyClass)).remove(); }, 10); @@ -1031,12 +1032,12 @@ define([ } else checkWarns(); Common.Gateway.documentReady(); - if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && (Common.Utils.InternalSettings.get("guest-username")===null)) + if (this.appOptions.user.guest && this.appOptions.canRenameAnonymous && !this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle && (Common.Utils.InternalSettings.get("guest-username")===null)) this.showRenameUserDialog(); }, onLicenseChanged: function(params) { - if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) return; + if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) return; var licType = params.asc_getLicenseType(); if (licType !== undefined && (this.appOptions.canEdit || this.appOptions.isRestrictedEdit) && this.editorConfig.mode !== 'view' && @@ -1089,7 +1090,7 @@ define([ } }); } - } else if (!this.appOptions.isDesktopApp && !this.appOptions.canBrandingExt && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && + } else if (!this.appOptions.isDesktopApp && !this.appOptions.canBrandingExt && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) && this.editorConfig && this.editorConfig.customization && (this.editorConfig.customization.loaderName || this.editorConfig.customization.loaderLogo)) { Common.UI.warning({ title: this.textPaidFeature, @@ -1185,7 +1186,7 @@ define([ onEditorPermissions: function(params) { var licType = params ? params.asc_getLicenseType() : Asc.c_oLicenseResult.Error; - if ( params && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge)) { + if ( params && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle)) { if (Asc.c_oLicenseResult.Expired === licType || Asc.c_oLicenseResult.Error === licType || Asc.c_oLicenseResult.ExpiredTrial === licType) { Common.UI.warning({ title: this.titleLicenseExp, @@ -1251,10 +1252,10 @@ define([ this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights; this.appOptions.canEdit = this.permissions.edit !== false && // can edit (this.editorConfig.canRequestEditRights || this.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined - this.appOptions.isEdit = (this.appOptions.canLicense || this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && this.permissions.edit !== false && this.editorConfig.mode !== 'view'; + this.appOptions.isEdit = (this.appOptions.canLicense || this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) && this.permissions.edit !== false && this.editorConfig.mode !== 'view'; this.appOptions.canDownload = (this.permissions.download !== false); this.appOptions.canPrint = (this.permissions.print !== false); - this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && + this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave); this.appOptions.forcesave = this.appOptions.canForcesave; this.appOptions.canEditComments= this.appOptions.isOffline || !this.permissions.editCommentAuthorOnly; @@ -1265,17 +1266,17 @@ define([ this.appOptions.canEditComments = this.appOptions.canDeleteComments = this.appOptions.isOffline; } this.appOptions.isSignatureSupport= this.appOptions.isEdit && this.appOptions.isDesktopApp && this.appOptions.isOffline && this.api.asc_isSignaturesSupport() && (this.permissions.protect!==false) - && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge); + && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); this.appOptions.isPasswordSupport = this.appOptions.isEdit && this.api.asc_isProtectionSupport() && (this.permissions.protect!==false) - && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge); + && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); this.appOptions.canProtect = (this.appOptions.isSignatureSupport || this.appOptions.isPasswordSupport); this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && this.appOptions.canComments; - this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && this.appOptions.canCoAuthoring && + this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) && this.appOptions.canCoAuthoring && !(typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false); - if (!this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge) { + if (!this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle) { this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout); @@ -1354,7 +1355,7 @@ define([ statusbarView = app.getController('Statusbar').getView('Statusbar'); if (this.headerView) { - this.headerView.setVisible(!this.appOptions.isEditMailMerge && !this.appOptions.isDesktopApp && !this.appOptions.isEditDiagram); + this.headerView.setVisible(!this.appOptions.isEditMailMerge && !this.appOptions.isDesktopApp && !this.appOptions.isEditDiagram && !this.appOptions.isEditOle); } viewport && viewport.setMode(this.appOptions, true); @@ -1366,6 +1367,8 @@ define([ if (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram) { statusbarView.hide(); + } + if (this.appOptions.isEditMailMerge || this.appOptions.isEditDiagram || this.appOptions.isEditOle) { app.getController('LeftMenu').getView('LeftMenu').hide(); $(window) @@ -1379,7 +1382,7 @@ define([ },this)); } - if (!this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram) { + if (!this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram && !this.appOptions.isEditOle) { this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); this.api.asc_registerCallback('asc_onDownloadUrl', _.bind(this.onDownloadUrl, this)); this.api.asc_registerCallback('asc_onDocumentModifiedChanged', _.bind(this.onDocumentModifiedChanged, this)); @@ -1434,10 +1437,11 @@ define([ application.getController('WBProtection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); if (statusbarController) { - statusbarController.getView('Statusbar').changeViewMode(true); + statusbarController.getView('Statusbar').changeViewMode(!me.appOptions.isEditOle); + me.appOptions.isEditOle && statusbarController.onChangeViewMode(null, true, true); // set compact status bar for ole editing mode } - if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && me.appOptions.canFeaturePivot) + if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && !me.appOptions.isEditOle && me.appOptions.canFeaturePivot) application.getController('PivotTable').setMode(me.appOptions); var viewport = this.getApplication().getController('Viewport').getView('Viewport'); @@ -1446,7 +1450,7 @@ define([ this.toolbarView = toolbarController.getView('Toolbar'); - if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { + if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && !me.appOptions.isEditOle) { var options = {}; JSON.parse(Common.localStorage.getItem('sse-hidden-formula')) && (options.formula = true); application.getController('Toolbar').hideElements(options); @@ -2063,7 +2067,7 @@ define([ onBeforeUnload: function() { Common.localStorage.save(); - var isEdit = this.permissions.edit !== false && this.editorConfig.mode !== 'view' && this.editorConfig.mode !== 'editdiagram' && this.editorConfig.mode !== 'editmerge'; + var isEdit = this.permissions.edit !== false && this.editorConfig.mode !== 'view' && this.editorConfig.mode !== 'editdiagram' && this.editorConfig.mode !== 'editmerge' && this.editorConfig.mode !== 'editole'; if (isEdit && this.api.asc_isDocumentModified()) { var me = this; this.api.asc_stopSaving(); @@ -2228,7 +2232,7 @@ define([ if (!this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram && window.editor_elements_prepared) { this.application.getController('Statusbar').selectTab(index); - if (this.appOptions.canViewComments && !this.dontCloseDummyComment) { + if (!this.appOptions.isEditOle && this.appOptions.canViewComments && !this.dontCloseDummyComment) { Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getWorksheetId(index)], false ); // hide popover } } @@ -2465,7 +2469,7 @@ define([ onSendThemeColors: function(colors, standart_colors) { Common.Utils.ThemeColor.setColors(colors, standart_colors); - if (window.styles_loaded && !this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram) { + if (window.styles_loaded && !this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram && !this.appOptions.isEditOle) { this.updateThemeColors(); var me = this; setTimeout(function(){ diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 4ab02c01e..f3925e36d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -779,9 +779,9 @@ define([ this._sheetViewTip.hide(); }, - onChangeViewMode: function(item, compact) { + onChangeViewMode: function(item, compact, suppressEvent) { this.statusbar.fireEvent('view:compact', [this.statusbar, compact]); - Common.localStorage.setBool('sse-compact-statusbar', compact); + !suppressEvent && Common.localStorage.setBool('sse-compact-statusbar', compact); Common.NotificationCenter.trigger('layout:changed', 'status'); this.statusbar.onChangeCompact(compact); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index f2d4bf681..5f5d2adde 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -301,6 +301,17 @@ define([ toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending)); toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); + } else + if ( me.appConfig.isEditOle ) { + toolbar.btnUndo.on('click', _.bind(this.onUndo, this)); + toolbar.btnRedo.on('click', _.bind(this.onRedo, this)); + toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, true)); + toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, false)); + toolbar.btnSearch.on('click', _.bind(this.onSearch, this)); + toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending)); + toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending)); + toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); + toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); } else { toolbar.btnPrint.on('click', _.bind(this.onPrint, this)); toolbar.btnPrint.on('disabled', _.bind(this.onBtnChangeState, this, 'print:disabled')); @@ -419,7 +430,7 @@ define([ var config = SSE.getController('Main').appOptions; if (config.isEdit) { - if ( !config.isEditDiagram && !config.isEditMailMerge ) { + if ( !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this)); this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); @@ -1846,7 +1857,7 @@ define([ this.toolbar.createDelayedElements(); this.attachUIEvents(this.toolbar); - if ( !this.appConfig.isEditDiagram && !this.appConfig.isEditMailMerge ) { + if ( !this.appConfig.isEditDiagram && !this.appConfig.isEditMailMerge && !this.appConfig.isEditOle ) { this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); this.api.asc_registerCallback('asc_onUpdateSheetViewSettings', _.bind(this.onApiSheetChanged, this)); this.api.asc_registerCallback('asc_onEndAddShape', _.bind(this.onApiEndAddShape, this)); @@ -1901,7 +1912,7 @@ define([ e.stopPropagation(); }, 'command+k,ctrl+k': function (e) { - if (me.editMode && !me.toolbar.mode.isEditMailMerge && !me.toolbar.mode.isEditDiagram && !me.api.isCellEdited && !me._state.multiselect && !me._state.inpivot && + if (me.editMode && !me.toolbar.mode.isEditMailMerge && !me.toolbar.mode.isEditDiagram && !me.toolbar.mode.isEditOle && !me.api.isCellEdited && !me._state.multiselect && !me._state.inpivot && !me.getApplication().getController('LeftMenu').leftMenu.menuFile.isVisible() && !me._state.wsProps['InsertHyperlinks']) { var cellinfo = me.api.asc_getCellInfo(), selectionType = cellinfo.asc_getSelectionType(); @@ -1911,7 +1922,7 @@ define([ e.preventDefault(); }, 'command+1,ctrl+1': function(e) { - if (me.editMode && !me.toolbar.mode.isEditMailMerge && !me.api.isCellEdited && !me.toolbar.cmbNumberFormat.isDisabled()) { + if (me.editMode && !me.toolbar.mode.isEditMailMerge && !me.toolbar.mode.isEditOle && !me.api.isCellEdited && !me.toolbar.cmbNumberFormat.isDisabled()) { me.onCustomNumberFormat(); } @@ -2192,7 +2203,7 @@ define([ if ($('.asc-window.enable-key-events:visible').length>0) return; var toolbar = this.toolbar; - if (toolbar.mode.isEditDiagram || toolbar.mode.isEditMailMerge) { + if (toolbar.mode.isEditDiagram || toolbar.mode.isEditMailMerge || toolbar.mode.isEditOle) { is_cell_edited = (state == Asc.c_oAscCellEditorState.editStart); toolbar.lockToolbar(Common.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.btnDecDecimal,toolbar.btnIncDecimal,toolbar.cmbNumberFormat, toolbar.btnEditChartData, toolbar.btnEditChartType]}); } else @@ -2243,7 +2254,7 @@ define([ onApiSheetChanged: function() { - if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return; + if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge || this.toolbar.mode.isEditOle) return; var currentSheet = this.api.asc_getActiveWorksheetIndex(), props = this.api.asc_getPageOptions(currentSheet), @@ -2401,7 +2412,7 @@ define([ Common.NotificationCenter.trigger('fonts:change', fontobj); /* read font params */ - if (!toolbar.mode.isEditMailMerge && !toolbar.mode.isEditDiagram) { + if (!toolbar.mode.isEditMailMerge && !toolbar.mode.isEditDiagram && !toolbar.mode.isEditOle) { val = fontobj.asc_getFontBold(); if (this._state.bold !== val) { toolbar.btnBold.toggle(val === true, true); @@ -2508,10 +2519,12 @@ define([ if ( this.toolbar.mode.isEditDiagram ) return this.onApiSelectionChanged_DiagramEditor(info); else if ( this.toolbar.mode.isEditMailMerge ) - return this.onApiSelectionChanged_MailMergeEditor(info); + return this.onApiSelectionChanged_MailMergeEditor(info); else + if ( this.toolbar.mode.isEditOle ) + return this.onApiSelectionChanged_OleEditor(info); var selectionType = info.asc_getSelectionType(), - coauth_disable = (!this.toolbar.mode.isEditMailMerge && !this.toolbar.mode.isEditDiagram) ? (info.asc_getLocked()===true || info.asc_getLockedTable()===true || info.asc_getLockedPivotTable()===true) : false, + coauth_disable = (!this.toolbar.mode.isEditMailMerge && !this.toolbar.mode.isEditDiagram && !this.toolbar.mode.isEditOle) ? (info.asc_getLocked()===true || info.asc_getLockedTable()===true || info.asc_getLockedPivotTable()===true) : false, editOptionsDisabled = this._disableEditOptions(selectionType, coauth_disable), me = this, toolbar = this.toolbar, @@ -2570,7 +2583,7 @@ define([ if (editOptionsDisabled) return; /* read font params */ - if (!toolbar.mode.isEditMailMerge && !toolbar.mode.isEditDiagram) { + if (!toolbar.mode.isEditMailMerge && !toolbar.mode.isEditDiagram && !toolbar.mode.isEditOle) { val = xfs.asc_getFontBold(); if (this._state.bold !== val) { toolbar.btnBold.toggle(val === true, true); @@ -3067,6 +3080,63 @@ define([ } }, + onApiSelectionChanged_OleEditor: function(info) { + if ( !this.editMode || this.api.isCellEdited || this.api.isRangeSelection) return; + + var me = this; + var _disableEditOptions = function(seltype, coauth_disable) { + var is_chart_text = seltype == Asc.c_oAscSelectionType.RangeChartText, + is_chart = seltype == Asc.c_oAscSelectionType.RangeChart, + is_shape_text = seltype == Asc.c_oAscSelectionType.RangeShapeText, + is_shape = seltype == Asc.c_oAscSelectionType.RangeShape, + is_image = seltype == Asc.c_oAscSelectionType.RangeImage || seltype == Asc.c_oAscSelectionType.RangeSlicer, + is_mode_2 = is_shape_text || is_shape || is_chart_text || is_chart, + is_objLocked = false; + + if (!(is_mode_2 || is_image) && + me._state.selection_type === seltype && + me._state.coauthdisable === coauth_disable) + return seltype === Asc.c_oAscSelectionType.RangeImage; + + if ( is_mode_2 ) { + var selectedObjects = me.api.asc_getGraphicObjectProps(); + is_objLocked = selectedObjects.some(function (object) { + return object.asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image && object.asc_getObjectValue().asc_getLocked(); + }); + } + + me.toolbar.lockToolbar(Common.enumLock.coAuthText, is_objLocked); + + return is_image; + }; + + var selectionType = info.asc_getSelectionType(), + coauth_disable = false, + editOptionsDisabled = _disableEditOptions(selectionType, coauth_disable), + val, need_disable = false; + + if (editOptionsDisabled) return; + if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText) + return; + + if ( !me.toolbar.mode.isEditDiagram ) { + var filterInfo = info.asc_getAutoFilterInfo(); + + val = filterInfo ? filterInfo.asc_getIsAutoFilter() : null; + if ( this._state.filter !== val ) { + me.toolbar.btnSetAutofilter.toggle(val===true, true); + this._state.filter = val; + } + + need_disable = this._state.controlsdisabled.filters || (val===null); + me.toolbar.lockToolbar(Common.enumLock.ruleFilter, need_disable, + { array: [me.toolbar.btnSetAutofilter, me.toolbar.btnSortDown, me.toolbar.btnSortUp] }); + + need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); + me.toolbar.lockToolbar(Common.enumLock.ruleDelFilter, need_disable, {array: [me.toolbar.btnClearAutofilter]}); + } + }, + onApiStyleChange: function() { this.toolbar.btnCopyStyle.toggle(false, true); this.modeAlwaysSetStyle = false; @@ -3511,7 +3581,7 @@ define([ case Asc.c_oAscSelectionType.RangeSlicer: type = _set.selSlicer; break; } - if ( !this.appConfig.isEditDiagram && !this.appConfig.isEditMailMerge ) + if ( !this.appConfig.isEditDiagram && !this.appConfig.isEditMailMerge && !this.appConfig.isEditOle ) toolbar.lockToolbar(type, type != seltype, { array: [ toolbar.btnClearStyle.menu.items[1], @@ -3723,8 +3793,8 @@ define([ var me = this; me.appConfig = config; - var compactview = !config.isEdit; - if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge ) { + var compactview = !config.isEdit || config.isEditOle; + if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { if ( Common.localStorage.itemExists("sse-compact-toolbar") ) { compactview = Common.localStorage.getBool("sse-compact-toolbar"); } else @@ -3734,7 +3804,7 @@ define([ me.toolbar.render(_.extend({isCompactView: compactview}, config)); - if ( !config.isEditDiagram && !config.isEditMailMerge ) { + if ( !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'toolbar-collaboration', dataHintTitle: 'U'}; var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); if ($panel) { @@ -3752,7 +3822,7 @@ define([ me.toolbar.btnPrint && me.toolbar.btnPrint.on('disabled', _.bind(me.onBtnChangeState, me, 'print:disabled')); me.toolbar.setApi(me.api); - if ( !config.isEditDiagram && !config.isEditMailMerge ) { + if ( !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { var datatab = me.getApplication().getController('DataTab'); datatab.setApi(me.api).setConfig({toolbar: me}); @@ -3810,7 +3880,7 @@ define([ } } } - if ( !config.isEditDiagram && !config.isEditMailMerge ) { + if ( !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { tab = {caption: me.toolbar.textTabView, action: 'view', extcls: config.isEdit ? 'canedit' : '', layoutname: 'toolbar-view', dataHintTitle: 'W'}; var viewtab = me.getApplication().getController('ViewTab'); viewtab.setApi(me.api).setConfig({toolbar: me, mode: config}); diff --git a/apps/spreadsheeteditor/main/app/controller/ViewTab.js b/apps/spreadsheeteditor/main/app/controller/ViewTab.js index a620e84cd..66637dbd8 100644 --- a/apps/spreadsheeteditor/main/app/controller/ViewTab.js +++ b/apps/spreadsheeteditor/main/app/controller/ViewTab.js @@ -251,7 +251,7 @@ define([ }, onApiSheetChanged: function() { - if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return; + if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge || this.toolbar.mode.isEditOle) return; var params = this.api.asc_getSheetViewSettings(); this.view.chHeadings.setValue(!!params.asc_getShowRowColHeaders(), true); diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index caf8cf4e6..7cf81b17c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -79,7 +79,7 @@ define([ 'Toolbar': { 'render:before' : function (toolbar) { var config = SSE.getController('Main').appOptions; - if (!config.isEditDiagram && !config.isEditMailMerge) + if (!config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle) toolbar.setExtra('right', me.header.getPanel('right', config)); if (!config.isEdit || config.customization && !!config.customization.compactHeader) @@ -148,11 +148,11 @@ define([ { me.viewport.vlayout.getItem('toolbar').height = _intvars.get('toolbar-height-compact'); } else - if ( config.isEditDiagram || config.isEditMailMerge ) { + if ( config.isEditDiagram || config.isEditMailMerge || config.isEditOle ) { me.viewport.vlayout.getItem('toolbar').height = 41; } - if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !(config.customization && config.customization.compactHeader)) { + if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle && !(config.customization && config.customization.compactHeader)) { var $title = me.viewport.vlayout.getItem('title').el; $title.html(me.header.getPanel('title', config)).show(); $title.find('.extra').html(me.header.getPanel('left', config)); diff --git a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template index cc642b5ad..79bc438f3 100644 --- a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template +++ b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template @@ -71,5 +71,40 @@
+ <% } else if ( isEditOle ) { %> + + + +
+
+
+ + + + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
<% } %> \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index ff64e3b6e..6fd07ea32 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -516,7 +516,7 @@ define([ this.mode = _.extend({}, this.mode, mode); // this.$el.find('.el-edit')[mode.isEdit?'show':'hide'](); //this.btnAddWorksheet.setVisible(this.mode.isEdit); - $('#status-addtabs-box')[this.mode.isEdit ? 'show' : 'hide'](); + $('#status-addtabs-box')[(this.mode.isEdit && !this.mode.isEditOle ) ? 'show' : 'hide'](); this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); this.updateTabbarBorders(); }, @@ -607,7 +607,7 @@ define([ this.tabbar.setTabVisible(sindex); this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || wbprotected || me.api.isCellEdited); - if (this.mode.isEdit) { + if (this.mode.isEdit && !this.mode.isEditOle) { this.tabbar.addDataHint(_.findIndex(items, function (item) { return item.sheetindex === sindex; })); @@ -698,7 +698,7 @@ define([ this.tabbar.setTabVisible(index); } - if (this.mode.isEdit) { + if (this.mode.isEdit && !this.mode.isEditOle) { this.tabbar.addDataHint(index); } @@ -710,7 +710,7 @@ define([ onTabMenu: function (o, index, tab, select) { var me = this; - if (this.mode.isEdit && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) && + if (this.mode.isEdit && !this.mode.isEditOle && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable) && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles) && !this.mode.isDisconnected ) { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 4e87d1e0e..ccac769ae 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -342,7 +342,7 @@ define([ dataHintOffset: 'medium' }); } else - if ( config.isEditMailMerge ) { + if ( config.isEditMailMerge || config.isEditOle ) { me.$layout = $(_.template(simple)(config)); me.btnSearch = new Common.UI.Button({ @@ -1781,7 +1781,7 @@ define([ }); if ( mode.isEdit ) { - if (!mode.isEditDiagram && !mode.isEditMailMerge) { + if (!mode.isEditDiagram && !mode.isEditMailMerge && !mode.isEditOle) { var top = Common.localStorage.getItem("sse-pgmargins-top"), left = Common.localStorage.getItem("sse-pgmargins-left"), bottom = Common.localStorage.getItem("sse-pgmargins-bottom"), @@ -2361,7 +2361,7 @@ define([ })); } - if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) + if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram && !this.mode.isEditOle) this.updateMetricUnit(); }, @@ -2412,7 +2412,7 @@ define([ setApi: function(api) { this.api = api; - if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) { + if (!this.mode.isEditMailMerge && !this.mode.isEditDiagram && !this.mode.isEditOle) { this.api.asc_registerCallback('asc_onCollaborativeChanges', _.bind(this.onApiCollaborativeChanges, this)); this.api.asc_registerCallback('asc_onSendThemeColorSchemes', _.bind(this.onApiSendThemeColorSchemes, this)); this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onApiUsersChanged, this)); @@ -2572,7 +2572,7 @@ define([ }, onAppReady: function (config) { - if (!this.mode.isEdit || this.mode.isEditMailMerge || this.mode.isEditDiagram) return; + if (!this.mode.isEdit || this.mode.isEditMailMerge || this.mode.isEditDiagram || this.mode.isEditOle) return; var me = this; var _holder_view = SSE.getController('DocumentHolder').getView('DocumentHolder'); From 7a282063ef56ded5dc075ead43b9de9332eb3467 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 11 Mar 2022 17:20:24 +0300 Subject: [PATCH 04/10] [PE] Edit ole objects --- apps/presentationeditor/main/app.js | 2 ++ .../main/app/controller/DocumentHolder.js | 21 +++++++++++++++++++ .../main/app/controller/Main.js | 1 + .../main/app/view/DocumentHolder.js | 12 +++++++++++ apps/presentationeditor/main/app_dev.js | 2 ++ 5 files changed, 38 insertions(+) diff --git a/apps/presentationeditor/main/app.js b/apps/presentationeditor/main/app.js index 0b2f1c272..1e11ca2c5 100644 --- a/apps/presentationeditor/main/app.js +++ b/apps/presentationeditor/main/app.js @@ -161,6 +161,7 @@ require([ /** coauthoring end **/ ,'Common.Controllers.Plugins' ,'Common.Controllers.ExternalDiagramEditor' + ,'Common.Controllers.ExternalOleEditor' ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Transitions' @@ -197,6 +198,7 @@ require([ 'common/main/lib/controller/Plugins', 'presentationeditor/main/app/view/ChartSettings', 'common/main/lib/controller/ExternalDiagramEditor' + ,'common/main/lib/controller/ExternalOleEditor' ,'common/main/lib/controller/ReviewChanges' ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Themes' diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index 3183accd0..f6be16df6 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -126,6 +126,27 @@ define([ }, 10); }, this)); } + + var oleEditor = this.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); + if (oleEditor) { + oleEditor.on('internalmessage', _.bind(function(cmp, message) { + var command = message.data.command; + var data = message.data.data; + if (this.api) { + if (oleEditor.isEditMode()) + this.api.asc_editTableOleObject(data); + } + }, this)); + oleEditor.on('hide', _.bind(function(cmp, message) { + if (this.api) { + this.api.asc_enableKeyEvents(true); + } + var me = this; + setTimeout(function(){ + me.documentHolder.fireEvent('editcomplete', me.documentHolder); + }, 10); + }, this)); + } } }); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index c5e6085a0..024675c1a 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -851,6 +851,7 @@ define([ chatController.setApi(this.api).setMode(this.appOptions); application.getController('Common.Controllers.ExternalDiagramEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); + application.getController('Common.Controllers.ExternalOleEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); pluginsController.setApi(me.api); diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 28be6cf54..470364c18 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1622,6 +1622,7 @@ define([ if (me.mode.isEdit===true) { me.api.asc_registerCallback('asc_onDialogAddHyperlink', _.bind(onDialogAddHyperlink, me)); me.api.asc_registerCallback('asc_doubleClickOnChart', _.bind(me.editChartClick, me)); + me.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(me.onDoubleClickOnTableOleObject, me)); me.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, me)); me.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(onShowSpecialPasteOptions, me)); me.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(onHideSpecialPasteOptions, me)); @@ -1762,6 +1763,17 @@ define([ } }, + onDoubleClickOnTableOleObject: function(chart) { + if (this.mode.isEdit && !this._isDisabled) { + var oleEditor = PE.getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor'); + if (oleEditor && chart) { + oleEditor.setEditMode(true); + oleEditor.show(); + oleEditor.setOleData(Asc.asc_putBinaryDataToFrameFromTableOleObject(chart)); + } + } + }, + onCutCopyPaste: function(item, e) { var me = this; if (me.api) { diff --git a/apps/presentationeditor/main/app_dev.js b/apps/presentationeditor/main/app_dev.js index 37ddc109a..d14b880a3 100644 --- a/apps/presentationeditor/main/app_dev.js +++ b/apps/presentationeditor/main/app_dev.js @@ -152,6 +152,7 @@ require([ /** coauthoring end **/ ,'Common.Controllers.Plugins' ,'Common.Controllers.ExternalDiagramEditor' + ,'Common.Controllers.ExternalOleEditor' ,'Common.Controllers.ReviewChanges' ,'Common.Controllers.Protection' ,'Transitions' @@ -188,6 +189,7 @@ require([ 'common/main/lib/controller/Plugins', 'presentationeditor/main/app/view/ChartSettings', 'common/main/lib/controller/ExternalDiagramEditor' + ,'common/main/lib/controller/ExternalOleEditor' ,'common/main/lib/controller/ReviewChanges' ,'common/main/lib/controller/Protection' ,'common/main/lib/controller/Themes' From fc47f0f16794caf3b1d1dc8cd372d7216067b5df Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 16 Mar 2022 14:17:25 +0300 Subject: [PATCH 05/10] [SSE] Refactoring ole editor: add toolbar buttons --- .../common/main/lib/controller/HintManager.js | 2 +- .../main/app/controller/Main.js | 4 +- .../main/app/controller/Toolbar.js | 37 ++- .../main/app/template/ToolbarAnother.template | 14 + .../main/app/view/Statusbar.js | 8 +- .../main/app/view/Toolbar.js | 285 +++++++++--------- 6 files changed, 205 insertions(+), 145 deletions(-) diff --git a/apps/common/main/lib/controller/HintManager.js b/apps/common/main/lib/controller/HintManager.js index abbb3b897..9f135fda1 100644 --- a/apps/common/main/lib/controller/HintManager.js +++ b/apps/common/main/lib/controller/HintManager.js @@ -647,7 +647,7 @@ Common.UI.HintManager = new(function() { }; var _setMode = function (mode) { - _isEditDiagram = mode.isEditDiagram; + _isEditDiagram = mode.isEditDiagram || mode.isEditMailMerge || mode.isEditOle; }; return { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9e6f9796e..51f811314 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -468,7 +468,7 @@ define([ this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); Common.Controllers.Desktop.init(this.appOptions); - if (this.appOptions.isEditDiagram) { + if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) { Common.UI.HintManager.setMode(this.appOptions); } }, @@ -1437,7 +1437,7 @@ define([ application.getController('WBProtection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); if (statusbarController) { - statusbarController.getView('Statusbar').changeViewMode(!me.appOptions.isEditOle); + statusbarController.getView('Statusbar').changeViewMode(me.appOptions); me.appOptions.isEditOle && statusbarController.onChangeViewMode(null, true, true); // set compact status bar for ole editing mode } diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 5f5d2adde..e060c6f5f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -312,6 +312,14 @@ define([ toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending)); toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); + toolbar.btnInsertFormula.on('click', _.bind(this.onInsertFormulaMenu, this)); + toolbar.btnInsertFormula.menu.on('item:click', _.bind(this.onInsertFormulaMenu, this)); + toolbar.btnDecDecimal.on('click', _.bind(this.onDecrement, this)); + toolbar.btnIncDecimal.on('click', _.bind(this.onIncrement, this)); + toolbar.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); + toolbar.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatOpenBefore, this, true)); + if (toolbar.cmbNumberFormat.cmpEl) + toolbar.cmbNumberFormat.cmpEl.on('click', '#id-toolbar-mnu-item-more-formats a', _.bind(this.onNumberFormatSelect, this)); } else { toolbar.btnPrint.on('click', _.bind(this.onPrint, this)); toolbar.btnPrint.on('disabled', _.bind(this.onBtnChangeState, this, 'print:disabled')); @@ -3105,12 +3113,28 @@ define([ }); } + var _set = Common.enumLock; + var type = seltype; + switch ( seltype ) { + case Asc.c_oAscSelectionType.RangeSlicer: + case Asc.c_oAscSelectionType.RangeImage: type = _set.selImage; break; + case Asc.c_oAscSelectionType.RangeShape: type = _set.selShape; break; + case Asc.c_oAscSelectionType.RangeShapeText: type = _set.selShapeText; break; + case Asc.c_oAscSelectionType.RangeChart: type = _set.selChart; break; + case Asc.c_oAscSelectionType.RangeChartText: type = _set.selChartText; break; + } + + me.toolbar.lockToolbar(type, type != seltype, { + clear: [_set.selImage, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.coAuth] + }); + me.toolbar.lockToolbar(Common.enumLock.coAuthText, is_objLocked); return is_image; }; var selectionType = info.asc_getSelectionType(), + xfs = info.asc_getXfs(), coauth_disable = false, editOptionsDisabled = _disableEditOptions(selectionType, coauth_disable), val, need_disable = false; @@ -3135,6 +3159,17 @@ define([ need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); me.toolbar.lockToolbar(Common.enumLock.ruleDelFilter, need_disable, {array: [me.toolbar.btnClearAutofilter]}); } + + var val = xfs.asc_getNumFormatInfo(); + if ( val ) { + this._state.numformat = xfs.asc_getNumFormat(); + this._state.numformatinfo = val; + val = val.asc_getType(); + if (this._state.numformattype !== val) { + me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom); + this._state.numformattype = val; + } + } }, onApiStyleChange: function() { @@ -3793,7 +3828,7 @@ define([ var me = this; me.appConfig = config; - var compactview = !config.isEdit || config.isEditOle; + var compactview = !config.isEdit; if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { if ( Common.localStorage.itemExists("sse-compact-toolbar") ) { compactview = Common.localStorage.getBool("sse-compact-toolbar"); diff --git a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template index 79bc438f3..878aa4f2f 100644 --- a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template +++ b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template @@ -85,6 +85,12 @@
+
+
+ +
+
+
@@ -99,6 +105,14 @@
+
+
+ + + +
+
+
diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 6fd07ea32..8b318ccdb 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -516,7 +516,8 @@ define([ this.mode = _.extend({}, this.mode, mode); // this.$el.find('.el-edit')[mode.isEdit?'show':'hide'](); //this.btnAddWorksheet.setVisible(this.mode.isEdit); - $('#status-addtabs-box')[(this.mode.isEdit && !this.mode.isEditOle ) ? 'show' : 'hide'](); + $('#status-addtabs-box')[(this.mode.isEdit) ? 'show' : 'hide'](); + this.btnAddWorksheet.setVisible(!this.mode.isEditOle); this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); this.updateTabbarBorders(); }, @@ -890,11 +891,12 @@ define([ } }, - changeViewMode: function (edit) { + changeViewMode: function (mode) { + var edit = mode.isEdit && !mode.isEditOle; if (edit) { this.tabBarBox.css('left', '175px'); } else { - this.tabBarBox.css('left', ''); + this.tabBarBox.css('left', mode.isEditOle ? '152px' : ''); } this.tabbar.options.draggable = edit; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index ccac769ae..0572660fd 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -197,7 +197,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-copy', dataHint: '1', - dataHintDirection: config.isEditDiagram ? 'bottom' : 'top', + dataHintDirection: (config.isEditDiagram || config.isEditMailMerge || config.isEditOle) ? 'bottom' : 'top', dataHintTitle: 'C' }); @@ -207,7 +207,7 @@ define([ iconCls : 'toolbar__icon btn-paste', lock : [/*_set.editCell,*/ _set.coAuth, _set.lostConnect], dataHint : '1', - dataHintDirection: config.isEditDiagram ? 'bottom' : 'top', + dataHintDirection: (config.isEditDiagram || config.isEditMailMerge || config.isEditOle) ? 'bottom' : 'top', dataHintTitle: 'V' }); @@ -235,153 +235,162 @@ define([ dataHintTitle: 'Y' }); - if ( config.isEditDiagram ) { + if (config.isEditDiagram || config.isEditMailMerge || config.isEditOle ) { me.$layout = $(_.template(simple)(config)); + if ( config.isEditDiagram || config.isEditOle ) { + me.btnInsertFormula = new Common.UI.Button({ + id : 'id-toolbar-btn-insertformula', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-formula', + split : true, + lock : [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], + menu : new Common.UI.Menu({ + style : 'min-width: 110px', + items : [ + {caption: 'SUM', value: 'SUM'}, + {caption: 'AVERAGE', value: 'AVERAGE'}, + {caption: 'MIN', value: 'MIN'}, + {caption: 'MAX', value: 'MAX'}, + {caption: 'COUNT', value: 'COUNT'}, + {caption: '--'}, + { + caption: me.txtAdditional, + value: 'more', + hint: me.txtFormula + Common.Utils.String.platformKey('Shift+F3') + } + ] + }), + dataHint: '1', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); - me.btnInsertFormula = new Common.UI.Button({ - id : 'id-toolbar-btn-insertformula', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-formula', - split : true, - lock : [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], - menu : new Common.UI.Menu({ - style : 'min-width: 110px', - items : [ - {caption: 'SUM', value: 'SUM'}, - {caption: 'AVERAGE', value: 'AVERAGE'}, - {caption: 'MIN', value: 'MIN'}, - {caption: 'MAX', value: 'MAX'}, - {caption: 'COUNT', value: 'COUNT'}, - {caption: '--'}, - { - caption: me.txtAdditional, - value: 'more', - hint: me.txtFormula + Common.Utils.String.platformKey('Shift+F3') - } - ] - }), - dataHint: '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' - }); + me.btnDecDecimal = new Common.UI.Button({ + id : 'id-toolbar-btn-decdecimal', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-decdecimal', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnDecDecimal = new Common.UI.Button({ - id : 'id-toolbar-btn-decdecimal', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-decdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], - dataHint : '1', - dataHintDirection: 'bottom' - }); + me.btnIncDecimal = new Common.UI.Button({ + id : 'id-toolbar-btn-incdecimal', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-incdecimal', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnIncDecimal = new Common.UI.Button({ - id : 'id-toolbar-btn-incdecimal', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-incdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], - dataHint : '1', - dataHintDirection: 'bottom' - }); + var formatTemplate = + _.template([ + '<% _.each(items, function(item) { %>', + '
  • ', + '
    <%= scope.getDisplayValue(item) %>
    ', + '
    <%= item.exampleval ? item.exampleval : "" %>
    ', + '
  • ', + '<% }); %>', + '
  • ', + '
  • ' + me.textMoreFormats + '
  • ' + ].join('')); - var formatTemplate = - _.template([ - '<% _.each(items, function(item) { %>', - '
  • ', - '
    <%= scope.getDisplayValue(item) %>
    ', - '
    <%= item.exampleval ? item.exampleval : "" %>
    ', - '
  • ', - '<% }); %>', - '
  • ', - '
  • ' + me.textMoreFormats + '
  • ' - ].join('')); + me.cmbNumberFormat = new Common.UI.ComboBox({ + cls : 'input-group-nr', + menuStyle : 'min-width: 180px;', + hint : me.tipNumFormat, + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], + itemsTemplate: formatTemplate, + editable : false, + data : me.numFormatData, + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); + } + if ( config.isEditDiagram ) { + me.btnEditChart = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart', + cls : 'btn-toolbar btn-text-default auto', + caption : me.tipEditChart, + lock : [_set.lostConnect], + style : 'min-width: 120px;', + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); - me.cmbNumberFormat = new Common.UI.ComboBox({ - cls : 'input-group-nr', - menuStyle : 'min-width: 180px;', - hint : me.tipNumFormat, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], - itemsTemplate: formatTemplate, - editable : false, - data : me.numFormatData, - dataHint : '1', - dataHintDirection: config.isEditDiagram ? 'bottom' : 'top', - dataHintOffset: config.isEditDiagram ? 'big' : undefined - }); + me.btnEditChartData = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart-data', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-select-range', + caption : me.tipEditChartData, + lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'medium' + }); - me.btnEditChart = new Common.UI.Button({ - id : 'id-toolbar-rtn-edit-chart', - cls : 'btn-toolbar btn-text-default auto', - caption : me.tipEditChart, - lock : [_set.lostConnect], - style : 'min-width: 120px;', - dataHint : '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' - }); + me.btnEditChartType = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart-type', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-menu-chart', + caption : me.tipEditChartType, + lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], + style : 'min-width: 120px;', + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'medium' + }); + } + if ( config.isEditMailMerge || config.isEditOle ) { + me.btnSearch = new Common.UI.Button({ + id : 'id-toolbar-btn-search', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-menu-search', + lock : [_set.lostConnect], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnEditChartData = new Common.UI.Button({ - id : 'id-toolbar-rtn-edit-chart-data', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-select-range', - caption : me.tipEditChartData, - lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], - dataHint : '1', - dataHintDirection: 'left', - dataHintOffset: 'medium' - }); + me.btnSortDown = new Common.UI.Button({ + id : 'id-toolbar-btn-sort-down', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-sort-down', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnEditChartType = new Common.UI.Button({ - id : 'id-toolbar-rtn-edit-chart-type', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-menu-chart', - caption : me.tipEditChartType, - lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], - style : 'min-width: 120px;', - dataHint : '1', - dataHintDirection: 'left', - dataHintOffset: 'medium' - }); - } else - if ( config.isEditMailMerge || config.isEditOle ) { - me.$layout = $(_.template(simple)(config)); + me.btnSortUp = new Common.UI.Button({ + id : 'id-toolbar-btn-sort-up', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-sort-up', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnSearch = new Common.UI.Button({ - id : 'id-toolbar-btn-search', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-menu-search', - lock : [_set.lostConnect] - }); + me.btnSetAutofilter = new Common.UI.Button({ + id : 'id-toolbar-btn-setautofilter', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-autofilter', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + enableToggle: true, + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnSortDown = new Common.UI.Button({ - id : 'id-toolbar-btn-sort-down', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-sort-down', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot] - }); - - me.btnSortUp = new Common.UI.Button({ - id : 'id-toolbar-btn-sort-up', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-sort-up', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot] - }); - - me.btnSetAutofilter = new Common.UI.Button({ - id : 'id-toolbar-btn-setautofilter', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-autofilter', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], - enableToggle: true - }); - - me.btnClearAutofilter = new Common.UI.Button({ - id : 'id-toolbar-btn-clearfilter', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-clear-filter', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot] - }); - } else - if ( config.isEdit ) { + me.btnClearAutofilter = new Common.UI.Button({ + id : 'id-toolbar-btn-clearfilter', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-clear-filter', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot], + dataHint : '1', + dataHintDirection: 'bottom' + }); + } + } else if ( config.isEdit ) { Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), tabs: [ From bd481f0b55cf23d1c532f78f7581360948db246f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 16 Mar 2022 14:59:11 +0300 Subject: [PATCH 06/10] Fix hints in mail merge editor --- apps/common/main/lib/view/ExternalMergeEditor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/common/main/lib/view/ExternalMergeEditor.js b/apps/common/main/lib/view/ExternalMergeEditor.js index 390430587..d3e800794 100644 --- a/apps/common/main/lib/view/ExternalMergeEditor.js +++ b/apps/common/main/lib/view/ExternalMergeEditor.js @@ -61,8 +61,8 @@ define([ '
    ', '
    ', '' ].join(''); From 9503475e6968f504688fbcaa5f8a52a0adbe8c11 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 16 Mar 2022 16:24:14 +0300 Subject: [PATCH 07/10] [SSE] Fix hints for ole editor --- apps/spreadsheeteditor/main/app/view/Statusbar.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 8b318ccdb..702c6ab03 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -519,6 +519,15 @@ define([ $('#status-addtabs-box')[(this.mode.isEdit) ? 'show' : 'hide'](); this.btnAddWorksheet.setVisible(!this.mode.isEditOle); this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); + if (this.mode.isEditOle) { // change hints order + this.btnScrollFirst.$el.find('button').attr('data-hint', '1'); + this.btnScrollLast.$el.find('button').attr('data-hint', '1'); + this.btnScrollBack.$el.find('button').attr('data-hint', '1'); + this.btnScrollNext.$el.find('button').attr('data-hint', '1'); + this.cntSheetList.$el.find('button').attr('data-hint', '1'); + this.cntSheetList.$el.find('button').removeAttr('data-hint-title'); // 'v' hint is used for paste + this.cntZoom.$el.find('.dropdown-toggle').attr('data-hint', '1'); + } this.updateTabbarBorders(); }, From da4c5b0e82460673f1f78b128460d90d3e17ed32 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 16 Mar 2022 17:40:53 +0300 Subject: [PATCH 08/10] [SSE] Fix ole editor status bar --- apps/spreadsheeteditor/main/app/controller/Statusbar.js | 2 +- apps/spreadsheeteditor/main/app/view/Statusbar.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index f3925e36d..e64ce0c08 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -255,7 +255,7 @@ define([ this.statusbar.$el.css('z-index', ''); this.statusbar.tabMenu.on('item:click', _.bind(this.onTabMenu, this)); this.statusbar.btnAddWorksheet.on('click', _.bind(this.onAddWorksheetClick, this)); - if (!Common.UI.LayoutManager.isElementVisible('statusBar-actionStatus')) { + if (!Common.UI.LayoutManager.isElementVisible('statusBar-actionStatus') || this.statusbar.mode.isEditOle) { this.statusbar.customizeStatusBarMenu.items[0].setVisible(false); this.statusbar.customizeStatusBarMenu.items[1].setVisible(false); this.statusbar.boxAction.addClass('hide'); diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 702c6ab03..26f9610bf 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -979,7 +979,7 @@ define([ //this.boxAction.show(); } this.updateTabbarBorders(); - this.onTabInvisible(undefined, this.tabbar.checkInvisible(true)); + (this.tabbar.getCount()>0) && this.onTabInvisible(undefined, this.tabbar.checkInvisible(true)); }, updateNumberOfSheet: function (active, count) { From 05996df295f3179769ba8cef5420ccd646c271f0 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 16 Mar 2022 18:39:50 +0300 Subject: [PATCH 09/10] [SSE] Add chart editing to ole editor --- .../main/app/controller/DocumentHolder.js | 71 +++++++++++++++++-- .../main/app/view/DocumentHolder.js | 15 +++- apps/spreadsheeteditor/main/locale/en.json | 2 + 3 files changed, 82 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 6113b60b6..18d006074 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -241,6 +241,8 @@ define([ view.pmiTextAdvanced.on('click', _.bind(me.onTextAdvanced, me)); view.mnuShapeAdvanced.on('click', _.bind(me.onShapeAdvanced, me)); view.mnuChartEdit.on('click', _.bind(me.onChartEdit, me)); + view.mnuChartData.on('click', _.bind(me.onChartData, me)); + view.mnuChartType.on('click', _.bind(me.onChartType, me)); view.mnuImgAdvanced.on('click', _.bind(me.onImgAdvanced, me)); view.mnuSlicerAdvanced.on('click', _.bind(me.onSlicerAdvanced, me)); view.textInShapeMenu.on('render:after', _.bind(me.onTextInShapeAfterRender, me)); @@ -1034,6 +1036,60 @@ define([ } }, + onChartData: function(btn) { + var me = this; + var props; + if (me.api){ + props = me.api.asc_getChartObject(); + if (props) { + me._isEditRanges = true; + props.startEdit(); + var win = new SSE.Views.ChartDataDialog({ + chartSettings: props, + api: me.api, + handler: function(result, value) { + if (result == 'ok') { + props.endEdit(); + me._isEditRanges = false; + } + Common.NotificationCenter.trigger('edit:complete', me); + } + }).on('close', function() { + me._isEditRanges && props.cancelEdit(); + me._isEditRanges = false; + }); + win.show(); + } + } + }, + + onChartType: function(btn) { + var me = this; + var props; + if (me.api){ + props = me.api.asc_getChartObject(); + if (props) { + me._isEditType = true; + props.startEdit(); + var win = new SSE.Views.ChartTypeDialog({ + chartSettings: props, + api: me.api, + handler: function(result, value) { + if (result == 'ok') { + props.endEdit(); + me._isEditType = false; + } + Common.NotificationCenter.trigger('edit:complete', me); + } + }).on('close', function() { + me._isEditType && props.cancelEdit(); + me._isEditType = false; + }); + win.show(); + } + } + }, + onImgMacro: function(item) { var me = this; @@ -1843,11 +1899,11 @@ define([ case Asc.c_oAscSelectionType.RangeCol: iscolmenu = true; break; case Asc.c_oAscSelectionType.RangeMax: isallmenu = true; break; case Asc.c_oAscSelectionType.RangeSlicer: - case Asc.c_oAscSelectionType.RangeImage: isimagemenu = !internaleditor; break; - case Asc.c_oAscSelectionType.RangeShape: isshapemenu = !internaleditor; break; - case Asc.c_oAscSelectionType.RangeChart: ischartmenu = !internaleditor; break; - case Asc.c_oAscSelectionType.RangeChartText:istextchartmenu = !internaleditor; break; - case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = !internaleditor; break; + case Asc.c_oAscSelectionType.RangeImage: isimagemenu = !(this.permissions.isEditMailMerge || this.permissions.isEditDiagram); break; + case Asc.c_oAscSelectionType.RangeShape: isshapemenu = !(this.permissions.isEditMailMerge || this.permissions.isEditDiagram); break; + case Asc.c_oAscSelectionType.RangeChart: ischartmenu = !(this.permissions.isEditMailMerge || this.permissions.isEditDiagram); break; + case Asc.c_oAscSelectionType.RangeChartText:istextchartmenu = !(this.permissions.isEditMailMerge || this.permissions.isEditDiagram); break; + case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = !(this.permissions.isEditMailMerge || this.permissions.isEditDiagram); break; } if (this.api.asc_getHeaderFooterMode()) { @@ -1918,6 +1974,10 @@ define([ documentHolder.mnuShapeAdvanced.setDisabled(isObjLocked); documentHolder.mnuChartEdit.setVisible(ischartmenu && !isimagemenu && !isshapemenu && has_chartprops); documentHolder.mnuChartEdit.setDisabled(isObjLocked); + documentHolder.mnuChartData.setVisible(this.permissions.isEditOle && ischartmenu && !isimagemenu && !isshapemenu && has_chartprops); + documentHolder.mnuChartData.setDisabled(isObjLocked); + documentHolder.mnuChartType.setVisible(this.permissions.isEditOle && ischartmenu && !isimagemenu && !isshapemenu && has_chartprops); + documentHolder.mnuChartType.setDisabled(isObjLocked); documentHolder.pmiImgCut.setDisabled(isObjLocked); documentHolder.pmiImgPaste.setDisabled(isObjLocked); documentHolder.mnuImgAdvanced.setVisible(isimagemenu && (!isshapemenu || isimageonly) && !ischartmenu); @@ -1946,6 +2006,7 @@ define([ documentHolder.menuSignatureEditSetup.setVisible(isInSign); documentHolder.menuEditSignSeparator.setVisible(isInSign); + documentHolder.menuImgMacro.setVisible(!internaleditor); documentHolder.menuImgMacro.setDisabled(isObjLocked); var canEditPoints = this.api && this.api.asc_canEditGeometry(); diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index ee6847814..8d1cc357e 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -634,6 +634,15 @@ define([ caption : me.chartText }); + me.mnuChartData = new Common.UI.MenuItem({ + iconCls : 'menu__icon btn-select-range', + caption : me.chartDataText + }); + + me.mnuChartType = new Common.UI.MenuItem({ + caption : me.chartTypeText + }); + me.pmiImgCut = new Common.UI.MenuItem({ iconCls: 'menu__icon btn-cut', caption : me.txtCut, @@ -849,6 +858,8 @@ define([ me.menuImgMacro, me.mnuShapeSeparator, me.menuImgCrop, + me.mnuChartData, + me.mnuChartType, me.mnuChartEdit, me.mnuShapeAdvanced, me.menuImgOriginalSize, @@ -1279,7 +1290,9 @@ define([ tipMarkersArrow: 'Arrow bullets', tipMarkersCheckmark: 'Checkmark bullets', tipMarkersFRhombus: 'Filled rhombus bullets', - tipMarkersDash: 'Dash bullets' + tipMarkersDash: 'Dash bullets', + chartDataText: 'Select Chart Data', + chartTypeText: 'Change Chart Type' }, SSE.Views.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 47ea91186..0257c8ecd 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1993,6 +1993,8 @@ "SSE.Views.DocumentHolder.txtUngroup": "Ungroup", "SSE.Views.DocumentHolder.txtWidth": "Width", "SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", + "SSE.Views.DocumentHolder.chartDataText": "Select Chart Data", + "SSE.Views.DocumentHolder.chartTypeText": "Change Chart Type", "SSE.Views.FieldSettingsDialog.strLayout": "Layout", "SSE.Views.FieldSettingsDialog.strSubtotals": "Subtotals", "SSE.Views.FieldSettingsDialog.textReport": "Report Form", From 883b955fff019a2f83a52e675417b84d4339e182 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 18 Mar 2022 21:41:25 +0300 Subject: [PATCH 10/10] [SSE] Ole editor: change status bar and context menu --- apps/common/main/lib/component/TabBar.js | 4 +-- .../main/app/controller/DocumentHolder.js | 19 +++++++------- .../main/app/controller/Main.js | 26 ++++++++++++------- .../main/app/view/Statusbar.js | 25 +++++++++--------- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index b445a8477..ec6ce90e5 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -610,7 +610,7 @@ define([ return false; }, - addDataHint: function (index) { //Hint Manager + addDataHint: function (index, dataHint) { //Hint Manager var oldHintTab = this.$bar.find('[data-hint]'); if (oldHintTab.length > 0) { oldHintTab.removeAttr('data-hint'); @@ -619,7 +619,7 @@ define([ oldHintTab.removeAttr('data-hint-title'); } var newHintTab = this.tabs[index].$el; - newHintTab.attr('data-hint', '0'); + newHintTab.attr('data-hint', dataHint || '0'); newHintTab.attr('data-hint-direction', 'top'); newHintTab.attr('data-hint-offset', 'medium'); newHintTab.attr('data-hint-title', 'M'); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 18d006074..90402d245 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1889,6 +1889,7 @@ define([ isObjLocked = false, commentsController = this.getApplication().getController('Common.Controllers.Comments'), internaleditor = this.permissions.isEditMailMerge || this.permissions.isEditDiagram || this.permissions.isEditOle, + diagramOrMergeEditor = this.permissions.isEditMailMerge || this.permissions.isEditDiagram, xfs = cellinfo.asc_getXfs(), isSmartArt = false, isSmartArtInternal = false; @@ -2146,14 +2147,14 @@ define([ documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable); documentHolder.pmiSparklines.setVisible(isinsparkline); documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu) && !iscelledit && !inPivot); - documentHolder.pmiSortCells.menu.items[2].setVisible(!internaleditor); - documentHolder.pmiSortCells.menu.items[3].setVisible(!internaleditor); + documentHolder.pmiSortCells.menu.items[2].setVisible(!diagramOrMergeEditor); + documentHolder.pmiSortCells.menu.items[3].setVisible(!diagramOrMergeEditor); documentHolder.pmiSortCells.menu.items[4].setVisible(!internaleditor); - documentHolder.pmiFilterCells.setVisible(iscellmenu && !iscelledit && !internaleditor && !inPivot); - documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu) && !iscelledit && !internaleditor && !inPivot); - documentHolder.pmiCondFormat.setVisible(!iscelledit && !internaleditor); - documentHolder.mnuGroupPivot.setVisible(iscellmenu && !iscelledit && !internaleditor && inPivot); - documentHolder.mnuUnGroupPivot.setVisible(iscellmenu && !iscelledit && !internaleditor && inPivot); + documentHolder.pmiFilterCells.setVisible(iscellmenu && !iscelledit && !diagramOrMergeEditor && !inPivot); + documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu) && !iscelledit && !diagramOrMergeEditor && !inPivot); + documentHolder.pmiCondFormat.setVisible(!iscelledit && !diagramOrMergeEditor); + documentHolder.mnuGroupPivot.setVisible(iscellmenu && !iscelledit && !diagramOrMergeEditor && inPivot); + documentHolder.mnuUnGroupPivot.setVisible(iscellmenu && !iscelledit && !diagramOrMergeEditor && inPivot); documentHolder.ssMenu.items[12].setVisible((iscellmenu||isallmenu||isinsparkline) && !iscelledit); documentHolder.pmiInsFunction.setVisible(iscellmenu && !iscelledit && !inPivot); documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit && !internaleditor); @@ -2171,8 +2172,8 @@ define([ } var hyperinfo = cellinfo.asc_getHyperlink(); - documentHolder.menuHyperlink.setVisible(iscellmenu && hyperinfo && !iscelledit && !ismultiselect && !internaleditor && !inPivot); - documentHolder.menuAddHyperlink.setVisible(iscellmenu && !hyperinfo && !iscelledit && !ismultiselect && !internaleditor && !inPivot); + documentHolder.menuHyperlink.setVisible(iscellmenu && hyperinfo && !iscelledit && !ismultiselect && !diagramOrMergeEditor && !inPivot); + documentHolder.menuAddHyperlink.setVisible(iscellmenu && !hyperinfo && !iscelledit && !ismultiselect && !diagramOrMergeEditor && !inPivot); documentHolder.pmiRowHeight.setVisible(isrowmenu||isallmenu); documentHolder.pmiColumnWidth.setVisible(iscolmenu||isallmenu); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 51f811314..a2f72abae 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -969,6 +969,8 @@ define([ me.updateThemeColors(); toolbarController.activateControls(); + } else if (me.appOptions.isEditOle) { + me.updateThemeColors(); } rightmenuController.createDelayedElements(); @@ -1389,8 +1391,8 @@ define([ var printController = app.getController('Print'); printController && this.api && printController.setApi(this.api); - - } + } else if (this.appOptions.isEditOle) + this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); var celleditorController = this.getApplication().getController('CellEditor'); celleditorController && celleditorController.setApi(this.api).setMode(this.appOptions); @@ -2454,11 +2456,11 @@ define([ updateThemeColors: function() { var me = this; - setTimeout(function(){ + !me.appOptions.isEditOle && setTimeout(function(){ me.getApplication().getController('RightMenu').UpdateThemeColors(); }, 50); - setTimeout(function(){ + !me.appOptions.isEditOle && setTimeout(function(){ me.getApplication().getController('Toolbar').updateThemeColors(); }, 50); @@ -2469,12 +2471,16 @@ define([ onSendThemeColors: function(colors, standart_colors) { Common.Utils.ThemeColor.setColors(colors, standart_colors); - if (window.styles_loaded && !this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram && !this.appOptions.isEditOle) { - this.updateThemeColors(); - var me = this; - setTimeout(function(){ - me.fillTextArt(); - }, 1); + if (window.styles_loaded) { + if (!this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram) + this.updateThemeColors(); + + if (!this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram && !this.appOptions.isEditOle) { + var me = this; + setTimeout(function(){ + me.fillTextArt(); + }, 1); + } } }, diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 26f9610bf..19827c534 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -517,13 +517,13 @@ define([ // this.$el.find('.el-edit')[mode.isEdit?'show':'hide'](); //this.btnAddWorksheet.setVisible(this.mode.isEdit); $('#status-addtabs-box')[(this.mode.isEdit) ? 'show' : 'hide'](); - this.btnAddWorksheet.setVisible(!this.mode.isEditOle); this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); if (this.mode.isEditOle) { // change hints order - this.btnScrollFirst.$el.find('button').attr('data-hint', '1'); - this.btnScrollLast.$el.find('button').attr('data-hint', '1'); - this.btnScrollBack.$el.find('button').attr('data-hint', '1'); - this.btnScrollNext.$el.find('button').attr('data-hint', '1'); + this.btnAddWorksheet.$el.find('button').addBack().filter('button').attr('data-hint', '1'); + this.btnScrollFirst.$el.find('button').addBack().filter('button').attr('data-hint', '1'); + this.btnScrollLast.$el.find('button').addBack().filter('button').attr('data-hint', '1'); + this.btnScrollBack.$el.find('button').addBack().filter('button').attr('data-hint', '1'); + this.btnScrollNext.$el.find('button').addBack().filter('button').attr('data-hint', '1'); this.cntSheetList.$el.find('button').attr('data-hint', '1'); this.cntSheetList.$el.find('button').removeAttr('data-hint-title'); // 'v' hint is used for paste this.cntZoom.$el.find('.dropdown-toggle').attr('data-hint', '1'); @@ -617,10 +617,10 @@ define([ this.tabbar.setTabVisible(sindex); this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || wbprotected || me.api.isCellEdited); - if (this.mode.isEdit && !this.mode.isEditOle) { + if (this.mode.isEdit) { this.tabbar.addDataHint(_.findIndex(items, function (item) { return item.sheetindex === sindex; - })); + }), this.mode.isEditOle ? '1' : '0'); } $('#status-label-zoom').text(Common.Utils.String.format(this.zoomText, Math.floor((this.api.asc_getZoom() +.005)*100))); @@ -708,8 +708,8 @@ define([ this.tabbar.setTabVisible(index); } - if (this.mode.isEdit && !this.mode.isEditOle) { - this.tabbar.addDataHint(index); + if (this.mode.isEdit) { + this.tabbar.addDataHint(index, this.mode.isEditOle ? '1' : '0'); } this.fireEvent('sheet:changed', [this, tab.sheetindex]); @@ -720,7 +720,7 @@ define([ onTabMenu: function (o, index, tab, select) { var me = this; - if (this.mode.isEdit && !this.mode.isEditOle && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) && + if (this.mode.isEdit && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable) && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles) && !this.mode.isDisconnected ) { @@ -755,6 +755,7 @@ define([ this.tabMenu.items[7].setDisabled(select.length>1); this.tabMenu.items[8].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[7].setVisible(!this.mode.isEditOle); this.tabMenu.items[7].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect); if (select.length === 1) { @@ -901,11 +902,11 @@ define([ }, changeViewMode: function (mode) { - var edit = mode.isEdit && !mode.isEditOle; + var edit = mode.isEdit; if (edit) { this.tabBarBox.css('left', '175px'); } else { - this.tabBarBox.css('left', mode.isEditOle ? '152px' : ''); + this.tabBarBox.css('left', ''); } this.tabbar.options.draggable = edit;