Commit 54fe8c7d authored by Sergey Konovalov's avatar Sergey Konovalov

open/save csv with user defined delimiters

parent 6ef31345
......@@ -114,9 +114,16 @@ var c_oAscError = Asc.c_oAscError;
window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{
if (window["Asc"].c_oAscAdvancedOptionsID.CSV === idOption) {
var delimiter = option.asc_getDelimiter();
var delimiterChar = option.asc_getDelimiterChar();
var _param = "";
_param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
_param += ("<m_nCsvDelimiter>" + option.asc_getDelimiter() + "</m_nCsvDelimiter>");
if (null != delimiter) {
_param += ("<m_nCsvDelimiter>" + delimiter + "</m_nCsvDelimiter>");
}
if (null != delimiterChar) {
_param += ("<m_nCsvDelimiterChar>" + delimiterChar + "</m_nCsvDelimiterChar>");
}
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
......
......@@ -603,6 +603,7 @@ var editor;
"title": this.documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts,
"delimiter": option.asc_getDelimiter(),
"delimiterChar": option.asc_getDelimiterChar(),
"codepage": option.asc_getCodePage()};
sendCommand(this, null, v);
......@@ -646,8 +647,9 @@ var editor;
var t = this;
// Проверяем, возможно нам пришли опции для CSV
if (this.documentOpenOptions && !opt_isPassword) {
var codePageCsv = AscCommon.c_oAscEncodingsMap[this.documentOpenOptions["codePage"]] || AscCommon.c_oAscCodePageUtf8, delimiterCsv = this.documentOpenOptions["delimiter"];
if (null != codePageCsv && null != delimiterCsv) {
var codePageCsv = AscCommon.c_oAscEncodingsMap[this.documentOpenOptions["codePage"]] || AscCommon.c_oAscCodePageUtf8, delimiterCsv = this.documentOpenOptions["delimiter"],
delimiterCharCsv = this.documentOpenOptions["delimiterChar"];
if (null != codePageCsv && (null != delimiterCsv || null != delimiterCharCsv)) {
this.asc_setAdvancedOptions(c_oAscAdvancedOptionsID.CSV, new asc.asc_CCSVAdvancedOptions(codePageCsv, delimiterCsv));
return;
}
......@@ -772,6 +774,7 @@ var editor;
if (options.CSVOptions instanceof asc.asc_CCSVAdvancedOptions) {
oAdditionalData["codepage"] = options.CSVOptions.asc_getCodePage();
oAdditionalData["delimiter"] = options.CSVOptions.asc_getDelimiter();
oAdditionalData["delimiterChar"] = options.CSVOptions.asc_getDelimiterChar();
}
}
dataContainer.data = oBinaryFileWriter.Write();
......
......@@ -94,12 +94,15 @@
asc_CTXTOptions.prototype.asc_getRecommendedSettings = function () { return this.recommendedSettings; };
/** @constructor */
function asc_CCSVAdvancedOptions(codepage,delimiter){
function asc_CCSVAdvancedOptions(codepage, delimiter, delimiterChar){
this.codePage = codepage;
this.delimiter = delimiter;
this.delimiterChar = delimiterChar;
}
asc_CCSVAdvancedOptions.prototype.asc_getDelimiter = function(){return this.delimiter;};
asc_CCSVAdvancedOptions.prototype.asc_setDelimiter = function(v){this.delimiter = v;};
asc_CCSVAdvancedOptions.prototype.asc_getDelimiterChar = function(){return this.delimiterChar;};
asc_CCSVAdvancedOptions.prototype.asc_setDelimiterChar = function(v){this.delimiterChar = v;};
asc_CCSVAdvancedOptions.prototype.asc_getCodePage = function(){return this.codePage;};
asc_CCSVAdvancedOptions.prototype.asc_setCodePage = function(v){this.codePage = v;};
......@@ -187,6 +190,8 @@
prot = asc_CCSVAdvancedOptions.prototype;
prot["asc_getDelimiter"] = prot.asc_getDelimiter;
prot["asc_setDelimiter"] = prot.asc_setDelimiter;
prot["asc_getDelimiterChar"] = prot.asc_getDelimiterChar;
prot["asc_setDelimiterChar"] = prot.asc_setDelimiterChar;
prot["asc_getCodePage"] = prot.asc_getCodePage;
prot["asc_setCodePage"] = prot.asc_setCodePage;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment