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);
}
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;
});
var actionType = null;
var options = {oDocumentMailMerge: oDocumentMailMerge, downloadType: 'asc_onSaveMailMerge', errorDirect: c_oAscError.ID.MailMergeSaveFile};
if (bIsDownload) {
actionType = c_oAscAsyncAction.DownloadMerge;
options.downloadType = null;
}
_downloadAs(this, "save", typeFile, actionType, options, null);
}
return null != oDocumentMailMerge ? true : false;
};
......
This diff is collapsed.
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