diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 82cd8e62b..24d7ac4e7 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'; @@ -2248,7 +2249,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 @@ -2328,7 +2330,8 @@ define([ })).show(); setTimeout(function(){menu.hide();}, 100); }); - } else { + me._arrSpecialPaste[menuItem][2] = importText; + } else if (me._arrSpecialPaste[menuItem]) { var mnu = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0], value: menuItem, @@ -2343,6 +2346,7 @@ define([ setTimeout(function(){menu.hide();}, 100); }); groups[me._arrSpecialPaste[menuItem][1]].push(mnu); + me._arrSpecialPaste[menuItem][2] = mnu; } }); var newgroup = false; @@ -2363,6 +2367,30 @@ 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, + isTable: isTable, + handler: function (result, settings) { + if (result == 'ok') { + 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(); + setTimeout(function(){menu.hide();}, 100); + }); + menu.addItem(mnu); + } } if ( coord[0].asc_getX()<0 || coord[0].asc_getY()<0) { @@ -3335,16 +3363,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', @@ -3380,7 +3408,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..894738de9 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/SpecialPasteDialog.js @@ -0,0 +1,442 @@ +/* + * + * (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; + this.isTable = !!options.isTable; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + + render: function() { + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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'), + 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) { + 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 () { + 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, + 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); + } + }, + + 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 982878ee4..a752333f9 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",