From e5c5c93e055d96edb83e4583e940283afc653a0e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Feb 2020 16:30:58 +0300 Subject: [PATCH 1/4] [SSE] Bug 42544: add special paste settings --- .../main/app/controller/DocumentHolder.js | 47 +- .../main/app/view/SpecialPasteDialog.js | 408 ++++++++++++++++++ apps/spreadsheeteditor/main/locale/en.json | 39 +- 3 files changed, 476 insertions(+), 18 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index c62edcc75..f6dcd9cef 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -70,7 +70,8 @@ define([ 'spreadsheeteditor/main/app/view/ParagraphSettingsAdvanced', 'spreadsheeteditor/main/app/view/ImageSettingsAdvanced', 'spreadsheeteditor/main/app/view/SetValueDialog', - 'spreadsheeteditor/main/app/view/AutoFilterDialog' + 'spreadsheeteditor/main/app/view/AutoFilterDialog', + 'spreadsheeteditor/main/app/view/SpecialPasteDialog' ], function () { 'use strict'; @@ -2327,6 +2328,7 @@ define([ })).show(); setTimeout(function(){menu.hide();}, 100); }); + me._arrSpecialPaste[menuItem][2] = importText; } else { var mnu = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0], @@ -2342,6 +2344,7 @@ define([ setTimeout(function(){menu.hide();}, 100); }); groups[me._arrSpecialPaste[menuItem][1]].push(mnu); + me._arrSpecialPaste[menuItem][2] = mnu; } }); var newgroup = false; @@ -2362,6 +2365,29 @@ define([ menu.addItem(new Common.UI.MenuItem({ caption: '--' })); menu.addItem(importText); } + if (menu.items.length>0 && specialPasteShowOptions.asc_getShowPasteSpecial()) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + var mnu = new Common.UI.MenuItem({ + caption: me.textPasteSpecial, + value: 'special' + }).on('click', function(item, e) { + (new SSE.Views.SpecialPasteDialog({ + props: pasteItems, + handler: function (result, settings) { + if (result == 'ok') { + if (me && me.api) { + me.api.asc_SpecialPaste(settings); + } + me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(false, true); + me._state.lastSpecPasteChecked = settings && me._arrSpecialPaste[settings.asc_getProps()] ? me._arrSpecialPaste[settings.asc_getProps()][2] : null; + me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true); + } + } + })).show(); + setTimeout(function(){menu.hide();}, 100); + }); + menu.addItem(mnu); + } } if ( coord[0].asc_getX()<0 || coord[0].asc_getY()<0) { @@ -3334,16 +3360,16 @@ define([ txtSorting: 'Sorting', txtSortSelected: 'Sort selected', txtPaste: 'Paste', - txtPasteFormulas: 'Paste only formula', - txtPasteFormulaNumFormat: 'Formula + number format', - txtPasteKeepSourceFormat: 'Formula + all formatting', - txtPasteBorders: 'Formula without borders', - txtPasteColWidths: 'Formula + column width', + txtPasteFormulas: 'Formulas', + txtPasteFormulaNumFormat: 'Formulas & number formats', + txtPasteKeepSourceFormat: 'Formulas & formatting', + txtPasteBorders: 'All except borders', + txtPasteColWidths: 'Formulas & column widths', txtPasteMerge: 'Merge conditional formatting', txtPasteTranspose: 'Transpose', - txtPasteValues: 'Paste only value', - txtPasteValNumFormat: 'Value + number format', - txtPasteValFormat: 'Value + all formatting', + txtPasteValues: 'Values', + txtPasteValNumFormat: 'Values & number formats', + txtPasteValFormat: 'Values & formatting', txtPasteFormat: 'Paste only formatting', txtPasteLink: 'Paste Link', txtPastePicture: 'Picture', @@ -3379,7 +3405,8 @@ define([ txtAll: '(All)', txtBlanks: '(Blanks)', txtColumn: 'Column', - txtImportWizard: 'Text Import Wizard' + txtImportWizard: 'Text Import Wizard', + textPasteSpecial: 'Paste special' }, SSE.Controllers.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js new file mode 100644 index 000000000..182869c0b --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js @@ -0,0 +1,408 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2020 + * + * 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 + * + */ + +/** + * SpecialPasteDialog.js + * + * Created by Julia Radzhabova on 27.02.2020 + * Copyright (c) 2020 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/RadioBox', + 'common/main/lib/component/CheckBox', + 'common/main/lib/view/AdvancedSettingsWindow' +], function () { 'use strict'; + + SSE.Views.SpecialPasteDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + contentWidth: 350, + height: 385 + }, + + initialize : function(options) { + var me = this; + + _.extend(this.options, { + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + // '
', + '', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + // '
', + // '', + '', + '', + '', + '', + '', + '', + '', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
' + ].join('') + }, options); + + this.handler = options.handler; + this.props = options.props; + this._changedProps = null; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.radioAll = new Common.UI.RadioBox({ + el: $('#paste-radio-all'), + name: 'asc-radio-paste', + labelText: this.textAll, + value: Asc.c_oSpecialPasteProps.paste, + checked: true + }); + this.radioAll.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioFormulas = new Common.UI.RadioBox({ + el: $('#paste-radio-formulas'), + name: 'asc-radio-paste', + labelText: this.textFormulas, + value: Asc.c_oSpecialPasteProps.pasteOnlyFormula + }); + this.radioFormulas.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioValues = new Common.UI.RadioBox({ + el: $('#paste-radio-values'), + name: 'asc-radio-paste', + labelText: this.textValues, + value: Asc.c_oSpecialPasteProps.pasteOnlyValues + }); + this.radioValues.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioFormats = new Common.UI.RadioBox({ + el: $('#paste-radio-formats'), + name: 'asc-radio-paste', + labelText: this.textFormats, + value: Asc.c_oSpecialPasteProps.pasteOnlyFormating + }); + this.radioFormats.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioComments = new Common.UI.RadioBox({ + el: $('#paste-radio-comments'), + name: 'asc-radio-paste', + labelText: this.textComments, + value: Asc.c_oSpecialPasteProps.comments + }); + this.radioComments.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioColWidth = new Common.UI.RadioBox({ + el: $('#paste-radio-col-width'), + name: 'asc-radio-paste', + labelText: this.textColWidth, + value: Asc.c_oSpecialPasteProps.columnWidth + }); + this.radioColWidth.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioWBorders = new Common.UI.RadioBox({ + el: $('#paste-radio-without-borders'), + name: 'asc-radio-paste', + labelText: this.textWBorders, + value: Asc.c_oSpecialPasteProps.formulaWithoutBorders + }); + this.radioWBorders.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioFFormat = new Common.UI.RadioBox({ + el: $('#paste-radio-formula-formats'), + name: 'asc-radio-paste', + labelText: this.textFFormat, + value: Asc.c_oSpecialPasteProps.formulaAllFormatting + }); + this.radioFFormat.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioFWidth = new Common.UI.RadioBox({ + el: $('#paste-radio-formula-col-width'), + name: 'asc-radio-paste', + labelText: this.textFWidth, + value: Asc.c_oSpecialPasteProps.formulaColumnWidth + }); + this.radioFWidth.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioFNFormat = new Common.UI.RadioBox({ + el: $('#paste-radio-formula-num-format'), + name: 'asc-radio-paste', + labelText: this.textFNFormat, + value: Asc.c_oSpecialPasteProps.formulaNumberFormat + }); + this.radioFNFormat.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioVNFormat = new Common.UI.RadioBox({ + el: $('#paste-radio-value-num-format'), + name: 'asc-radio-paste', + labelText: this.textVNFormat, + value: Asc.c_oSpecialPasteProps.valueNumberFormat + }); + this.radioVNFormat.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioVFormat = new Common.UI.RadioBox({ + el: $('#paste-radio-value-formats'), + name: 'asc-radio-paste', + labelText: this.textVFormat, + value: Asc.c_oSpecialPasteProps.valueAllFormating + }); + this.radioVFormat.on('change', _.bind(this.onRadioPasteChange, this)); + + this.radioNone = new Common.UI.RadioBox({ + el: $('#paste-radio-none'), + name: 'asc-radio-paste-operation', + labelText: this.textNone, + value: Asc.c_oSpecialPasteOperation.none, + checked: true + }); + this.radioNone.on('change', _.bind(this.onRadioOperationChange, this)); + + this.radioAdd = new Common.UI.RadioBox({ + el: $('#paste-radio-add'), + name: 'asc-radio-paste-operation', + labelText: this.textAdd, + value: Asc.c_oSpecialPasteOperation.add + }); + this.radioAdd.on('change', _.bind(this.onRadioOperationChange, this)); + + this.radioMult = new Common.UI.RadioBox({ + el: $('#paste-radio-mult'), + name: 'asc-radio-paste-operation', + labelText: this.textMult, + value: Asc.c_oSpecialPasteOperation.multiply + }); + this.radioMult.on('change', _.bind(this.onRadioOperationChange, this)); + + this.radioSub = new Common.UI.RadioBox({ + el: $('#paste-radio-sub'), + name: 'asc-radio-paste-operation', + labelText: this.textSub, + value: Asc.c_oSpecialPasteOperation.subtract + }); + this.radioSub.on('change', _.bind(this.onRadioOperationChange, this)); + + this.radioDiv = new Common.UI.RadioBox({ + el: $('#paste-radio-div'), + name: 'asc-radio-paste-operation', + labelText: this.textDiv, + value: Asc.c_oSpecialPasteOperation.divide + }); + this.radioDiv.on('change', _.bind(this.onRadioOperationChange, this)); + + this.chBlanks = new Common.UI.CheckBox({ + el: $('#paste-checkbox-blanks'), + labelText: this.textBlanks + }); + this.chTranspose = new Common.UI.CheckBox({ + el: $('#paste-checkbox-transpose'), + labelText: this.textTranspose + }); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + show: function() { + Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); + }, + + _setDefaults: function (props) { + this._changedProps = new Asc.SpecialPasteProps(); + this._changedProps.asc_setProps(Asc.c_oSpecialPasteProps.paste); + this._changedProps.asc_setOperation(Asc.c_oSpecialPasteOperation.none); + }, + + getSettings: function () { + if (this._changedProps) { + this._changedProps.asc_setTranspose(this.chTranspose.getValue()=='checked'); + this._changedProps.asc_setSkipBlanks(this.chBlanks.getValue()=='checked'); + } + return this._changedProps; + }, + + onDlgBtnClick: function(event) { + this._handleInput((typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event); + }, + + onPrimary: function() { + this._handleInput('ok'); + return false; + }, + + _handleInput: function(state) { + this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined); + this.close(); + }, + + onRadioPasteChange: function(field, newValue, eOpts) { + if (newValue && this._changedProps) { + this._changedProps.asc_setProps(field.options.value); + var disable = field.options.value == Asc.c_oSpecialPasteProps.pasteOnlyFormating || field.options.value == Asc.c_oSpecialPasteProps.comments || + field.options.value == Asc.c_oSpecialPasteProps.columnWidth; + this.radioNone.setDisabled(disable); + this.radioAdd.setDisabled(disable); + this.radioDiv.setDisabled(disable); + this.radioSub.setDisabled(disable); + this.radioMult.setDisabled(disable); + } + }, + + onRadioOperationChange: function(field, newValue, eOpts) { + if (newValue && this._changedProps) { + this._changedProps.asc_setOperation(field.options.value); + } + }, + + textTitle: 'Paste Special', + textAll: 'All', + textFormulas: 'Formulas', + textValues: 'Values', + textFormats: 'Formats', + textComments: 'Comments', + textColWidth: 'Column widths', + textWBorders: 'All except borders', + textFFormat: 'Formulas & formatting', + textFWidth: 'Formulas & column widths', + textFNFormat: 'Formulas & number formats', + textVNFormat: 'Values & number formats', + textVFormat: 'Values & formatting', + textNone: 'None', + textAdd: 'Add', + textMult: 'Multiply', + textDiv: 'Divide', + textSub: 'Subtract', + textBlanks: 'Skip blanks', + textTranspose: 'Transpose', + textOperation: 'Operation', + textPaste: 'Paste' + + }, SSE.Views.SpecialPasteDialog || {})) +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5e92d56e4..a742d7ac7 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -347,22 +347,22 @@ "SSE.Controllers.DocumentHolder.txtOr": "or", "SSE.Controllers.DocumentHolder.txtOverbar": "Bar over text", "SSE.Controllers.DocumentHolder.txtPaste": "Paste", - "SSE.Controllers.DocumentHolder.txtPasteBorders": "Formula without borders", - "SSE.Controllers.DocumentHolder.txtPasteColWidths": "Formula + column width", + "SSE.Controllers.DocumentHolder.txtPasteBorders": "All except borders", + "SSE.Controllers.DocumentHolder.txtPasteColWidths": "Formulas & column widths", "SSE.Controllers.DocumentHolder.txtPasteDestFormat": "Destination formatting", "SSE.Controllers.DocumentHolder.txtPasteFormat": "Paste only formatting", - "SSE.Controllers.DocumentHolder.txtPasteFormulaNumFormat": "Formula + number format", - "SSE.Controllers.DocumentHolder.txtPasteFormulas": "Paste only formula", - "SSE.Controllers.DocumentHolder.txtPasteKeepSourceFormat": "Formula + all formatting", + "SSE.Controllers.DocumentHolder.txtPasteFormulaNumFormat": "Formulas & number formats", + "SSE.Controllers.DocumentHolder.txtPasteFormulas": "Formulas", + "SSE.Controllers.DocumentHolder.txtPasteKeepSourceFormat": "Formulas & formatting", "SSE.Controllers.DocumentHolder.txtPasteLink": "Paste link", "SSE.Controllers.DocumentHolder.txtPasteLinkPicture": "Linked picture", "SSE.Controllers.DocumentHolder.txtPasteMerge": "Merge conditional formatting", "SSE.Controllers.DocumentHolder.txtPastePicture": "Picture", "SSE.Controllers.DocumentHolder.txtPasteSourceFormat": "Source formatting", "SSE.Controllers.DocumentHolder.txtPasteTranspose": "Transpose", - "SSE.Controllers.DocumentHolder.txtPasteValFormat": "Value + all formatting", - "SSE.Controllers.DocumentHolder.txtPasteValNumFormat": "Value + number format", - "SSE.Controllers.DocumentHolder.txtPasteValues": "Paste only value", + "SSE.Controllers.DocumentHolder.txtPasteValFormat": "Values & formatting", + "SSE.Controllers.DocumentHolder.txtPasteValNumFormat": "Values & number formats", + "SSE.Controllers.DocumentHolder.txtPasteValues": "Values", "SSE.Controllers.DocumentHolder.txtPercent": "percent", "SSE.Controllers.DocumentHolder.txtRedoExpansion": "Redo table autoexpansion", "SSE.Controllers.DocumentHolder.txtRemFractionBar": "Remove fraction bar", @@ -389,6 +389,7 @@ "SSE.Controllers.DocumentHolder.txtUndoExpansion": "Undo table autoexpansion", "SSE.Controllers.DocumentHolder.txtUseTextImport": "Use text import wizard", "SSE.Controllers.DocumentHolder.txtWidth": "Width", + "SSE.Controllers.DocumentHolder.textPasteSpecial": "Paste special", "SSE.Controllers.FormulaDialog.sCategoryAll": "All", "SSE.Controllers.FormulaDialog.sCategoryCube": "Cube", "SSE.Controllers.FormulaDialog.sCategoryDatabase": "Database", @@ -2091,6 +2092,28 @@ "SSE.Views.SignatureSettings.txtRequestedSignatures": "This spreadsheet needs to be signed.", "SSE.Views.SignatureSettings.txtSigned": "Valid signatures has been added to the spreadsheet. The spreadsheet is protected from editing.", "SSE.Views.SignatureSettings.txtSignedInvalid": "Some of the digital signatures in spreadsheet are invalid or could not be verified. The spreadsheet is protected from editing.", + "SSE.Views.SpecialPasteDialog.textTitle": "Paste Special", + "SSE.Views.SpecialPasteDialog.textAll": "All", + "SSE.Views.SpecialPasteDialog.textFormulas": "Formulas", + "SSE.Views.SpecialPasteDialog.textValues": "Values", + "SSE.Views.SpecialPasteDialog.textFormats": "Formats", + "SSE.Views.SpecialPasteDialog.textComments": "Comments", + "SSE.Views.SpecialPasteDialog.textColWidth": "Column widths", + "SSE.Views.SpecialPasteDialog.textWBorders": "All except borders", + "SSE.Views.SpecialPasteDialog.textFFormat": "Formulas & formatting", + "SSE.Views.SpecialPasteDialog.textFWidth": "Formulas & column widths", + "SSE.Views.SpecialPasteDialog.textFNFormat": "Formulas & number formats", + "SSE.Views.SpecialPasteDialog.textVNFormat": "Values & number formats", + "SSE.Views.SpecialPasteDialog.textVFormat": "Values & formatting", + "SSE.Views.SpecialPasteDialog.textNone": "None", + "SSE.Views.SpecialPasteDialog.textAdd": "Add", + "SSE.Views.SpecialPasteDialog.textMult": "Multiply", + "SSE.Views.SpecialPasteDialog.textDiv": "Divide", + "SSE.Views.SpecialPasteDialog.textSub": "Subtract", + "SSE.Views.SpecialPasteDialog.textBlanks": "Skip blanks", + "SSE.Views.SpecialPasteDialog.textTranspose": "Transpose", + "SSE.Views.SpecialPasteDialog.textOperation": "Operation", + "SSE.Views.SpecialPasteDialog.textPaste": "Paste", "SSE.Views.Spellcheck.noSuggestions": "No spelling suggestions", "SSE.Views.Spellcheck.textChange": "Change", "SSE.Views.Spellcheck.textChangeAll": "Change All", From da988c609b992b7a76ac5fbe9f758349bada48de Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Feb 2020 17:23:06 +0300 Subject: [PATCH 2/4] [SSE] Refactoring special paste settings --- .../main/app/controller/DocumentHolder.js | 2 +- .../main/app/view/SpecialPasteDialog.js | 54 ++++++++++++++----- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index f6dcd9cef..4ad902e1f 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2329,7 +2329,7 @@ define([ setTimeout(function(){menu.hide();}, 100); }); me._arrSpecialPaste[menuItem][2] = importText; - } else { + } else if (me._arrSpecialPaste[menuItem]) { var mnu = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0], value: menuItem, diff --git a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js index 182869c0b..6c5995602 100644 --- a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js @@ -176,102 +176,127 @@ define([ Common.Views.AdvancedSettingsWindow.prototype.render.call(this); var me = this; + this.propControls = []; this.radioAll = new Common.UI.RadioBox({ el: $('#paste-radio-all'), name: 'asc-radio-paste', labelText: this.textAll, value: Asc.c_oSpecialPasteProps.paste, - checked: true + checked: true, + disabled: true }); this.radioAll.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.paste] = this.radioAll; this.radioFormulas = new Common.UI.RadioBox({ el: $('#paste-radio-formulas'), name: 'asc-radio-paste', labelText: this.textFormulas, - value: Asc.c_oSpecialPasteProps.pasteOnlyFormula + value: Asc.c_oSpecialPasteProps.pasteOnlyFormula, + disabled: true }); this.radioFormulas.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = this.radioFormulas; this.radioValues = new Common.UI.RadioBox({ el: $('#paste-radio-values'), name: 'asc-radio-paste', labelText: this.textValues, - value: Asc.c_oSpecialPasteProps.pasteOnlyValues + value: Asc.c_oSpecialPasteProps.pasteOnlyValues, + disabled: true }); this.radioValues.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.pasteOnlyValues] = this.radioValues; this.radioFormats = new Common.UI.RadioBox({ el: $('#paste-radio-formats'), name: 'asc-radio-paste', labelText: this.textFormats, - value: Asc.c_oSpecialPasteProps.pasteOnlyFormating + value: Asc.c_oSpecialPasteProps.pasteOnlyFormating, + disabled: true }); this.radioFormats.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = this.radioFormats; this.radioComments = new Common.UI.RadioBox({ el: $('#paste-radio-comments'), name: 'asc-radio-paste', labelText: this.textComments, - value: Asc.c_oSpecialPasteProps.comments + value: Asc.c_oSpecialPasteProps.comments, + disabled: true }); this.radioComments.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.comments] = this.radioComments; this.radioColWidth = new Common.UI.RadioBox({ el: $('#paste-radio-col-width'), name: 'asc-radio-paste', labelText: this.textColWidth, - value: Asc.c_oSpecialPasteProps.columnWidth + value: Asc.c_oSpecialPasteProps.columnWidth, + disabled: true }); this.radioColWidth.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.columnWidth] = this.radioColWidth; this.radioWBorders = new Common.UI.RadioBox({ el: $('#paste-radio-without-borders'), name: 'asc-radio-paste', labelText: this.textWBorders, - value: Asc.c_oSpecialPasteProps.formulaWithoutBorders + value: Asc.c_oSpecialPasteProps.formulaWithoutBorders, + disabled: true }); this.radioWBorders.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = this.radioWBorders; this.radioFFormat = new Common.UI.RadioBox({ el: $('#paste-radio-formula-formats'), name: 'asc-radio-paste', labelText: this.textFFormat, - value: Asc.c_oSpecialPasteProps.formulaAllFormatting + value: Asc.c_oSpecialPasteProps.formulaAllFormatting, + disabled: true }); this.radioFFormat.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.formulaAllFormatting] = this.radioFFormat; this.radioFWidth = new Common.UI.RadioBox({ el: $('#paste-radio-formula-col-width'), name: 'asc-radio-paste', labelText: this.textFWidth, - value: Asc.c_oSpecialPasteProps.formulaColumnWidth + value: Asc.c_oSpecialPasteProps.formulaColumnWidth, + disabled: true }); this.radioFWidth.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.formulaColumnWidth] = this.radioFWidth; this.radioFNFormat = new Common.UI.RadioBox({ el: $('#paste-radio-formula-num-format'), name: 'asc-radio-paste', labelText: this.textFNFormat, - value: Asc.c_oSpecialPasteProps.formulaNumberFormat + value: Asc.c_oSpecialPasteProps.formulaNumberFormat, + disabled: true }); this.radioFNFormat.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.formulaNumberFormat] = this.radioFNFormat; this.radioVNFormat = new Common.UI.RadioBox({ el: $('#paste-radio-value-num-format'), name: 'asc-radio-paste', labelText: this.textVNFormat, - value: Asc.c_oSpecialPasteProps.valueNumberFormat + value: Asc.c_oSpecialPasteProps.valueNumberFormat, + disabled: true }); this.radioVNFormat.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.valueNumberFormat] = this.radioVNFormat; this.radioVFormat = new Common.UI.RadioBox({ el: $('#paste-radio-value-formats'), name: 'asc-radio-paste', labelText: this.textVFormat, - value: Asc.c_oSpecialPasteProps.valueAllFormating + value: Asc.c_oSpecialPasteProps.valueAllFormating, + disabled: true }); this.radioVFormat.on('change', _.bind(this.onRadioPasteChange, this)); + this.propControls[Asc.c_oSpecialPasteProps.valueAllFormating] = this.radioVFormat; this.radioNone = new Common.UI.RadioBox({ el: $('#paste-radio-none'), @@ -335,6 +360,11 @@ define([ }, _setDefaults: function (props) { + var me = this; + props && _.each(props, function(menuItem, index) { + me.propControls[menuItem] && me.propControls[menuItem].setDisabled(false); + }); + this._changedProps = new Asc.SpecialPasteProps(); this._changedProps.asc_setProps(Asc.c_oSpecialPasteProps.paste); this._changedProps.asc_setOperation(Asc.c_oSpecialPasteOperation.none); From 7a875c8df1662d7395410aad260368f940a8bcdf Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 3 Mar 2020 12:42:06 +0300 Subject: [PATCH 3/4] [SSE] Special paste for tables --- .../main/app/controller/DocumentHolder.js | 2 +- .../main/app/view/SpecialPasteDialog.js | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 4ad902e1f..df9ada125 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2372,7 +2372,7 @@ define([ value: 'special' }).on('click', function(item, e) { (new SSE.Views.SpecialPasteDialog({ - props: pasteItems, + props: specialPasteShowOptions, handler: function (result, settings) { if (result == 'ok') { if (me && me.api) { diff --git a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js index 6c5995602..e1b2137af 100644 --- a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js @@ -168,6 +168,7 @@ define([ this.handler = options.handler; this.props = options.props; this._changedProps = null; + this.isTable = false; Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); }, @@ -360,10 +361,14 @@ define([ }, _setDefaults: function (props) { - var me = this; - props && _.each(props, function(menuItem, index) { - me.propControls[menuItem] && me.propControls[menuItem].setDisabled(false); - }); + if (props) { + var me = this; + var pasteItems = props.asc_getOptions(); + pasteItems && _.each(pasteItems, function(menuItem, index) { + me.propControls[menuItem] && me.propControls[menuItem].setDisabled(false); + }); + this.isTable = !!props.asc_getContainTables(); + } this._changedProps = new Asc.SpecialPasteProps(); this._changedProps.asc_setProps(Asc.c_oSpecialPasteProps.paste); @@ -396,12 +401,15 @@ define([ if (newValue && this._changedProps) { this._changedProps.asc_setProps(field.options.value); var disable = field.options.value == Asc.c_oSpecialPasteProps.pasteOnlyFormating || field.options.value == Asc.c_oSpecialPasteProps.comments || - field.options.value == Asc.c_oSpecialPasteProps.columnWidth; - this.radioNone.setDisabled(disable); - this.radioAdd.setDisabled(disable); - this.radioDiv.setDisabled(disable); - this.radioSub.setDisabled(disable); - this.radioMult.setDisabled(disable); + field.options.value == Asc.c_oSpecialPasteProps.columnWidth, + disableTable = this.isTable && !!this._changedProps.asc_getTableAllowed(); + this.radioNone.setDisabled(disable || disableTable); + this.radioAdd.setDisabled(disable || disableTable); + this.radioDiv.setDisabled(disable || disableTable); + this.radioSub.setDisabled(disable || disableTable); + this.radioMult.setDisabled(disable || disableTable); + this.chBlanks.setDisabled(disableTable); + this.chTranspose.setDisabled(disableTable); } }, From 11bd243b0a2165b755c24e1968a742ac6c5b2a61 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 3 Mar 2020 14:01:20 +0300 Subject: [PATCH 4/4] [SSE] Fix special paste for tables --- .../main/app/controller/DocumentHolder.js | 12 +++++++----- .../main/app/view/SpecialPasteDialog.js | 18 +++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index df9ada125..d63580599 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2248,7 +2248,8 @@ define([ documentHolderView = me.documentHolder, coord = specialPasteShowOptions.asc_getCellCoord(), pasteContainer = documentHolderView.cmpEl.find('#special-paste-container'), - pasteItems = specialPasteShowOptions.asc_getOptions(); + pasteItems = specialPasteShowOptions.asc_getOptions(), + isTable = !!specialPasteShowOptions.asc_getContainTables(); if (!pasteItems) return; // Prepare menu container @@ -2372,15 +2373,16 @@ define([ value: 'special' }).on('click', function(item, e) { (new SSE.Views.SpecialPasteDialog({ - props: specialPasteShowOptions, + props: pasteItems, + isTable: isTable, handler: function (result, settings) { if (result == 'ok') { - if (me && me.api) { - me.api.asc_SpecialPaste(settings); - } me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(false, true); me._state.lastSpecPasteChecked = settings && me._arrSpecialPaste[settings.asc_getProps()] ? me._arrSpecialPaste[settings.asc_getProps()][2] : null; me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true); + if (me && me.api) { + me.api.asc_SpecialPaste(settings); + } } } })).show(); diff --git a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js index e1b2137af..894738de9 100644 --- a/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js @@ -168,7 +168,7 @@ define([ this.handler = options.handler; this.props = options.props; this._changedProps = null; - this.isTable = false; + this.isTable = !!options.isTable; Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); }, @@ -183,7 +183,6 @@ define([ name: 'asc-radio-paste', labelText: this.textAll, value: Asc.c_oSpecialPasteProps.paste, - checked: true, disabled: true }); this.radioAll.on('change', _.bind(this.onRadioPasteChange, this)); @@ -361,18 +360,15 @@ define([ }, _setDefaults: function (props) { - if (props) { - var me = this; - var pasteItems = props.asc_getOptions(); - pasteItems && _.each(pasteItems, function(menuItem, index) { - me.propControls[menuItem] && me.propControls[menuItem].setDisabled(false); - }); - this.isTable = !!props.asc_getContainTables(); - } - + var me = this; + props && _.each(props, function(menuItem, index) { + me.propControls[menuItem] && me.propControls[menuItem].setDisabled(false); + }); this._changedProps = new Asc.SpecialPasteProps(); this._changedProps.asc_setProps(Asc.c_oSpecialPasteProps.paste); this._changedProps.asc_setOperation(Asc.c_oSpecialPasteOperation.none); + + this.radioAll.setValue(true); }, getSettings: function () {