Commit 21d5f451 authored by Ilya Kirillov's avatar Ilya Kirillov

Some changes for working with columns in footnotes.

parent 8231b7b3
...@@ -2862,7 +2862,8 @@ CDocument.prototype.private_RecalculateIsNewSection = function(nPageAbs, nConten ...@@ -2862,7 +2862,8 @@ CDocument.prototype.private_RecalculateIsNewSection = function(nPageAbs, nConten
}; };
CDocument.prototype.private_RecalculatePageFootnotes = function(nPageAbs, nColumnAbs) CDocument.prototype.private_RecalculatePageFootnotes = function(nPageAbs, nColumnAbs)
{ {
this.Footnotes.Recalculate(nPageAbs, nColumnAbs, 0, 10000); var oPageMetrics = this.Get_PageContentStartPos(nPageAbs);
this.Footnotes.Recalculate(nPageAbs, nColumnAbs, oPageMetrics.YLimit);
}; };
CDocument.prototype.private_RecalculateShiftFootnotes = function(nPageAbs, nColumnAbs) CDocument.prototype.private_RecalculateShiftFootnotes = function(nPageAbs, nColumnAbs)
{ {
......
...@@ -45,13 +45,16 @@ function CFootEndnote(DocumentController) ...@@ -45,13 +45,16 @@ function CFootEndnote(DocumentController)
AscCommon.extendClass(CFootEndnote, CDocumentContent); AscCommon.extendClass(CFootEndnote, CDocumentContent);
CFootEndnote.prototype.GetRelaitivePageIndex = function(nPageAbs, nColumnAbs) CFootEndnote.prototype.GetElementPageIndex = function(nPageAbs, nColumnAbs)
{ {
// TODO: Переделать с учетом колонок // Функция аналогична Document.private_GetElementPageIndex
var nStartPage = this.StartPage;
var nStartColumn = this.StartColumn;
var nColumnsCount = this.ColumnsCount;
var StartPageAbs = this.Get_StartPage_Absolute(); var nCurPage = nColumnAbs - nStartColumn + (nPageAbs - nStartPage) * nColumnsCount;
var PagesCount = this.Get_PagesCount(); nCurPage = Math.max(0, Math.min(this.Pages.length - 1, nCurPage));
return Math.max(0, Math.min(PagesCount - 1, nPageAbs - StartPageAbs)); return nCurPage;
}; };
CFootEndnote.prototype.Write_ToBinary2 = function(Writer) CFootEndnote.prototype.Write_ToBinary2 = function(Writer)
{ {
......
...@@ -94,6 +94,11 @@ CFootnotesController.prototype.Init = function() ...@@ -94,6 +94,11 @@ CFootnotesController.prototype.Init = function()
this.SeparatorFootnote.Paragraph_Add(new ParaSeparator(), false); this.SeparatorFootnote.Paragraph_Add(new ParaSeparator(), false);
var oParagraph = this.SeparatorFootnote.Get_ElementByIndex(0); var oParagraph = this.SeparatorFootnote.Get_ElementByIndex(0);
oParagraph.Set_Spacing({After : 0, Line : 1, LineRule : Asc.linerule_Auto}, false); oParagraph.Set_Spacing({After : 0, Line : 1, LineRule : Asc.linerule_Auto}, false);
this.ContinuationSeparatorFootnote = new CFootEndnote(this);
this.ContinuationSeparatorFootnote.Paragraph_Add(new ParaContinuationSeparator(), false);
oParagraph = this.ContinuationSeparatorFootnote.Get_ElementByIndex(0);
oParagraph.Set_Spacing({After : 0, Line : 1, LineRule : Asc.linerule_Auto}, false);
}; };
/** /**
* Создаем новую сноску. * Создаем новую сноску.
...@@ -150,7 +155,7 @@ CFootnotesController.prototype.Reset = function(nPageIndex, oSectPr) ...@@ -150,7 +155,7 @@ CFootnotesController.prototype.Reset = function(nPageIndex, oSectPr)
/** /**
* Пересчитываем сноски на заданной странице. * Пересчитываем сноски на заданной странице.
*/ */
CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, YLimit) CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, YLimit)
{ {
if (true === this.IsEmptyPageColumn(nPageAbs, nColumnAbs)) if (true === this.IsEmptyPageColumn(nPageAbs, nColumnAbs))
return; return;
...@@ -162,14 +167,43 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, Y ...@@ -162,14 +167,43 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, Y
var X = oColumn.X; var X = oColumn.X;
var XLimit = oColumn.XLimit; var XLimit = oColumn.XLimit;
var _YLimit = YLimit - oColumn.Y;
// Мы пересчет начинаем с 0, потом просто делаем сдвиг, через функцию Shift. // Мы пересчет начинаем с 0, потом просто делаем сдвиг, через функцию Shift.
var CurY = Y; 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)
{
var oLastFootnote = oPrevColumn.Elements[oPrevColumn.Elements.length - 1];
if (oLastFootnote !== oColumn.Elements[0])
oColumn.Elements.splice(0, 0, oLastFootnote);
oColumn.ContinuePrev = true;
}
var CurY = 0;
if (oColumn.ContinuePrev)
{
if (null !== this.ContinuationSeparatorFootnote)
{
this.ContinuationSeparatorFootnote.Prepare_RecalculateObject();
this.ContinuationSeparatorFootnote.Reset(X, CurY, XLimit, _YLimit);
this.ContinuationSeparatorFootnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount);
this.ContinuationSeparatorFootnote.Recalculate_Page(0, true);
oColumn.ContinuationSeparatorFootnote = this.ContinuationSeparatorFootnote.Save_RecalculateObject();
var Bounds = this.ContinuationSeparatorFootnote.Get_PageBounds(0);
CurY += Bounds.Bottom - Bounds.Top;
}
}
else
{
if (null !== this.SeparatorFootnote) if (null !== this.SeparatorFootnote)
{ {
this.SeparatorFootnote.Prepare_RecalculateObject(); this.SeparatorFootnote.Prepare_RecalculateObject();
this.SeparatorFootnote.Reset(X, CurY, XLimit, 10000); this.SeparatorFootnote.Reset(X, CurY, XLimit, _YLimit);
this.SeparatorFootnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount); this.SeparatorFootnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount);
this.SeparatorFootnote.Recalculate_Page(0, true); this.SeparatorFootnote.Recalculate_Page(0, true);
oColumn.SeparatorRecalculateObject = this.SeparatorFootnote.Save_RecalculateObject(); oColumn.SeparatorRecalculateObject = this.SeparatorFootnote.Save_RecalculateObject();
...@@ -177,19 +211,34 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, Y ...@@ -177,19 +211,34 @@ CFootnotesController.prototype.Recalculate = function(nPageAbs, nColumnAbs, Y, Y
var Bounds = this.SeparatorFootnote.Get_PageBounds(0); var Bounds = this.SeparatorFootnote.Get_PageBounds(0);
CurY += Bounds.Bottom - Bounds.Top; CurY += Bounds.Bottom - Bounds.Top;
} }
}
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];
Footnote.Reset(X, CurY, XLimit, 10000); if (0 !== nIndex || true !== oColumn.ContinuePrev)
{
Footnote.Reset(X, CurY, XLimit, _YLimit);
Footnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount); Footnote.Set_StartPage(nPageAbs, nColumnAbs, nColumnsCount);
}
var CurPage = 0; var nRelativePage = Footnote.GetElementPageIndex(nPageAbs, nColumnAbs);
var RecalcResult = recalcresult2_NextPage; if (recalcresult2_NextPage === Footnote.Recalculate_Page(nRelativePage, true))
while (recalcresult2_End != RecalcResult) {
RecalcResult = Footnote.Recalculate_Page(CurPage++, true); if (nIndex === oColumn.Elements.length - 1)
{
// Продолжаем сноску
oColumn.Continue = true;
}
else
{
// TODO: Надо пересчитать данную колонку заново, с учетом того, что последнюю сноску необходимо перенести на новую страницу
}
var Bounds = Footnote.Get_PageBounds(0); break;
}
var Bounds = Footnote.Get_PageBounds(nRelativePage);
CurY += Bounds.Bottom - Bounds.Top; CurY += Bounds.Bottom - Bounds.Top;
} }
...@@ -292,13 +341,18 @@ CFootnotesController.prototype.Shift = function(nPageAbs, nColumnAbs, dX, dY) ...@@ -292,13 +341,18 @@ CFootnotesController.prototype.Shift = function(nPageAbs, nColumnAbs, dX, dY)
* @param {number} nPageAbs * @param {number} nPageAbs
* @param {number} nColumnAbs * @param {number} nColumnAbs
* @param {CFootEndnote} oFootnote * @param {CFootEndnote} oFootnote
* @param {number} dBottom
*/ */
CFootnotesController.prototype.AddFootnoteToPage = function(nPageAbs, nColumnAbs, oFootnote) CFootnotesController.prototype.AddFootnoteToPage = function(nPageAbs, nColumnAbs, oFootnote, dBottom)
{ {
var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs); var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
if (!oColumn) if (!oColumn)
return; return;
// TODO: Проверить ссылку с предыдущей колонки
if (oColumn.Elements.length <= 0)
oColumn.Y = dBottom;
oColumn.Elements.push(oFootnote); oColumn.Elements.push(oFootnote);
}; };
/** /**
...@@ -441,8 +495,7 @@ CFootnotesController.prototype.IsInDrawing = function(X, Y, PageAbs) ...@@ -441,8 +495,7 @@ CFootnotesController.prototype.IsInDrawing = function(X, Y, PageAbs)
if (oResult) if (oResult)
{ {
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); return oFootnote.Is_InDrawing(X, Y, oResult.FootnotePageIndex);
return oFootnote.Is_InDrawing(X, Y, PageRel);
} }
return false; return false;
...@@ -453,8 +506,7 @@ CFootnotesController.prototype.IsTableBorder = function(X, Y, PageAbs) ...@@ -453,8 +506,7 @@ CFootnotesController.prototype.IsTableBorder = function(X, Y, PageAbs)
if (oResult) if (oResult)
{ {
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); return oFootnote.Is_TableBorder(X, Y, oResult.FootnotePageIndex);
return oFootnote.Is_TableBorder(X, Y, PageRel);
} }
return null; return null;
...@@ -465,8 +517,7 @@ CFootnotesController.prototype.IsInText = function(X, Y, PageAbs) ...@@ -465,8 +517,7 @@ CFootnotesController.prototype.IsInText = function(X, Y, PageAbs)
if (oResult) if (oResult)
{ {
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); return oFootnote.Is_InText(X, Y, oResult.FootnotePageIndex);
return oFootnote.Is_InText(X, Y, PageRel);
} }
return null; return null;
...@@ -477,8 +528,7 @@ CFootnotesController.prototype.GetNearestPos = function(X, Y, PageAbs, bAnchor, ...@@ -477,8 +528,7 @@ CFootnotesController.prototype.GetNearestPos = function(X, Y, PageAbs, bAnchor,
if (oResult) if (oResult)
{ {
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); return oFootnote.Get_NearestPos(oResult.FootnotePageIndex, X, Y, bAnchor, Drawing);
return oFootnote.Get_NearestPos(PageRel, X, Y, bAnchor, Drawing);
} }
return null; return null;
...@@ -798,14 +848,17 @@ CFootnotesController.prototype.private_GetFootnoteOnPageByXY = function(X, Y, nP ...@@ -798,14 +848,17 @@ CFootnotesController.prototype.private_GetFootnoteOnPageByXY = function(X, Y, nP
for (var nIndex = oColumn.Elements.length - 1; nIndex >= 0; --nIndex) for (var nIndex = oColumn.Elements.length - 1; nIndex >= 0; --nIndex)
{ {
var oFootnote = oColumn.Elements[nIndex]; var oFootnote = oColumn.Elements[nIndex];
var oBounds = oFootnote.Get_PageBounds(0);
var nElementPageIndex = oFootnote.GetElementPageIndex(nPageAbs, nColumnIndex);
var oBounds = oFootnote.Get_PageBounds(nElementPageIndex);
if (oBounds.Top <= Y || 0 === nIndex) if (oBounds.Top <= Y || 0 === nIndex)
return { return {
Footnote : oFootnote, Footnote : oFootnote,
Index : nIndex, Index : nIndex,
Page : nPageAbs, Page : nPageAbs,
Column : nColumnIndex Column : nColumnIndex,
FootnotePageIndex : nElementPageIndex
}; };
} }
...@@ -1757,7 +1810,7 @@ CFootnotesController.prototype.MoveCursorToXY = function(X, Y, PageAbs, AddToSel ...@@ -1757,7 +1810,7 @@ CFootnotesController.prototype.MoveCursorToXY = function(X, Y, PageAbs, AddToSel
return; return;
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); var PageRel = oResult.FootnotePageIndex;
if (true === AddToSelect) if (true === AddToSelect)
{ {
var StartFootnote = null; var StartFootnote = null;
...@@ -2107,8 +2160,8 @@ CFootnotesController.prototype.DrawSelectionOnPage = function(nPageAbs) ...@@ -2107,8 +2160,8 @@ CFootnotesController.prototype.DrawSelectionOnPage = function(nPageAbs)
var oFootnote = oColumn.Elements[nIndex]; var oFootnote = oColumn.Elements[nIndex];
if (oFootnote === this.Selection.Footnotes[oFootnote.Get_Id()]) if (oFootnote === this.Selection.Footnotes[oFootnote.Get_Id()])
{ {
var nPageRel = oFootnote.GetRelaitivePageIndex(nPageAbs, nColumnIndex); var nFootnotePageIndex = oFootnote.GetElementPageIndex(nPageAbs, nColumnIndex);
oFootnote.Selection_Draw_Page(nPageRel); oFootnote.Selection_Draw_Page(nFootnotePageIndex);
} }
} }
} }
...@@ -2154,8 +2207,7 @@ CFootnotesController.prototype.CheckPosInSelection = function(X, Y, PageAbs, Nea ...@@ -2154,8 +2207,7 @@ CFootnotesController.prototype.CheckPosInSelection = function(X, Y, PageAbs, Nea
if (oResult) if (oResult)
{ {
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); return oFootnote.Selection_Check(X, Y, oResult.FootnotePageIndex, NearPos);
return oFootnote.Selection_Check(X, Y, PageRel, NearPos);
} }
return false; return false;
...@@ -2234,8 +2286,7 @@ CFootnotesController.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseE ...@@ -2234,8 +2286,7 @@ CFootnotesController.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseE
if (oResult) if (oResult)
{ {
var oFootnote = oResult.Footnote; var oFootnote = oResult.Footnote;
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); oFootnote.Update_CursorType(X, Y, oResult.FootnotePageIndex, MouseEvent);
oFootnote.Update_CursorType(X, Y, PageRel, MouseEvent);
} }
}; };
CFootnotesController.prototype.PasteFormatting = function(TextPr, ParaPr) CFootnotesController.prototype.PasteFormatting = function(TextPr, ParaPr)
...@@ -2824,6 +2875,9 @@ function CFootEndnotePageColumn() ...@@ -2824,6 +2875,9 @@ function CFootEndnotePageColumn()
this.YLimit = 0; this.YLimit = 0;
this.Elements = []; this.Elements = [];
this.Continue = false;
this.ContinuePrev = false;
this.SeparatorRecalculateObject = null; this.SeparatorRecalculateObject = null;
this.ContinuationSeparatorRecalculateObject = null; this.ContinuationSeparatorRecalculateObject = null;
...@@ -2837,6 +2891,9 @@ CFootEndnotePageColumn.prototype.Reset = function() ...@@ -2837,6 +2891,9 @@ CFootEndnotePageColumn.prototype.Reset = function()
this.YLimit = 0; this.YLimit = 0;
this.Elements = []; this.Elements = [];
this.Continue = false;
this.ContinuePrev = false;
this.SeparatorRecalculateObject = null; this.SeparatorRecalculateObject = null;
this.ContinuationSeparatorRecalculateObject = null; this.ContinuationSeparatorRecalculateObject = null;
......
...@@ -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.Parent.Footnotes.AddFootnoteToPage(nPageAbs, nColumnAbs, oFootnote, 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