Commit f84e7241 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Merged revision(s) 66096-66117 from...

Merged revision(s) 66096-66117 from AVS/Sources/TeamlabOffice/branches/TeamlabOffice_v3.5_PrintWithoutDownload


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66119 954022d7-b5bf-4e40-9824-e11837661b57
parent 1ce9377e
......@@ -540,7 +540,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
};
spreadsheet_api.prototype.asc_DownloadAs = function(typeFile, bIsDownload) {//передаем число соответствующее своему формату. например c_oAscFileType.XLSX
spreadsheet_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) {//передаем число соответствующее своему формату. например c_oAscFileType.XLSX
if (!this.canSave || this.isChartEditor || c_oAscAdvancedOptionsAction.None !== this.advancedOptionsAction) {
return;
}
......@@ -550,29 +550,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
return;
}
this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
var t = this;
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
this._asc_downloadAs(typeFile, function(input) {
if (null != input && ("save" == input["type"] || "sfct" == input["type"])) {
if ('ok' == input["status"]) {
var url = input["data"];
if (url) {
t.asc_processSavedFile(url, bIsDownload);
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
}, true);
this._asc_downloadAs(typeFile, c_oAscAsyncAction.DownloadAs, {downloadType: bIsDownloadEvent ? 'asc_onDownloadUrl': null});
};
spreadsheet_api.prototype.asc_Save = function(isAutoSave) {
......@@ -597,7 +575,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
});
};
spreadsheet_api.prototype.asc_Print = function(adjustPrint) {
spreadsheet_api.prototype.asc_Print = function(adjustPrint, bIsDownloadEvent) {
if (window["AscDesktopEditor"]) {
window.AscDesktopEditor_PrintData = adjustPrint;
window["AscDesktopEditor"]["Print"]();
......@@ -605,7 +583,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
this.adjustPrint = adjustPrint ? adjustPrint : new asc_CAdjustPrint();
this.asc_DownloadAs(c_oAscFileType.PDF);
this._asc_downloadAs(c_oAscFileType.PDF, c_oAscAsyncAction.Print, {downloadType: bIsDownloadEvent ? 'asc_onPrintUrl': null});
};
spreadsheet_api.prototype.asc_Copy = function() {
......@@ -800,33 +778,14 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
sendCommand2(this, null, v);
} else if (this.advancedOptionsAction === c_oAscAdvancedOptionsAction.Save) {
this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
this._asc_downloadAs(c_oAscFileType.CSV, function(input) {
if (null != input && "save" == input["type"]) {
if ('ok' == input["status"]) {
var url = input["data"];
if (url) {
t.asc_processSavedFile(url, false);
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
}, true, option);
this._asc_downloadAs(c_oAscFileType.CSV, c_oAscAsyncAction.DownloadAs, {CSVOptions: option});
}
break;
}
};
spreadsheet_api.prototype.asc_processSavedFile = function(url, bInner) {
if (bInner) {
this.handlers.trigger("asc_onDownloadUrl", url, function(hasError) {
spreadsheet_api.prototype.asc_processSavedFile = function(url, downloadType) {
if (downloadType) {
this.handlers.trigger(downloadType, url, function(hasError) {
});
} else {
getFile(url);
......@@ -952,11 +911,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}, t.fCurCallback, null, oAdditionalData, dataContainer);
};
spreadsheet_api.prototype._asc_downloadAs = function(sFormat, fCallback, bStart, options) { //fCallback({returnCode:"", ...})
spreadsheet_api.prototype._asc_downloadAs = function(sFormat, actionType, options) { //fCallback({returnCode:"", ...})
var t = this;
if (!options) {
options = {};
}
if (actionType) {
this.asc_StartAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
//sFormat: xlsx, xls, ods, csv, html
var dataContainer = {data: null, part: null, index: 0, count: 0};
var command = "save";
var oAdditionalData = {};
oAdditionalData["c"] = "save";
oAdditionalData["c"] = command;
oAdditionalData["id"] = this.documentId;
oAdditionalData["userid"] = this.documentUserId;
oAdditionalData["vkey"] = this.documentVKey;
......@@ -968,9 +938,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var isEndPrint = this.wb.printSheet(pdf_writer, printPagesData);
dataContainer.data = pdf_writer.DocumentRenderer.Memory.GetBase64Memory();
} else if (c_oAscFileType.CSV === sFormat && !options) {
} else if (c_oAscFileType.CSV === sFormat && !options.CSVOptions) {
// Мы открывали команду, надо ее закрыть.
this.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
if (actionType) {
this.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
var cp = {'delimiter': c_oAscCsvDelimiter.Comma, 'codepage': c_oAscCodePageUtf8, 'encodings': getEncodingParams()};
this.handlers.trigger("asc_onAdvancedOptions", new asc.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.CSV, cp), this.advancedOptionsAction);
return;
......@@ -978,9 +950,9 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.wb._initCommentsToSave();
var oBinaryFileWriter = new Asc.BinaryFileWriter(this.wbModel);
if (c_oAscFileType.CSV === sFormat) {
if (options instanceof asc.asc_CCSVAdvancedOptions) {
oAdditionalData["codepage"] = options.asc_getCodePage();
oAdditionalData["delimiter"] = options.asc_getDelimiter();
if (options.CSVOptions instanceof asc.asc_CCSVAdvancedOptions) {
oAdditionalData["codepage"] = options.CSVOptions.asc_getCodePage();
oAdditionalData["delimiter"] = options.CSVOptions.asc_getDelimiter();
}
}
dataContainer.data = oBinaryFileWriter.Write();
......@@ -990,7 +962,28 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
return;
}
}
var t = this;
var fCallback = function(input) {
var error = c_oAscError.ID.Unknown;
if (null != input && command == input["type"]) {
if ('ok' == input["status"]) {
var url = input["data"];
if (url) {
error = c_oAscError.ID.No;
t.asc_processSavedFile(url, options.downloadType);
}
} else {
error = g_fMapAscServerErrorToAscError(parseInt(input["data"]));
}
}
if (c_oAscError.ID.No != error) {
t.handlers.trigger("asc_onError", error, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
if (actionType) {
t.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
};
t.fCurCallback = fCallback;
g_fSaveWithParts(function(fCallback1, oAdditionalData1, dataContainer1) {
sendCommand2(t, fCallback1, oAdditionalData1, dataContainer1);
......
......@@ -1368,33 +1368,15 @@ asc_docs_api.prototype.UpdateParagraphProp = function(ParaPr, bParaPr){
/*----------------------------------------------------------------*/
/*functions for working with clipboard, document*/
/*TODO: Print,Undo,Redo,Copy,Cut,Paste,Share,Save,DownloadAs,ReturnToDocuments(вернуться на предыдущую страницу) & callbacks for these functions*/
asc_docs_api.prototype.asc_Print = function(){
asc_docs_api.prototype.asc_Print = function(bIsDownloadEvent){
if (window["AscDesktopEditor"])
{
window["AscDesktopEditor"]["Print"]();
return;
}
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);
var t = this;
_downloadAs(this, c_oAscFileType.PDF, function(input){
if(null != input && "save" == input["type"]) {
if('ok' == input["status"]){
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);
}, true);
var options = bIsDownloadEvent ? {downloadType: 'asc_onPrintUrl'} : null;
_downloadAs(this, c_oAscFileType.PDF, c_oAscAsyncAction.Print, options);
};
asc_docs_api.prototype.Undo = function(){
this.WordControl.m_oLogicDocument.Document_Undo();
......@@ -1547,34 +1529,17 @@ asc_docs_api.prototype.asc_Save = function (isNoUserSave)
this.CoAuthoringApi.askSaveChanges(OnSave_Callback);
}
};
asc_docs_api.prototype.processSavedFile = function(url, bInner){
if(bInner)
editor.asc_fireCallback("asc_onDownloadUrl", url, function(hasError){});
asc_docs_api.prototype.processSavedFile = function(url, downloadType){
if(downloadType)
editor.asc_fireCallback(downloadType, url, function(hasError){});
else
{
getFile(url);
}
};
asc_docs_api.prototype.asc_DownloadAs = function(typeFile, bIsDownload){//передаем число соответствующее своему формату.
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
var t = this;
_downloadAs(this, typeFile, function(input){
if(null != input && ("save" == input["type"] || "sfct" == input["type"])) {
if('ok' == input["status"]){
var url = input["data"];
if(url) {
t.processSavedFile(url, bIsDownload);
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
}, true);
asc_docs_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent){//передаем число соответствующее своему формату.
var options = bIsDownloadEvent ? {downloadType: 'asc_onDownloadUrl'} : null;
_downloadAs(this, typeFile, c_oAscAsyncAction.DownloadAs, options);
};
asc_docs_api.prototype.Resize = function(){
if (false === this.bInit_word_control)
......@@ -5096,11 +5061,19 @@ function _onOpenCommand(fCallback, incomeObject) {
if(fCallback) fCallback();
});
}
function _downloadAs(editor, filetype, fCallback, bStart, sSaveKey)
function _downloadAs(editor, filetype, actionType, options)
{
if (!options) {
options = {};
}
if (actionType) {
editor.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
var dataContainer = {data: null, part: null, index: 0, count: 0};
var command = "save";
var oAdditionalData = {};
oAdditionalData["c"] = "save";
oAdditionalData["c"] = command;
oAdditionalData["id"] = documentId;
oAdditionalData["userid"] = documentUserId;
oAdditionalData["vkey"] = documentVKey;
......@@ -5114,6 +5087,26 @@ function _downloadAs(editor, filetype, fCallback, bStart, sSaveKey)
}
else
dataContainer.data = editor.WordControl.SaveDocument();
var fCallback = function(input) {
var error = c_oAscError.ID.Unknown;
if(null != input && command == input["type"]) {
if('ok' == input["status"]){
var url = input["data"];
if(url) {
error = c_oAscError.ID.No;
editor.processSavedFile(url, options.downloadType);
}
} else {
error = g_fMapAscServerErrorToAscError(parseInt(input["data"]));
}
}
if (c_oAscError.ID.No != error) {
editor.asc_fireCallback("asc_onError", error, c_oAscError.Level.NoCritical);
}
if (actionType) {
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
};
editor.fCurCallback = fCallback;
g_fSaveWithParts(function(fCallback1, oAdditionalData1, dataContainer1){sendCommand2(editor, fCallback1, oAdditionalData1, dataContainer1);}, fCallback, null, oAdditionalData, dataContainer);
}
......
......@@ -115,13 +115,11 @@ asc_docs_api.prototype.asc_setMailMergeData = function(aList)
asc_docs_api.prototype.asc_sendMailMergeData = function(oData)
{
var actionType = c_oAscAsyncAction.SendMailMerge;
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, actionType);
oData.put_UserId(documentUserId);
oData.put_RecordCount(oData.get_RecordTo() - oData.get_RecordFrom() + 1);
var options = {oMailMergeSendData: oData, isNoCallback: true};
var t = this;
_downloadAs(this, "sendmm", null, oData, null, c_oAscFileType.TXT, null, function(input)
{
_downloadAs(this, "sendmm", c_oAscFileType.TXT, actionType, options, function(input) {
if (null != input && "sendmm" == input["type"])
{
if ("ok" == input["status"])
......@@ -149,51 +147,13 @@ asc_docs_api.prototype.asc_DownloadAsMailMerge = function(typeFile, StartIndex,
var oDocumentMailMerge = this.WordControl.m_oLogicDocument.Get_MailMergedDocument(StartIndex, EndIndex);
if (null != oDocumentMailMerge)
{
var actionType = c_oAscAsyncAction.DownloadMerge;
if (bIsDownload)
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, actionType);
var t = this;
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
_downloadAs(this, "save", oDocumentMailMerge, null, null, typeFile, function(input)
{
if (null != input && "save" == input["type"])
{
if ('ok' == input["status"])
{
var url = input["data"];
if (url)
{
if (bIsDownload)
{
t.processSavedFile(url, false);
var actionType = null;
var options = {oDocumentMailMerge: oDocumentMailMerge, downloadType: 'asc_onSaveMailMerge', errorDirect: c_oAscError.ID.MailMergeSaveFile};
if (bIsDownload) {
actionType = c_oAscAsyncAction.DownloadMerge;
options.downloadType = null;
}
else
{
t.asc_fireCallback("asc_onSaveMailMerge", url);
}
}
else
{
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
}
else
{
t.asc_fireCallback("asc_onError", c_oAscError.ID.MailMergeSaveFile, c_oAscError.Level.NoCritical);
}
}
else
{
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
if (bIsDownload)
{
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
// Меняем тип состояния (на никакое)
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
});
_downloadAs(this, "save", typeFile, actionType, options, null);
}
return null != oDocumentMailMerge ? true : false;
};
......
......@@ -2054,7 +2054,7 @@ asc_docs_api.prototype.UpdateParagraphProp = function(ParaPr)
/*----------------------------------------------------------------*/
/*functions for working with clipboard, document*/
/*TODO: Print,Undo,Redo,Copy,Cut,Paste,Share,Save,DownloadAs,ReturnToDocuments(вернуться на предыдущую страницу) & callbacks for these functions*/
asc_docs_api.prototype.asc_Print = function()
asc_docs_api.prototype.asc_Print = function(bIsDownloadEvent)
{
if (window["AscDesktopEditor"])
{
......@@ -2069,62 +2069,15 @@ asc_docs_api.prototype.asc_Print = function()
return;
}
}
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);
var t = this;
if(null == this.WordControl.m_oLogicDocument)
{
var rData = {
"id":documentId,
"userid": documentUserId,
"vkey": documentVKey,
"format": documentFormat,
"title": changeFileExtention(documentTitle, getExtentionByFormat(c_oAscFileType.PDF)),
"c":"savefromorigin"};
this.fCurCallback = function(input) {
if(null != input && "savefromorigin" == input["type"]) {
if('ok' == input["status"]) {
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
}
} else {
t.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
var command;
var options = {isNoData: false, downloadType: bIsDownloadEvent ? 'asc_onPrintUrl' : null};
if (null == this.WordControl.m_oLogicDocument) {
command = 'savefromorigin';
options.isNoData = true;
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
editor.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);
};
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
sendCommand2(t, null, rData);
}
else {
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
_downloadAs(this, "save", null, null, null, c_oAscFileType.PDF, function(input){
if(null != input && "save" == input["type"]) {
if('ok' == input["status"]){
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
editor.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);
});
command = 'save';
}
_downloadAs(this, command, c_oAscFileType.PDF, c_oAscAsyncAction.Print, options, null);
};
asc_docs_api.prototype.Undo = function()
{
......@@ -2286,31 +2239,10 @@ asc_docs_api.prototype.asc_Save = function (isNoUserSave)
}
};
asc_docs_api.prototype.asc_DownloadAs = function(typeFile, bIsDownload, txtOptions) {//передаем число соответствующее своему формату.
asc_docs_api.prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) {//передаем число соответствующее своему формату.
var actionType = this.mailMergeFileData ? c_oAscAsyncAction.MailMergeLoadFile : c_oAscAsyncAction.DownloadAs;
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, actionType);
var t = this;
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
_downloadAs(this, "save", null, null, txtOptions, typeFile, function (input) {
if(null != input && ("save" == input["type"] || "sfct" == input["type"])) {
if('ok' == input["status"]){
var url = input["data"];
if(url) {
t.processSavedFile(url, bIsDownload);
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", g_fMapAscServerErrorToAscError(parseInt(input["data"])), c_oAscError.Level.NoCritical);
}
} else {
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
});
var options = {downloadType: bIsDownloadEvent ? 'asc_onDownloadUrl' : null};
_downloadAs(this, "save", typeFile, actionType, options, null);
};
asc_docs_api.prototype.Resize = function(){
if (false === this.bInit_word_control)
......@@ -2348,7 +2280,8 @@ asc_docs_api.prototype.asc_setAdvancedOptions = function(idOption, option) {
};
sendCommand2(t, null, rData);
} else if (this.advancedOptionsAction === c_oAscAdvancedOptionsAction.Save) {
t.asc_DownloadAs(c_oAscFileType.TXT, false, option);
var options = {txtOptions: option};
_downloadAs(t, "save", c_oAscFileType.TXT, c_oAscAsyncAction.DownloadAs, options, null);
}
break;
}
......@@ -2371,7 +2304,7 @@ asc_docs_api.prototype.SetFontRenderingMode = function(mode)
if (this.bInit_word_control)
this.WordControl.OnScroll();
};
asc_docs_api.prototype.processSavedFile = function(url, bInner) {
asc_docs_api.prototype.processSavedFile = function(url, downloadType) {
var t = this;
if (this.mailMergeFileData) {
this.mailMergeFileData = null;
......@@ -2390,8 +2323,8 @@ asc_docs_api.prototype.processSavedFile = function(url, bInner) {
}
});
} else {
if (bInner) {
this.asc_fireCallback("asc_onDownloadUrl", url, function (hasError) {
if (downloadType) {
this.asc_fireCallback(downloadType, url, function (hasError) {
});
} else {
getFile(url);
......@@ -6795,7 +6728,16 @@ function _onOpenCommand(fCallback, incomeObject) {
if(fCallback) fCallback();
});
}
function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, txtOptions, filetype, fCallback, fCallbackRequest) {
function _downloadAs(editor, command, filetype, actionType, options, fCallbackRequest) {
if (!options) {
options = {};
}
if (actionType) {
editor.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
// Меняем тип состояния (на сохранение)
editor.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
var dataContainer = {data: null, part: null, index: 0, count: 0};
var oAdditionalData = {};
oAdditionalData["c"] = command;
......@@ -6805,7 +6747,9 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, tx
oAdditionalData["outputformat"] = filetype;
oAdditionalData["title"] = changeFileExtention(documentTitle, getExtentionByFormat(filetype));
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
if (null == oDocumentMailMerge && c_oAscFileType.PDF === filetype) {
if (options.isNoData) {
;//nothing
} else if (null == options.oDocumentMailMerge && c_oAscFileType.PDF === filetype) {
var dd = editor.WordControl.m_oDrawingDocument;
dataContainer.data = dd.ToRendererPart();
//console.log(oAdditionalData["data"]);
......@@ -6815,13 +6759,15 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, tx
// ToDo select csv params
oAdditionalData['codepage'] = c_oAscCodePageUtf8;
oAdditionalData['delimiter'] = c_oAscCsvDelimiter.Comma
} else if (c_oAscFileType.TXT === filetype && !txtOptions && null == oDocumentMailMerge && null == oMailMergeSendData) {
} else if (c_oAscFileType.TXT === filetype && !options.txtOptions && null == options.oDocumentMailMerge && null == options.oMailMergeSendData) {
// Мы открывали команду, надо ее закрыть.
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
if (actionType) {
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
var cp = {'codepage': c_oAscCodePageUtf8, 'encodings': getEncodingParams()};
editor.asc_fireCallback("asc_onAdvancedOptions", new asc.asc_CAdvancedOptions(c_oAscAdvancedOptionsID.TXT, cp), editor.advancedOptionsAction);
return;
} else if (c_oAscFileType.HTML === filetype && null == oDocumentMailMerge && null == oMailMergeSendData) {
} else if (c_oAscFileType.HTML === filetype && null == options.oDocumentMailMerge && null == options.oMailMergeSendData) {
//в asc_nativeGetHtml будет вызван select all, чтобы выделился документ должны выйти из колонтитулов и автофигур
var _e = new CKeyboardEvent();
_e.CtrlKey = false;
......@@ -6830,23 +6776,23 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, tx
//сделано через сервер, потому что нет простого механизма сохранения на клиенте
dataContainer.data = '\ufeff' + window["asc_docs_api"].prototype["asc_nativeGetHtml"].call(editor);
} else {
if (txtOptions instanceof asc.asc_CTXTAdvancedOptions) {
oAdditionalData["codepage"] = txtOptions.asc_getCodePage();
if (options.txtOptions instanceof asc.asc_CTXTAdvancedOptions) {
oAdditionalData["codepage"] = options.txtOptions.asc_getCodePage();
}
var oLogicDocument;
if(null != oDocumentMailMerge)
oLogicDocument = oDocumentMailMerge;
if(null != options.oDocumentMailMerge)
oLogicDocument = options.oDocumentMailMerge;
else
oLogicDocument = editor.WordControl.m_oLogicDocument;
var oBinaryFileWriter;
if(null != oMailMergeSendData && c_oAscFileType.HTML == oMailMergeSendData.get_MailFormat())
if(null != options.oMailMergeSendData && c_oAscFileType.HTML == options.oMailMergeSendData.get_MailFormat())
oBinaryFileWriter = new BinaryFileWriter(oLogicDocument, false, true);
else
oBinaryFileWriter = new BinaryFileWriter(oLogicDocument);
dataContainer.data = oBinaryFileWriter.Write();
}
if(null != oMailMergeSendData){
oAdditionalData["mailmergesend"] = oMailMergeSendData;
if(null != options.oMailMergeSendData){
oAdditionalData["mailmergesend"] = options.oMailMergeSendData;
var MailMergeMap = editor.WordControl.m_oLogicDocument.MailMergeMap;
var aJsonOut = [];
if(MailMergeMap.length > 0){
......@@ -6866,6 +6812,36 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, tx
}
dataContainer.data = dataContainer.data.length + ';' + dataContainer.data + JSON.stringify(aJsonOut);
}
var fCallback = null;
if (!options.isNoCallback) {
fCallback = function (input) {
var error = c_oAscError.ID.Unknown;
//input = {'type': command, 'status': 'err', 'data': -80};
if (null != input && command == input['type']) {
if ('ok' == input['status']){
if (options.isNoUrl) {
error = c_oAscError.ID.No;
} else {
var url = input['data'];
if (url) {
error = c_oAscError.ID.No;
editor.processSavedFile(url, options.downloadType);
}
}
} else {
error = g_fMapAscServerErrorToAscError(parseInt(input["data"]));
}
}
if (c_oAscError.ID.No != error) {
editor.asc_fireCallback('asc_onError', options.errorDirect || error, c_oAscError.Level.NoCritical);
}
// Меняем тип состояния (на никакое)
editor.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
if (actionType) {
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}
};
}
editor.fCurCallback = fCallback;
g_fSaveWithParts(function(fCallback1, oAdditionalData1, dataContainer1){sendCommand2(editor, fCallback1, oAdditionalData1, dataContainer1);}, fCallback, fCallbackRequest, oAdditionalData, dataContainer);
}
......
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