Commit 132336ce authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed bug with auto save during a composite input. Rework of calculating footnotes with columns.

parent 2a872e61
...@@ -909,6 +909,8 @@ function CDocumentRecalcInfo() ...@@ -909,6 +909,8 @@ function CDocumentRecalcInfo()
this.ParaMath = null; this.ParaMath = null;
this.FootnoteReference = null; // Ссылка на сноску, которую мы пересчитываем this.FootnoteReference = null; // Ссылка на сноску, которую мы пересчитываем
this.FootnotePage = 0;
this.FootnoteColumn = 0;
this.AdditionalInfo = null; this.AdditionalInfo = null;
} }
...@@ -933,6 +935,8 @@ CDocumentRecalcInfo.prototype = ...@@ -933,6 +935,8 @@ CDocumentRecalcInfo.prototype =
this.ParaMath = null; this.ParaMath = null;
this.FootnoteReference = null; this.FootnoteReference = null;
this.FootnotePage = 0;
this.FootnoteColumn = 0;
}, },
Can_RecalcObject : function() Can_RecalcObject : function()
...@@ -1046,22 +1050,23 @@ CDocumentRecalcInfo.prototype = ...@@ -1046,22 +1050,23 @@ CDocumentRecalcInfo.prototype =
this.FrameRecalc = Value; this.FrameRecalc = Value;
}, },
Set_FootnoteReference : function(FootnoteReference, PageIndex) Set_FootnoteReference : function(oFootnoteReference, nPageAbs, nColumnAbs)
{ {
this.FootnoteReference = FootnoteReference; this.FootnoteReference = oFootnoteReference;
this.FlowObjectPage = PageIndex; this.FlowObjectPage = nPageAbs;
}, },
Check_FootnoteReference : function(FootnoteReference) Check_FootnoteReference : function(oFootnoteReference)
{ {
return (this.FootnoteReference === FootnoteReference ? true : false); return (this.FootnoteReference === oFootnoteReference ? true : false);
}, },
Reset_FootnoteReference : function() Reset_FootnoteReference : function()
{ {
this.FootnoteReference = null; this.FootnoteReference = null;
this.FlowObjectPage = 0; this.FootnotePage = 0;
this.FlowObjectPageBreakBefore = false; this.FootnoteColumn = 0;
this.FlowObjectPageBreakBefore = false;
} }
}; };
...@@ -11237,12 +11242,14 @@ CDocument.prototype.Begin_CompositeInput = function() ...@@ -11237,12 +11242,14 @@ CDocument.prototype.Begin_CompositeInput = function()
} }
this.CompositeInput = { this.CompositeInput = {
Run : oRun, Run : oRun,
Pos : oRun.State.ContentPos, Pos : oRun.State.ContentPos,
Length : 0 Length : 0,
CanUndo : true
}; };
oRun.Set_CompositeInput(this.CompositeInput); oRun.Set_CompositeInput(this.CompositeInput);
return true; return true;
} }
...@@ -11266,7 +11273,8 @@ CDocument.prototype.Replace_CompositeText = function(arrCharCodes) ...@@ -11266,7 +11273,8 @@ CDocument.prototype.Replace_CompositeText = function(arrCharCodes)
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
this.Document_UpdateUndoRedoState(); this.Document_UpdateUndoRedoState();
this.History.Check_UninonLastPoints(); if (!this.History.Check_UninonLastPoints())
this.CompositeInput.CanUndo = false;
}; };
CDocument.prototype.Set_CursorPosInCompositeText = function(nPos) CDocument.prototype.Set_CursorPosInCompositeText = function(nPos)
{ {
...@@ -11298,16 +11306,15 @@ CDocument.prototype.End_CompositeInput = function() ...@@ -11298,16 +11306,15 @@ CDocument.prototype.End_CompositeInput = function()
var oRun = this.CompositeInput.Run; var oRun = this.CompositeInput.Run;
oRun.Set_CompositeInput(null); oRun.Set_CompositeInput(null);
this.CompositeInput = null;
this.History.Check_UninonLastPoints();
if (0 === nLen && true === this.History.CanRemoveLastPoint()) if (0 === nLen && true === this.History.CanRemoveLastPoint() && true === this.CompositeInput.CanUndo)
{ {
this.Document_Undo(); this.Document_Undo();
this.History.Clear_Redo(); this.History.Clear_Redo();
} }
this.CompositeInput = null;
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
this.DrawingDocument.ClearCachePages(); this.DrawingDocument.ClearCachePages();
......
...@@ -180,7 +180,7 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, Y ...@@ -180,7 +180,7 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, Y
{ {
var Footnote = oColumn.Elements[nIndex]; var Footnote = oColumn.Elements[nIndex];
Footnote.Reset(X, CurY, XLimit, 10000); Footnote.Reset(X, CurY, XLimit, 10000);
Footnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnCount); Footnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount);
var CurPage = 0; var CurPage = 0;
var RecalcResult = recalcresult2_NextPage; var RecalcResult = recalcresult2_NextPage;
...@@ -212,7 +212,7 @@ CFootnotesController.prototype.GetHeight = function(nPageAbs, nColumnAbs) ...@@ -212,7 +212,7 @@ CFootnotesController.prototype.GetHeight = function(nPageAbs, nColumnAbs)
nHeight += Bounds.Bottom - Bounds.Top; nHeight += Bounds.Bottom - Bounds.Top;
} }
for (var nIndex = 0, nCount = oColumn.Element.length; nIndex < nCount; ++nIndex) for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{ {
var Footnote = oColumn.Elements[nIndex]; var Footnote = oColumn.Elements[nIndex];
var Bounds = Footnote.Get_PageBounds(0); var Bounds = Footnote.Get_PageBounds(0);
...@@ -223,24 +223,33 @@ CFootnotesController.prototype.GetHeight = function(nPageAbs, nColumnAbs) ...@@ -223,24 +223,33 @@ CFootnotesController.prototype.GetHeight = function(nPageAbs, nColumnAbs)
}; };
/** /**
* Отрисовываем сноски на заданной странице. * Отрисовываем сноски на заданной странице.
* @param {number} nPageIndex * @param {number} nPageAbs
* @param {CGraphics} pGraphics * @param {CGraphics} pGraphics
*/ */
CFootnotesController.prototype.Draw = function(nPageIndex, pGraphics) CFootnotesController.prototype.Draw = function(nPageAbs, pGraphics)
{ {
if (true === this.Is_EmptyPage(nPageIndex)) var oPage = this.Pages[nPageAbs];
if (!oPage)
return; return;
if (null !== this.SeparatorFootnote && null !== this.Pages[nPageIndex].SeparatorRecalculateObject) var nColumnsCount = oPage.Columns.length;
for (var nColumnIndex = 0; nColumnIndex < nColumnsCount; ++nColumnIndex)
{ {
this.SeparatorFootnote.Load_RecalculateObject(this.Pages[nPageIndex].SeparatorRecalculateObject); var oColumn = oPage.Columns[nColumnIndex];
this.SeparatorFootnote.Draw(nPageIndex, pGraphics); if (!oColumn || oColumn.Elements.length <= 0)
} continue;
for (var nIndex = 0; nIndex < this.Pages[nPageIndex].Elements.length; ++nIndex) if (null !== this.SeparatorFootnote && null !== oColumn.SeparatorRecalculateObject)
{ {
var Footnote = this.Pages[nPageIndex].Elements[nIndex]; this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject);
Footnote.Draw(nPageIndex, pGraphics); this.SeparatorFootnote.Draw(nPageAbs, pGraphics);
}
for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{
var Footnote = oColumn.Elements[nIndex];
Footnote.Draw(nPageAbs, pGraphics);
}
} }
}; };
/** /**
...@@ -286,17 +295,17 @@ CFootnotesController.prototype.AddFootnoteToPage = function(nPageAbs, nColumnAbs ...@@ -286,17 +295,17 @@ CFootnotesController.prototype.AddFootnoteToPage = function(nPageAbs, nColumnAbs
* @param {number} nPageAbs * @param {number} nPageAbs
* @param {CFootEndnote} oFootnote * @param {CFootEndnote} oFootnote
*/ */
CFootnotesController.prototype.RemoveFootnoteFromPage = function(nPageAbs, oFootnote) CFootnotesController.prototype.RemoveFootnoteFromPage = function(nPageAbs, nColumnAbs, oFootnote)
{ {
if (!this.Pages[nPageAbs]) var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
this.Pages[nPageAbs] = new CFootEndnotePage(); if (!oColumn)
return;
var oPage = this.Pages[nPageAbs]; for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
for (var nIndex = 0, nCount = oPage.Elements.length; nIndex < nCount; ++nIndex)
{ {
if (oPage.Elements[nIndex] === oFootnote) if (oColumn.Elements[nIndex] === oFootnote)
{ {
oPage.Elements.splice(nIndex, 1); oColumn.Elements.splice(nIndex, 1);
return; return;
} }
} }
......
...@@ -647,20 +647,20 @@ CHistory.prototype = ...@@ -647,20 +647,20 @@ CHistory.prototype =
// Не объединяем точки в истории, когда отключается пересчет. // Не объединяем точки в истории, когда отключается пересчет.
// TODO: Неправильно изменяется RecalcIndex // TODO: Неправильно изменяется RecalcIndex
if (true !== this.Document.Is_OnRecalculate()) if (true !== this.Document.Is_OnRecalculate())
return; return false;
// Не объединяем точки истории, если на предыдущей точке произошло сохранение // Не объединяем точки истории, если на предыдущей точке произошло сохранение
if (this.Points.length < 2 if (this.Points.length < 2
|| (true !== this.Is_UserSaveMode() && null !== this.SavedIndex && this.SavedIndex >= this.Points.length - 2) || (true !== this.Is_UserSaveMode() && null !== this.SavedIndex && this.SavedIndex >= this.Points.length - 2)
|| (true === this.Is_UserSaveMode() && null !== this.UserSavedIndex && this.UserSavedIndex >= this.Points.length - 2)) || (true === this.Is_UserSaveMode() && null !== this.UserSavedIndex && this.UserSavedIndex >= this.Points.length - 2))
return; return false;
var Point1 = this.Points[this.Points.length - 2]; var Point1 = this.Points[this.Points.length - 2];
var Point2 = this.Points[this.Points.length - 1]; var Point2 = this.Points[this.Points.length - 1];
// Не объединяем слова больше 63 элементов // Не объединяем слова больше 63 элементов
if (Point1.Items.length > 63 && AscDFH.historydescription_Document_AddLetterUnion === Point1.Description) if (Point1.Items.length > 63 && AscDFH.historydescription_Document_AddLetterUnion === Point1.Description)
return; return false;
var StartIndex1 = 0; var StartIndex1 = 0;
var StartIndex2 = 0; var StartIndex2 = 0;
...@@ -731,6 +731,8 @@ CHistory.prototype = ...@@ -731,6 +731,8 @@ CHistory.prototype =
this.Index += DiffIndex; this.Index += DiffIndex;
this.RecIndex = Math.max( -1, this.RecIndex + DiffIndex); this.RecIndex = Math.max( -1, this.RecIndex + DiffIndex);
} }
return true;
}, },
CanRemoveLastPoint : function() CanRemoveLastPoint : function()
......
...@@ -1848,11 +1848,12 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu ...@@ -1848,11 +1848,12 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
if (this.Parent instanceof CDocument) if (this.Parent instanceof CDocument)
{ {
var RecalcInfo = this.Parent.RecalcInfo; var RecalcInfo = this.Parent.RecalcInfo;
var nPageAbs = this.Get_AbsolutePage(CurPage);
var nColumnAbs = this.Get_AbsoluteColumn(CurPage);
if (true === RecalcInfo.Can_RecalcObject()) if (true === RecalcInfo.Can_RecalcObject())
{ {
var PageAbs = this.Get_AbsolutePage(CurPage); RecalcInfo.Set_FootnoteReference(oFootnote, nPageAbs, nColumnAbs);
RecalcInfo.Set_FootnoteReference(oFootnote, PageAbs); this.Parent.Footnotes.AddFootnoteToPage(nPageAbs, nColumnAbs, oFootnote);
this.Parent.Footnotes.AddFootnoteToPage(PageAbs, oFootnote);
PRS.RecalcResult = recalcresult_CurPage | recalcresultflags_Column | recalcresultflags_Footnotes; PRS.RecalcResult = recalcresult_CurPage | recalcresultflags_Column | recalcresultflags_Footnotes;
return false; return false;
} }
...@@ -1863,8 +1864,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu ...@@ -1863,8 +1864,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
//PRS.RecalcResult //PRS.RecalcResult
} }
var PageAbs = this.Get_AbsolutePage(CurPage); if (nPageAbs === RecalcInfo.FootnotePage && nColumnAbs === RecalcInfo.FootnoteColumn)
if (PageAbs === RecalcInfo.FlowObjectPage)
{ {
// Все нормально пересчиталось // Все нормально пересчиталось
RecalcInfo.Reset_FootnoteReference(); RecalcInfo.Reset_FootnoteReference();
...@@ -1873,7 +1873,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu ...@@ -1873,7 +1873,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
{ {
// TODO: Реализовать // TODO: Реализовать
RecalcInfo.Set_PageBreaFlowObjectPageBreakBefore(true); RecalcInfo.Set_PageBreaFlowObjectPageBreakBefore(true);
this.Parent.Footnotes.RemoveFootnoteFromPage(PageAbs, oFootnote); this.Parent.Footnotes.RemoveFootnoteFromPage(nPageAbs, nColumnAbs, oFootnote);
PRS.RecalcResult = recalcresult_CurPage | recalcresultflags_Column | recalcresultflags_Footnotes; PRS.RecalcResult = recalcresult_CurPage | recalcresultflags_Column | recalcresultflags_Footnotes;
return false; return false;
} }
......
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