Commit b806cee5 authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed some bugs with restoring state in fast collaboration. Implemented...

Fixed some bugs with restoring state in fast collaboration. Implemented saving/restoring footnotes state in fast collaboration.
parent aef49347
...@@ -7623,6 +7623,21 @@ CDocument.prototype.Document_End_HdrFtrEditing = function() ...@@ -7623,6 +7623,21 @@ CDocument.prototype.Document_End_HdrFtrEditing = function()
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
} }
}; };
CDocument.prototype.EndFootnotesEditing = function()
{
if (docpostype_Footnotes === this.Get_DocPosType())
{
this.Set_DocPosType(docpostype_Content);
this.Cursor_MoveAt(0, 0, false);
this.DrawingDocument.ClearCachePages();
this.DrawingDocument.FirePaint();
this.Document_UpdateRulersState();
this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState();
}
};
CDocument.prototype.Document_Format_Paste = function() CDocument.prototype.Document_Format_Paste = function()
{ {
this.Controller.PasteFormatting(this.CopyTextPr, this.CopyParaPr); this.Controller.PasteFormatting(this.CopyTextPr, this.CopyParaPr);
...@@ -10069,7 +10084,8 @@ CDocument.prototype.Save_DocumentStateBeforeLoadChanges = function() ...@@ -10069,7 +10084,8 @@ CDocument.prototype.Save_DocumentStateBeforeLoadChanges = function()
Use : this.Selection.Use, Use : this.Selection.Use,
Flag : this.Selection.Flag, Flag : this.Selection.Flag,
UpdateOnRecalc : this.Selection.UpdateOnRecalc, UpdateOnRecalc : this.Selection.UpdateOnRecalc,
DragDrop : {Flag : this.Selection.DragDrop.Flag, DragDrop : {
Flag : this.Selection.DragDrop.Flag,
Data : null === this.Selection.DragDrop.Data ? null : { Data : null === this.Selection.DragDrop.Data ? null : {
X : this.Selection.DragDrop.Data.X, X : this.Selection.DragDrop.Data.X,
Y : this.Selection.DragDrop.Data.Y, Y : this.Selection.DragDrop.Data.Y,
...@@ -10093,7 +10109,7 @@ CDocument.prototype.Load_DocumentStateAfterLoadChanges = function(State) ...@@ -10093,7 +10109,7 @@ CDocument.prototype.Load_DocumentStateAfterLoadChanges = function(State)
this.CurPos.Y = State.CurPos.Y; this.CurPos.Y = State.CurPos.Y;
this.CurPos.RealX = State.CurPos.RealX; this.CurPos.RealX = State.CurPos.RealX;
this.CurPos.RealY = State.CurPos.RealY; this.CurPos.RealY = State.CurPos.RealY;
this.CurPos.Type = State.CurPos.Type; this.Set_DocPosType(State.CurPos.Type);
this.Selection.Start = State.Selection.Start; this.Selection.Start = State.Selection.Start;
this.Selection.Use = State.Selection.Use; this.Selection.Use = State.Selection.Use;
......
...@@ -400,7 +400,7 @@ CDocumentContent.prototype.Set_CurrentElement = function(Index, bUp ...@@ -400,7 +400,7 @@ CDocumentContent.prototype.Set_CurrentElement = function(Index, bUp
}; };
CDocumentContent.prototype.Is_ThisElementCurrent = function() CDocumentContent.prototype.Is_ThisElementCurrent = function()
{ {
return this.Parent.Is_ThisElementCurrent(); return this.Parent.Is_ThisElementCurrent(this);
}; };
CDocumentContent.prototype.Content_GetPrev = function(Id) CDocumentContent.prototype.Content_GetPrev = function(Id)
{ {
......
...@@ -483,9 +483,9 @@ CDrawingsController.prototype.RestoreDocumentStateAfterLoadChanges = function(St ...@@ -483,9 +483,9 @@ CDrawingsController.prototype.RestoreDocumentStateAfterLoadChanges = function(St
{ {
if (true !== this.DrawingObjects.Load_DocumentStateAfterLoadChanges(State)) if (true !== this.DrawingObjects.Load_DocumentStateAfterLoadChanges(State))
{ {
this.Set_DocPosType(docpostype_Content);
var LogicDocument = this.LogicDocument; var LogicDocument = this.LogicDocument;
LogicDocument.Set_DocPosType(docpostype_Content);
var ContentPos = 0; var ContentPos = 0;
if (LogicDocument.Pages[LogicDocument.CurPage]) if (LogicDocument.Pages[LogicDocument.CurPage])
ContentPos = LogicDocument.Pages[LogicDocument.CurPage].Pos + 1; ContentPos = LogicDocument.Pages[LogicDocument.CurPage].Pos + 1;
......
...@@ -251,17 +251,43 @@ CFootnotesController.prototype.Add_FootnoteOnPage = function(nPageIndex, oFootno ...@@ -251,17 +251,43 @@ CFootnotesController.prototype.Add_FootnoteOnPage = function(nPageIndex, oFootno
* @param {string} sFootnoteId * @param {string} sFootnoteId
* @returns {boolean} * @returns {boolean}
*/ */
CFootnotesController.prototype.Is_UseInDocument = function(sFootnoteId) CFootnotesController.prototype.Is_UseInDocument = function(sFootnoteId, arrFootnotesList)
{ {
// TODO: Надо бы еще проверить, если ли в документе ссылка на данную сноску. if (!arrFootnotesList)
for (var sId in this.Footnote) arrFootnotesList = this.private_GetFootnotesLogicRange(null, null);
var oFootnote = null;
for (var nIndex = 0, nCount = arrFootnotesList.length; nIndex < nCount; ++nIndex)
{ {
if (sId === sFootnoteId) var oTempFootnote = arrFootnotesList[nIndex];
return true; if (oTempFootnote.Get_Id() === sFootnoteId)
{
oFootnote = oTempFootnote;
break;
} }
}
if (this.Footnote[sFootnoteId] === oFootnote)
return true;
return false; return false;
}; };
/**
* Проверяем является ли данная сноска текущей.
* @param oFootnote
* return {boolean}
*/
CFootnotesController.prototype.Is_ThisElementCurrent = function(oFootnote)
{
if (oFootnote === this.CurFootnote && docpostype_Footnotes === this.LogicDocument.Get_DocPosType())
return true;
return false;
};
CFootnotesController.prototype.OnContentReDraw = function(StartPageAbs, EndPageAbs)
{
this.LogicDocument.OnContentReDraw(StartPageAbs, EndPageAbs);
};
/** /**
* Проверяем пустая ли страница. * Проверяем пустая ли страница.
* @param {number} nPageIndex * @param {number} nPageIndex
...@@ -2226,13 +2252,12 @@ CFootnotesController.prototype.CanAddComment = function() ...@@ -2226,13 +2252,12 @@ CFootnotesController.prototype.CanAddComment = function()
}; };
CFootnotesController.prototype.GetSelectionAnchorPos = function() CFootnotesController.prototype.GetSelectionAnchorPos = function()
{ {
// TODO: Реализовать if (true !== this.Selection.Use || 0 === this.Selection.Direction)
return { return this.CurFootnote.Get_SelectionAnchorPos();
X0 : 0, else if (1 === this.Selection.Direction)
Y : 0, return this.Selection.Start.Footnote.Get_SelectionAnchorPos();
X1 : 0, else
Page : 0 return this.Selection.End.Footnote.Get_SelectionAnchorPos();
};
}; };
CFootnotesController.prototype.StartSelectionFromCurPos = function() CFootnotesController.prototype.StartSelectionFromCurPos = function()
{ {
...@@ -2248,11 +2273,207 @@ CFootnotesController.prototype.StartSelectionFromCurPos = function() ...@@ -2248,11 +2273,207 @@ CFootnotesController.prototype.StartSelectionFromCurPos = function()
}; };
CFootnotesController.prototype.SaveDocumentStateBeforeLoadChanges = function(State) CFootnotesController.prototype.SaveDocumentStateBeforeLoadChanges = function(State)
{ {
// TODO: Реализовать State.FootnotesSelectDirection = this.Selection.Direction;
State.FootnotesSelectionUse = this.Selection.Use;
if (0 === this.Selection.Direction || false === this.Selection.Use)
{
var oFootnote = this.CurFootnote;
State.CurFootnote = oFootnote;
State.CurFootnoteSelection = oFootnote.Selection.Use;
State.CurFootnoteDocPosType = oFootnote.Get_DocPosType();
if (docpostype_Content === oFootnote.Get_DocPosType())
{
State.Pos = oFootnote.Get_ContentPosition(false, false, undefined);
State.StartPos = oFootnote.Get_ContentPosition(true, true, undefined);
State.EndPos = oFootnote.Get_ContentPosition(true, false, undefined);
}
else if (docpostype_DrawingObjects === oFootnote.Get_DocPosType())
{
this.LogicDocument.DrawingObjects.Save_DocumentStateBeforeLoadChanges(State);
}
}
else
{
State.FootnotesList = this.private_GetSelectionArray();
var oFootnote = State.FootnotesList[0];
State.FootnotesStart = {
Pos : oFootnote.Get_ContentPosition(false, false, undefined),
StartPos : oFootnote.Get_ContentPosition(true, true, undefined),
EndPos : oFootnote.Get_ContentPosition(true, false, undefined)
};
oFootnote = State.FootnotesList[State.FootnotesList.length - 1];
State.FootnotesEnd = {
Pos : oFootnote.Get_ContentPosition(false, false, undefined),
StartPos : oFootnote.Get_ContentPosition(true, true, undefined),
EndPos : oFootnote.Get_ContentPosition(true, false, undefined)
};
}
}; };
CFootnotesController.prototype.RestoreDocumentStateAfterLoadChanges = function(State) CFootnotesController.prototype.RestoreDocumentStateAfterLoadChanges = function(State)
{ {
// TODO: Реализовать this.RemoveSelection();
if (0 === State.FootnotesSelectDirection)
{
var oFootnote = State.CurFootnote;
if (oFootnote && true === this.Is_UseInDocument(oFootnote.Get_Id()))
{
this.Selection.Start.Footnote = oFootnote;
this.Selection.End.Footnote = oFootnote;
this.Selection.Direction = 0;
this.CurFootnote = oFootnote;
this.Selection.Footnotes = {};
this.Selection.Use = State.FootnotesSelectionUse;
this.Selection.Footnotes[oFootnote.Get_Id()] = oFootnote;
if (docpostype_Content === State.CurFootnoteDocPosType)
{
oFootnote.Set_DocPosType(docpostype_Content);
oFootnote.Selection.Use = State.CurFootnoteSelection;
if (true === oFootnote.Selection.Use)
{
oFootnote.Set_ContentPosition(State.StartPos, 0, 0);
oFootnote.Set_ContentSelection(State.StartPos, State.EndPos, 0, 0, 0);
}
else
{
oFootnote.Set_ContentPosition(State.Pos, 0, 0);
this.LogicDocument.NeedUpdateTarget = true;
}
}
else if (docpostype_DrawingObjects === State.CurFootnoteDocPosType)
{
oFootnote.Set_DocPosType(docpostype_DrawingObjects);
if (true !== this.LogicDocument.DrawingObjects.Load_DocumentStateAfterLoadChanges(State))
{
oFootnote.Set_DocPosType(docpostype_Content);
this.LogicDocument.Cursor_MoveAt(State.X ? State.X : 0, State.Y ? State.Y : 0, false);
}
}
}
else
{
this.LogicDocument.EndFootnotesEditing();
}
}
else
{
var arrFootnotesList = State.FootnotesList;
var StartFootnote = null;
var EndFootnote = null;
var arrAllFootnotes = this.private_GetFootnotesLogicRange(null, null);
for (var nIndex = 0, nCount = arrFootnotesList.length; nIndex < nCount; ++nIndex)
{
var oFootnote = arrFootnotesList[nIndex];
if (true === this.Is_UseInDocument(oFootnote.Get_Id(), arrAllFootnotes))
{
if (null === StartFootnote)
StartFootnote = oFootnote;
EndFootnote = oFootnote;
}
}
if (null === StartFootnote || null === EndFootnote)
{
this.LogicDocument.EndFootnotesEditing();
return;
}
var arrNewFootnotesList = this.private_GetFootnotesLogicRange(StartFootnote, EndFootnote);
if (arrNewFootnotesList.length < 1)
{
this.LogicDocument.EndFootnotesEditing();
return;
}
else if (arrNewFootnotesList.length === 1)
{
this.Selection.Use = true;
this.Selection.Direction = 0;
this.Selection.Footnotes = {};
this.Selection.Footnotes[StartFootnote.Get_Id()] = StartFootnote;
if (arrFootnotesList[0] === StartFootnote)
{
StartFootnote.Set_DocPosType(docpostype_Content);
StartFootnote.Selection.Use = true;
StartFootnote.Set_ContentPosition(State.FootnotesStart.Pos, 0, 0);
StartFootnote.Set_ContentSelection(State.FootnotesStart.StartPos, State.FootnotesStart.EndPos, 0, 0, 0);
}
else if (arrFootnotesList[arrAllFootnotes.length - 1] === StartFootnote)
{
StartFootnote.Set_DocPosType(docpostype_Content);
StartFootnote.Selection.Use = true;
StartFootnote.Set_ContentPosition(State.FootnotesEnd.Pos, 0, 0);
StartFootnote.Set_ContentSelection(State.FootnotesEnd.StartPos, State.FootnotesEnd.EndPos, 0, 0, 0);
}
else
{
StartFootnote.Set_DocPosType(docpostype_Content);
StartFootnote.Select_All(1);
}
}
else
{
this.Selection.Use = true;
this.Selection.Direction = State.FootnotesSelectDirection;
this.Selection.Footnotes = {};
for (var nIndex = 1, nCount = arrNewFootnotesList.length; nIndex < nCount - 1; ++nIndex)
{
var oFootnote = arrNewFootnotesList[nIndex];
oFootnote.Select_All(this.Selection.Direction);
this.Selection.Footnotes[oFootnote.Get_Id()] = oFootnote;
}
this.Selection.Footnotes[StartFootnote.Get_Id()] = StartFootnote;
this.Selection.Footnotes[EndFootnote.Get_Id()] = EndFootnote;
if (1 !== this.Selection.Direction)
{
var Temp = StartFootnote;
StartFootnote = EndFootnote;
EndFootnote = Temp;
}
this.Selection.Start.Footnote = StartFootnote;
this.Selection.End.Footnote = EndFootnote;
if (arrFootnotesList[0] === StartFootnote)
{
StartFootnote.Set_DocPosType(docpostype_Content);
StartFootnote.Selection.Use = true;
StartFootnote.Set_ContentPosition(State.FootnotesStart.Pos, 0, 0);
StartFootnote.Set_ContentSelection(State.FootnotesStart.StartPos, State.FootnotesStart.EndPos, 0, 0, 0);
}
else
{
StartFootnote.Set_DocPosType(docpostype_Content);
StartFootnote.Select_All(1);
}
if (arrFootnotesList[arrFootnotesList.length - 1] === EndFootnote)
{
EndFootnote.Set_DocPosType(docpostype_Content);
EndFootnote.Selection.Use = true;
EndFootnote.Set_ContentPosition(State.FootnotesEnd.Pos, 0, 0);
EndFootnote.Set_ContentSelection(State.FootnotesEnd.StartPos, State.FootnotesEnd.EndPos, 0, 0, 0);
}
else
{
EndFootnote.Set_DocPosType(docpostype_Content);
EndFootnote.Select_All(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