From 7311cd0c8c07d44b103ad341a28472bffda823af Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 23 Mar 2021 16:55:20 +0300 Subject: [PATCH] Refactoring open dialog --- apps/common/main/lib/view/OpenDialog.js | 11 +++++++-- .../main/app/controller/Main.js | 8 +++---- .../main/app/controller/Main.js | 2 +- .../main/app/controller/DataTab.js | 23 +++++-------------- .../main/app/controller/DocumentHolder.js | 8 ++----- .../main/app/controller/Main.js | 8 +++---- 6 files changed, 26 insertions(+), 34 deletions(-) diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index e59b5302b..796ab4cfb 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -264,7 +264,7 @@ define([ _handleInput: function(state) { if (this.handler) { if (this.type == Common.Utils.importTextType.DRM) { - this.handler.call(this, state, this.inputPwd.getValue()); + this.handler.call(this, state, {drmOptions: new Asc.asc_CDRMAdvancedOptions(this.inputPwd.getValue())}); } else { if ( this.type == Common.Utils.importTextType.Data && state == 'ok' && !this.isRangeValid() ) { return; @@ -281,7 +281,14 @@ define([ var decimal = this.separatorOptions ? this.separatorOptions.decimal : undefined, thousands = this.separatorOptions ? this.separatorOptions.thousands : undefined; - this.handler.call(this, state, encoding, delimiter, delimiterChar, decimal, thousands, this.txtDestRange ? this.txtDestRange.getValue() : ''); + var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar); + decimal && options.asc_setNumberDecimalSeparator(decimal); + thousands && options.asc_setNumberGroupSeparator(thousands); + this.handler.call(this, state, { + textOptions: options, + range: this.txtDestRange ? this.txtDestRange.getValue() : '', + data: this.data + }); } } diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index f4e20e493..b801f9f24 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -2147,15 +2147,15 @@ define([ codepages: advOptions.asc_getCodePages(), settings: advOptions.asc_getRecommendedSettings(), api: me.api, - handler: function (result, encoding) { + handler: function (result, settings) { me.isShowOpenDialog = false; if (result == 'ok') { if (me && me.api) { if (mode==2) { - formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding)); + formatOptions && formatOptions.asc_setAdvancedOptions(settings.textOptions); me.api.asc_DownloadAs(formatOptions); } else - me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding)); + me.api.asc_setAdvancedOptions(type, settings.textOptions); me.loadMask && me.loadMask.show(); } } @@ -2174,7 +2174,7 @@ define([ me.isShowOpenDialog = false; if (result == 'ok') { if (me.api) { - me.api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(value)); + me.api.asc_setAdvancedOptions(type, value.drmOptions); me.loadMask && me.loadMask.show(); } } else { diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index ef200e2b0..27ebb2f64 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1978,7 +1978,7 @@ define([ me.isShowOpenDialog = false; if (result == 'ok') { if (me.api) { - me.api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(value)); + me.api.asc_setAdvancedOptions(type, value.drmOptions); me.loadMask && me.loadMask.show(); } } else { diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 2279c2c7a..486cffcb8 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -209,14 +209,9 @@ define([ previewData: data, settings: me._state.CSVOptions, api: me.api, - handler: function (result, encoding, delimiter, delimiterChar, decimal, thousands) { - if (result == 'ok') { - if (me && me.api) { - var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar); - decimal && options.asc_setNumberDecimalSeparator(decimal); - thousands && options.asc_setNumberGroupSeparator(thousands); - me.api.asc_TextToColumns(options); - } + handler: function (result, settings) { + if (result == 'ok' && me.api) { + me.api.asc_TextToColumns(settings.textOptions); } } })).show(); @@ -263,16 +258,10 @@ define([ settings: advOptions ? advOptions.asc_getRecommendedSettings() : me._state.CSVOptions, codepages: advOptions ? advOptions.asc_getCodePages() : null, api: me.api, - handler: function (result, encoding, delimiter, delimiterChar, decimal, thousands, range) { - if (result == 'ok') { - if (me && me.api) { - var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar); - decimal && options.asc_setNumberDecimalSeparator(decimal); - thousands && options.asc_setNumberGroupSeparator(thousands); - me.api.asc_TextToColumns(options, me.api.asc_getTextFromFileOrUrl(), range); - } + handler: function (result, settings) { + if (result == 'ok' && me.api) { + me.api.asc_TextToColumns(settings.textOptions, settings.data, settings.range); } - me.api.asc_cleanTextFromFileOrUrl(); } })).show(); }, diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index d40201c40..8dc2f1ebe 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -2557,16 +2557,12 @@ define([ type: Common.Utils.importTextType.Paste, preview: true, api: me.api, - handler: function (result, encoding, delimiter, delimiterChar, decimal, thousands) { + handler: function (result, settings) { if (result == 'ok') { if (me && me.api) { var props = new Asc.SpecialPasteProps(); props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport); - - var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar); - decimal && options.asc_setNumberDecimalSeparator(decimal); - thousands && options.asc_setNumberGroupSeparator(thousands); - props.asc_setAdvancedOptions(options); + props.asc_setAdvancedOptions(settings.textOptions); me.api.asc_SpecialPaste(props); } me._state.lastSpecPasteChecked = item; diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 70ab7427e..a29deec59 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1869,15 +1869,15 @@ define([ codepages: advOptions.asc_getCodePages(), settings: advOptions.asc_getRecommendedSettings(), api: me.api, - handler: function (result, encoding, delimiter, delimiterChar) { + handler: function (result, settings) { me.isShowOpenDialog = false; if (result == 'ok') { if (me && me.api) { if (mode==2) { - formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar)); + formatOptions && formatOptions.asc_setAdvancedOptions(settings.textOptions); me.api.asc_DownloadAs(formatOptions); } else - me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar)); + me.api.asc_setAdvancedOptions(type, settings.textOptions); me.loadMask && me.loadMask.show(); } } @@ -1896,7 +1896,7 @@ define([ me.isShowOpenDialog = false; if (result == 'ok') { if (me && me.api) { - me.api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(value)); + me.api.asc_setAdvancedOptions(type, value.drmOptions); me.loadMask && me.loadMask.show(); } } else {