Change usage of advanced options on load/save csv, txt, rtf

This commit is contained in:
Julia Radzhabova 2019-07-25 10:14:45 +03:00
parent c0862be9b9
commit a43e7a0c85
11 changed files with 38 additions and 44 deletions

View file

@ -339,14 +339,14 @@ define([
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));
this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTextOptions(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));
this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTextOptions(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);
this.api.asc_TextImport(new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar), _.bind(this.previewCallback, this), this.type == Common.Utils.importTextType.Paste);
break;
}
},

View file

@ -302,7 +302,7 @@ define([
buttons: ['ok', 'cancel'],
callback: _.bind(function(btn){
if (btn == 'ok') {
Common.NotificationCenter.trigger('download:advanced', this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format));
Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.TXT, this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format));
menu.hide();
}
}, this)
@ -348,7 +348,7 @@ define([
callback: _.bind(function(btn){
if (btn == 'ok') {
this.isFromFileDownloadAs = ext;
Common.NotificationCenter.trigger('download:advanced', this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format, true));
Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.TXT, this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format, true));
menu.hide();
}
}, this)

View file

@ -1949,29 +1949,28 @@ define([
this.getApplication().getController('Toolbar').getView().updateMetricUnit();
},
onAdvancedOptions: function(advOptions, mode, formatOptions) {
onAdvancedOptions: function(type, advOptions, mode, formatOptions) {
if (this._state.openDlg) return;
var type = advOptions.asc_getOptionId(),
me = this;
var me = this;
if (type == Asc.c_oAscAdvancedOptionsID.TXT) {
me._state.openDlg = new Common.Views.OpenDialog({
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(),
preview: advOptions.asc_getData(),
codepages: advOptions.asc_getCodePages(),
settings: advOptions.asc_getRecommendedSettings(),
api: me.api,
handler: function (result, encoding) {
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me && me.api) {
if (mode==2) {
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTXTAdvancedOptions(encoding));
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding));
me.api.asc_DownloadAs(formatOptions);
} else
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTXTAdvancedOptions(encoding));
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding));
me.loadMask && me.loadMask.show();
}
}

View file

