Commit 3c5e77c6 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

OpenDocumentProgress и SendOpenProgress вынес в base

Добавил метод sendEvent (его реализацию в классах через handlers.trigger и asc_fireCallback)
убрал sync_SendProgress и asc_onOpenDocumentProgress2. Убрал _lastConvertProgress.
COpenProgress вынес в общий apiCommon.js

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66223 954022d7-b5bf-4e40-9824-e11837661b57
parent 5941fd0b
......@@ -19,6 +19,7 @@ function baseEditorsApi(name) {
// Тип состояния на данный момент (сохранение, открытие или никакое)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
this.OpenDocumentProgress = new COpenProgress();
// Chart
this.chartTranslate = new asc_CChartTranslate();
......@@ -57,6 +58,12 @@ function baseEditorsApi(name) {
baseEditorsApi.prototype.asc_GetFontThumbnailsPath = function() {
return '../Common/Images/';
};
// Events
baseEditorsApi.prototype.sendEvent = function() {
};
baseEditorsApi.prototype.SendOpenProgress = function() {
this.sendEvent("asc_onOpenDocumentProgress", this.OpenDocumentProgress);
};
// send chart message
baseEditorsApi.prototype.asc_coAuthoringChatSendMessage = function(message) {
this.CoAuthoringApi.sendMessage(message);
......
......@@ -2738,6 +2738,31 @@
prot["put_ChartEditor"] = prot["asc_putChartEditor"] = prot.asc_putChartEditor;
prot["get_UserInfo"] = prot["asc_getUserInfo"] = prot.asc_getUserInfo;
prot["put_UserInfo"] = prot["asc_putUserInfo"] = prot.asc_putUserInfo;
// ToDo продолжаем делать плохие вещи...Нужно с этим что-то делать!
function COpenProgress() {
this.Type = c_oAscAsyncAction.Open;
this.FontsCount = 0;
this.CurrentFont = 0;
this.ImagesCount = 0;
this.CurrentImage = 0;
}
COpenProgress.prototype.asc_getType = function(){return this.Type};
COpenProgress.prototype.asc_getFontsCount = function(){return this.FontsCount};
COpenProgress.prototype.asc_getCurrentFont = function(){return this.CurrentFont};
COpenProgress.prototype.asc_getImagesCount = function(){return this.ImagesCount};
COpenProgress.prototype.asc_getCurrentImage = function(){return this.CurrentImage};
prot = COpenProgress.prototype;
prot["asc_getType"] = COpenProgress.prototype.asc_getType;
prot["asc_getFontsCount"] = COpenProgress.prototype.asc_getFontsCount;
prot["asc_getCurrentFont"] = COpenProgress.prototype.asc_getCurrentFont;
prot["asc_getImagesCount"] = COpenProgress.prototype.asc_getImagesCount;
prot["asc_getCurrentImage"] = COpenProgress.prototype.asc_getCurrentImage;
window["COpenProgress"] = COpenProgress;
}
)(window);
......@@ -2796,6 +2821,7 @@ var asc_CStroke = window["asc_CStroke"];
var CParagraphFrame = window["CParagraphFrame"];
var asc_CParagraphFrame = window["asc_CParagraphFrame"];
var CMouseMoveData = window["CMouseMoveData"];
var COpenProgress = window["COpenProgress"];
var asc_TextArtProperties = window["asc_TextArtProperties"];
var asc_TextArtTranslate = window["asc_TextArtTranslate"];
var CDocInfo = window["CDocInfo"];
......@@ -2842,8 +2868,6 @@ CAscMathCategory.prototype["get_W"] = function(){ return this.W; };
CAscMathCategory.prototype["get_H"] = function(){ return this.H; };
CAscMathCategory.prototype.private_Sort = function(){ this.Data.sort( function(a,b){ return a.Id- b.Id; } ); };
// эта функция ДОЛЖНА минимизироваться
function CreateAscFill(unifill)
{
......
......@@ -97,15 +97,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
//находится ли фокус в рабочей области редактора(используется для copy/paste в MAC)
this.IsFocus = null;
/**************************************/
this.OpenDocumentProgress = {
Type: c_oAscAsyncAction.Open,
FontsCount: 0,
CurrentFont: 0,
ImagesCount: 0,
CurrentImage: 0
};
// На этапе сборки значение переменной ASC_DOCS_API_USE_EMBEDDED_FONTS может менятся.
// По дефолту встроенные шрифты использоваться не будут, как и при любом значении
......@@ -123,6 +114,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
asc.extendClass(spreadsheet_api, baseEditorsApi);
spreadsheet_api.prototype.sendEvent = function() {
this.handlers.trigger.apply(this.handlers, arguments);
};
spreadsheet_api.prototype._init = function() {
var t = this;
this.HtmlElement = document.getElementById(this.HtmlElementName);
......@@ -960,7 +955,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
* asc_onEndAction (type, id)
* asc_onInitEditorFonts (gui_fonts)
* asc_onInitEditorStyles (gui_styles)
* asc_onOpenDocumentProgress (_OpenDocumentProgress)
* asc_onOpenDocumentProgress (COpenProgress)
* asc_onAdvancedOptions (asc_CAdvancedOptions, ascAdvancedOptionsAction) - эвент на получение дополнительных опций (открытие/сохранение CSV)
* asc_onError (c_oAscError.ID, c_oAscError.Level) - эвент об ошибке
* asc_onEditCell (c_oAscCellEditorState) - эвент на редактирование ячейки с состоянием (переходами из формулы и обратно)
......@@ -1114,17 +1109,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.asc_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadFont);
};
spreadsheet_api.prototype.SendOpenProgress = function() {
var _OpenDocumentProgress = {
"Type": this.OpenDocumentProgress.Type,
"FontsCount": this.OpenDocumentProgress.FontsCount,
"CurrentFont": this.OpenDocumentProgress.CurrentFont,
"ImagesCount": this.OpenDocumentProgress.ImagesCount,
"CurrentImage": this.OpenDocumentProgress.CurrentImage
};
this.handlers.trigger("asc_onOpenDocumentProgress", _OpenDocumentProgress);
};
/**
* Функция для загрузчика шрифтов (нужно ли грузить default шрифты). Для Excel всегда возвращаем false
* @returns {boolean}
......
......@@ -96,9 +96,6 @@ function asc_docs_api(name)
this.SelectedObjectsStack = [];
this.OpenDocumentProgress = new CDocOpenProgress();
this._lastConvertProgress = 0;
this.CoAuthoringApi.isPowerPoint = true;
this.isDocumentCanSave = false; // Флаг, говорит о возможности сохранять документ (активна кнопка save или нет)
......@@ -148,6 +145,10 @@ function asc_docs_api(name)
}
asc.extendClass(asc_docs_api, baseEditorsApi);
asc_docs_api.prototype.sendEvent = function() {
this.asc_fireCallback.apply(this, arguments);
};
/////////////////////////////////////////////////////////////////////////
///////////////////CoAuthoring and Chat api//////////////////////////////
/////////////////////////////////////////////////////////////////////////
......@@ -3998,25 +3999,6 @@ asc_docs_api.prototype.get_PresentationHeight = function()
return this.WordControl.m_oLogicDocument.Height;
};
asc_docs_api.prototype.SendOpenProgress = function()
{
// Пока отсылаем старый callback
this.asc_fireCallback("asc_onOpenDocumentProgress", this.OpenDocumentProgress);
var _progress = this.OpenDocumentProgress;
var _percents = (_progress.get_CurrentFont() + _progress.get_CurrentImage())/(_progress.get_FontsCount() + _progress.get_ImagesCount());
// приводим к 0..100
_percents *= 100;
// рассчет исходя из того, что часть прогресса прошли на конвертации
_percents = Math.min(this._lastConvertProgress + _percents * (100.0 - this._lastConvertProgress) / 100.0, 100.0);
return this.sync_SendProgress(_percents);
//console.log("" + this.OpenDocumentProgress.CurrentFont);
};
asc_docs_api.prototype.sync_SendProgress = function(Percents)
{
this.asc_fireCallback("asc_onOpenDocumentProgress2", Percents);
}
asc_docs_api.prototype.pre_Paste = function(_fonts, _images, callback)
{
this.pasteCallback = callback;
......
"use strict";
function CDocOpenProgress()
{
this.Type = c_oAscAsyncAction.Open;
this.FontsCount = 0;
this.CurrentFont = 0;
this.ImagesCount = 0;
this.CurrentImage = 0;
}
CDocOpenProgress.prototype.get_Type = function(){return this.Type};
CDocOpenProgress.prototype.get_FontsCount = function(){return this.FontsCount};
CDocOpenProgress.prototype.get_CurrentFont = function(){return this.CurrentFont};
CDocOpenProgress.prototype.get_ImagesCount = function(){return this.ImagesCount};
CDocOpenProgress.prototype.get_CurrentImage = function(){return this.CurrentImage};
// ---------------------------------------------------------------
// ---------------------------------------------------------------
function CAscSlideTiming()
......
......@@ -302,7 +302,6 @@ asc_docs_api.prototype['asyncImageEndLoaded'] = asc_docs_api.prototype.asyncImag
asc_docs_api.prototype['get_PresentationWidth'] = asc_docs_api.prototype.get_PresentationWidth;
asc_docs_api.prototype['get_PresentationHeight'] = asc_docs_api.prototype.get_PresentationHeight;
asc_docs_api.prototype['SendOpenProgress'] = asc_docs_api.prototype.SendOpenProgress;
asc_docs_api.prototype['sync_SendProgress'] = asc_docs_api.prototype.sync_SendProgress;
asc_docs_api.prototype['pre_Paste'] = asc_docs_api.prototype.pre_Paste;
asc_docs_api.prototype['pre_SaveCallback'] = asc_docs_api.prototype.pre_SaveCallback;
asc_docs_api.prototype['initEvents2MobileAdvances'] = asc_docs_api.prototype.initEvents2MobileAdvances;
......@@ -446,12 +445,6 @@ CContextMenuData.prototype['get_Y'] = CContextMenuData.prototype.get_Y;
CContextMenuData.prototype['get_IsSlideSelect'] = CContextMenuData.prototype.get_IsSlideSelect;
window['_onOpenCommand'] = _onOpenCommand;
window['_downloadAs'] = _downloadAs;
window['CDocOpenProgress'] = CDocOpenProgress;
CDocOpenProgress.prototype['get_Type'] = CDocOpenProgress.prototype.get_Type;
CDocOpenProgress.prototype['get_FontsCount'] = CDocOpenProgress.prototype.get_FontsCount;
CDocOpenProgress.prototype['get_CurrentFont'] = CDocOpenProgress.prototype.get_CurrentFont;
CDocOpenProgress.prototype['get_ImagesCount'] = CDocOpenProgress.prototype.get_ImagesCount;
CDocOpenProgress.prototype['get_CurrentImage'] = CDocOpenProgress.prototype.get_CurrentImage;
window['CAscSlideTiming'] = CAscSlideTiming;
CAscSlideTiming.prototype['put_TransitionType'] = CAscSlideTiming.prototype.put_TransitionType;
CAscSlideTiming.prototype['get_TransitionType'] = CAscSlideTiming.prototype.get_TransitionType;
......
......@@ -17,23 +17,6 @@ var documentOrigin = "";
var documentFormatSave = c_oAscFileType.DOCX;
var documentCallbackUrl = undefined; // Ссылка для отправления информации о документе
function CDocOpenProgress()
{
this.Type = c_oAscAsyncAction.Open;
this.FontsCount = 0;
this.CurrentFont = 0;
this.ImagesCount = 0;
this.CurrentImage = 0;
}
CDocOpenProgress.prototype.get_Type = function(){return this.Type};
CDocOpenProgress.prototype.get_FontsCount = function(){return this.FontsCount};
CDocOpenProgress.prototype.get_CurrentFont = function(){return this.CurrentFont};
CDocOpenProgress.prototype.get_ImagesCount = function(){return this.ImagesCount};
CDocOpenProgress.prototype.get_CurrentImage = function(){return this.CurrentImage};
function CAscSection()
{
this.PageWidth = 0;
......@@ -382,9 +365,6 @@ function asc_docs_api(name)
this.nCurPointItemsLength = 0;
this.isDocumentEditor = true;
this.OpenDocumentProgress = new CDocOpenProgress();
this._lastConvertProgress = 0;
this.CurrentTranslate = translations_map["en"];
this.CollaborativeMarksShowType = c_oAscCollaborativeMarksShowType.All;
......@@ -440,6 +420,10 @@ function asc_docs_api(name)
}
asc.extendClass(asc_docs_api, baseEditorsApi);
asc_docs_api.prototype.sendEvent = function() {
this.asc_fireCallback.apply(this, arguments);
};
asc_docs_api.prototype.LoadFontsFromServer = function(_fonts)
{
if (undefined === _fonts)
......@@ -6082,24 +6066,6 @@ asc_docs_api.prototype.IsAsyncOpenDocumentImages = function()
return true;
};
asc_docs_api.prototype.SendOpenProgress = function()
{
// Пока отсылаем старый callback
this.asc_fireCallback("asc_onOpenDocumentProgress", this.OpenDocumentProgress);
var _progress = this.OpenDocumentProgress;
var _percents = (_progress.get_CurrentFont() + _progress.get_CurrentImage())/(_progress.get_FontsCount() + _progress.get_ImagesCount());
// приводим к 0..100
_percents *= 100;
// рассчет исходя из того, что часть прогресса прошли на конвертации
_percents = this._lastConvertProgress + _percents * (100.0 - this._lastConvertProgress) / 100.0;
return this.sync_SendProgress(_percents);
//console.log("" + this.OpenDocumentProgress.CurrentFont);
};
asc_docs_api.prototype.sync_SendProgress = function(Percents) {
this.asc_fireCallback("asc_onOpenDocumentProgress2", Percents);
};
asc_docs_api.prototype.pre_Paste = function(_fonts, _images, callback)
{
if (undefined !== window["Native"] && undefined !== window["Native"]["GetImageUrl"])
......
window['CDocOpenProgress'] = CDocOpenProgress;
CDocOpenProgress.prototype['get_Type'] = CDocOpenProgress.prototype.get_Type;
CDocOpenProgress.prototype['get_FontsCount'] = CDocOpenProgress.prototype.get_FontsCount;
CDocOpenProgress.prototype['get_CurrentFont'] = CDocOpenProgress.prototype.get_CurrentFont;
CDocOpenProgress.prototype['get_ImagesCount'] = CDocOpenProgress.prototype.get_ImagesCount;
CDocOpenProgress.prototype['get_CurrentImage'] = CDocOpenProgress.prototype.get_CurrentImage;
window['CAscSection'] = CAscSection;
CAscSection.prototype['get_PageWidth'] = CAscSection.prototype.get_PageWidth;
CAscSection.prototype['get_PageHeight'] = CAscSection.prototype.get_PageHeight;
......@@ -448,7 +442,6 @@ asc_docs_api.prototype['asyncImageEndLoaded'] = asc_docs_api.prototype.asyncImag
asc_docs_api.prototype['asyncImageEndLoadedBackground'] = asc_docs_api.prototype.asyncImageEndLoadedBackground;
asc_docs_api.prototype['IsAsyncOpenDocumentImages'] = asc_docs_api.prototype.IsAsyncOpenDocumentImages;
asc_docs_api.prototype['SendOpenProgress'] = asc_docs_api.prototype.SendOpenProgress;
asc_docs_api.prototype['sync_SendProgress'] = asc_docs_api.prototype.sync_SendProgress;
asc_docs_api.prototype['pre_Paste'] = asc_docs_api.prototype.pre_Paste;
asc_docs_api.prototype['pre_Save'] = asc_docs_api.prototype.pre_Save;
asc_docs_api.prototype['SyncLoadImages'] = asc_docs_api.prototype.SyncLoadImages;
......
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