Commit dd4a173c authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed problem with positions of cursor/select after a new undo.

parent addf2669
......@@ -341,78 +341,14 @@ CCollaborativeEditingBase.prototype.Apply_Changes = function()
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.ApplyChanges);
var LogicDocument = editor.WordControl.m_oLogicDocument;
var DocState;
if (true !== this.Is_Fast())
{
DocState = LogicDocument.Get_SelectionState2();
this.m_aCursorsToUpdate = {};
}
else
{
DocState = LogicDocument.Save_DocumentStateBeforeLoadChanges();
this.Clear_DocumentPositions();
if (DocState.Pos)
this.Add_DocumentPosition(DocState.Pos);
if (DocState.StartPos)
this.Add_DocumentPosition(DocState.StartPos);
if (DocState.EndPos)
this.Add_DocumentPosition(DocState.EndPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.Pos)
this.Add_DocumentPosition(DocState.FootnotesStart.Pos);
if (DocState.FootnotesStart && DocState.FootnotesStart.StartPos)
this.Add_DocumentPosition(DocState.FootnotesStart.StartPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.EndPos)
this.Add_DocumentPosition(DocState.FootnotesStart.EndPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.Pos)
this.Add_DocumentPosition(DocState.FootnotesEnd.Pos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.StartPos)
this.Add_DocumentPosition(DocState.FootnotesEnd.StartPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.EndPos)
this.Add_DocumentPosition(DocState.FootnotesEnd.EndPos);
}
var DocState = this.private_SaveDocumentState();
this.Clear_NewImages();
this.Apply_OtherChanges();
// После того как мы приняли чужие изменения, мы должны залочить новые объекты, которые были залочены
this.Lock_NeedLock();
if (true !== this.Is_Fast())
{
LogicDocument.Set_SelectionState2(DocState);
}
else
{
if (DocState.Pos)
this.Update_DocumentPosition(DocState.Pos);
if (DocState.StartPos)
this.Update_DocumentPosition(DocState.StartPos);
if (DocState.EndPos)
this.Update_DocumentPosition(DocState.EndPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.Pos)
this.Update_DocumentPosition(DocState.FootnotesStart.Pos);
if (DocState.FootnotesStart && DocState.FootnotesStart.StartPos)
this.Update_DocumentPosition(DocState.FootnotesStart.StartPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.EndPos)
this.Update_DocumentPosition(DocState.FootnotesStart.EndPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.Pos)
this.Update_DocumentPosition(DocState.FootnotesEnd.Pos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.StartPos)
this.Update_DocumentPosition(DocState.FootnotesEnd.StartPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.EndPos)
this.Update_DocumentPosition(DocState.FootnotesEnd.EndPos);
LogicDocument.Load_DocumentStateAfterLoadChanges(DocState);
this.Refresh_ForeignCursors();
}
this.private_RestoreDocumentState(DocState);
this.OnStart_Load_Objects();
}
};
......@@ -749,6 +685,77 @@ CCollaborativeEditingBase.prototype.InitMemory = function() {
this.m_oMemory = new AscCommon.CMemory();
}
};
CCollaborativeEditingBase.prototype.private_SaveDocumentState = function()
{
var LogicDocument = editor.WordControl.m_oLogicDocument;
var DocState;
if (true !== this.Is_Fast())
{
DocState = LogicDocument.Get_SelectionState2();
this.m_aCursorsToUpdate = {};
}
else
{
DocState = LogicDocument.Save_DocumentStateBeforeLoadChanges();
this.Clear_DocumentPositions();
if (DocState.Pos)
this.Add_DocumentPosition(DocState.Pos);
if (DocState.StartPos)
this.Add_DocumentPosition(DocState.StartPos);
if (DocState.EndPos)
this.Add_DocumentPosition(DocState.EndPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.Pos)
this.Add_DocumentPosition(DocState.FootnotesStart.Pos);
if (DocState.FootnotesStart && DocState.FootnotesStart.StartPos)
this.Add_DocumentPosition(DocState.FootnotesStart.StartPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.EndPos)
this.Add_DocumentPosition(DocState.FootnotesStart.EndPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.Pos)
this.Add_DocumentPosition(DocState.FootnotesEnd.Pos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.StartPos)
this.Add_DocumentPosition(DocState.FootnotesEnd.StartPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.EndPos)
this.Add_DocumentPosition(DocState.FootnotesEnd.EndPos);
}
return DocState;
};
CCollaborativeEditingBase.prototype.private_RestoreDocumentState = function(DocState)
{
var LogicDocument = editor.WordControl.m_oLogicDocument;
if (true !== this.Is_Fast())
{
LogicDocument.Set_SelectionState2(DocState);
}
else
{
if (DocState.Pos)
this.Update_DocumentPosition(DocState.Pos);
if (DocState.StartPos)
this.Update_DocumentPosition(DocState.StartPos);
if (DocState.EndPos)
this.Update_DocumentPosition(DocState.EndPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.Pos)
this.Update_DocumentPosition(DocState.FootnotesStart.Pos);
if (DocState.FootnotesStart && DocState.FootnotesStart.StartPos)
this.Update_DocumentPosition(DocState.FootnotesStart.StartPos);
if (DocState.FootnotesStart && DocState.FootnotesStart.EndPos)
this.Update_DocumentPosition(DocState.FootnotesStart.EndPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.Pos)
this.Update_DocumentPosition(DocState.FootnotesEnd.Pos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.StartPos)
this.Update_DocumentPosition(DocState.FootnotesEnd.StartPos);
if (DocState.FootnotesEnd && DocState.FootnotesEnd.EndPos)
this.Update_DocumentPosition(DocState.FootnotesEnd.EndPos);
LogicDocument.Load_DocumentStateAfterLoadChanges(DocState);
this.Refresh_ForeignCursors();
}
};
//----------------------------------------------------------------------------------------------------------------------
// Private area
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -726,19 +726,14 @@ CWordCollaborativeEditing.prototype.Undo = function()
oLogicDocument.DrawingDocument.EndTrackTable(null, true);
oLogicDocument.DrawingObjects.TurnOffCheckChartSelection();
var DocState = this.private_SaveDocumentState();
for (var nIndex = 0, nCount = arrReverseChanges.length; nIndex < nCount; ++nIndex)
{
arrReverseChanges[nIndex].Load();
this.m_aAllChanges.push(arrReverseChanges[nIndex]);
}
oLogicDocument.DrawingObjects.TurnOnCheckChartSelection();
oLogicDocument.Recalculate(false, false, AscCommon.History.Get_RecalcData(null, arrReverseChanges));
oLogicDocument.Document_UpdateSelectionState();
oLogicDocument.Document_UpdateInterfaceState();
oLogicDocument.Document_UpdateRulersState();
var oBinaryWriter = History.BinaryWriter;
var aSendingChanges = [];
for (var nIndex = 0, nCount = arrReverseChanges.length; nIndex < nCount; ++nIndex)
......@@ -758,6 +753,16 @@ CWordCollaborativeEditing.prototype.Undo = function()
aSendingChanges.push(oChange.m_pData);
}
editor.CoAuthoringApi.saveChanges(aSendingChanges, 0, null);
this.private_RestoreDocumentState(DocState);
oLogicDocument.DrawingObjects.TurnOnCheckChartSelection();
oLogicDocument.Recalculate(false, false, AscCommon.History.Get_RecalcData(null, arrReverseChanges));
oLogicDocument.Document_UpdateSelectionState();
oLogicDocument.Document_UpdateInterfaceState();
oLogicDocument.Document_UpdateRulersState();
};
CWordCollaborativeEditing.prototype.CanUndo = function()
{
......
......@@ -11826,9 +11826,17 @@ Paragraph.prototype.Set_ContentPosition = function(DocPos, Depth, Flag)
}
}
// TODO: Как только разберемся с ParaEnd, исправить здесь.
if (Pos === this.Content.length - 1 && this.Content.length > 1)
{
Pos = this.Content.length - 2;
_Flag = -1;
_DocPos = null;
}
this.CurPos.ContentPos = Pos;
if (this.Content[Pos] && this.Content[Pos].Set_ContentPosition)
this.Content[Pos].Set_ContentPosition(_DocPos, Depth + 1, _Flag);
this.Content[Pos].Set_ContentPosition(_DocPos, Depth + 1, _Flag);
else
this.Correct_ContentPos2();
};
......
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