@ -1113,17 +1113,16 @@ define([
Common.Utils.ThemeColor.setColors(colors, standart_colors);
},
onAdvancedOptions: function(advOptions) {
onAdvancedOptions: function(type, advOptions) {
if (this._state.openDlg) return;
var type = advOptions.asc_getOptionId(),
me = this;
var me = this;
if (type == Asc.c_oAscAdvancedOptionsID.TXT) {
var picker,
pages = [],
pagesName = [];
_.each(advOptions.asc_getOptions().asc_getCodePages(), function(page) {
_.each(advOptions.asc_getCodePages(), function(page) {
pages.push(page.asc_getCodePage());
pagesName.push(page.asc_getCodePageName());
});
@ -1150,7 +1149,7 @@ define([
var encoding = picker.value;
if (me.api) {
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTXTAdvancedOptions(encoding));
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding));
if (!me._isDocReady) {
me.onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
@ -1166,7 +1165,7 @@ define([
container: '#txt-encoding',
toolbar: false,
rotateEffect: true,
value: [advOptions.asc_getOptions().asc_getRecommendedSettings().asc_getCodePage()],
value: [advOptions.asc_getRecommendedSettings().asc_getCodePage()],
cols: [{
values: pages,
displayValues: pagesName

View file

@ -1791,11 +1791,10 @@ define([
if (url) this.iframePrint.src = url;
},
onAdvancedOptions: function(advOptions) {
onAdvancedOptions: function(type, advOptions) {
if (this._state.openDlg) return;
var type = advOptions.asc_getOptionId(),
me = this;
var me = this;
if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
me._state.openDlg = new Common.Views.OpenDialog({
title: Common.Views.OpenDialog.prototype.txtTitleProtected,

View file

@ -1089,11 +1089,10 @@ define([
this.isThumbnailsShow = isShow;
},
onAdvancedOptions: function(advOptions) {
onAdvancedOptions: function(type, advOptions) {
if (this._state.openDlg) return;
var type = advOptions.asc_getOptionId(),
me = this;
var me = this;
if (type == Asc.c_oAscAdvancedOptionsID.DRM) {
$(me.loadMask).hasClass('modal-in') && uiApp.closeModal(me.loadMask);

View file

@ -68,7 +68,7 @@ define([
});
this._state = {
CSVOptions: new Asc.asc_CCSVAdvancedOptions(0, 4, '')
CSVOptions: new Asc.asc_CTextOptions(0, 4, '')
};
},
onLaunch: function () {
@ -177,7 +177,7 @@ define([
handler: function (result, encoding, delimiter, delimiterChar) {
if (result == 'ok') {
if (me && me.api) {
me.api.asc_TextToColumns(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar));
me.api.asc_TextToColumns(new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar));
}
}
}

View file

@ -2204,7 +2204,7 @@ define([
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));
props.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar));
me.api.asc_SpecialPaste(props);
}
me._state.lastSpecPasteChecked = item;

View file

@ -264,7 +264,7 @@ define([
buttons: ['ok', 'cancel'],
callback: _.bind(function(btn){
if (btn == 'ok') {
Common.NotificationCenter.trigger('download:advanced', this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format));
Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.CSV, this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format));
menu.hide();
}
}, this)
@ -287,7 +287,7 @@ define([
callback: _.bind(function(btn){
if (btn == 'ok') {
this.isFromFileDownloadAs = ext;
Common.NotificationCenter.trigger('download:advanced', this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format, true));
Common.NotificationCenter.trigger('download:advanced', Asc.c_oAscAdvancedOptionsID.CSV, this.api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format, true));
menu.hide();
}
}, this)

View file

@ -1603,29 +1603,28 @@ define([
return false;
},
onAdvancedOptions: function(advOptions, mode, formatOptions) {
onAdvancedOptions: function(type, advOptions, mode, formatOptions) {
if (this._state.openDlg) return;
var type = advOptions.asc_getOptionId(),
me = this;
var me = this;
if (type == Asc.c_oAscAdvancedOptionsID.CSV) {
me._state.openDlg = new Common.Views.OpenDialog({
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(),
preview: advOptions.asc_getData(),
codepages: advOptions.asc_getCodePages(),
settings: advOptions.asc_getRecommendedSettings(),
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar) {
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me && me.api) {
if (mode==2) {
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar));
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar));
me.api.asc_DownloadAs(formatOptions);
} else
me.api.asc_setAdvancedOptions(type, new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar));
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar));
me.loadMask && me.loadMask.show();
}
}

View file

@ -1213,17 +1213,16 @@ define([
Common.Utils.ThemeColor.setColors(colors, standart_colors);
},
onAdvancedOptions: function(advOptions) {
onAdvancedOptions: function(type, advOptions) {
if (this._state.openDlg) return;
var type = advOptions.asc_getOptionId(),
me = this;
var me = this;
if (type == Asc.c_oAscAdvancedOptionsID.CSV) {
var picker,
pages = [],
pagesName = [];
_.each(advOptions.asc_getOptions().asc_getCodePages(), function(page) {
_.each(advOptions.asc_getCodePages(), function(page) {
pages.push(page.asc_getCodePage());
pagesName.push(page.asc_getCodePageName());
});
@ -1252,7 +1251,7 @@ define([
delimiter = picker.cols[1].value;
if (me.api) {
me.api.asc_setAdvancedOptions(type, new Asc.asc_CCSVAdvancedOptions(encoding, delimiter));
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter));
if (!me._isDocReady) {
me.onLongActionBegin(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument);
@ -1264,7 +1263,7 @@ define([
]
});
var recommendedSettings = advOptions.asc_getOptions().asc_getRecommendedSettings();
var recommendedSettings = advOptions.asc_getRecommendedSettings();
picker = uiApp.picker({
container: '#txt-encoding',