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

для Bug 30246 - Экспортированный файл всегда сохраняется с именем output

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64999 954022d7-b5bf-4e40-9824-e11837661b57
parent 325b6455
......@@ -231,14 +231,6 @@ function g_fOpenFileCommand (binUrl, changesUrl, Signature, callback) {
} else
bEndLoadChanges = true;
}
function g_fGetSaveUrl(urls){
for(var i in urls) {
if(-1 != i.indexOf('output')) {
return urls[i];
}
}
return null;
}
function sendCommand2(editor, fCallback, rdata, dataContainer) {
//json не должен превышать размера 2097152, иначе при его чтении будет exception
var docConnectionId = editor.CoAuthoringApi.getDocId();
......@@ -592,6 +584,43 @@ function GetFileExtension (sName) {
return sName.substring(nIndex + 1).toLowerCase();
return null;
}
function changeFileExtention (sName, sNewExt) {
var sOldExt = GetFileExtension(sName);
if(sOldExt) {
return sName.substring(0, sName.length - sOldExt.length) + sNewExt;
} else {
return sName + '.' + sNewExt;
}
}
function getExtentionByFormat (format) {
switch(format) {
case c_oAscFileType.PDF: return 'pdf'; break;
case c_oAscFileType.HTML: return 'html'; break;
// Word
case c_oAscFileType.DOCX: return 'docx'; break;
case c_oAscFileType.DOC: return 'doc'; break;
case c_oAscFileType.ODT: return 'odt'; break;
case c_oAscFileType.RTF: return 'rtf'; break;
case c_oAscFileType.TXT: return 'txt'; break;
case c_oAscFileType.MHT: return 'mht'; break;
case c_oAscFileType.EPUB: return 'epub'; break;
case c_oAscFileType.FB2: return 'fb2'; break;
case c_oAscFileType.MOBI: return 'mobi'; break;
case c_oAscFileType.DOCY: return 'doct'; break;
case c_oAscFileType.JSON: return 'json'; break;
// Excel
case c_oAscFileType.XLSX: return 'xlsx'; break;
case c_oAscFileType.XLS: return 'xls'; break;
case c_oAscFileType.ODS: return 'ods'; break;
case c_oAscFileType.CSV: return 'csv'; break;
case c_oAscFileType.XLSY: return 'xlst'; break;
// PowerPoint
case c_oAscFileType.PPTX: return 'pptx'; break;
case c_oAscFileType.PPT: return 'ppt'; break;
case c_oAscFileType.ODP: return 'odp'; break;
}
return '';
}
function InitOnMessage (callback) {
if (window.addEventListener) {
window.addEventListener("message", function (event) {
......
......@@ -560,7 +560,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this._asc_downloadAs(typeFile, function(input) {
if (null != input && ("save" == input["type"] || "sfct" == input["type"])) {
if ('ok' == input["status"]) {
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if (url) {
t.asc_processSavedFile(url, false);
} else {
......@@ -807,7 +807,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this._asc_downloadAs(c_oAscFileType.CSV, function(input) {
if (null != input && "save" == input["type"]) {
if ('ok' == input["status"]) {
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if (url) {
t.asc_processSavedFile(url, false);
} else {
......@@ -946,19 +946,21 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var oBinaryFileWriter = new Asc.BinaryFileWriter(this.wbModel);
var dataContainer = {data: null, part: null, index: 0, count: 0};
dataContainer.data = oBinaryFileWriter.Write();
var filetype = 0x1002;
var oAdditionalData = {};
oAdditionalData["c"] = "sfct";
oAdditionalData["id"] = this.documentId;
oAdditionalData["userid"] = this.documentUserId;
oAdditionalData["vkey"] = this.documentVKey;
oAdditionalData["outputformat"] = 0x1002;
oAdditionalData["outputformat"] = filetype;
oAdditionalData["title"] = changeFileExtention(this.documentTitle, getExtentionByFormat(filetype));
this.wb._initCommentsToSave();
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
var t = this;
t.fCurCallback = function(incomeObject) {
if (null != input && "save" == input["type"]) {
if ('ok' == input["status"]) {
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if (url) {
t.asc_processSavedFile(url, false);
} else {
......@@ -985,6 +987,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["userid"] = this.documentUserId;
oAdditionalData["vkey"] = this.documentVKey;
oAdditionalData["outputformat"] = sFormat;
oAdditionalData["title"] = changeFileExtention(this.documentTitle, getExtentionByFormat(sFormat));
if (c_oAscFileType.PDF === sFormat) {
var printPagesData = this.wb.calcPagesPrint(this.adjustPrint);
var pdf_writer = new CPdfPrinter();
......
......@@ -1335,7 +1335,7 @@ asc_docs_api.prototype.asc_Print = function(){
_downloadAs(this, c_oAscFileType.PDF, function(input){
if(null != input && "save" == input["type"]) {
if('ok' == input["status"]){
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
} else {
......@@ -1509,7 +1509,7 @@ asc_docs_api.prototype.asc_DownloadAs = function(typeFile){//передаем ч
_downloadAs(this, typeFile, function(input){
if(null != input && ("save" == input["type"] || "sfct" == input["type"])) {
if('ok' == input["status"]){
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
} else {
......@@ -5066,6 +5066,7 @@ function _downloadAs(editor, filetype, fCallback, bStart, sSaveKey)
oAdditionalData["userid"] = documentUserId;
oAdditionalData["vkey"] = documentVKey;
oAdditionalData["outputformat"] = filetype;
oAdditionalData["title"] = changeFileExtention(documentTitle, getExtentionByFormat(filetype));
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
if(c_oAscFileType.PDF == filetype)
{
......
......@@ -2113,7 +2113,7 @@ asc_docs_api.prototype.asc_Print = function()
this.fCurCallback = function(input) {
if(null != input && "savefromorigin" == input["type"]) {
if('ok' == input["status"]) {
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
}
......@@ -2137,7 +2137,7 @@ asc_docs_api.prototype.asc_Print = function()
_downloadAs(this, "save", null, null, null, c_oAscFileType.PDF, function(input){
if(null != input && "save" == input["type"]) {
if('ok' == input["status"]){
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
} else {
......@@ -2313,7 +2313,7 @@ asc_docs_api.prototype.asc_DownloadAs = function(typeFile, txtOptions) {//пер
_downloadAs(this, "save", null, null, txtOptions, typeFile, function (input) {
if(null != input && ("save" == input["type"] || "sfct" == input["type"])) {
if('ok' == input["status"]){
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if(url) {
t.processSavedFile(url, false);
} else {
......@@ -2342,7 +2342,7 @@ asc_docs_api.prototype.asc_DownloadAsMailMerge = function(typeFile, StartIndex,
_downloadAs(this, "save", oDocumentMailMerge, null, null, typeFile, function (input) {
if(null != input && "save" == input["type"]) {
if('ok' == input["status"]){
var url = g_fGetSaveUrl(input["data"]);
var url = input["data"];
if(url) {
if(bIsDownload) {
t.processSavedFile(url, false);
......@@ -6813,6 +6813,7 @@ function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, tx
oAdditionalData["userid"] = documentUserId;
oAdditionalData["vkey"] = documentVKey;
oAdditionalData["outputformat"] = filetype;
oAdditionalData["title"] = changeFileExtention(documentTitle, getExtentionByFormat(filetype));
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
if (null == oDocumentMailMerge && c_oAscFileType.PDF === filetype) {
var dd = editor.WordControl.m_oDrawingDocument;
......
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