From da22437f35bfe1766f6a9346c8ef3db938f587db Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 16 Apr 2019 15:28:07 +0300 Subject: [PATCH 1/6] [SSE] Fill groups for special paste. Add item for Text import --- .../main/app/controller/DocumentHolder.js | 101 ++++++++++++------ 1 file changed, 66 insertions(+), 35 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 28cecea7d..767333578 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2135,23 +2135,25 @@ define([ // Prepare menu container if (pasteContainer.length < 1) { me._arrSpecialPaste = []; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = me.txtPaste; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = me.txtPasteFormulas; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = me.txtPasteFormulaNumFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = me.txtPasteKeepSourceFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = me.txtPasteBorders; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = me.txtPasteColWidths; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = me.txtPasteMerge; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = me.txtPasteValues; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = me.txtPasteValNumFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = me.txtPasteValFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = me.txtPasteFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = me.txtPasteTranspose; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.link] = me.txtPasteLink; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = me.txtPastePicture; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.linkedPicture] = me.txtPasteLinkPicture; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = me.txtPasteSourceFormat; - me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = me.txtPasteDestFormat; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.paste] = [me.txtPaste, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormula] = [me.txtPasteFormulas, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaNumberFormat] = [me.txtPasteFormulaNumFormat, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaAllFormatting] = [me.txtPasteKeepSourceFormat, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaWithoutBorders] = [me.txtPasteBorders, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.formulaColumnWidth] = [me.txtPasteColWidths, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.mergeConditionalFormating] = [me.txtPasteMerge, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.transpose] = [me.txtPasteTranspose, 0]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyValues] = [me.txtPasteValues, 1]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueNumberFormat] = [me.txtPasteValNumFormat, 1]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.valueAllFormating] = [me.txtPasteValFormat, 1]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.pasteOnlyFormating] = [me.txtPasteFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.link] = [me.txtPasteLink, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.picture] = [me.txtPastePicture, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.linkedPicture] = [me.txtPasteLinkPicture, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.sourceformatting] = [me.txtPasteSourceFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.destinationFormatting] = [me.txtPasteDestFormat, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.keepTextOnly] = [me.txtKeepTextOnly, 2]; + me._arrSpecialPaste[Asc.c_oSpecialPasteProps.useTextImport] = [me.txtUseTextImport, 3]; pasteContainer = $('
'); documentHolderView.cmpEl.append(pasteContainer); @@ -2170,28 +2172,55 @@ define([ menu.removeItem(menu.items[i]); i--; } + var groups = []; + for (var i = 0; i < 3; i++) { + groups[i] = []; + } - var group_prev = -1; + var importText; _.each(pasteItems, function(menuItem, index) { - var group = (menuItem<7) ? 0 : (menuItem>9 ? 2 : 1); - if (group_prev !== group && group_prev>=0) - menu.addItem(new Common.UI.MenuItem({ caption: '--' })); - group_prev = group; - - var mnu = new Common.UI.MenuItem({ - caption: me._arrSpecialPaste[menuItem], - value: menuItem, - checkable: true, - toggleGroup : 'specialPasteGroup' - }).on('click', function(item, e) { - var props = new Asc.SpecialPasteProps(); - props.asc_setProps(item.value); - me.api.asc_SpecialPaste(props); - setTimeout(function(){menu.hide();}, 100); - }); - menu.addItem(mnu); + if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { + importText = new Common.UI.MenuItem({ + caption: me._arrSpecialPaste[menuItem][0], + value: menuItem + }).on('click', function(item, e) { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(item.value); + me.api.asc_SpecialPaste(props); + setTimeout(function(){menu.hide();}, 100); + }); + } else { + var mnu = new Common.UI.MenuItem({ + caption: me._arrSpecialPaste[menuItem][0], + value: menuItem, + checkable: true, + toggleGroup : 'specialPasteGroup' + }).on('click', function(item, e) { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(item.value); + me.api.asc_SpecialPaste(props); + setTimeout(function(){menu.hide();}, 100); + }); + groups[me._arrSpecialPaste[menuItem][1]].push(mnu); + } }); + var newgroup = false; + for (var i = 0; i < 3; i++) { + if (newgroup && groups[i].length>0) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + newgroup = false; + } + _.each(groups[i], function(menuItem, index) { + menu.addItem(menuItem); + newgroup = true; + }); + } (menu.items.length>0) && menu.items[0].setChecked(true, true); + + if (importText) { + menu.addItem(new Common.UI.MenuItem({ caption: '--' })); + menu.addItem(importText); + } } if ( coord[0].asc_getX()<0 || coord[0].asc_getY()<0) { @@ -3180,6 +3209,8 @@ define([ txtPasteLinkPicture: 'Linked Picture', txtPasteSourceFormat: 'Source formatting', txtPasteDestFormat: 'Destination formatting', + txtKeepTextOnly: 'Keep text only', + txtUseTextImport: 'Use text import wizard', txtUndoExpansion: 'Undo table autoexpansion', txtRedoExpansion: 'Redo table autoexpansion', txtAnd: 'and', From 60004afb1de6dabfe287da120a57214285db4758 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 17 Apr 2019 12:01:20 +0300 Subject: [PATCH 2/6] Change layout for Open Dialog. [SSE] Add import wizard for special paste --- apps/common/main/lib/util/utils.js | 8 ++ apps/common/main/lib/view/OpenDialog.js | 114 ++++++++++-------- .../main/app/controller/Main.js | 8 +- .../main/app/controller/Main.js | 3 +- .../main/app/controller/DocumentHolder.js | 23 +++- .../main/app/controller/Main.js | 8 +- apps/spreadsheeteditor/main/locale/en.json | 3 + 7 files changed, 103 insertions(+), 64 deletions(-) diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 397fc45aa..5e9fd14ac 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -106,6 +106,13 @@ Common.Utils = _.extend(new(function() { Pivot : 10, Cell : 11 }, + importTextType = { + DRM: 0, + CSV: 1, + TXT: 2, + Paste: 3, + Columns: 4 + }, isMobile = /android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent || navigator.vendor || window.opera), me = this, checkSize = function() { @@ -203,6 +210,7 @@ Common.Utils = _.extend(new(function() { ipStrongRe: ipStrongRe, hostnameStrongRe: hostnameStrongRe, documentSettingsType: documentSettingsType, + importTextType: importTextType, zoom: function() {return me.zoom;}, innerWidth: function() {return me.innerWidth;}, innerHeight: function() {return me.innerHeight;} diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index e03d2a2e0..e6c5ea5fc 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -59,21 +59,20 @@ define([ width = 414; height = 277; } else { - width = (options.type !== Asc.c_oAscAdvancedOptionsID.DRM) ? 340 : (options.warning ? 370 : 262); - height = (options.type == Asc.c_oAscAdvancedOptionsID.CSV) ? 190 : (options.warning ? 187 : 147); + width = (options.type !== Common.Utils.importTextType.DRM) ? 340 : (options.warning ? 370 : 262); + height = (options.type == Common.Utils.importTextType.CSV || options.type == Common.Utils.importTextType.Paste || options.type == Common.Utils.importTextType.Columns) ? 190 : (options.warning ? 187 : 147); } _.extend(_options, { - mode : 1, // open settings - closable : (options.mode==2), // if save settings + closable : false, // true if save settings preview : options.preview, warning : options.warning, + codepages : options.codepages, width : width, height : height, header : true, cls : 'open-dlg', contentTemplate : '', - title : (options.type == Asc.c_oAscAdvancedOptionsID.DRM) ? t.txtTitleProtected : t.txtTitle.replace('%1', (options.type == Asc.c_oAscAdvancedOptionsID.CSV) ? 'CSV' : 'TXT'), toolcallback : _.bind(t.onToolClose, t), closeFile : false @@ -82,7 +81,7 @@ define([ this.template = options.template || [ '
', '
', - '<% if (type == Asc.c_oAscAdvancedOptionsID.DRM) { %>', + '<% if (type == Common.Utils.importTextType.DRM) { %>', '<% if (warning) { %>', '
', '
', @@ -97,13 +96,15 @@ define([ '
', '<% } %>', '<% } else { %>', - '
', + '<% if (codepages && codepages.length>0) { %>', + '
', '', '
', '
', '
', '
', - '<% if (type == Asc.c_oAscAdvancedOptionsID.CSV) { %>', + '<% } %>', + '<% if (type == Common.Utils.importTextType.CSV || type == Common.Utils.importTextType.Paste || type == Common.Utils.importTextType.Columns) { %>', '
', '', '
', @@ -168,7 +169,7 @@ define([ this.previewScrolled = this.$window.find('#id-preview'); this.previewInner = this.previewScrolled.find('div:first-child'); - if (this.type == Asc.c_oAscAdvancedOptionsID.DRM) { + if (this.type == Common.Utils.importTextType.DRM) { this.inputPwd = new Common.UI.InputField({ el: $('#id-password-txt'), type: 'text', @@ -200,7 +201,7 @@ define([ show: function() { Common.UI.Window.prototype.show.apply(this, arguments); - if (this.type == Asc.c_oAscAdvancedOptionsID.DRM) { + if (this.type == Common.Utils.importTextType.DRM) { var me = this; setTimeout(function(){ me.inputPwd.cmpEl.find('input').focus(); @@ -220,15 +221,15 @@ define([ _handleInput: function(state) { if (this.handler) { - if (this.cmbEncoding) { - var encoding = (!this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() : - ((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0), + if (this.type == Common.Utils.importTextType.DRM) { + this.handler.call(this, state, this.inputPwd.getValue()); + } else { + var encoding = (this.cmbEncoding && !this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() : + ((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0), delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null, delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null; (delimiter == -1) && (delimiter = null); this.handler.call(this, state, encoding, delimiter, delimiterChar); - } else { - this.handler.call(this, state, this.inputPwd.getValue()); } } @@ -253,37 +254,37 @@ define([ } length = encodedata.length; - for (i = 0; i < length; ++i) { - listItems.push({ - value: encodedata[i][0], - displayValue: Common.Utils.String.htmlEncode(encodedata[i][1]), - lcid: encodedata[i][2] || '' - }); - } + if (length) { + for (i = 0; i < length; ++i) { + listItems.push({ + value: encodedata[i][0], + displayValue: Common.Utils.String.htmlEncode(encodedata[i][1]), + lcid: encodedata[i][2] || '' + }); + } - var itemsTemplate = - _.template([ - '<% _.each(items, function(item) { %>', - '
  • ', + var itemsTemplate = + _.template([ + '<% _.each(items, function(item) { %>', + '
  • ', '
    <%= item.displayValue %>
    ', '', - '
  • ', - '<% }); %>' - ].join('')); + '', + '<% }); %>' + ].join('')); - this.cmbEncoding = new Common.UI.ComboBox({ - el: $('#id-codepages-combo', this.$window), - style: 'width: 100%;', - menuStyle: 'min-width: 100%; max-height: 200px;', - cls: 'input-group-nr', - menuCls: 'scrollable-menu', - data: listItems, - editable: false, - disabled: true, - itemsTemplate: itemsTemplate - }); + this.cmbEncoding = new Common.UI.ComboBox({ + el: $('#id-codepages-combo', this.$window), + style: 'width: 100%;', + menuStyle: 'min-width: 100%; max-height: 200px;', + cls: 'input-group-nr', + menuCls: 'scrollable-menu', + data: listItems, + editable: false, + disabled: true, + itemsTemplate: itemsTemplate + }); - if (length) { this.cmbEncoding.setDisabled(false); this.cmbEncoding.setValue((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : encodedata[0][0]); if (this.preview) @@ -295,7 +296,7 @@ define([ ul.find('li div').width(width); } - if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) { + if (this.type == Common.Utils.importTextType.CSV || this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns) { this.cmbDelimiter = new Common.UI.ComboBox({ el: $('#id-delimiters-combo', this.$window), style: 'width: 100px;', @@ -328,16 +329,23 @@ define([ }, updatePreview: function() { - var encoding = (!this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() : + var encoding = (this.cmbEncoding && !this.cmbEncoding.isDisabled()) ? this.cmbEncoding.getValue() : ((this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : 0); + var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null, + delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null; + (delimiter == -1) && (delimiter = null); - if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) { - var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null, - delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null; - (delimiter == -1) && (delimiter = null); - this.api.asc_decodeBuffer(this.preview, new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this)); - } else { - this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTXTAdvancedOptions(encoding), _.bind(this.previewCallback, this)); + switch (this.type) { + case Common.Utils.importTextType.CSV: + this.api.asc_decodeBuffer(this.preview, new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this)); + break; + case Common.Utils.importTextType.TXT: + this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTXTAdvancedOptions(encoding), _.bind(this.previewCallback, this)); + break; + case Common.Utils.importTextType.Paste: + case Common.Utils.importTextType.Columns: + this.api.asc_TextImport(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this), this.type == Common.Utils.importTextType.Paste); + break; } }, @@ -379,7 +387,7 @@ define([ delete this.scrollerX; } - if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) { + if (this.type == Common.Utils.importTextType.CSV || this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns) { var maxlength = 0; for (var i=0; imaxlength) @@ -387,7 +395,7 @@ define([ } var tpl = ''; for (var i=0; i'; } @@ -400,7 +408,7 @@ define([ } else { var tpl = '
    '; for (var i=0; i'; + tpl += ''; } tpl += '
    ' + Common.Utils.String.htmlEncode(data[i]) + '
    '; } diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index c94a59a71..55d33757d 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1947,8 +1947,9 @@ define([ me = this; if (type == Asc.c_oAscAdvancedOptionsID.TXT) { me._state.openDlg = new Common.Views.OpenDialog({ - mode: mode, - type: type, + title: Common.Views.OpenDialog.prototype.txtTitle.replace('%1', 'TXT'), + closable: (mode==2), // if save settings + type: Common.Utils.importTextType.TXT, preview: advOptions.asc_getOptions().asc_getData(), codepages: advOptions.asc_getOptions().asc_getCodePages(), settings: advOptions.asc_getOptions().asc_getRecommendedSettings(), @@ -1966,8 +1967,9 @@ define([ }); } else if (type == Asc.c_oAscAdvancedOptionsID.DRM) { me._state.openDlg = new Common.Views.OpenDialog({ + title: Common.Views.OpenDialog.prototype.txtTitleProtected, closeFile: me.appOptions.canRequestClose, - type: type, + type: Common.Utils.importTextType.DRM, warning: !(me.appOptions.isDesktopApp && me.appOptions.isOffline), validatePwd: !!me._state.isDRM, handler: function (result, value) { diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index c8a32420c..373bd1208 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1788,8 +1788,9 @@ define([ me = this; if (type == Asc.c_oAscAdvancedOptionsID.DRM) { me._state.openDlg = new Common.Views.OpenDialog({ + title: Common.Views.OpenDialog.prototype.txtTitleProtected, closeFile: me.appOptions.canRequestClose, - type: type, + type: Common.Utils.importTextType.DRM, warning: !(me.appOptions.isDesktopApp && me.appOptions.isOffline), validatePwd: !!me._state.isDRM, handler: function (result, value) { diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 767333578..6aafac5da 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2184,9 +2184,23 @@ define([ caption: me._arrSpecialPaste[menuItem][0], value: menuItem }).on('click', function(item, e) { - var props = new Asc.SpecialPasteProps(); - props.asc_setProps(item.value); - me.api.asc_SpecialPaste(props); + (new Common.Views.OpenDialog({ + title: me.txtImportWizard, + closable: true, + type: Common.Utils.importTextType.Paste, + preview: true, + api: me.api, + handler: function (result, encoding, delimiter, delimiterChar) { + if (result == 'ok') { + if (me && me.api) { + var props = new Asc.SpecialPasteProps(); + props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport); + props.asc_setAdvancedOptions(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar)); + me.api.asc_SpecialPaste(props); + } + } + } + })).show(); setTimeout(function(){menu.hide();}, 100); }); } else { @@ -3237,7 +3251,8 @@ define([ txtEqualsToFontColor: 'Equals to font color', txtAll: '(All)', txtBlanks: '(Blanks)', - txtColumn: 'Column' + txtColumn: 'Column', + txtImportWizard: 'Text Import Wizard' }, SSE.Controllers.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index d359cea10..ab08089e4 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1605,8 +1605,9 @@ define([ me = this; if (type == Asc.c_oAscAdvancedOptionsID.CSV) { me._state.openDlg = new Common.Views.OpenDialog({ - mode: mode, - type: type, + title: Common.Views.OpenDialog.prototype.txtTitle.replace('%1', 'CSV'), + closable: (mode==2), // if save settings + type: Common.Utils.importTextType.CSV, preview: advOptions.asc_getOptions().asc_getData(), codepages: advOptions.asc_getOptions().asc_getCodePages(), settings: advOptions.asc_getOptions().asc_getRecommendedSettings(), @@ -1624,8 +1625,9 @@ define([ }); } else if (type == Asc.c_oAscAdvancedOptionsID.DRM) { me._state.openDlg = new Common.Views.OpenDialog({ + title: Common.Views.OpenDialog.prototype.txtTitleProtected, closeFile: me.appOptions.canRequestClose, - type: type, + type: Common.Utils.importTextType.DRM, warning: !(me.appOptions.isDesktopApp && me.appOptions.isOffline), validatePwd: !!me._state.isDRM, handler: function (result, value) { diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5c38e3620..9dfbcda75 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -368,6 +368,9 @@ "SSE.Controllers.DocumentHolder.txtUnderbar": "Bar under text", "SSE.Controllers.DocumentHolder.txtUndoExpansion": "Undo table autoexpansion", "SSE.Controllers.DocumentHolder.txtWidth": "Width", + "SSE.Controllers.DocumentHolder.txtKeepTextOnly": "Keep text only", + "SSE.Controllers.DocumentHolder.txtUseTextImport": "Use text import wizard", + "SSE.Controllers.DocumentHolder.txtImportWizard": "Text Import Wizard", "SSE.Controllers.LeftMenu.newDocumentTitle": "Unnamed spreadsheet", "SSE.Controllers.LeftMenu.textByColumns": "By columns", "SSE.Controllers.LeftMenu.textByRows": "By rows", From 3a2bce2d8cd0ac55afeeacf0c8d0f025fe74804d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 17 Apr 2019 15:58:55 +0300 Subject: [PATCH 3/6] [SSE] Special paste: check wizard menu item --- .../main/app/controller/DocumentHolder.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 6aafac5da..ccf2eb6d4 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2182,7 +2182,9 @@ define([ if (menuItem == Asc.c_oSpecialPasteProps.useTextImport) { importText = new Common.UI.MenuItem({ caption: me._arrSpecialPaste[menuItem][0], - value: menuItem + value: menuItem, + checkable: true, + toggleGroup : 'specialPasteGroup' }).on('click', function(item, e) { (new Common.Views.OpenDialog({ title: me.txtImportWizard, @@ -2198,6 +2200,10 @@ define([ props.asc_setAdvancedOptions(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar)); me.api.asc_SpecialPaste(props); } + me._state.lastSpecPasteChecked = item; + } else { + item.setChecked(false, true); + me._state.lastSpecPasteChecked && me._state.lastSpecPasteChecked.setChecked(true, true); } } })).show(); @@ -2210,6 +2216,8 @@ define([ checkable: true, toggleGroup : 'specialPasteGroup' }).on('click', function(item, e) { + me._state.lastSpecPasteChecked = item; + var props = new Asc.SpecialPasteProps(); props.asc_setProps(item.value); me.api.asc_SpecialPaste(props); @@ -2230,6 +2238,7 @@ define([ }); } (menu.items.length>0) && menu.items[0].setChecked(true, true); + me._state.lastSpecPasteChecked = (menu.items.length>0) ? menu.items[0] : null; if (importText) { menu.addItem(new Common.UI.MenuItem({ caption: '--' })); From df151f23d4279f7fcbf9e7618a0a86ec4dc8dde4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 17 Apr 2019 16:16:02 +0300 Subject: [PATCH 4/6] [SSE] Add Text to Columns button to the cell settings panel --- .../main/app/controller/DocumentHolder.js | 1 + .../main/app/template/CellSettings.template | 10 ++++++ .../main/app/view/CellSettings.js | 31 +++++++++++++++++-- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index ccf2eb6d4..601d66f10 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -45,6 +45,7 @@ define([ 'common/main/lib/util/utils', 'common/main/lib/util/Shortcuts', 'common/main/lib/view/CopyWarningDialog', + 'common/main/lib/view/OpenDialog', 'spreadsheeteditor/main/app/view/DocumentHolder', 'spreadsheeteditor/main/app/view/HyperlinkSettingsDialog', 'spreadsheeteditor/main/app/view/ParagraphSettingsAdvanced', diff --git a/apps/spreadsheeteditor/main/app/template/CellSettings.template b/apps/spreadsheeteditor/main/app/template/CellSettings.template index f02f4417d..59be2c71d 100644 --- a/apps/spreadsheeteditor/main/app/template/CellSettings.template +++ b/apps/spreadsheeteditor/main/app/template/CellSettings.template @@ -60,5 +60,15 @@
    + + +
    + + + + + + + \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/CellSettings.js b/apps/spreadsheeteditor/main/app/view/CellSettings.js index 776d80a9b..07520e2ec 100644 --- a/apps/spreadsheeteditor/main/app/view/CellSettings.js +++ b/apps/spreadsheeteditor/main/app/view/CellSettings.js @@ -46,7 +46,8 @@ define([ 'common/main/lib/component/Button', 'common/main/lib/component/ThemeColorPalette', 'common/main/lib/component/ColorButton', - 'common/main/lib/component/ComboBorderSize' + 'common/main/lib/component/ComboBorderSize', + 'common/main/lib/view/OpenDialog' ], function (menuTemplate, $, _, Backbone) { 'use strict'; @@ -138,6 +139,24 @@ define([ this.api && this.api.asc_setCellAngle(field.getNumberValue()); }, + onTextToColumn: function() { + var me = this; + (new Common.Views.OpenDialog({ + title: me.txtImportWizard, + closable: true, + type: Common.Utils.importTextType.Columns, + preview: true, + api: me.api, + handler: function (result, encoding, delimiter, delimiterChar) { + if (result == 'ok') { + if (me && me.api) { + me.api.asc_TextToColumns(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar)); + } + } + } + })).show(); + }, + render: function () { var el = $(this.el); el.html(this.template({ @@ -236,6 +255,12 @@ define([ }); this.lockedControls.push(this.spnAngle); this.spnAngle.on('change', _.bind(this.onAngleChange, this)); + + this.btnTextToColumn = new Common.UI.Button({ + el: $('#cell-btn-text-to-column') + }); + this.btnTextToColumn.on('click', _.bind(this.onTextToColumn, this)); + this.lockedControls.push(this.btnTextToColumn); }, createDelayedElements: function() { @@ -367,7 +392,9 @@ define([ tipDiagU: 'Set Diagonal Up Border', tipDiagD: 'Set Diagonal Down Border', textOrientation: 'Text Orientation', - textAngle: 'Angle' + textAngle: 'Angle', + textTextToColumn: 'Text to Columns', + textWizard: 'Text to Columns Wizard' }, SSE.Views.CellSettings || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 9dfbcda75..0dcac7cb2 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1145,6 +1145,8 @@ "SSE.Views.CellSettings.tipOuter": "Set outer border only", "SSE.Views.CellSettings.tipRight": "Set outer right border only", "SSE.Views.CellSettings.tipTop": "Set outer top border only", + "SSE.Views.CellSettings.textTextToColumn": "Text to Columns", + "SSE.Views.CellSettings.textWizard": "Text to Columns Wizard", "SSE.Views.ChartSettings.strLineWeight": "Line Weight", "SSE.Views.ChartSettings.strSparkColor": "Color", "SSE.Views.ChartSettings.strTemplate": "Template", From 59997a0212b5bcef4ac5b52f2bc159e73b0a314e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 18 Apr 2019 11:39:58 +0300 Subject: [PATCH 5/6] [SSE] Disable parsing text for multiselect, add error for empty source --- apps/common/main/lib/view/OpenDialog.js | 6 ++++-- .../main/app/controller/Main.js | 7 ++++++- .../main/app/view/CellSettings.js | 18 +++++++++++++++++- apps/spreadsheeteditor/main/locale/en.json | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index e6c5ea5fc..79b608529 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -144,6 +144,7 @@ define([ this.handler = _options.handler; this.type = _options.type; this.preview = _options.preview; + this.previewData = _options.previewData; this.warning = _options.warning || false; this.closable = _options.closable; this.codepages = _options.codepages; @@ -188,8 +189,9 @@ define([ }); } else { this.initCodePages(); - if (this.preview) - this.updatePreview(); + if (this.preview) { + (this.previewData) ? this.previewCallback(this.previewData) : this.updatePreview(); + } } this.onPrimary = function() { me._handleInput('ok'); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ab08089e4..c0e66f3d9 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1365,6 +1365,10 @@ define([ config.msg = this.errorEmailClient; break; + case Asc.c_oAscError.ID.NoDataToParse: + config.msg = this.errorNoDataToParse; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; @@ -2495,7 +2499,8 @@ define([ errorEmailClient: 'No email client could be found', txtPrintArea: 'Print_Area', txtTable: 'Table', - textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.
    Please contact our Sales Department to get a quote.' + textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.
    Please contact our Sales Department to get a quote.', + errorNoDataToParse: 'No data was selected to parse.' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/app/view/CellSettings.js b/apps/spreadsheeteditor/main/app/view/CellSettings.js index 07520e2ec..8fed6edaf 100644 --- a/apps/spreadsheeteditor/main/app/view/CellSettings.js +++ b/apps/spreadsheeteditor/main/app/view/CellSettings.js @@ -71,11 +71,13 @@ define([ this._state = { BackColor: undefined, DisabledControls: true, - CellAngle: undefined + CellAngle: undefined, + CSVOptions: new Asc.asc_CCSVAdvancedOptions(0, 4, '') }; this.lockedControls = []; this._locked = true; this.isEditCell = false; + this.isMultiSelect = false; this.BorderType = 1; this.render(); @@ -140,12 +142,20 @@ define([ }, onTextToColumn: function() { + this.api.asc_TextImport(this._state.CSVOptions, _.bind(this.onTextToColumnCallback, this), false); + }, + + onTextToColumnCallback: function(data) { + if (!data || !data.length) return; + var me = this; (new Common.Views.OpenDialog({ title: me.txtImportWizard, closable: true, type: Common.Utils.importTextType.Columns, preview: true, + previewData: data, + settings: this._state.CSVOptions, api: me.api, handler: function (result, encoding, delimiter, delimiterChar) { if (result == 'ok') { @@ -168,6 +178,7 @@ define([ this.api = o; if (o) { this.api.asc_registerCallback('asc_onEditCell', this.onApiEditCell.bind(this)); + this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); } return this; }, @@ -358,6 +369,10 @@ define([ this.disableControls(this._locked); }, + onApiSelectionChanged: function(info) { + this.isMultiSelect = info.asc_getFlags().asc_getMultiselect() || info.asc_getSelectedColsCount()>1; + }, + setLocked: function (locked) { this._locked = locked; }, @@ -372,6 +387,7 @@ define([ item.setDisabled(disable); }); } + this.btnTextToColumn.setDisabled(disable || this.isMultiSelect); }, textBorders: 'Border\'s Style', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 0dcac7cb2..f27301a55 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -725,6 +725,7 @@ "SSE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
    If you need more please consider purchasing a commercial license.", "SSE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
    If you need more please consider purchasing a commercial license.", "SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", + "SSE.Controllers.Main.errorNoDataToParse": "No data was selected to parse.", "SSE.Controllers.Print.strAllSheets": "All Sheets", "SSE.Controllers.Print.textWarning": "Warning", "SSE.Controllers.Print.txtCustom": "Custom", From b8291cd05f379f19893d79ed9353c2df33d012e1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 18 Apr 2019 13:24:14 +0300 Subject: [PATCH 6/6] [SSE] Fix translation --- apps/spreadsheeteditor/main/app/view/CellSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/CellSettings.js b/apps/spreadsheeteditor/main/app/view/CellSettings.js index 8fed6edaf..735fce90a 100644 --- a/apps/spreadsheeteditor/main/app/view/CellSettings.js +++ b/apps/spreadsheeteditor/main/app/view/CellSettings.js @@ -150,7 +150,7 @@ define([ var me = this; (new Common.Views.OpenDialog({ - title: me.txtImportWizard, + title: me.textWizard, closable: true, type: Common.Utils.importTextType.Columns, preview: true,