Commit 303c7501 authored by konovalovsergey's avatar konovalovsergey

drm asc_onAdvancedOptions, asc_setAdvancedOptions

parent ccf2e293
......@@ -75,11 +75,17 @@ var c_oAscError = Asc.c_oAscError;
this.onUpdateDocumentModified(AscCommon.History.Is_Modified());
};
asc['spreadsheet_api'].prototype._onNeedParams = function(data)
asc['spreadsheet_api'].prototype._onNeedParams = function(data, opt_isPassword)
{
var options;
if(opt_isPassword){
options = new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.DRM);
} else {
var cp = JSON.parse("{\"codepage\":46,\"delimiter\":1}");
cp['encodings'] = AscCommon.getEncodingParams();
this.handlers.trigger("asc_onAdvancedOptions", new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, cp), AscCommon.c_oAscAdvancedOptionsAction.Open);
options = new AscCommon.asc_CAdvancedOptions(Asc.c_oAscAdvancedOptionsID.CSV, cp);
}
this.handlers.trigger("asc_onAdvancedOptions", options, AscCommon.c_oAscAdvancedOptionsAction.Open);
};
asc['spreadsheet_api'].prototype.asc_addImageDrawingObject = function(url)
......@@ -105,7 +111,9 @@ var c_oAscError = Asc.c_oAscError;
window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{
if (c_oAscAdvancedOptionsID.CSV === idOption) {
window["AscDesktopEditor"]["SetAdvancedOptions"]("" + option.asc_getCodePage(), "" + option.asc_getDelimiter());
}
};
window["Asc"]['spreadsheet_api'].prototype["asc_setAdvancedOptions"] = window["Asc"]['spreadsheet_api'].prototype.asc_setAdvancedOptions;
......
......@@ -677,6 +677,24 @@ var editor;
this._asc_downloadAs(c_oAscFileType.CSV, c_oAscAsyncAction.DownloadAs, options);
}
break;
case c_oAscAdvancedOptionsID.DRM:
// Проверяем тип состояния в данный момент
if (this.advancedOptionsAction === c_oAscAdvancedOptionsAction.Open) {
var v = {
"id": this.documentId,
"userid": this.documentUserId,
"format": this.documentFormat,
"vkey": this.documentVKey,
"c": "reopen",
"url": this.documentUrl,
"title": this.documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts,
"password": option.asc_getPassword()
};
sendCommand(this, null, v);
}
break;
}
};
// Опции страницы (для печати)
......@@ -690,17 +708,19 @@ var editor;
return this.wbModel.getWorksheet(sheetIndex).PagePrintOptions;
};
spreadsheet_api.prototype._onNeedParams = function(data) {
spreadsheet_api.prototype._onNeedParams = function(data, opt_isPassword) {
var t = this;
// Проверяем, возможно нам пришли опции для CSV
if (this.documentOpenOptions) {
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) {
this.asc_setAdvancedOptions(c_oAscAdvancedOptionsID.CSV, new asc.asc_CCSVAdvancedOptions(codePageCsv, delimiterCsv));
return;
}
}
if (data) {
if (opt_isPassword) {
t.handlers.trigger("asc_onAdvancedOptions", new AscCommon.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.DRM), this.advancedOptionsAction);
} else if (data) {
AscCommon.loadFileContent(data, function(result) {
if (null === result) {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.Critical);
......
......@@ -107,6 +107,13 @@
asc_CTXTAdvancedOptions.prototype.asc_getCodePage = function(){return this.codePage;};
asc_CTXTAdvancedOptions.prototype.asc_setCodePage = function(v){this.codePage = v;};
/** @constructor */
function asc_CDRMAdvancedOptions(password){
this.password = password;
}
asc_CDRMAdvancedOptions.prototype.asc_getPassword = function(){return this.password;};
asc_CDRMAdvancedOptions.prototype.asc_setPassword = function(v){this.password = v;};
/** @constructor */
function asc_CCodePage(){
this.codePageName = null;
......@@ -185,6 +192,11 @@
prot["asc_getCodePage"] = prot.asc_getCodePage;
prot["asc_setCodePage"] = prot.asc_setCodePage;
window["Asc"].asc_CDRMAdvancedOptions = window["Asc"]["asc_CDRMAdvancedOptions"] = asc_CDRMAdvancedOptions;
prot = asc_CDRMAdvancedOptions.prototype;
prot["asc_getPassword"] = prot.asc_getPassword;
prot["asc_setPassword"] = prot.asc_setPassword;
prot = asc_CCodePage.prototype;
prot["asc_getCodePageName"] = prot.asc_getCodePageName;
prot["asc_setCodePageName"] = prot.asc_setCodePageName;
......
......@@ -431,7 +431,7 @@
baseEditorsApi.prototype._onOpenCommand = function(data)
{
};
baseEditorsApi.prototype._onNeedParams = function(data)
baseEditorsApi.prototype._onNeedParams = function(data, opt_isPassword)
{
};
baseEditorsApi.prototype.asyncServerIdEndLoaded = function()
......@@ -633,7 +633,7 @@
t._onNeedParams(input["data"]);
break;
case "needpassword":
t.sendEvent("asc_onError", Asc.c_oAscError.ID.ConvertationPassword, c_oAscError.Level.Critical);
t._onNeedParams(null, true);
break;
case "err":
t.sendEvent("asc_onError", AscCommon.mapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.Critical);
......
......@@ -179,7 +179,8 @@
var c_oAscAdvancedOptionsID = {
CSV : 0,
TXT : 1
TXT : 1,
DRM : 2
};
var c_oAscAdvancedOptionsAction = {
......
......@@ -2059,6 +2059,32 @@ background-repeat: no-repeat;\
asc_docs_api.prototype.Help = function()
{
};
/*
idOption идентификатор дополнительного параметра, c_oAscAdvancedOptionsID.TXT.
option - какие свойства применить, пока массив. для TXT объект asc_CTXTAdvancedOptions(codepage)
exp: asc_setAdvancedOptions(c_oAscAdvancedOptionsID.TXT, new Asc.asc_CCSVAdvancedOptions(1200) );
*/
asc_docs_api.prototype.asc_setAdvancedOptions = function(idOption, option)
{
switch (idOption)
{
case c_oAscAdvancedOptionsID.DRM:
var v = {
"id": this.documentId,
"userid": this.documentUserId,
"format": this.documentFormat,
"vkey": this.documentVKey,
"c": "reopen",
"url": this.documentUrl,
"title": this.documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts,
"password": option.asc_getPassword()
};
sendCommand(this, null, v);
break;
}
};
asc_docs_api.prototype.startGetDocInfo = function()
{
......@@ -5928,6 +5954,13 @@ background-repeat: no-repeat;\
this.asc_fireCallback("asc_onContextMenu", Data);
};
asc_docs_api.prototype._onNeedParams = function(data, opt_isPassword)
{
if (opt_isPassword) {
this.asc_fireCallback("asc_onAdvancedOptions", new AscCommon.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.DRM), c_oAscAdvancedOptionsAction.Open);
}
};
asc_docs_api.prototype._onOpenCommand = function(data)
{
var t = this;
......@@ -6487,6 +6520,7 @@ background-repeat: no-repeat;\
asc_docs_api.prototype['AddURL'] = asc_docs_api.prototype.AddURL;
asc_docs_api.prototype['Help'] = asc_docs_api.prototype.Help;
asc_docs_api.prototype['startGetDocInfo'] = asc_docs_api.prototype.startGetDocInfo;
asc_docs_api.prototype['asc_setAdvancedOptions'] = asc_docs_api.prototype.asc_setAdvancedOptions;;
asc_docs_api.prototype['stopGetDocInfo'] = asc_docs_api.prototype.stopGetDocInfo;
asc_docs_api.prototype['sync_DocInfoCallback'] = asc_docs_api.prototype.sync_DocInfoCallback;
asc_docs_api.prototype['sync_GetDocInfoStartCallback'] = asc_docs_api.prototype.sync_GetDocInfoStartCallback;
......
......@@ -83,7 +83,9 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data)
Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{
if (c_oAscAdvancedOptionsID.CSV === idOption) {
window["AscDesktopEditor"]["SetAdvancedOptions"]("" + option.asc_getCodePage());
}
};
Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions;
......
......@@ -2177,6 +2177,23 @@ background-repeat: no-repeat;\
this._downloadAs("save", c_oAscFileType.TXT, c_oAscAsyncAction.DownloadAs, options, null);
}
break;
case c_oAscAdvancedOptionsID.DRM:
if (this.advancedOptionsAction === c_oAscAdvancedOptionsAction.Open) {
var v = {
"id": this.documentId,
"userid": this.documentUserId,
"format": this.documentFormat,
"vkey": this.documentVKey,
"c": "reopen",
"url": this.documentUrl,
"title": this.documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts,
"password": option.asc_getPassword()
};
sendCommand(this, null, v);
}
break;
}
};
asc_docs_api.prototype.SetFontRenderingMode = function(mode)
......@@ -7389,10 +7406,16 @@ background-repeat: no-repeat;\
editor.SpellCheckApi.onSpellCheck(response);
};
asc_docs_api.prototype._onNeedParams = function(data)
asc_docs_api.prototype._onNeedParams = function(data, opt_isPassword)
{
var cp = {'codepage' : AscCommon.c_oAscCodePageUtf8, 'encodings' : AscCommon.getEncodingParams()};
this.asc_fireCallback("asc_onAdvancedOptions", new AscCommon.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.TXT, cp), this.advancedOptionsAction);
var options;
if (opt_isPassword) {
options = new AscCommon.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.DRM);
} else {
var cp = {'codepage': AscCommon.c_oAscCodePageUtf8, 'encodings': AscCommon.getEncodingParams()};
options = new AscCommon.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.TXT, cp);
}
this.asc_fireCallback("asc_onAdvancedOptions", options, this.advancedOptionsAction);
};
asc_docs_api.prototype._onOpenCommand = function(data)
{
......
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