Commit d644366a authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Метки к чужим курсорам в презентациях

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66212 954022d7-b5bf-4e40-9824-e11837661b57
parent b521d428
......@@ -6,6 +6,9 @@
* Time: 12:01
*/
var FOREIGN_CURSOR_LABEL_HIDETIME = 1500;
function CCollaborativeChanges()
{
this.m_pData = null;
......
......@@ -978,6 +978,10 @@ function CDrawingCollaborativeTarget()
this.Size = 0;
this.Page = -1;
this.Color = null;
this.Transform = null;
this.HtmlElement = null;
......@@ -1003,7 +1007,21 @@ CDrawingCollaborativeTarget.prototype =
var oUser = _drawing_doc.m_oWordControl.m_oApi.CoAuthoringApi.getUser(this.Id);
var nColor = oUser ? oUser.asc_getColorValue() : null;
var oColor = (null !== nColor ? new CDocumentColor( (nColor >> 16) & 0xFF, (nColor >> 8) & 0xFF, nColor & 0xFF ) : new CDocumentColor( 191, 255, 199 ));
this.Style ="rgb(" + oColor.r + "," + oColor.g + "," + oColor.b + ")";
var Y = Math.max(0, Math.min(255, 0.299 * oColor.r + 0.587 * oColor.g + 0.114 * oColor.b));
var Cb = Math.max(0, Math.min(255, 128 - 0.168736 * oColor.r - 0.331264 * oColor.g + 0.5 * oColor.b));
var Cr = Math.max(0, Math.min(255, 128 + 0.5 * oColor.r - 0.418688 * oColor.g - 0.081312 * oColor.b));
if (Y > 63)
Y = 63;
var R = Math.max(0, Math.min(255, Y + 1.402 * (Cr - 128))) | 0;
var G = Math.max(0, Math.min(255, Y - 0.34414 * (Cb - 128) - 0.71414 * (Cr - 128))) | 0;
var B = Math.max(0, Math.min(255, Y + 1.772 * (Cb - 128) )) | 0;
this.Color = new CDocumentColor(R, G, B);
this.Style ="rgb(" + R + "," + G + "," + B + ")";
}
// 2) определяем размер
......@@ -3475,6 +3493,28 @@ function CDrawingDocument()
}
}
};
this.Collaborative_GetTargetColor = function(UserId)
{
for (var i = 0; i < this.CollaborativeTargets.length; i++)
{
if (UserId == this.CollaborativeTargets[i].Id)
return this.CollaborativeTargets[i].Color;
}
return null;
};
this.Collaborative_GetTargetPosition = function(UserId)
{
for (var i = 0; i < this.CollaborativeTargets.length; i++)
{
if (UserId == this.CollaborativeTargets[i].Id)
return {X : this.CollaborativeTargets[i].HtmlElementX, Y : this.CollaborativeTargets[i].HtmlElementY};
}
return null;
};
}
function CThPage()
......
......@@ -15,12 +15,14 @@ function CCollaborativeEditing()
this.ScaleX = null;
this.ScaleY = null;
this.m_aForeignCursorsXY = {};
this.m_aForeignCursorsToShow = {};
}
Asc.extendClass(CCollaborativeEditing, CCollaborativeEditingBase);
CCollaborativeEditing.prototype.Send_Changes = function(IsUserSave)
CCollaborativeEditing.prototype.Send_Changes = function(IsUserSave, AdditionalInfo)
{
// Пересчитываем позиции
this.Refresh_DCChanges();
......@@ -138,7 +140,7 @@ CCollaborativeEditing.prototype.Send_Changes = function(IsUserSave)
this.m_aNeedUnlock2.length = 0;
if (0 < aChanges.length || null !== deleteIndex)
editor.CoAuthoringApi.saveChanges(aChanges, deleteIndex);
editor.CoAuthoringApi.saveChanges(aChanges, deleteIndex, AdditionalInfo);
else
editor.CoAuthoringApi.unLockDocument(true);
......@@ -177,6 +179,19 @@ CCollaborativeEditing.prototype.Send_Changes = function(IsUserSave)
// editor.WordControl.m_oLogicDocument.DrawingDocument.FirePaint();
};
CCollaborativeEditingBase.prototype.Refresh_ForeignCursors = function()
{
for (var UserId in this.m_aCursorsToUpdate)
{
var CursorInfo = this.m_aCursorsToUpdate[UserId];
editor.WordControl.m_oLogicDocument.Update_ForeignCursor(CursorInfo, UserId, false);
if (this.Add_ForeignCursorToShow)
this.Add_ForeignCursorToShow(UserId);
}
this.m_aCursorsToUpdate = {};
};
CCollaborativeEditing.prototype.Release_Locks = function()
{
var map_redraw = {};
......@@ -465,44 +480,177 @@ CCollaborativeEditing.prototype.Update_ForeignCursorsPositions = function()
var Run = DocPos[DocPos.length - 1].Class;
var InRunPos = DocPos[DocPos.length - 1].Position;
this.Update_ForeignCursorPosition(UserId, Run, InRunPos, false, oTargetDocContentOrTable, bTable);
}
};
CCollaborativeEditing.prototype.Update_ForeignCursorPosition = function(UserId, Run, InRunPos, isRemoveLabel, oTargetDocContentOrTable, bTable){
if (!(Run instanceof ParaRun))
continue;
return;
var DrawingDocument = editor.WordControl.m_oDrawingDocument;
var oPresentation = editor.WordControl.m_oLogicDocument;
var Paragraph = Run.Get_Paragraph();
if (!Paragraph || !Paragraph.Parent){
DrawingDocument.Collaborative_RemoveTarget(UserId);
continue;
return;
}
if(!bTable){
if(oTargetDocContentOrTable !== Paragraph.Parent){
DrawingDocument.Collaborative_RemoveTarget(UserId);
continue;
return;
}
}
else{
if(!Paragraph.Parent.Parent || !Paragraph.Parent.Parent.Row ||
!Paragraph.Parent.Parent.Row.Table || Paragraph.Parent.Parent.Row.Table !== oTargetDocContentOrTable){
DrawingDocument.Collaborative_RemoveTarget(UserId);
continue;
return;
}
}
var ParaContentPos = Paragraph.Get_PosByElement(Run);
if (!ParaContentPos){
DrawingDocument.Collaborative_RemoveTarget(UserId);
continue;
return;
}
ParaContentPos.Update(InRunPos, ParaContentPos.Get_Depth() + 1);
var XY = Paragraph.Get_XYByContentPos(ParaContentPos);
if (XY && XY.Height > 0.001)
if (XY && XY.Height > 0.001){
DrawingDocument.Collaborative_UpdateTarget(UserId, XY.X, XY.Y, XY.Height, oPresentation.CurPage, Paragraph.Get_ParentTextTransform());
else
this.Add_ForeignCursorXY(UserId, XY.X, XY.Y, XY.PageNum, XY.Height, Paragraph, isRemoveLabel);
if (true === this.m_aForeignCursorsToShow[UserId]){
this.Show_ForeignCursorLabel(UserId);
this.Remove_ForeignCursorToShow(UserId);
}
}
else{
DrawingDocument.Collaborative_RemoveTarget(UserId);
this.Remove_ForeignCursorXY(UserId);
this.Remove_ForeignCursorToShow(UserId);
}
};
CCollaborativeEditing.prototype.Check_ForeignCursorsLabels = function(X, Y, PageIndex){
var DrawingDocument = editor.WordControl.m_oDrawingDocument;
var Px7 = DrawingDocument.GetMMPerDot(7);
var Px3 = DrawingDocument.GetMMPerDot(3);
for (var UserId in this.m_aForeignCursorsXY){
var Cursor = this.m_aForeignCursorsXY[UserId];
if (true === Cursor.Transform && Cursor.PageIndex === PageIndex && Cursor.X0 - Px3 < X && X < Cursor.X1 + Px3 && Cursor.Y0 - Px3 < Y && Y < Cursor.Y1 + Px3){
this.Show_ForeignCursorLabel(UserId);
}
}
};
CCollaborativeEditing.prototype.Show_ForeignCursorLabel = function(UserId)
{
var Api = editor;
var DrawingDocument = editor.WordControl.m_oDrawingDocument;
if (!this.m_aForeignCursorsXY[UserId])
return;
var Cursor = this.m_aForeignCursorsXY[UserId];
if (Cursor.ShowId)
clearTimeout(Cursor.ShowId);
Cursor.ShowId = setTimeout(function()
{
Cursor.ShowId = null;
Api.sync_HideForeignCursorLabel(UserId);
}, FOREIGN_CURSOR_LABEL_HIDETIME);
var Color = DrawingDocument.Collaborative_GetTargetColor(UserId);
var Coords = DrawingDocument.Collaborative_GetTargetPosition(UserId);
if (!Color || !Coords)
return;
this.Update_ForeignCursorLabelPosition(UserId, Coords.X, Coords.Y, Color);
};
CCollaborativeEditing.prototype.Add_ForeignCursorToShow = function(UserId)
{
this.m_aForeignCursorsToShow[UserId] = true;
};
CCollaborativeEditing.prototype.Remove_ForeignCursorToShow = function(UserId)
{
delete this.m_aForeignCursorsToShow[UserId];
};
CCollaborativeEditing.prototype.Add_ForeignCursorXY = function(UserId, X, Y, PageIndex, H, Paragraph, isRemoveLabel)
{
var Cursor;
if (!this.m_aForeignCursorsXY[UserId])
{
Cursor = {X: X, Y: Y, H: H, PageIndex: PageIndex, Transform: false, ShowId: null};
this.m_aForeignCursorsXY[UserId] = Cursor;
}
else
{
Cursor = this.m_aForeignCursorsXY[UserId];
if (Cursor.ShowId)
{
if (true === isRemoveLabel)
{
clearTimeout(Cursor.ShowId);
Cursor.ShowId = null;
editor.sync_HideForeignCursorLabel(UserId);
}
}
else
{
Cursor.ShowId = null;
}
Cursor.X = X;
Cursor.Y = Y;
Cursor.PageIndex = PageIndex;
Cursor.H = H;
}
var Transform = Paragraph.Get_ParentTextTransform();
if (Transform)
{
Cursor.Transform = true;
var X0 = Transform.TransformPointX(Cursor.X, Cursor.Y);
var Y0 = Transform.TransformPointY(Cursor.X, Cursor.Y);
var X1 = Transform.TransformPointX(Cursor.X, Cursor.Y + Cursor.H);
var Y1 = Transform.TransformPointY(Cursor.X, Cursor.Y + Cursor.H);
Cursor.X0 = Math.min(X0, X1);
Cursor.Y0 = Math.min(Y0, Y1);
Cursor.X1 = Math.max(X0, X1);
Cursor.Y1 = Math.max(Y0, Y1);
}
else
{
Cursor.Transform = false;
}
};
CCollaborativeEditing.prototype.Remove_ForeignCursorXY = function(UserId)
{
if (this.m_aForeignCursorsXY[UserId])
{
if (this.m_aForeignCursorsXY[UserId].ShowId)
{
editor.sync_HideForeignCursorLabel(UserId);
clearTimeout(this.m_aForeignCursorsXY[UserId].ShowId);
}
delete this.m_aForeignCursorsXY[UserId];
}
};
CCollaborativeEditing.prototype.Update_ForeignCursorLabelPosition = function(UserId, X, Y, Color)
{
var Cursor = this.m_aForeignCursorsXY[UserId];
if (!Cursor || !Cursor.ShowId)
return;
editor.sync_ShowForeignCursorLabel(UserId, X, Y, Color);
};
var CollaborativeEditing = new CCollaborativeEditing();
\ No newline at end of file
......@@ -722,40 +722,7 @@ CPresentation.prototype =
return;
}
var bTable = (oTargetDocContentOrTable instanceof CTable);
var Paragraph = Run.Get_Paragraph();
if (!Paragraph || !Paragraph.Parent){
this.DrawingDocument.Collaborative_RemoveTarget(UserId);
return;
}
if(!bTable){
if(oTargetDocContentOrTable !== Paragraph.Parent){
this.DrawingDocument.Collaborative_RemoveTarget(UserId);
return;
}
}
else{
if(!Paragraph.Parent.Parent || !Paragraph.Parent.Parent.Row ||
!Paragraph.Parent.Parent.Row.Table || Paragraph.Parent.Parent.Row.Table !== oTargetDocContentOrTable){
this.DrawingDocument.Collaborative_RemoveTarget(UserId);
return;
}
}
var ParaContentPos = Paragraph.Get_PosByElement(Run);
if (!ParaContentPos){
this.DrawingDocument.Collaborative_RemoveTarget(UserId);
return;
}
ParaContentPos.Update(InRunPos, ParaContentPos.Get_Depth() + 1);
var XY = Paragraph.Get_XYByContentPos(ParaContentPos);
if (XY && XY.Height > 0.001)
this.DrawingDocument.Collaborative_UpdateTarget(UserId, XY.X, XY.Y, XY.Height, XY.PageNum, Paragraph.Get_ParentTextTransform());
else
this.DrawingDocument.Collaborative_RemoveTarget(UserId);
CollaborativeEditing.Update_ForeignCursorPosition(UserId, Run, InRunPos, true, oTargetDocContentOrTable, bTable);
}
},
......@@ -1798,20 +1765,19 @@ CPresentation.prototype =
},
Update_CursorType : function( X, Y, MouseEvent )
{
Update_CursorType : function( X, Y, MouseEvent ){
if(this.Slides[this.CurPage]){
var graphicObjectInfo = this.Slides[this.CurPage].graphicObjects.isPointInDrawingObjects(X, Y, MouseEvent);
if(graphicObjectInfo)
{
if(!graphicObjectInfo.updated)
{
if(graphicObjectInfo){
if(!graphicObjectInfo.updated){
this.DrawingDocument.SetCursorType(graphicObjectInfo.cursorType);
}
}
else
{
else{
this.DrawingDocument.SetCursorType("default");
}
CollaborativeEditing.Check_ForeignCursorsLabels(X, Y, this.CurPage);
}
},
......
......@@ -1403,9 +1403,12 @@ function OnSave_Callback(e) {
window["AscDesktopEditor"]["OnSave"]();
}
};
var CursorInfo = null;
if (true === CollaborativeEditing.Is_Fast()) {
CursorInfo = History.Get_DocumentPositionBinary();
}
// Пересылаем свои изменения
CollaborativeEditing.Send_Changes(editor.IsUserSave);
CollaborativeEditing.Send_Changes(editor.IsUserSave, {UserId: editor.CoAuthoringApi.getUserConnectionId(), CursorInfo: CursorInfo});
} else {
var nState = editor.CoAuthoringApi.get_state();
if (ConnectionState.Close === nState) {
......@@ -4271,6 +4274,16 @@ asc_docs_api.prototype.sync_MouseMoveCallback = function(Data)
this.asc_fireCallback("asc_onMouseMove", Data );
};
asc_docs_api.prototype.sync_ShowForeignCursorLabel = function(UserId, X, Y, Color)
{
this.asc_fireCallback("asc_onShowForeignCursorLabel", UserId, X, Y, new CColor(Color.r, Color.g, Color.b, 255));
};
asc_docs_api.prototype.sync_HideForeignCursorLabel = function(UserId)
{
this.asc_fireCallback("asc_onHideForeignCursorLabel", UserId);
};
asc_docs_api.prototype.ShowThumbnails = function(bIsShow)
{
if (bIsShow)
......
......@@ -6,7 +6,6 @@
* Time: 12:01
*/
var FOREIGN_CURSOR_LABEL_HIDETIME = 1500;
function CWordCollaborativeEditing()
{
......
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