Commit 0a4b67a0 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

mouse down-up


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61480 954022d7-b5bf-4e40-9824-e11837661b57
parent 90056915
......@@ -10435,7 +10435,7 @@ window.g_cAscCoAuthoringUrl = "";
var t = this;
this._CoAuthoringApi.onAuthParticipantsChanged = function (e, count) {t.callback_OnAuthParticipantsChanged(e, count);};
this._CoAuthoringApi.onParticipantsChanged = function (e, count) {t.callback_OnParticipantsChanged(e, count);};
this._CoAuthoringApi.onMessage = function (e) {t.callback_OnMessage(e);};
this._CoAuthoringApi.onMessage = function (e, clear) {t.callback_OnMessage(e, clear);};
this._CoAuthoringApi.onLocksAcquired = function (e) {t.callback_OnLocksAcquired(e);};
this._CoAuthoringApi.onLocksReleased = function (e, bChanges) {t.callback_OnLocksReleased(e, bChanges);};
this._CoAuthoringApi.onLocksReleasedEnd = function () {t.callback_OnLocksReleasedEnd();};
......@@ -10566,9 +10566,9 @@ window.g_cAscCoAuthoringUrl = "";
this.onParticipantsChanged(e, count);
};
CDocsCoApi.prototype.callback_OnMessage = function (e) {
CDocsCoApi.prototype.callback_OnMessage = function (e, clear) {
if (this.onMessage)
this.onMessage(e);
this.onMessage(e, clear);
};
CDocsCoApi.prototype.callback_OnLocksAcquired = function (e) {
......@@ -10671,8 +10671,8 @@ window.g_cAscCoAuthoringUrl = "";
this._saveCallback = [];
this.saveLockCallbackErrorTimeOutId = null;
this.saveCallbackErrorTimeOutId = null;
this._id = "";
this._indexuser = -1;
this._id = null;
this._indexUser = -1;
// Если пользователей больше 1, то совместно редактируем
this.isCoAuthoring = false;
// Мы сами отключились от совместного редактирования
......@@ -10711,6 +10711,7 @@ window.g_cAscCoAuthoringUrl = "";
this.ownedLockBlocks = [];
this.sockjs_url = null;
this.sockjs = null;
this.editorType = -1;
this._isExcel = false;
this._isPresentation = false;
this._isAuth = false;
......@@ -10729,9 +10730,9 @@ window.g_cAscCoAuthoringUrl = "";
DocsCoApi.prototype.get_state = function () {
return this._state;
};
DocsCoApi.prototype.get_indexUser = function () {
return this._indexuser;
return this._indexUser;
};
DocsCoApi.prototype.getSessionId = function () {
......@@ -10753,7 +10754,7 @@ window.g_cAscCoAuthoringUrl = "";
var isLock = false;
var idLockInArray = null;
for (; i < lengthArray; ++i) {
idLockInArray = (this._isExcel) ? arrayBlockId[i].guid : (this._isPresentation) ? arrayBlockId[i]["guid"] : arrayBlockId[i];
idLockInArray = (this._isExcel || this._isPresentation) ? arrayBlockId[i]['guid'] : arrayBlockId[i];
if (this._locks[idLockInArray] && 0 !== this._locks[idLockInArray].state) {
isLock = true;
break;
......@@ -10762,11 +10763,11 @@ window.g_cAscCoAuthoringUrl = "";
if (0 === lengthArray)
isLock = true;
idLockInArray = (this._isExcel) ? arrayBlockId[0].guid : (this._isPresentation) ? arrayBlockId[0]["guid"] : arrayBlockId[0];
idLockInArray = (this._isExcel || this._isPresentation) ? arrayBlockId[0]['guid'] : arrayBlockId[0];
if (!isLock) {
//Ask
this._locks[idLockInArray] = {"state": 1};//1-asked for block
this._locks[idLockInArray] = {'state': 1};//1-asked for block
if (callback && _.isFunction(callback)) {
this._lockCallbacks[idLockInArray] = callback;
var lockCalbacks = this._lockCallbacks;
......@@ -10775,22 +10776,17 @@ window.g_cAscCoAuthoringUrl = "";
window.setTimeout(function () {
if (lockCalbacks.hasOwnProperty(idLockInArray)) {
//Not signaled already
callback({error: "Timed out"});
callback({error: 'Timed out'});
delete lockCalbacks[idLockInArray];
}
}, this.errorTimeOut);
}
if (this._isExcel)
this._send({"type": "getLockRange", "block": arrayBlockId});
else if (this._isPresentation)
this._send({"type": "getLockPresentation", "block": arrayBlockId});
else
this._send({"type": "getLock", "block": arrayBlockId});
this._send({"type": 'getLock', 'editorType': this.editorType, 'block': arrayBlockId});
} else {
// Вернем ошибку, т.к. залочены элементы
window.setTimeout(function () {
if (callback && _.isFunction(callback)) {
callback({error: idLockInArray + "-lock"});
callback({error: idLockInArray + '-lock'});
}
}, 100);
}
......@@ -10927,10 +10923,9 @@ window.g_cAscCoAuthoringUrl = "";
}
};
DocsCoApi.prototype._onMessages = function (data) {
if (data["messages"] && this.onMessage) {
this.onMessage(data["messages"]);
}
DocsCoApi.prototype._onMessages = function (data, clear) {
if (data["messages"] && this.onMessage)
this.onMessage(data["messages"], clear);
};
DocsCoApi.prototype._onGetLock = function (data) {
......@@ -10938,8 +10933,8 @@ window.g_cAscCoAuthoringUrl = "";
for (var key in data["locks"]) {
if (data["locks"].hasOwnProperty(key)) {
var lock = data["locks"][key],
blockTmp = (this._isExcel) ? lock["block"]["guid"] : (this._isPresentation) ? lock["block"]["guid"] : key,
blockValue = (this._isExcel) ? lock["block"] : (this._isPresentation) ? lock["block"] : key;
blockTmp = (this._isExcel || this._isPresentation) ? lock["block"]["guid"] : key,
blockValue = (this._isExcel || this._isPresentation) ? lock["block"] : key;
if (lock !== null) {
var changed = true;
if (this._locks[blockTmp] && 1 !== this._locks[blockTmp].state /*asked for it*/) {
......@@ -10981,7 +10976,7 @@ window.g_cAscCoAuthoringUrl = "";
for (var block in data["locks"]) {
if (data["locks"].hasOwnProperty(block)) {
var lock = data["locks"][block],
blockTmp = (this._isExcel) ? lock["block"]["guid"] : (this._isPresentation) ? lock["block"]["guid"] : lock["block"];
blockTmp = (this._isExcel || this._isPresentation) ? lock["block"]["guid"] : lock["block"];
if (lock !== null) {
this._locks[blockTmp] = {"state":0, "user":lock["user"], "time":lock["time"], "changes":lock["changes"], "block":lock["block"]};
if (this.onLocksReleased) {
......@@ -11003,7 +10998,7 @@ window.g_cAscCoAuthoringUrl = "";
for (var block in data["locks"]) {
if (data["locks"].hasOwnProperty(block)) {
var lock = data["locks"][block],
blockTmp = (this._isExcel) ? lock["block"]["guid"] : (this._isPresentation) ? lock["block"]["guid"] : lock["block"];
blockTmp = (this._isExcel || this._isPresentation) ? lock["block"]["guid"] : lock["block"];
if (lock !== null) {
this._locks[blockTmp] = {"state":0, "user":lock["user"], "time":lock["time"], "changes":lock["changes"], "block":lock["block"]};
if (this.onLocksReleased) {
......@@ -11067,27 +11062,17 @@ window.g_cAscCoAuthoringUrl = "";
this.onUnSaveLock();
};
DocsCoApi.prototype._checkSaveChangesInDisconnect = function (allServerChanges) {
for (var changeId in allServerChanges) {
var change = allServerChanges[changeId];
var changesOneUser = change["changes"];
if (changesOneUser && change["user"] !== this._userId && this.lastOtherSaveTime !== change["time"])
return true;
}
return false;
};
DocsCoApi.prototype._updateChanges = function (allServerChanges, changesIndex, bFirstLoad) {
if (this.onSaveChanges) {
this.changesIndex = changesIndex;
if (allServerChanges) {
for (var changeId in allServerChanges) {
var change = allServerChanges[changeId];
var changesOneUser = change["change"];
for (var i = 0; i < allServerChanges.length; ++i) {
var change = allServerChanges[i];
var changesOneUser = change['change'];
if (changesOneUser) {
if (change["user"] !== this._userId)
this.lastOtherSaveTime = change["time"];
this.onSaveChanges(JSON.parse(changesOneUser), change["user"], bFirstLoad);
if (change['user'] !== this._userId)
this.lastOtherSaveTime = change['time'];
this.onSaveChanges(JSON.parse(changesOneUser), change['user'], bFirstLoad);
}
}
}
......@@ -11095,9 +11080,8 @@ window.g_cAscCoAuthoringUrl = "";
};
DocsCoApi.prototype._onSetIndexUser = function (data) {
if (data && this.onSetIndexUser) {
this.onSetIndexUser (data);
}
if (this.onSetIndexUser)
this.onSetIndexUser(data);
};
DocsCoApi.prototype._onSavePartChanges = function (data) {
......@@ -11204,39 +11188,33 @@ window.g_cAscCoAuthoringUrl = "";
DocsCoApi.prototype._onAuth = function (data) {
if (true === this._isAuth) {
// Мы уже авторизовывались, это просто reconnect и нужно проверить не было ли изменений пока не было сети
if (this._checkSaveChangesInDisconnect(data["changes"] || [])) {
// делаем drop
this._onDrop();
}
this._state = 2; // Authorized
// Мы уже авторизовывались, нужно обновить пользователей (т.к. пользователи могли входить и выходить пока у нас не было соединения)
this._onAuthParticipantsChanged(data['participants']);
//if (this.ownedLockBlocks && this.ownedLockBlocks.length > 0) {
// this._onPreviousLocks(data["locks"], this.ownedLockBlocks);
//}
this._onMessages(data, true);
this._onGetLock(data);
return;
}
if (data["result"] === 1) {
if (data['result'] === 1) {
// Выставляем флаг, что мы уже авторизовывались
this._isAuth = true;
//TODO: add checks
this._state = 2; // Authorized
this._id = data["sessionId"];
this._id = data['sessionId'];
this._onAuthParticipantsChanged(data["participants"]);
this._onAuthParticipantsChanged(data['participants']);
if (data["indexUser"]) {
this._indexuser = data["indexUser"];
this._onSetIndexUser (this._indexuser);
}
this._onSetIndexUser(this._indexUser = data['indexUser']);
this._userId = this._user.asc_getId() + this._indexUser;
this._userId = this._user.asc_getId() + this._indexuser;
this._onMessages(data, false);
this._onGetLock(data);
if (data["messages"] && this.onMessage) {
this._onMessages(data);
}
if (data["locks"]) {
if (this.ownedLockBlocks && this.ownedLockBlocks.length > 0) {
this._onPreviousLocks(data["locks"], this.ownedLockBlocks);
}
this._onGetLock(data);
}
// Применения изменений пользователя
if (window['AscApplyChanges'] && window['AscChanges']) {
var userOfflineChanges = window['AscChanges'], changeOneUser;
......@@ -11268,6 +11246,7 @@ window.g_cAscCoAuthoringUrl = "";
this._initCallback = callback;
this.ownedLockBlocks = [];
this.sockjs_url = this._url + '/doc/'+docid+'/c';
this.editorType = editorType;
this._isExcel = c_oEditorId.Spreadsheet === editorType;
this._isPresentation = c_oEditorId.Presentation === editorType;
this._isAuth = false;
......@@ -11294,13 +11273,11 @@ window.g_cAscCoAuthoringUrl = "";
if (t._locks) {
t.ownedLockBlocks = [];
//If we already have locks
for (var block in t._locks) {
if (t._locks.hasOwnProperty(block)) {
var lock = t._locks[block];
if (lock["state"] === 2) {
//Our lock.
t.ownedLockBlocks.push(lock["block"]);
}
for (var block in t._locks) if (t._locks.hasOwnProperty(block)) {
var lock = t._locks[block];
if (lock["state"] === 2) {
//Our lock.
t.ownedLockBlocks.push(lock["blockValue"]);
}
}
t._locks = {};
......@@ -11312,10 +11289,13 @@ window.g_cAscCoAuthoringUrl = "";
'documentCallbackUrl' : t._documentCallbackUrl,
'token' : t._token,
'user' : {
'id' : t._user.asc_getId(),
'name' : t._user.asc_getUserName()
'id' : t._user.asc_getId(),
'name' : t._user.asc_getUserName(),
'indexUser' : t._indexUser
},
'locks' : t.ownedLockBlocks,
'editorType': t.editorType,
'lastOtherSaveTime' : t.lastOtherSaveTime,
'block' : t.ownedLockBlocks,
'sessionId' : t._id,
'server' : window.location.protocol + '//' + window.location.host + g_sMainServiceLocalUrl,
'documentFormatSave' : t._documentFormatSave,
......@@ -11331,7 +11311,7 @@ window.g_cAscCoAuthoringUrl = "";
var type = dataObject.type;
switch (type) {
case 'auth' : t._onAuth(dataObject); break;
case 'message' : t._onMessages(dataObject); break;
case 'message' : t._onMessages(dataObject, false); break;
case 'getLock' : t._onGetLock(dataObject); break;
case 'releaseLock' : t._onReleaseLock(dataObject); break;
case 'connectState' : t._onConnectionStateChanged(dataObject); break;
......@@ -65175,7 +65155,7 @@ function DecodeBase64(imData, szSrc)
// сначала заполняем массив this.fonts_loading объекстами fontinfo
for (var i in _fonts)
{
if (_fonts[i].Type != FONT_TYPE_EMBEDDED)
if (_fonts[i].type != FONT_TYPE_EMBEDDED)
{
var info = this.AddLoadFonts(_fonts[i].name, _fonts[i].NeedStyles);
......@@ -65195,7 +65175,7 @@ function DecodeBase64(imData, szSrc)
{
if (this.embeddedFontInfos[j].Name == _fonts[i].name)
{
this.AddLoadFontsNotPick(this.embeddedFontInfos[j], 0);
this.AddLoadFontsNotPick(this.embeddedFontInfos[j], 0x0F);
break;
}
}
......@@ -208266,6 +208246,7 @@ Paragraph.prototype.private_RecalculateLineBaseLine = function(CurLine, CurPa
if (this.Lines[CurLine].Info & paralineinfo_RangeY)
{
this.Lines[CurLine].Y = PRS.Y - this.Pages[CurPage].Y;
PRS.BaseLineOffset = this.Lines[CurLine].Metrics.Ascent;
}
else
{
......@@ -348705,7 +348686,7 @@ asc_docs_api.prototype._coAuthoringInit = function()
t.asc_fireCallback("asc_onParticipantsChanged", e, CountEditUsers);
};
this.CoAuthoringApi.onAuthParticipantsChanged = function (e, count) { t.asc_fireCallback("asc_onAuthParticipantsChanged", e, count); };
this.CoAuthoringApi.onMessage = function (e, count) { t.asc_fireCallback("asc_onCoAuthoringChatReceiveMessage", e); };
this.CoAuthoringApi.onMessage = function (e, clear) { t.asc_fireCallback("asc_onCoAuthoringChatReceiveMessage", e, clear); };
this.CoAuthoringApi.onConnectionStateChanged = function (e) { t.asc_fireCallback("asc_onConnectionStateChanged", e); };
this.CoAuthoringApi.onLocksAcquired = function (e)
{
......@@ -355448,8 +355429,13 @@ CTextMeasurerWrapper.prototype =
if (null != this.LastFontOriginInfo.Replace)
lUnicode = g_fontApplication.GetReplaceGlyph(lUnicode, this.LastFontOriginInfo.Replace);
var _width = this.Measurer["MeasureChar"](lUnicode);
return { Width : _width, Height : 0 };
var _bounds = this.Measurer["GetDrawingBox"](lUnicode);
return {
Width : _bounds[0],
Ascent : _bounds[4],
Height : _bounds[4] - _bounds[3]
};
},
Measure2Code : function(lUnicode)
{
......@@ -356186,6 +356172,7 @@ function CDrawingDocument()
this.IsLockObjectsEnable = false;
this.LogicDocument = null;
this.m_bIsMouseLock = false;
this.CanvasHitContext = CreateHitControl();
......@@ -357047,6 +357034,27 @@ CDrawingDocument.prototype =
return true;
},
LogicDocumentOnMouseDown : function(e, x, y, page)
{
if (this.m_bIsMouseLock)
{
this.LogicDocument.OnMouseUp(e, x, y, page);
this.m_bIsMouseLock = false;
}
this.LogicDocument.OnMouseDown(e, x, y, page);
this.m_bIsMouseLock = true;
},
LogicDocumentOnMouseUp : function(e, x, y, page)
{
if (!this.m_bIsMouseLock)
{
this.LogicDocument.OnMouseDown(e, x, y, page);
this.m_bIsMouseLock = true;
}
this.LogicDocument.OnMouseUp(e, x, y, page);
this.m_bIsMouseLock = false;
},
OnCheckMouseDown : function(e)
{
// 0 - none
......@@ -357121,11 +357129,11 @@ CDrawingDocument.prototype =
var _yDown = this.SelectRect2.Y + this.SelectRect2.H / 2;
if (!this.TextMatrix)
{
this.LogicDocument.OnMouseDown(global_mouseEvent, _xDown, _yDown, this.SelectRect2.Page);
this.LogicDocumentOnMouseDown(global_mouseEvent, _xDown, _yDown, this.SelectRect2.Page);
}
else
{
this.LogicDocument.OnMouseDown(global_mouseEvent, this.TextMatrix.TransformPointX(_xDown, _yDown),
this.LogicDocumentOnMouseDown(global_mouseEvent, this.TextMatrix.TransformPointX(_xDown, _yDown),
this.TextMatrix.TransformPointY(_xDown, _yDown), this.SelectRect2.Page);
}
......@@ -357157,11 +357165,11 @@ CDrawingDocument.prototype =
var _yDown = this.SelectRect1.Y + this.SelectRect1.H / 2;
if (!this.TextMatrix)
{
this.LogicDocument.OnMouseDown(global_mouseEvent, _xDown, _yDown, this.SelectRect1.Page);
this.LogicDocumentOnMouseDown(global_mouseEvent, _xDown, _yDown, this.SelectRect1.Page);
}
else
{
this.LogicDocument.OnMouseDown(global_mouseEvent, this.TextMatrix.TransformPointX(_xDown, _yDown),
this.LogicDocumentOnMouseDown(global_mouseEvent, this.TextMatrix.TransformPointX(_xDown, _yDown),
this.TextMatrix.TransformPointY(_xDown, _yDown), this.SelectRect1.Page);
}
......@@ -357252,7 +357260,7 @@ CDrawingDocument.prototype =
return;
this.Native["DD_NeedScrollToTargetFlag"](true);
this.LogicDocument.OnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page);
this.LogicDocumentOnMouseDown.OnMouseDown(global_mouseEvent, pos.X, pos.Y, pos.Page);
this.Native["DD_NeedScrollToTargetFlag"](false);
}
......@@ -357304,7 +357312,8 @@ CDrawingDocument.prototype =
this.Native.m_bIsMouseUpSend = true;
this.Native["DD_NeedScrollToTargetFlag"](true);
this.LogicDocument.OnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page);
this.LogicDocumentOnMouseUp(global_mouseEvent, pos.X, pos.Y, pos.Page);
this.Native["DD_NeedScrollToTargetFlag"](false);
this.Native.m_bIsMouseUpSend = false;
......@@ -359033,7 +359042,7 @@ CDrawingStream.prototype =
},
p_width : function(w)
{
this.Native["PD_p_width"](w);
this.Native["PD_p_width"](w / 1000);
},
// brush methods
b_color1 : function(r,g,b,a)
......@@ -361936,7 +361945,6 @@ var Y_Bottom_Field = Page_Height - Y_Bottom_Margin;
var Y_Top_Field = Y_Top_Margin;
var docpostype_Content = 0x00;
var docpostype_FlowObjects = 0x01;
var docpostype_HdrFtr = 0x02;
var selectionflag_Common = 0x00;
......@@ -363398,6 +363406,12 @@ function asc_menu_WriteParaFrame(_type, _frame, _stream)
asc_docs_api.prototype["Call_Menu_Event"] = function(type, _params)
{
if (this.m_oWordControl.m_oDrawingDocument.m_bIsMouseLock)
{
// не делаем ничего. Как в веб версии отрубаем клавиатуру
return undefined;
}
var _return = undefined;
var _current = { pos : 0 };
var _continue = true;
......@@ -366879,8 +366893,8 @@ asc_docs_api.prototype.AddImageUrlNative = function(url, _w, _h)
_page_height = _section_select.H;
}
var __w = Math.max(1, _page_width - (_page_x_left_margin + _page_x_right_margin));
var __h = Math.max(1, _page_height - (_page_y_top_margin + _page_y_bottom_margin));
var __w = Math.max(1, (_page_width - (_page_x_left_margin + _page_x_right_margin)) / 2);
var __h = Math.max(1, (_page_height - (_page_y_top_margin + _page_y_bottom_margin)) / 2);
var wI = (undefined !== _w) ? Math.max(_w * g_dKoef_pix_to_mm, 1) : 1;
var hI = (undefined !== _h) ? Math.max(_h * g_dKoef_pix_to_mm, 1) : 1;
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