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