Commit a34f4756 authored by Ilya.Kirillov's avatar Ilya.Kirillov

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

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

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@65421 954022d7-b5bf-4e40-9824-e11837661b57
parent 9c245732
...@@ -1954,7 +1954,7 @@ CGraphics.prototype = ...@@ -1954,7 +1954,7 @@ CGraphics.prototype =
DrawLockParagraph : function(lock_type, x, y1, y2) DrawLockParagraph : function(lock_type, x, y1, y2)
{ {
if (lock_type == locktype_None || editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false || editor.isViewMode) if (lock_type == locktype_None || editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false || editor.isViewMode || (lock_type === locktype_Mine && true === CollaborativeEditing.Is_Fast()))
return; return;
if (lock_type == locktype_Mine) if (lock_type == locktype_Mine)
...@@ -2046,7 +2046,7 @@ CGraphics.prototype = ...@@ -2046,7 +2046,7 @@ CGraphics.prototype =
DrawLockObjectRect : function(lock_type, x, y, w, h) DrawLockObjectRect : function(lock_type, x, y, w, h)
{ {
if (editor.isViewMode || this.IsThumbnail || lock_type == locktype_None || this.IsDemonstrationMode) if (editor.isViewMode || this.IsThumbnail || lock_type == locktype_None || this.IsDemonstrationMode || (lock_type === locktype_Mine && true === CollaborativeEditing.Is_Fast()))
return; return;
if (editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false && lock_type == locktype_Mine) if (editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false && lock_type == locktype_Mine)
......
This diff is collapsed.
This diff is collapsed.
...@@ -8925,6 +8925,8 @@ CDocumentContent.prototype = ...@@ -8925,6 +8925,8 @@ CDocumentContent.prototype =
Element.Parent = this; Element.Parent = this;
this.Content.splice( Pos, 0, Element ); this.Content.splice( Pos, 0, Element );
CollaborativeEditing.Update_DocumentPositionsOnAdd(this, Pos);
this.protected_ReindexContent(Pos);
} }
} }
...@@ -8947,6 +8949,8 @@ CDocumentContent.prototype = ...@@ -8947,6 +8949,8 @@ CDocumentContent.prototype =
continue; continue;
this.Content.splice( Pos, 1 ); this.Content.splice( Pos, 1 );
CollaborativeEditing.Update_DocumentPositionsOnRemove(this, Pos, 1);
this.protected_ReindexContent(Pos);
if ( Pos > 0 ) if ( Pos > 0 )
{ {
...@@ -9533,7 +9537,162 @@ CDocumentContent.prototype.Get_ElementByIndex = function(Index) ...@@ -9533,7 +9537,162 @@ CDocumentContent.prototype.Get_ElementByIndex = function(Index)
{ {
return this.Content[Index]; return this.Content[Index];
}; };
CDocumentContent.prototype.Get_ContentPosition = function(bSelection, bStart, PosArray)
{
if (undefined === PosArray)
PosArray = [];
var Pos = (true === bSelection ? (true === bStart ? this.Selection.StartPos : this.Selection.EndPos) : this.CurPos.ContentPos);
PosArray.push({Class : this, Position : Pos});
if (undefined !== this.Content[Pos] && this.Content[Pos].Get_ContentPosition)
this.Content[Pos].Get_ContentPosition(bSelection, bStart, PosArray);
return PosArray;
};
CDocumentContent.prototype.Get_DocumentPositionFromObject = function(PosArray)
{
if (!PosArray)
PosArray = [];
if (this.Parent && this.Parent.Get_DocumentPositionFromObject)
this.Parent.Get_DocumentPositionFromObject(PosArray);
return PosArray;
};
CDocumentContent.prototype.Set_ContentSelection = function(StartDocPos, EndDocPos, Depth, StartFlag, EndFlag)
{
if (this.Content.length <= 0)
return;
var StartPos = 0, EndPos = 0;
switch (StartFlag)
{
case 0 : StartPos = StartDocPos[Depth].Position; break;
case 1 : StartPos = 0; break;
case -1: StartPos = this.Content.length - 1; break;
}
switch (EndFlag)
{
case 0 : EndPos = EndDocPos[Depth].Position; break;
case 1 : EndPos = 0; break;
case -1: EndPos = this.Content.length - 1; break;
}
var _StartDocPos = StartDocPos, _StartFlag = StartFlag;
if (null !== StartDocPos && true === StartDocPos[Depth].Deleted)
{
if (StartPos < this.Content.length)
{
_StartDocPos = null;
_StartFlag = 1;
}
else if (StartPos > 0)
{
StartPos--;
_StartDocPos = null;
_StartFlag = -1;
}
else
{
// Такого не должно быть
return;
}
}
var _EndDocPos = EndDocPos, _EndFlag = EndFlag;
if (null !== EndDocPos && true === EndDocPos[Depth].Deleted)
{
if (EndPos < this.Content.length)
{
_EndDocPos = null;
_EndFlag = 1;
}
else if (EndPos > 0)
{
EndPos--;
_EndDocPos = null;
_EndFlag = -1;
}
else
{
// Такого не должно быть
return;
}
}
StartPos = Math.min(this.Content.length - 1, Math.max(0, StartPos));
EndPos = Math.min(this.Content.length - 1, Math.max(0, EndPos));
this.Selection.Use = true;
this.Selection.StartPos = StartPos;
this.Selection.EndPos = EndPos;
if (StartPos !== EndPos)
{
this.Content[StartPos].Set_ContentSelection(_StartDocPos, null, Depth + 1, _StartFlag, StartPos > EndPos ? 1 : -1);
this.Content[EndPos].Set_ContentSelection(null, _EndDocPos, Depth + 1, StartPos > EndPos ? -1 : 1, _EndFlag);
var _StartPos = StartPos;
var _EndPos = EndPos;
var Direction = 1;
if (_StartPos > _EndPos)
{
_StartPos = EndPos;
_EndPos = StartPos;
Direction = -1;
}
for (var CurPos = _StartPos + 1; CurPos < _EndPos; CurPos++)
{
this.Content[CurPos].Select_All(Direction);
}
}
else
{
this.Content[StartPos].Set_ContentSelection(_StartDocPos, _EndDocPos, Depth + 1, _StartFlag, _EndFlag);
}
};
CDocumentContent.prototype.Set_ContentPosition = function(DocPos, Depth, Flag)
{
if (this.Content.length <= 0)
return;
var Pos = 0;
switch (Flag)
{
case 0 : Pos = DocPos[Depth].Position; break;
case 1 : Pos = 0; break;
case -1: Pos = this.Content.length - 1; break;
}
var _DocPos = DocPos, _Flag = Flag;
if (null !== DocPos && true === DocPos[Depth].Deleted)
{
if (Pos < this.Content.length)
{
_DocPos = null;
_Flag = 1;
}
else if (Pos > 0)
{
Pos--;
_DocPos = null;
_Flag = -1;
}
else
{
// Такого не должно быть
return;
}
}
Pos = Math.min(this.Content.length - 1, Math.max(0, Pos));
this.CurPos.ContentPos = Pos;
this.Content[Pos].Set_ContentPosition(_DocPos, Depth + 1, _Flag);
};
function CDocumentContentStartState(DocContent) function CDocumentContentStartState(DocContent)
{ {
...@@ -9614,4 +9773,22 @@ CDocumentRecalculateObject.prototype = ...@@ -9614,4 +9773,22 @@ CDocumentRecalculateObject.prototype =
} }
} }
};
function CDocumentContentBase()
{
}
CDocumentContentBase.prototype.Get_ContentPosition = function(bSelection, bStart, PosArray)
{
if (undefined === PosArray)
PosArray = [];
var Pos = (true === bSelection ? (true === bStart ? this.Selection.StartPos : this.Selection.EndPos) : this.CurPos.ContentPos);
PosArray.push({Class : this, Position : Pos});
if (undefined !== this.Content[Pos] && this.Content[Pos].Get_ContentPosition)
this.Content[Pos].Get_ContentPosition(bSelection, bStart, PosArray);
return PosArray;
}; };
\ No newline at end of file
...@@ -501,6 +501,7 @@ ParaField.prototype.Load_Changes = function(Reader) ...@@ -501,6 +501,7 @@ ParaField.prototype.Load_Changes = function(Reader)
if ( null != Element ) if ( null != Element )
{ {
this.Content.splice( Pos, 0, Element ); this.Content.splice( Pos, 0, Element );
CollaborativeEditing.Update_DocumentPositionsOnAdd(this, Pos);
} }
} }
this.private_UpdateTrackRevisions(); this.private_UpdateTrackRevisions();
...@@ -524,6 +525,7 @@ ParaField.prototype.Load_Changes = function(Reader) ...@@ -524,6 +525,7 @@ ParaField.prototype.Load_Changes = function(Reader)
continue; continue;
this.Content.splice( ChangesPos, 1 ); this.Content.splice( ChangesPos, 1 );
CollaborativeEditing.Update_DocumentPositionsOnRemove(this, ChangesPos, 1);
} }
this.private_UpdateTrackRevisions(); this.private_UpdateTrackRevisions();
this.protected_UpdateSpellChecking(); this.protected_UpdateSpellChecking();
......
...@@ -498,6 +498,7 @@ ParaHyperlink.prototype.Load_Changes = function(Reader) ...@@ -498,6 +498,7 @@ ParaHyperlink.prototype.Load_Changes = function(Reader)
if ( null != Element ) if ( null != Element )
{ {
this.Content.splice( Pos, 0, Element ); this.Content.splice( Pos, 0, Element );
CollaborativeEditing.Update_DocumentPositionsOnAdd(this, Pos);
} }
} }
this.private_UpdateTrackRevisions(); this.private_UpdateTrackRevisions();
...@@ -521,6 +522,7 @@ ParaHyperlink.prototype.Load_Changes = function(Reader) ...@@ -521,6 +522,7 @@ ParaHyperlink.prototype.Load_Changes = function(Reader)
continue; continue;
this.Content.splice( ChangesPos, 1 ); this.Content.splice( ChangesPos, 1 );
CollaborativeEditing.Update_DocumentPositionsOnRemove(this, ChangesPos, 1);
} }
this.private_UpdateTrackRevisions(); this.private_UpdateTrackRevisions();
this.protected_UpdateSpellChecking(); this.protected_UpdateSpellChecking();
......
...@@ -11630,23 +11630,25 @@ Paragraph.prototype = ...@@ -11630,23 +11630,25 @@ Paragraph.prototype =
if ( null != Element ) if ( null != Element )
{ {
if ( para_Comment === Element.Type ) if (para_Comment === Element.Type)
{ {
var Comment = g_oTableId.Get_ById( Element.CommentId ); var Comment = g_oTableId.Get_ById(Element.CommentId);
// При копировании не всегда сразу заполняется правильно CommentId // При копировании не всегда сразу заполняется правильно CommentId
if (null != Comment && Comment instanceof CComment) if (null != Comment && Comment instanceof CComment)
{ {
if ( true === Element.Start ) if (true === Element.Start)
Comment.Set_StartId( this.Get_Id() ); Comment.Set_StartId(this.Get_Id());
else else
Comment.Set_EndId( this.Get_Id() ); Comment.Set_EndId(this.Get_Id());
} }
}
if (Element.Set_Paragraph)
Element.Set_Paragraph(this); Element.Set_Paragraph(this);
}
this.Content.splice( Pos, 0, Element ); this.Content.splice(Pos, 0, Element);
CollaborativeEditing.Update_DocumentPositionsOnAdd(this, Pos);
if (Element.Recalc_RunsCompiledPr) if (Element.Recalc_RunsCompiledPr)
Element.Recalc_RunsCompiledPr(); Element.Recalc_RunsCompiledPr();
...@@ -11667,13 +11669,14 @@ Paragraph.prototype = ...@@ -11667,13 +11669,14 @@ Paragraph.prototype =
for ( var Index = 0; Index < Count; Index++ ) for ( var Index = 0; Index < Count; Index++ )
{ {
var ChangesPos = this.m_oContentChanges.Check( contentchanges_Remove, Reader.GetLong() ); var ChangesPos = this.m_oContentChanges.Check(contentchanges_Remove, Reader.GetLong());
// действие совпало, не делаем его // действие совпало, не делаем его
if ( false === ChangesPos ) if (false === ChangesPos)
continue; continue;
this.Content.splice( ChangesPos, 1 ); this.Content.splice(ChangesPos, 1);
CollaborativeEditing.Update_DocumentPositionsOnRemove(this, ChangesPos, 1);
} }
this.private_ResetSelection(); this.private_ResetSelection();
...@@ -12431,10 +12434,14 @@ Paragraph.prototype = ...@@ -12431,10 +12434,14 @@ Paragraph.prototype =
var Count = Reader.GetLong(); var Count = Reader.GetLong();
for ( var Index = 0; Index < Count; Index++ ) for ( var Index = 0; Index < Count; Index++ )
{ {
var Element = g_oTableId.Get_ById( Reader.GetString2() ); var Element = g_oTableId.Get_ById(Reader.GetString2());
if ( null != Element ) if (null != Element)
this.Content.push( Element ); {
this.Content.push(Element);
if (Element.Set_Paragraph)
Element.Set_Paragraph(this);
}
} }
CollaborativeEditing.Add_NewObject( this ); CollaborativeEditing.Add_NewObject( this );
...@@ -12457,6 +12464,8 @@ Paragraph.prototype = ...@@ -12457,6 +12464,8 @@ Paragraph.prototype =
{ {
CollaborativeEditing.Add_LinkData(this, {}); CollaborativeEditing.Add_LinkData(this, {});
} }
this.PageNum = 0;
}, },
Load_LinkData : function(LinkData) Load_LinkData : function(LinkData)
...@@ -13399,6 +13408,165 @@ Paragraph.prototype.Get_HdrFtr = function() ...@@ -13399,6 +13408,165 @@ Paragraph.prototype.Get_HdrFtr = function()
return null; return null;
}; };
Paragraph.prototype.Get_ContentPosition = function(bSelection, bStart, PosArray)
{
if (!PosArray)
PosArray = [];
var Index = PosArray.length;
var ParaContentPos = this.Get_ParaContentPos(bSelection, bStart);
var Depth = ParaContentPos.Get_Depth();
while (Depth > 0)
{
var Pos = ParaContentPos.Get(Depth);
var Class = this.Get_ElementByPos(ParaContentPos);
ParaContentPos.Decrease_Depth(1);
Depth--;
PosArray.splice(Index, 0, {Class : Class, Position : Pos});
}
PosArray.splice(Index, 0, {Class : this, Position : ParaContentPos.Get(0)});
return PosArray;
};
Paragraph.prototype.Set_ContentSelection = function(StartDocPos, EndDocPos, Depth, StartFlag, EndFlag)
{
var StartPos = 0, EndPos = 0;
switch (StartFlag)
{
case 0 : StartPos = StartDocPos[Depth].Position; break;
case 1 : StartPos = 0; break;
case -1: StartPos = this.Content.length - 1; break;
}
switch (EndFlag)
{
case 0 : EndPos = EndDocPos[Depth].Position; break;
case 1 : EndPos = 0; break;
case -1: EndPos = this.Content.length - 1; break;
}
var _StartDocPos = StartDocPos, _StartFlag = StartFlag;
if (null !== StartDocPos && true === StartDocPos[Depth].Deleted)
{
if (StartPos < this.Content.length)
{
_StartDocPos = null;
_StartFlag = 1;
}
else if (StartPos > 0)
{
StartPos--;
_StartDocPos = null;
_StartFlag = -1;
}
else
{
// Такого не должно быть
return;
}
}
var _EndDocPos = EndDocPos, _EndFlag = EndFlag;
if (null !== EndDocPos && true === EndDocPos[Depth].Deleted)
{
if (EndPos < this.Content.length)
{
_EndDocPos = null;
_EndFlag = 1;
}
else if (EndPos > 0)
{
EndPos--;
_EndDocPos = null;
_EndFlag = -1;
}
else
{
// Такого не должно быть
return;
}
}
this.Selection.Use = true;
this.Selection.StartPos = StartPos;
this.Selection.EndPos = EndPos;
if (StartPos !== EndPos)
{
this.Content[StartPos].Set_ContentSelection(_StartDocPos, null, Depth + 1, _StartFlag, StartPos > EndPos ? 1 : -1);
this.Content[EndPos].Set_ContentSelection(null, _EndDocPos, Depth + 1, StartPos > EndPos ? -1 : 1, _EndFlag);
var _StartPos = StartPos;
var _EndPos = EndPos;
var Direction = 1;
if (_StartPos > _EndPos)
{
_StartPos = EndPos;
_EndPos = StartPos;
Direction = -1;
}
for (var CurPos = _StartPos + 1; CurPos < _EndPos; CurPos++)
{
this.Content[CurPos].Select_All(Direction);
}
}
else
{
this.Content[StartPos].Set_ContentSelection(_StartDocPos, _EndDocPos, Depth + 1, _StartFlag, _EndFlag);
}
};
Paragraph.prototype.Set_ContentPosition = function(DocPos, Depth, Flag)
{
var Pos = 0;
switch (Flag)
{
case 0 : Pos = DocPos[Depth].Position; break;
case 1 : Pos = 0; break;
case -1: Pos = this.Content.length - 1; break;
}
var _DocPos = DocPos, _Flag = Flag;
if (null !== DocPos && true === DocPos[Depth].Deleted)
{
if (Pos < this.Content.length)
{
_DocPos = null;
_Flag = 1;
}
else if (Pos > 0)
{
Pos--;
_DocPos = null;
_Flag = -1;
}
else
{
// Такого не должно быть
return;
}
}
this.CurPos.ContentPos = Pos;
this.Content[Pos].Set_ContentPosition(_DocPos, Depth + 1, _Flag);
};
Paragraph.prototype.Get_DocumentPositionFromObject = function(PosArray)
{
if (!PosArray)
PosArray = [];
if (this.Parent)
{
PosArray.splice(0, 0, {Class : this.Parent, Position : this.Get_Index()});
this.Parent.Get_DocumentPositionFromObject(PosArray);
}
return PosArray;
};
var pararecalc_0_All = 0; var pararecalc_0_All = 0;
var pararecalc_0_None = 1; var pararecalc_0_None = 1;
......
This diff is collapsed.
This diff is collapsed.
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