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