Commit 3f414e86 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented very first variant of continuation a footnote on the next column.

parent 21d5f451
...@@ -2260,8 +2260,7 @@ CDocument.prototype.Recalculate_Page = function() ...@@ -2260,8 +2260,7 @@ CDocument.prototype.Recalculate_Page = function()
var StartPos = this.Get_PageContentStartPos(PageIndex, StartIndex); var StartPos = this.Get_PageContentStartPos(PageIndex, StartIndex);
this.Footnotes.Reset(PageIndex, this.SectionsInfo.Get_SectPr(StartIndex).SectPr); this.Footnotes.Reset(PageIndex, this.SectionsInfo.Get_SectPr(StartIndex).SectPr);
this.private_RecalculatePageFootnotes(PageIndex, 0);
//this.private_RecalculatePageFootnotes(PageIndex);
this.Pages[PageIndex].ResetStartElement = this.FullRecalc.ResetStartElement; this.Pages[PageIndex].ResetStartElement = this.FullRecalc.ResetStartElement;
this.Pages[PageIndex].X = StartPos.X; this.Pages[PageIndex].X = StartPos.X;
...@@ -2765,6 +2764,9 @@ CDocument.prototype.Recalculate_PageColumn = function() ...@@ -2765,6 +2764,9 @@ CDocument.prototype.Recalculate_PageColumn = function()
if (Index >= Count || _PageIndex > PageIndex || _ColumnIndex > ColumnIndex) if (Index >= Count || _PageIndex > PageIndex || _ColumnIndex > ColumnIndex)
{ {
this.private_RecalculateShiftFootnotes(PageIndex, ColumnIndex); this.private_RecalculateShiftFootnotes(PageIndex, ColumnIndex);
if (Index < Count && _PageIndex === PageIndex || _ColumnIndex > ColumnIndex)
this.private_RecalculatePageFootnotes(_PageIndex, _ColumnIndex);
} }
if (true === bReDraw) if (true === bReDraw)
...@@ -2863,7 +2865,7 @@ CDocument.prototype.private_RecalculateIsNewSection = function(nPageAbs, nConten ...@@ -2863,7 +2865,7 @@ CDocument.prototype.private_RecalculateIsNewSection = function(nPageAbs, nConten
CDocument.prototype.private_RecalculatePageFootnotes = function(nPageAbs, nColumnAbs) CDocument.prototype.private_RecalculatePageFootnotes = function(nPageAbs, nColumnAbs)
{ {
var oPageMetrics = this.Get_PageContentStartPos(nPageAbs); var oPageMetrics = this.Get_PageContentStartPos(nPageAbs);
this.Footnotes.Recalculate(nPageAbs, nColumnAbs, oPageMetrics.YLimit); this.Footnotes.Recalculate(nPageAbs, nColumnAbs, oPageMetrics.Y, oPageMetrics.YLimit);
}; };
CDocument.prototype.private_RecalculateShiftFootnotes = function(nPageAbs, nColumnAbs) CDocument.prototype.private_RecalculateShiftFootnotes = function(nPageAbs, nColumnAbs)
{ {
......
...@@ -8416,29 +8416,43 @@ CDocumentContent.prototype.Get_StartPage_Relative = function() ...@@ -8416,29 +8416,43 @@ CDocumentContent.prototype.Get_StartPage_Relative = function()
{ {
return this.StartPage; return this.StartPage;
}; };
CDocumentContent.prototype.Get_AbsolutePage = function(CurPage)
{
return this.Parent.Get_AbsolutePage(this.StartPage + CurPage);
};
CDocumentContent.prototype.Get_AbsoluteColumn = function(CurPage)
{
return (this.StartColumn + CurPage) - (((this.StartColumn + CurPage) / this.ColumnsCount | 0) * this.ColumnsCount);
};
CDocumentContent.prototype.Set_StartPage = function(StartPage, StartColumn, ColumnsCount) CDocumentContent.prototype.Set_StartPage = function(StartPage, StartColumn, ColumnsCount)
{ {
this.StartPage = StartPage; this.StartPage = StartPage;
this.StartColumn = undefined !== StartColumn ? StartColumn : 0; this.StartColumn = undefined !== StartColumn ? StartColumn : 0;
this.ColumnsCount = undefined !== ColumnsCount ? ColumnsCount : 1; this.ColumnsCount = undefined !== ColumnsCount ? ColumnsCount : 1;
}; };
// Приходит абсолютное значение страницы(по отношению к родительскому классу), на выходе - относительное
CDocumentContent.prototype.Get_Page_Relative = function(AbsPage)
{
return Math.min(this.Pages.length - 1, Math.max(AbsPage - this.StartPage, 0));
};
CDocumentContent.prototype.Get_ColumnsCount = function() CDocumentContent.prototype.Get_ColumnsCount = function()
{ {
return this.ColumnsCount; return this.ColumnsCount;
}; };
CDocumentContent.prototype.private_GetRelativePageIndex = function(CurPage)
{
if (!this.ColumnsCount || 0 === this.ColumnsCount)
return this.StartPage + CurPage;
return this.StartPage + ((this.StartColumn + CurPage) / this.ColumnsCount | 0);
};
CDocumentContent.prototype.private_GetAbsolutePageIndex = function(CurPage)
{
return this.Parent.Get_AbsolutePage(this.private_GetRelativePageIndex(CurPage));
};
CDocumentContent.prototype.Get_StartColumn = function()
{
return this.StartColumn;
};
CDocumentContent.prototype.Get_AbsolutePage = function(CurPage)
{
return this.private_GetAbsolutePageIndex(CurPage);
};
CDocumentContent.prototype.Get_AbsoluteColumn = function(CurPage)
{
return this.private_GetColumnIndex(CurPage);
};
CDocumentContent.prototype.private_GetColumnIndex = function(CurPage)
{
return (this.StartColumn + CurPage) - (((this.StartColumn + CurPage) / this.ColumnsCount | 0) * this.ColumnsCount);
};
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Undo/Redo функции // Undo/Redo функции
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
......
...@@ -52,9 +52,13 @@ CFootEndnote.prototype.GetElementPageIndex = function(nPageAbs, nColumnAbs) ...@@ -52,9 +52,13 @@ CFootEndnote.prototype.GetElementPageIndex = function(nPageAbs, nColumnAbs)
var nStartColumn = this.StartColumn; var nStartColumn = this.StartColumn;
var nColumnsCount = this.ColumnsCount; var nColumnsCount = this.ColumnsCount;
var nCurPage = nColumnAbs - nStartColumn + (nPageAbs - nStartPage) * nColumnsCount; return Math.max(0, nColumnAbs - nStartColumn + (nPageAbs - nStartPage) * nColumnsCount);
nCurPage = Math.max(0, Math.min(this.Pages.length - 1, nCurPage)); };
return nCurPage; CFootEndnote.prototype.Get_PageContentStartPos = function(nCurPage)
{
var nPageAbs = this.Get_AbsolutePage(nCurPage);
var nColumnAbs = this.Get_AbsoluteColumn(nCurPage);
return this.Parent.Get_PageContentStartPos(nPageAbs, nColumnAbs);
}; };
CFootEndnote.prototype.Write_ToBinary2 = function(Writer) CFootEndnote.prototype.Write_ToBinary2 = function(Writer)
{ {
......
...@@ -155,9 +155,10 @@ CFootnotesController.prototype.Reset = function(nPageIndex, oSectPr) ...@@ -155,9 +155,10 @@ CFootnotesController.prototype.Reset = function(nPageIndex, oSectPr)
/** /**
* Пересчитываем сноски на заданной странице. * Пересчитываем сноски на заданной странице.
*/ */
CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLimit) CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, YLimit)
{ {
if (true === this.IsEmptyPageColumn(nPageAbs, nColumnAbs)) var oPrevColumn = (nColumnAbs > 0 ? this.Pages[nPageAbs].Columns[nColumnAbs - 1] : (nPageAbs > 0 ? this.Pages[nPageAbs - 1].Columns[this.Pages[nPageAbs - 1].Columns.length - 1] : null));
if (true === this.IsEmptyPageColumn(nPageAbs, nColumnAbs) && (null === oPrevColumn || true !== oPrevColumn.Continue))
return; return;
var oPage = this.Pages[nPageAbs]; var oPage = this.Pages[nPageAbs];
...@@ -166,12 +167,9 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim ...@@ -166,12 +167,9 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim
var X = oColumn.X; var X = oColumn.X;
var XLimit = oColumn.XLimit; var XLimit = oColumn.XLimit;
oColumn.YLimit = YLimit;
var _YLimit = YLimit - oColumn.Y;
// Мы пересчет начинаем с 0, потом просто делаем сдвиг, через функцию Shift. // Мы пересчет начинаем с 0, потом просто делаем сдвиг, через функцию Shift.
var oPrevColumn = (nColumnAbs > 0 ? oPage.Columns[nColumnAbs - 1] : (nPageAbs > 0 ? this.Pages[nPageAbs - 1].Columns[this.Pages[nPageAbs - 1].Colums.length - 1] : null));
if (null !== oPrevColumn && true === oPrevColumn.Continue && oPrevColumn.Elements.length > 0) if (null !== oPrevColumn && true === oPrevColumn.Continue && oPrevColumn.Elements.length > 0)
{ {
var oLastFootnote = oPrevColumn.Elements[oPrevColumn.Elements.length - 1]; var oLastFootnote = oPrevColumn.Elements[oPrevColumn.Elements.length - 1];
...@@ -179,9 +177,10 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim ...@@ -179,9 +177,10 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim
oColumn.Elements.splice(0, 0, oLastFootnote); oColumn.Elements.splice(0, 0, oLastFootnote);
oColumn.ContinuePrev = true; oColumn.ContinuePrev = true;
oColumn.Y = Y;
} }
var _YLimit = YLimit - oColumn.Y;
var CurY = 0; var CurY = 0;
if (oColumn.ContinuePrev) if (oColumn.ContinuePrev)
...@@ -192,7 +191,7 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim ...@@ -192,7 +191,7 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim
this.ContinuationSeparatorFootnote.Reset(X, CurY, XLimit, _YLimit); this.ContinuationSeparatorFootnote.Reset(X, CurY, XLimit, _YLimit);
this.ContinuationSeparatorFootnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount); this.ContinuationSeparatorFootnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount);
this.ContinuationSeparatorFootnote.Recalculate_Page(0, true); this.ContinuationSeparatorFootnote.Recalculate_Page(0, true);
oColumn.ContinuationSeparatorFootnote = this.ContinuationSeparatorFootnote.Save_RecalculateObject(); oColumn.ContinuationSeparatorRecalculateObject = this.ContinuationSeparatorFootnote.Save_RecalculateObject();
var Bounds = this.ContinuationSeparatorFootnote.Get_PageBounds(0); var Bounds = this.ContinuationSeparatorFootnote.Get_PageBounds(0);
CurY += Bounds.Bottom - Bounds.Top; CurY += Bounds.Bottom - Bounds.Top;
...@@ -213,6 +212,7 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim ...@@ -213,6 +212,7 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLim
} }
} }
oColumn.YStart = CurY;
for (var nIndex = 0; nIndex < oColumn.Elements.length; ++nIndex) for (var nIndex = 0; nIndex < oColumn.Elements.length; ++nIndex)
{ {
var Footnote = oColumn.Elements[nIndex]; var Footnote = oColumn.Elements[nIndex];
...@@ -258,18 +258,32 @@ CFootnotesController.prototype.GetHeight = function(nPageAbs, nColumnAbs) ...@@ -258,18 +258,32 @@ CFootnotesController.prototype.GetHeight = function(nPageAbs, nColumnAbs)
var oColumn = this.Pages[nPageAbs].Columns[nColumnAbs]; var oColumn = this.Pages[nPageAbs].Columns[nColumnAbs];
var nHeight = 0; var nHeight = 0;
if (true === oColumn.ContinuePrev)
{
if (null !== oColumn.ContinuationSeparatorRecalculateObject)
{
this.ContinuationSeparatorFootnote.Load_RecalculateObject(oColumn.ContinuationSeparatorRecalculateObject);
var oBounds = this.ContinuationSeparatorFootnote.Get_PageBounds(0);
nHeight += oBounds.Bottom - oBounds.Top;
}
}
else
{
if (null !== oColumn.SeparatorRecalculateObject) if (null !== oColumn.SeparatorRecalculateObject)
{ {
this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject); this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject);
var Bounds = this.SeparatorFootnote.Get_PageBounds(0); var oBounds = this.SeparatorFootnote.Get_PageBounds(0);
nHeight += Bounds.Bottom - Bounds.Top; nHeight += oBounds.Bottom - oBounds.Top;
}
} }
for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex) for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{ {
var Footnote = oColumn.Elements[nIndex]; var oFootnote = oColumn.Elements[nIndex];
var Bounds = Footnote.Get_PageBounds(0); var nFootnotePageIndex = oFootnote.GetElementPageIndex(nPageAbs, nColumnAbs);
nHeight += Bounds.Bottom - Bounds.Top;
var oBounds = oFootnote.Get_PageBounds(nFootnotePageIndex);
nHeight += oBounds.Bottom - oBounds.Top;
} }
return nHeight; return nHeight;
...@@ -292,16 +306,28 @@ CFootnotesController.prototype.Draw = function(nPageAbs, pGraphics) ...@@ -292,16 +306,28 @@ CFootnotesController.prototype.Draw = function(nPageAbs, pGraphics)
if (!oColumn || oColumn.Elements.length <= 0) if (!oColumn || oColumn.Elements.length <= 0)
continue; continue;
if (true === oColumn.ContinuePrev)
{
if (null !== this.ContinuationSeparatorFootnote && null !== oColumn.ContinuationSeparatorRecalculateObject)
{
this.ContinuationSeparatorFootnote.Load_RecalculateObject(oColumn.ContinuationSeparatorRecalculateObject);
this.ContinuationSeparatorFootnote.Draw(nPageAbs, pGraphics);
}
}
else
{
if (null !== this.SeparatorFootnote && null !== oColumn.SeparatorRecalculateObject) if (null !== this.SeparatorFootnote && null !== oColumn.SeparatorRecalculateObject)
{ {
this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject); this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject);
this.SeparatorFootnote.Draw(nPageAbs, pGraphics); this.SeparatorFootnote.Draw(nPageAbs, pGraphics);
} }
}
for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex) for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{ {
var Footnote = oColumn.Elements[nIndex]; var oFootnote = oColumn.Elements[nIndex];
Footnote.Draw(nPageAbs, pGraphics); var nFootnotePageIndex = oFootnote.GetElementPageIndex(nPageAbs, nColumnIndex);
oFootnote.Draw(nFootnotePageIndex + oFootnote.StartPage, pGraphics);
} }
} }
}; };
...@@ -321,17 +347,30 @@ CFootnotesController.prototype.Shift = function(nPageAbs, nColumnAbs, dX, dY) ...@@ -321,17 +347,30 @@ CFootnotesController.prototype.Shift = function(nPageAbs, nColumnAbs, dX, dY)
if (!oColumn) if (!oColumn)
return; return;
if (true === oColumn.ContinuePrev)
{
if (null !== this.ContinuationSeparatorFootnote && null !== oColumn.ContinuationSeparatorRecalculateObject)
{
this.ContinuationSeparatorFootnote.Load_RecalculateObject(oColumn.ContinuationSeparatorRecalculateObject);
this.ContinuationSeparatorFootnote.Shift(0, dX, dY);
oColumn.ContinuationSeparatorRecalculateObject = this.ContinuationSeparatorFootnote.Save_RecalculateObject();
}
}
else
{
if (null !== this.SeparatorFootnote && null !== oColumn.SeparatorRecalculateObject) if (null !== this.SeparatorFootnote && null !== oColumn.SeparatorRecalculateObject)
{ {
this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject); this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject);
this.SeparatorFootnote.Shift(0, dX, dY); this.SeparatorFootnote.Shift(0, dX, dY);
oColumn.SeparatorRecalculateObject = this.SeparatorFootnote.Save_RecalculateObject(); oColumn.SeparatorRecalculateObject = this.SeparatorFootnote.Save_RecalculateObject();
} }
}
for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex) for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{ {
var Footnote = oColumn.Elements[nIndex]; var oFootnote = oColumn.Elements[nIndex];
Footnote.Shift(0, dX, dY); var nFootnotePageIndex = oFootnote.GetElementPageIndex(nPageAbs, nColumnAbs);
oFootnote.Shift(nFootnotePageIndex, dX, dY);
} }
this.NeedShift = false; this.NeedShift = false;
...@@ -480,10 +519,13 @@ CFootnotesController.prototype.Refresh_RecalcData2 = function(nRelPageIndex) ...@@ -480,10 +519,13 @@ CFootnotesController.prototype.Refresh_RecalcData2 = function(nRelPageIndex)
this.LogicDocument.Refresh_RecalcData2(nIndex, nAbsPageIndex); this.LogicDocument.Refresh_RecalcData2(nIndex, nAbsPageIndex);
} }
}; };
CFootnotesController.prototype.Get_PageContentStartPos = function(PageAbs) CFootnotesController.prototype.Get_PageContentStartPos = function(nPageAbs, nColumnAbs)
{ {
//TODO: Реализовать var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
if (!oColumn)
return {X : 0, Y : 0, XLimit : 0, YLimit : 0}; return {X : 0, Y : 0, XLimit : 0, YLimit : 0};
return {X : oColumn.X, Y : oColumn.YStart, XLimit : oColumn.XLimit, YLimit : oColumn.YLimit - oColumn.Y};
}; };
CFootnotesController.prototype.GetCurFootnote = function() CFootnotesController.prototype.GetCurFootnote = function()
{ {
...@@ -2873,6 +2915,7 @@ function CFootEndnotePageColumn() ...@@ -2873,6 +2915,7 @@ function CFootEndnotePageColumn()
this.Y = 0; this.Y = 0;
this.XLimit = 0; this.XLimit = 0;
this.YLimit = 0; this.YLimit = 0;
this.YStart = 0; // фактически тут задается высота специальной сноски-разделителя
this.Elements = []; this.Elements = [];
this.Continue = false; this.Continue = false;
...@@ -2889,6 +2932,7 @@ CFootEndnotePageColumn.prototype.Reset = function() ...@@ -2889,6 +2932,7 @@ CFootEndnotePageColumn.prototype.Reset = function()
this.Y = 0; this.Y = 0;
this.XLimit = 0; this.XLimit = 0;
this.YLimit = 0; this.YLimit = 0;
this.YStart = 0;
this.Elements = []; this.Elements = [];
this.Continue = false; this.Continue = false;
......
...@@ -1853,7 +1853,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu ...@@ -1853,7 +1853,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
if (true === RecalcInfo.Can_RecalcObject()) if (true === RecalcInfo.Can_RecalcObject())
{ {
RecalcInfo.Set_FootnoteReference(oFootnote, nPageAbs, nColumnAbs); RecalcInfo.Set_FootnoteReference(oFootnote, nPageAbs, nColumnAbs);
this.Parent.Footnotes.AddFootnoteToPage(nPageAbs, nColumnAbs, oFootnote, this.Lines[CurLine].Bottom); this.Parent.Footnotes.AddFootnoteToPage(nPageAbs, nColumnAbs, oFootnote, this.Pages[CurPage].Y + this.Lines[CurLine].Bottom);
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