Commit 789347ec authored by Ilya Kirillov's avatar Ilya Kirillov

Handled out the situation with a footnotes when paragraph's page had been...

Handled out the situation with a footnotes when paragraph's page had been recalculated second time because of flow-image. Also fixed several bugs with footnotes references which were divided into wrap ranges on the line.
parent 7e9b70ba
...@@ -213,8 +213,8 @@ CFootnotesController.prototype.ContinueElementsFromPreviousColumn = function(nPa ...@@ -213,8 +213,8 @@ CFootnotesController.prototype.ContinueElementsFromPreviousColumn = function(nPa
if (recalcresult2_NextPage === nRecalcResult) if (recalcresult2_NextPage === nRecalcResult)
{ {
// Начиная с данной сноски мы все оставшиеся сноски заносим в массив ContinuesElements у данной колонки // Начиная с данной сноски мы все оставшиеся сноски заносим в массив ContinuesElements у данной колонки
var arrContniuesElements = arrElements.slice(nIndex); var arrContinuesElements = arrElements.slice(nIndex);
oColumn.SetContinutesElements(arrContniuesElements); oColumn.SetContinuesElements(arrContinuesElements);
} }
else if (recalcresult2_CurPage === nRecalcResult) else if (recalcresult2_CurPage === nRecalcResult)
{ {
...@@ -288,8 +288,8 @@ CFootnotesController.prototype.RecalculateFootnotes = function(nPageAbs, nColumn ...@@ -288,8 +288,8 @@ CFootnotesController.prototype.RecalculateFootnotes = function(nPageAbs, nColumn
return false; return false;
// Начиная с данной сноски мы все оставшиеся сноски заносим в массив ContinuesElements у данной колонки // Начиная с данной сноски мы все оставшиеся сноски заносим в массив ContinuesElements у данной колонки
var arrContniuesElements = arrFootnotes.slice(nIndex); var arrContinuesElements = arrFootnotes.slice(nIndex);
oColumn.SetContinutesElements(arrContniuesElements); oColumn.SetContinuesElements(arrContinuesElements);
} }
else if (recalcresult2_CurPage === nRecalcResult) else if (recalcresult2_CurPage === nRecalcResult)
{ {
...@@ -419,6 +419,22 @@ CFootnotesController.prototype.GetFootnoteNumberOnPage = function(nPageAbs, nCol ...@@ -419,6 +419,22 @@ CFootnotesController.prototype.GetFootnoteNumberOnPage = function(nPageAbs, nCol
return 1; return 1;
}; };
CFootnotesController.prototype.SaveRecalculateObject = function(nPageAbs, nColumnAbs)
{
var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
if (!oColumn)
return null;
return oColumn.SaveRecalculateObject();
};
CFootnotesController.prototype.LoadRecalculateObject = function(nPageAbs, nColumnAbs, oRObject)
{
var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
if (!oColumn)
return;
oColumn.LoadRecalculateObject(oRObject);
};
/** /**
* Проверяем, используется заданная сноска в документе. * Проверяем, используется заданная сноска в документе.
* @param {string} sFootnoteId * @param {string} sFootnoteId
...@@ -2904,7 +2920,7 @@ function CFootEndnotePageColumn() ...@@ -2904,7 +2920,7 @@ function CFootEndnotePageColumn()
this.Height = 0; this.Height = 0;
this.Elements = []; // Элементы, которые пересчитаны на данной странице this.Elements = []; // Элементы, которые пересчитаны на данной странице
this.ContniuesElements = []; // Элементы, которые нужно пересчитывать на следующей колонке this.ContinuesElements = []; // Элементы, которые нужно пересчитывать на следующей колонке
this.SeparatorRecalculateObject = null; this.SeparatorRecalculateObject = null;
this.ContinuationSeparatorRecalculateObject = null; this.ContinuationSeparatorRecalculateObject = null;
...@@ -2914,7 +2930,7 @@ CFootEndnotePageColumn.prototype.Reset = function() ...@@ -2914,7 +2930,7 @@ CFootEndnotePageColumn.prototype.Reset = function()
{ {
this.Height = 0; this.Height = 0;
this.Elements = []; this.Elements = [];
this.ContniuesElements = []; this.ContinuesElements = [];
this.SeparatorRecalculateObject = null; this.SeparatorRecalculateObject = null;
this.ContinuationSeparatorRecalculateObject = null; this.ContinuationSeparatorRecalculateObject = null;
...@@ -2922,11 +2938,55 @@ CFootEndnotePageColumn.prototype.Reset = function() ...@@ -2922,11 +2938,55 @@ CFootEndnotePageColumn.prototype.Reset = function()
}; };
CFootEndnotePageColumn.prototype.GetContinuesElements = function() CFootEndnotePageColumn.prototype.GetContinuesElements = function()
{ {
return this.ContniuesElements; return this.ContinuesElements;
}; };
CFootEndnotePageColumn.prototype.SetContinutesElements = function(arrContniuesElements) CFootEndnotePageColumn.prototype.SetContinuesElements = function(arrContinuesElements)
{ {
this.ContniuesElements = arrContniuesElements; this.ContinuesElements = arrContinuesElements;
};
CFootEndnotePageColumn.prototype.SaveRecalculateObject = function()
{
var oColumn = new CFootEndnotePageColumn();
oColumn.X = this.X;
oColumn.Y = this.Y;
oColumn.XLimit = this.XLimit;
oColumn.YLimit = this.YLimit;
oColumn.Height = this.Height;
for (var nIndex = 0, nCount = this.Elements.length; nIndex < nCount; ++nIndex)
{
oColumn.Elements[nIndex] = this.Elements[nIndex];
}
oColumn.ContinuesElements = this.ContinuesElements;
oColumn.SeparatorRecalculateObject = this.SeparatorRecalculateObject;
oColumn.ContinuationSeparatorRecalculateObject = this.SeparatorRecalculateObject;
oColumn.ContinuationNoticeRecalculateObject = this.ContinuationSeparatorRecalculateObject;
return oColumn;
};
CFootEndnotePageColumn.prototype.LoadRecalculateObject = function(oObject)
{
this.X = oObject.X;
this.Y = oObject.Y;
this.XLimit = oObject.XLimit;
this.YLimit = oObject.YLimit;
this.Height = oObject.Height;
this.Elements = [];
for (var nIndex = 0, nCount = oObject.Elements.length; nIndex < nCount; ++nIndex)
{
this.Elements[nIndex] = oObject.Elements[nIndex];
}
this.ContinuesElements = oObject.ContinuesElements;
this.SeparatorRecalculateObject = oObject.SeparatorRecalculateObject;
this.ContinuationSeparatorRecalculateObject = oObject.SeparatorRecalculateObject;
this.ContinuationNoticeRecalculateObject = oObject.ContinuationSeparatorRecalculateObject;
}; };
function CFootEndnotePage() function CFootEndnotePage()
......
...@@ -7647,7 +7647,7 @@ ParaFootnoteReference.prototype.UpdateNumber = function(PRS) ...@@ -7647,7 +7647,7 @@ ParaFootnoteReference.prototype.UpdateNumber = function(PRS)
{ {
var nPageAbs = PRS.GetPageAbs(); var nPageAbs = PRS.GetPageAbs();
var nColumnAbs = PRS.GetColumnAbs(); var nColumnAbs = PRS.GetColumnAbs();
var nAdditional = PRS.GetFootnoteReferencesCount() var nAdditional = PRS.GetFootnoteReferencesCount(this);
var oLogicDocument = this.Footnote.Get_LogicDocument(); var oLogicDocument = this.Footnote.Get_LogicDocument();
var oFootnotesController = oLogicDocument.GetFootnotesController(); var oFootnotesController = oLogicDocument.GetFootnotesController();
......
...@@ -605,7 +605,12 @@ Paragraph.prototype.private_RecalculatePage = function(CurPage, bFirs ...@@ -605,7 +605,12 @@ Paragraph.prototype.private_RecalculatePage = function(CurPage, bFirs
{ {
PRS.Reset_RestartPageRecalcInfo(); PRS.Reset_RestartPageRecalcInfo();
PRS.Reset_MathRecalcInfo(); PRS.Reset_MathRecalcInfo();
PRS.SaveFootnotesInfo();
} }
else
{
PRS.LoadFootnotesInfo();
}
var RecalcResult; var RecalcResult;
while (true) while (true)
...@@ -2621,7 +2626,8 @@ function CParagraphRecalculateStateWrap(Para) ...@@ -2621,7 +2626,8 @@ function CParagraphRecalculateStateWrap(Para)
Object : null // Объект, который вызвал пересчет Object : null // Объект, который вызвал пересчет
}; };
this.Footnotes = []; this.Footnotes = [];
this.FootnotesRecalculateObject = null;
// for ParaMath // for ParaMath
this.bMath_OneLine = false; this.bMath_OneLine = false;
...@@ -2962,12 +2968,28 @@ CParagraphRecalculateStateWrap.prototype = ...@@ -2962,12 +2968,28 @@ CParagraphRecalculateStateWrap.prototype =
return X; return X;
} }
}; };
CParagraphRecalculateStateWrap.prototype.AddFootnoteReference = function(FootnoteReference, Pos) CParagraphRecalculateStateWrap.prototype.AddFootnoteReference = function(oFootnoteReference, oPos)
{ {
this.Footnotes.push({FootnoteReference : FootnoteReference, Pos : Pos}); // Ссылки могут добавляться несколько раз, если строка разбита на несколько отрезков
for (var nIndex = 0, nCount = this.Footnotes.length; nIndex < nCount; ++nIndex)
{
if (this.Footnotes[nIndex].FootnoteReference === oFootnoteReference)
return;
}
this.Footnotes.push({FootnoteReference : oFootnoteReference, Pos : oPos});
}; };
CParagraphRecalculateStateWrap.prototype.GetFootnoteReferencesCount = function() CParagraphRecalculateStateWrap.prototype.GetFootnoteReferencesCount = function(oFootnoteReference)
{ {
// Если данную ссылку мы добавляли уже в строке, тогда ищем сколько было элементов до нее, если не добавляли,
// тогда возвращаем просто количество ссылок.
for (var nIndex = 0, nCount = this.Footnotes.length; nIndex < nCount; ++nIndex)
{
if (this.Footnotes[nIndex].FootnoteReference === oFootnoteReference)
return nIndex;
}
return this.Footnotes.length; return this.Footnotes.length;
}; };
CParagraphRecalculateStateWrap.prototype.SetFast = function(bValue) CParagraphRecalculateStateWrap.prototype.SetFast = function(bValue)
...@@ -2993,6 +3015,18 @@ CParagraphRecalculateStateWrap.prototype.GetCurrentContentPos = function(nPos) ...@@ -2993,6 +3015,18 @@ CParagraphRecalculateStateWrap.prototype.GetCurrentContentPos = function(nPos)
oContentPos.Add(nPos); oContentPos.Add(nPos);
return oContentPos; return oContentPos;
}; };
CParagraphRecalculateStateWrap.prototype.SaveFootnotesInfo = function()
{
var oTopDocument = this.TopDocument;
if (oTopDocument instanceof CDocument)
this.FootnotesRecalculateObject = oTopDocument.Footnotes.SaveRecalculateObject(this.PageAbs, this.ColumnAbs);
};
CParagraphRecalculateStateWrap.prototype.LoadFootnotesInfo = function()
{
var oTopDocument = this.TopDocument;
if (oTopDocument instanceof CDocument && this.FootnotesRecalculateObject)
oTopDocument.Footnotes.LoadRecalculateObject(this.PageAbs, this.ColumnAbs, this.FootnotesRecalculateObject);
};
function CParagraphRecalculateStateCounter() function CParagraphRecalculateStateCounter()
{ {
......
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