Commit b0f5b5a0 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Вынес открытие файла в общую функцию

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62435 954022d7-b5bf-4e40-9824-e11837661b57
parent 946934d1
...@@ -42,6 +42,29 @@ function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) { ...@@ -42,6 +42,29 @@ function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) {
}, oAdditionalData); }, oAdditionalData);
} }
function g_fOpenFileCommand (data, Signature, callback) {
var openData = JSON.parse(data);
var sFileUrl = g_sResourceServiceLocalUrl + openData['urlfile'];
asc_ajax({
url: sFileUrl,
dataType: "text",
success: function(result) {
//получаем url к папке с файлом
var url;
var nIndex = sFileUrl.lastIndexOf("/");
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
if (0 < result.length) {
if (callback) callback(false, {bSerFormat: Signature === result.substring(0, Signature.length), data: result, url: url});
} else {
if (callback) callback(true);
}
},
error: function () {
if (callback) callback(true);
}
});
}
function fSortAscending( a, b ) { function fSortAscending( a, b ) {
return a - b; return a - b;
} }
......
...@@ -1013,40 +1013,18 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1013,40 +1013,18 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
dataType: "text"}); dataType: "text"});
}; };
spreadsheet_api.prototype._onOpenCommand = function (callback, url) { spreadsheet_api.prototype._onOpenCommand = function (callback, data) {
var t = this; var t = this;
var sJsonUrl = g_sResourceServiceLocalUrl + url; g_fOpenFileCommand(data, Asc.c_oSerFormat.Signature, function (error, result) {
asc_ajax({ if (error || !result.bSerFormat) {
url: sJsonUrl, var oError = {returnCode: c_oAscError.Level.Critical, val: c_oAscError.ID.Unknown};
dataType: "text", t.handlers.trigger("asc_onError", oError.val, oError.returnCode);
success: function(result) { if (callback) callback(oError);
//получаем url к папке с файлом return;
var url;
var nIndex = sJsonUrl.lastIndexOf("/");
if(-1 !== nIndex)
url = sJsonUrl.substring(0, nIndex + 1);
else
url = sJsonUrl;
if (Asc.c_oSerFormat.Signature === result.substring(0, Asc.c_oSerFormat.Signature.length))
{
var wb = t.asc_OpenDocument(url, result);
if (callback)
callback({returnCode: 0, val:wb});
}
else
{
result = {returnCode: c_oAscError.Level.Critical, val:c_oAscError.ID.Unknown};
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.Critical);
if(callback)
callback(result);
}
},
error:function(){
var result = {returnCode: c_oAscError.Level.Critical, val:c_oAscError.ID.Unknown};
t.handlers.trigger("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.Critical);
if(callback)
callback(result);
} }
var wb = t.asc_OpenDocument(result.url, result.data);
if (callback) callback({returnCode: 0, val: wb});
}); });
}; };
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
/** @enum */ /** @enum */
var c_oSerFormat = { var c_oSerFormat = {
Version:2, //1.0.0.2 Version : 2, //1.0.0.2
Signature: "XLSY" Signature : "XLSY"
}; };
var g_nCurFileVersion = c_oSerFormat.Version; var g_nCurFileVersion = c_oSerFormat.Version;
//dif: //dif:
......
...@@ -16,10 +16,9 @@ var documentOrigin = ""; ...@@ -16,10 +16,9 @@ var documentOrigin = "";
var documentFormatSave = c_oAscFileType.PPTX;//пока не во что другое сохранять не можем. var documentFormatSave = c_oAscFileType.PPTX;//пока не во что другое сохранять не можем.
var documentCallbackUrl = undefined; // Ссылка для отправления информации о документе var documentCallbackUrl = undefined; // Ссылка для отправления информации о документе
var c_oSerFormat = var c_oSerFormat = {
{ Version : 1,
Version:1, Signature : "PPTY"
Signature: "PPTY"
}; };
...@@ -5197,40 +5196,18 @@ function sendTrack(fCallback, url, rdata){ ...@@ -5197,40 +5196,18 @@ function sendTrack(fCallback, url, rdata){
}) })
} }
function _onOpenCommand(fCallback, incomeObject) { function _onOpenCommand(fCallback, incomeObject) {
var sJsonUrl = g_sResourceServiceLocalUrl + incomeObject["data"]; g_fOpenFileCommand(incomeObject["data"], c_oSerFormat.Signature, function (error, result) {
asc_ajax({ if (error || !result.bSerFormat) {
url: sJsonUrl,
dataType: "text",
success: function(result) {
//получаем url к папке с файлом
var url;
var nIndex = sJsonUrl.lastIndexOf("/");
if(-1 != nIndex)
url = sJsonUrl.substring(0, nIndex + 1);
else
url = sJsonUrl;
var bIsViewer = false;
if(result.length > 0)
{
if(c_oSerFormat.Signature != result.substring(0, c_oSerFormat.Signature.length))
bIsViewer = true;
}
if(true == bIsViewer)
editor.OpenDocument(url, result);
else
editor.OpenDocument2(url, result);
//callback
editor.DocumentOrientation = (null == editor.WordControl.m_oLogicDocument) ? true : !editor.WordControl.m_oLogicDocument.Orientation;
editor.sync_DocSizeCallback(Page_Width, Page_Height);
editor.sync_PageOrientCallback(editor.get_DocumentOrientation());
if(fCallback)
fCallback(incomeObject);
},
error:function(){
editor.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.Critical); editor.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.Critical);
if(fCallback) if(fCallback) fCallback();
fCallback(); return;
} }
editor.OpenDocument2(result.url, result.data);
editor.DocumentOrientation = (null == editor.WordControl.m_oLogicDocument) ? true : !editor.WordControl.m_oLogicDocument.Orientation;
editor.sync_DocSizeCallback(Page_Width, Page_Height);
editor.sync_PageOrientCallback(editor.get_DocumentOrientation());
if(fCallback) fCallback();
}); });
} }
function _downloadAs(editor, filetype, fCallback, bStart, sSaveKey) function _downloadAs(editor, filetype, fCallback, bStart, sSaveKey)
......
"use strict"; "use strict";
var c_oSerFormat = { var c_oSerFormat = {
Version:5, //1.0.0.5 Version : 5, //1.0.0.5
Signature: "DOCY" Signature : "DOCY"
}; };
var g_nCurFileVersion = c_oSerFormat.Version; var g_nCurFileVersion = c_oSerFormat.Version;
//dif: //dif:
......
...@@ -7155,36 +7155,18 @@ function sendTrack(fCallback, url, rdata){ ...@@ -7155,36 +7155,18 @@ function sendTrack(fCallback, url, rdata){
}) })
} }
function _onOpenCommand(fCallback, incomeObject) { function _onOpenCommand(fCallback, incomeObject) {
var sJsonUrl = g_sResourceServiceLocalUrl + incomeObject["data"]; g_fOpenFileCommand(incomeObject["data"], c_oSerFormat.Signature, function (error, result) {
asc_ajax({ if (error) {
url: sJsonUrl,
dataType: "text",
success: function(result) {
//получаем url к папке с файлом
var url;
var nIndex = sJsonUrl.lastIndexOf("/");
if(-1 != nIndex)
url = sJsonUrl.substring(0, nIndex + 1);
else
url = sJsonUrl;
var bIsViewer = false;
if(result.length > 0)
{
if(c_oSerFormat.Signature != result.substring(0, c_oSerFormat.Signature.length))
bIsViewer = true;
}
if(true == bIsViewer)
editor.OpenDocument(url, result);
else
editor.OpenDocument2(url, result);
if(fCallback)
fCallback(incomeObject);
},
error:function(){
editor.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.Critical); editor.asc_fireCallback("asc_onError",c_oAscError.ID.Unknown,c_oAscError.Level.Critical);
if(fCallback) if(fCallback) fCallback();
fCallback(); return;
} }
if (result.bSerFormat)
editor.OpenDocument2(result.url, result.data);
else
editor.OpenDocument(result.url, result.data);
if(fCallback) fCallback();
}); });
} }
function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, filetype, fCallback) { function _downloadAs(editor, command, oDocumentMailMerge, oMailMergeSendData, filetype, fCallback) {
......
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