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

Ускорение открытия, для нового документа не отправляем запрос на конвертацию,...

Ускорение открытия, для нового документа не отправляем запрос на конвертацию, а открываем бинарник из скриптов.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50862 954022d7-b5bf-4e40-9824-e11837661b57
parent 44cc431b
......@@ -133,6 +133,7 @@
"../Word/api-all.js",
"../Word/merge/api_merge.js",
"../Word/Build/Log/apiExport.js",
"../Word/document/empty.js",
"../Excel/graphics/DrawingContextWord.js"
],
"dst": "../Word/sdk-all.js",
......
......@@ -428,6 +428,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.documentOrigin = this.DocInfo["Origin"];
this.chartEditor = this.DocInfo["ChartEditor"];
this.documentOpenOptions = this.DocInfo["Options"];
this.documentIsNew = this.DocInfo["IsNew"];
var nIndex = -1;
if(this.documentTitle)
......@@ -471,16 +472,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var emptyWorkbook = getEmptyWorkbook() + "";
if ( emptyWorkbook.length && (c_oSerFormat.Signature === emptyWorkbook.substring(0, c_oSerFormat.Signature.length)) ) {
this.isChartEditor = true;
var wb = new Workbook("", this.handlers, this);
wb.initGlobalObjects();
this.wbModel = wb;
var oBinaryFileReader = new BinaryFileReader("");
oBinaryFileReader.Read(emptyWorkbook, wb);
var wb = this.asc_OpenDocument("", emptyWorkbook);
this._startOpenDocument({returnCode: 0, val:wb});
}
},
asc_OpenDocument: function(url, data)
{
var wb = new Workbook(url, this.handlers, this);
wb.initGlobalObjects();
this.wbModel = wb;
var oBinaryFileReader = new BinaryFileReader(url);
oBinaryFileReader.Read(data, wb);
return wb;
},
asc_getEditorPermissions : function(){
if (this.DocInfo &&
this.DocInfo["Id"] &&
......@@ -760,11 +767,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
url = sJsonUrl;
if( c_oSerFormat.Signature === result.substring(0, c_oSerFormat.Signature.length))
{
var wb = new Workbook(url, oThis.handlers, oThis);
wb.initGlobalObjects();
oThis.wbModel = wb;
var oBinaryFileReader = new BinaryFileReader(url);
oBinaryFileReader.Read(result, wb);
var wb = oThis.asc_OpenDocument(url, result);
if (callback)
callback({returnCode: 0, val:wb});
}
......@@ -904,19 +907,26 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if( c_oSerFormat.Signature === sData.substring(0, c_oSerFormat.Signature.length))
{
var sUrlPath = "offlinedocs/test-workbook9/";
var wb = new Workbook(sUrlPath, this.handlers, this);
wb.initGlobalObjects();
this.wbModel = wb;
var oBinaryFileReader = new BinaryFileReader(sUrlPath);
oBinaryFileReader.Read(sData, wb);
var wb = this.asc_OpenDocument(sUrlPath, sData);
fCallback({returnCode: 0, val:wb});
}
}
else {
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
var v = {"id":this.documentId, "format": this.documentFormat, "vkey": this.documentVKey, "editorid": c_oEditorId.Speadsheet, "c":"open", "url": this.documentUrl, "title": this.documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts};
this._asc_sendCommand (fCallback, JSON.stringify(v));
if(this.documentIsNew)
{
var sEmptyWorkbook = getEmptyWorkbook();
var v = {"id":this.documentId, "format": this.documentFormat, "vkey": this.documentVKey, "editorid": c_oEditorId.Speadsheet, "c":"create", "url": this.documentUrl, "title": this.documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts, "data": sEmptyWorkbook};
this._asc_sendCommand (fCallback, JSON.stringify(v));
var wb = this.asc_OpenDocument(g_sResourceServiceLocalUrl + this.documentId + "/", sEmptyWorkbook);
fCallback({returnCode: 0, val:wb});
}
else
{
// Меняем тип состояния (на открытие)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Open;
var v = {"id":this.documentId, "format": this.documentFormat, "vkey": this.documentVKey, "editorid": c_oEditorId.Speadsheet, "c":"open", "url": this.documentUrl, "title": this.documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts};
this._asc_sendCommand (fCallback, JSON.stringify(v));
}
}
},
......@@ -3047,12 +3057,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (!window['scriptBridge']['loadDocumentFromString']) {
window['scriptBridge']['loadDocumentFromString'] = function(workbook) {
var wb = new Workbook("", t.handlers, t);
wb.initGlobalObjects();
t.wbModel = wb;
var oBinaryFileReader = new BinaryFileReader("");
oBinaryFileReader.Read(workbook, wb);
var wb = t.asc_OpenDocument("", workbook);
t._startOpenDocument({returnCode: 0, val:wb});
}
}
......@@ -3069,13 +3074,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (!data || c_oSerFormat.Signature !== data.substring(0, c_oSerFormat.Signature.length)) {
workbook = "XLSY;v1;1001;BAKAAgAAAwwDAAAEHwMAAADgAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIgAAAAAHgAAAAEZAAAAAAAAAAABAAAAAAIAAAAABAAAAAAFAAAAAAIdAAAAAxgAAAAGBAAAAAAHBAAAAAAIBAAAAAAJBAAAAAAECgAAAAUAAAAABQAAAAAGLwAAAAcqAAAAAQYGAAAAAAQAAAD/BAYOAAAAQwBhAGwAaQBiAHIAaQAGBQAAAAAAACZADwAAAAAAAAAAAQUAAAACAAAAAL0AAAAAOgAAAAEYAAAAAAYMAAAAUwBoAGUAZQB0ADEAAQQBAAAABAQAAABBADEACwoAAAABBQAAAAAAAC5ACQAAAAAAOgAAAAEYAAAAAAYMAAAAUwBoAGUAZQB0ADIAAQQCAAAABAQAAABBADEACwoAAAABBQAAAAAAAC5ACQAAAAAAOgAAAAEYAAAAAAYMAAAAUwBoAGUAZQB0ADMAAQQDAAAABAQAAABBADEACwoAAAABBQAAAAAAAC5ACQAAAAAFAAAAAAAAAAA=";
}
var wb = new Workbook("", t.handlers, t);
wb.initGlobalObjects();
t.wbModel = wb;
var oBinaryFileReader = new BinaryFileReader("");
oBinaryFileReader.Read(workbook, wb);
var wb = t.asc_OpenDocument("", workbook);
t._startOpenDocument({returnCode: 0, val:wb});
}
......
......@@ -37,6 +37,9 @@ function CDocInfo (obj){
}
if (typeof obj.UserName != 'undefined'){
this.UserName = obj.UserName;
}
if (typeof obj.IsNew != 'undefined'){
this.IsNew = obj.IsNew;
}
if (obj.OfflineApp === true)
this.OfflineApp = true;
......@@ -49,6 +52,7 @@ function CDocInfo (obj){
this.VKey = null;
this.UserId = null;
this.UserName = null;
this.IsNew = null;
}
}
CDocInfo.prototype.get_Id = function(){return this.Id}
......@@ -67,6 +71,8 @@ CDocInfo.prototype.get_UserId = function(){return this.UserId;}
CDocInfo.prototype.put_UserId = function(v){this.UserId = v;}
CDocInfo.prototype.get_UserName = function(){return this.UserName;}
CDocInfo.prototype.put_UserName = function(v){this.UserName = v;}
CDocInfo.prototype.get_IsNew = function(){return this.IsNew;}
CDocInfo.prototype.put_IsNew = function(v){this.IsNew = v;}
// ---------------------------------------------------------------
function CAscColorScheme()
......
......@@ -122,6 +122,7 @@
<script type="text/javascript" src="apiDefines.js"></script>
<script type="text/javascript" src="apiCommon.js"></script>
<script type="text/javascript" src="api.js"></script>
<script type="text/javascript" src="document/empty.js"></script>
<script type="text/javascript" src="merge/api_merge.js"></script>
<script type="text/javascript" src="../Common/scroll.js"></script>
......
......@@ -158,6 +158,7 @@
<script type="text/javascript" src="apiDefines.js"></script>
<script type="text/javascript" src="apiCommon.js"></script>
<script type="text/javascript" src="api.js"></script>
<script type="text/javascript" src="document/empty.js"></script>
<script type="text/javascript" src="../Common/scroll.js"></script>
<script type="text/javascript" src="Editor/CollaborativeEditing.js"></script>
......
......@@ -51,6 +51,9 @@ function CDocInfo (obj){
if (typeof obj.UserName != 'undefined'){
this.UserName = obj.UserName;
}
if (typeof obj.IsNew != 'undefined'){
this.IsNew = obj.IsNew;
}
if (obj.OfflineApp === true)
this.OfflineApp = true;
}
......@@ -62,6 +65,7 @@ function CDocInfo (obj){
this.VKey = null;
this.UserId = null;
this.UserName = null;
this.IsNew = null;
}
}
CDocInfo.prototype.get_Id = function(){return this.Id}
......@@ -80,6 +84,8 @@ CDocInfo.prototype.get_UserId = function(){return this.UserId;}
CDocInfo.prototype.put_UserId = function(v){this.UserId = v;}
CDocInfo.prototype.get_UserName = function(){return this.UserName;}
CDocInfo.prototype.put_UserName = function(v){this.UserName = v;}
CDocInfo.prototype.get_IsNew = function(){return this.IsNew;}
CDocInfo.prototype.put_IsNew = function(v){this.IsNew = v;}
function CListType(obj)
{
......@@ -910,11 +916,19 @@ asc_docs_api.prototype.LoadDocument = function(c_DocInfo)
}
if(documentId){
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
var rData = {"id":documentId, "format": documentFormat, "vkey": documentVKey, "editorid": c_oEditorId.Word, "c":"open", "url": documentUrl, "title": documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts};
sendCommand( oThis, function(){}, JSON.stringify(rData) );
this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, 0);
if(this.DocInfo.get_IsNew())
{
var rData = {"id":documentId, "format": documentFormat, "vkey": documentVKey, "editorid": c_oEditorId.Word, "c":"create", "url": documentUrl, "title": documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts, "data": g_sEmpty_bin};
sendCommand( oThis, function(){}, JSON.stringify(rData) );
editor.OpenDocument2(g_sResourceServiceLocalUrl + documentId + "/", g_sEmpty_bin);
}
else
{
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
var rData = {"id":documentId, "format": documentFormat, "vkey": documentVKey, "editorid": c_oEditorId.Word, "c":"open", "url": documentUrl, "title": documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts};
sendCommand( oThis, function(){}, JSON.stringify(rData) );
}
this.sync_zoomChangeCallback(this.WordControl.m_nZoomValue, 0);
}
else
{
......@@ -1160,6 +1174,16 @@ asc_docs_api.prototype.OpenDocument2 = function(url, gObject)
else
editor.asc_fireCallback("asc_onError",c_oAscError.ID.MobileUnexpectedCharCount,c_oAscError.Level.Critical);
//callback
editor.DocumentOrientation = (null == editor.WordControl.m_oLogicDocument) ? true : !editor.WordControl.m_oLogicDocument.Orientation;
var sizeMM;
if(editor.DocumentOrientation)
sizeMM = DocumentPageSize.getSize(Page_Width, Page_Height);
else
sizeMM = DocumentPageSize.getSize(Page_Height, Page_Width);
editor.sync_DocSizeCallback(sizeMM.w_mm, sizeMM.h_mm);
editor.sync_PageOrientCallback(editor.get_DocumentOrientation());
this.ParcedDocument = true;
if (this.isStartCoAuthoringOnEndLoad) {
this.CoAuthoringApi.onStartCoAuthoring(true);
......@@ -6640,15 +6664,6 @@ asc_docs_api.prototype.OfflineAppDocumentEndLoad = function()
editor.OpenDocument(documentUrl, window["editor_bin"]);
else
editor.OpenDocument2(documentUrl, window["editor_bin"]);
//callback
editor.DocumentOrientation = (null == editor.WordControl.m_oLogicDocument) ? true : !editor.WordControl.m_oLogicDocument.Orientation;
var sizeMM;
if(editor.DocumentOrientation)
sizeMM = DocumentPageSize.getSize(Page_Width, Page_Height);
else
sizeMM = DocumentPageSize.getSize(Page_Height, Page_Width);
editor.sync_DocSizeCallback(sizeMM.w_mm, sizeMM.h_mm);
editor.sync_PageOrientCallback(editor.get_DocumentOrientation());
}
asc_docs_api.prototype.SetDrawImagePlaceParagraph = function(element_id, props)
......@@ -6782,15 +6797,6 @@ function sendCommand(editor, fCallback, rdata){
editor.OpenDocument(url, result);
else
editor.OpenDocument2(url, result);
//callback
editor.DocumentOrientation = (null == editor.WordControl.m_oLogicDocument) ? true : !editor.WordControl.m_oLogicDocument.Orientation;
var sizeMM;
if(editor.DocumentOrientation)
sizeMM = DocumentPageSize.getSize(Page_Width, Page_Height);
else
sizeMM = DocumentPageSize.getSize(Page_Height, Page_Width);
editor.sync_DocSizeCallback(sizeMM.w_mm, sizeMM.h_mm);
editor.sync_PageOrientCallback(editor.get_DocumentOrientation());
if(fCallback)
fCallback(incomeObject);
},
......
This diff is collapsed.
......@@ -208,6 +208,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/apiDefines.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/api.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/document/empty.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/scroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/CollaborativeEditing.js"></script>
......
......@@ -181,6 +181,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/apiDefines.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/api.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/document/empty.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/scroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Shapes/EditorSettings.js"></script>
......
......@@ -128,6 +128,7 @@
<script type="text/javascript" src="../../OfficeWeb/Word/apiDefines.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/apiCommon.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/api.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/document/empty.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Common/scroll.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/Editor/CollaborativeEditing.js"></script>
......
......@@ -160,6 +160,7 @@
<script type="text/javascript" src="apiDefines.js"></script>
<script type="text/javascript" src="apiCommon.js"></script>
<script type="text/javascript" src="document/empty.js"></script>
<!--<script type="text/javascript" src="api.js"></script>-->
<script type="text/javascript" src="../Common/scroll.js"></script>
......
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