Commit 04a1c2e0 authored by Ilya Kirillov's avatar Ilya Kirillov

Reworked some functions in Footnotes based on columns

parent 67431313
...@@ -1053,7 +1053,8 @@ CDocumentRecalcInfo.prototype = ...@@ -1053,7 +1053,8 @@ CDocumentRecalcInfo.prototype =
Set_FootnoteReference : function(oFootnoteReference, nPageAbs, nColumnAbs) Set_FootnoteReference : function(oFootnoteReference, nPageAbs, nColumnAbs)
{ {
this.FootnoteReference = oFootnoteReference; this.FootnoteReference = oFootnoteReference;
this.FlowObjectPage = nPageAbs; this.FootnotePage = nPageAbs;
this.FootnoteColumn = nColumnAbs;
}, },
Check_FootnoteReference : function(oFootnoteReference) Check_FootnoteReference : function(oFootnoteReference)
...@@ -2867,7 +2868,7 @@ CDocument.prototype.private_RecalculateShiftFootnotes = function(nPageAbs, nColu ...@@ -2867,7 +2868,7 @@ CDocument.prototype.private_RecalculateShiftFootnotes = function(nPageAbs, nColu
{ {
var dFootnotesHeight = this.Footnotes.GetHeight(nPageAbs, nColumnAbs); var dFootnotesHeight = this.Footnotes.GetHeight(nPageAbs, nColumnAbs);
var oPageMetrics = this.Get_PageContentStartPos(nPageAbs); var oPageMetrics = this.Get_PageContentStartPos(nPageAbs);
this.Footnotes.Shift(nPageAbs, 0, oPageMetrics.YLimit - dFootnotesHeight); this.Footnotes.Shift(nPageAbs, nColumnAbs, 0, oPageMetrics.YLimit - dFootnotesHeight);
}; };
CDocument.prototype.private_RecalculateFlowTable = function(RecalcInfo) CDocument.prototype.private_RecalculateFlowTable = function(RecalcInfo)
{ {
......
...@@ -45,11 +45,13 @@ function CFootEndnote(DocumentController) ...@@ -45,11 +45,13 @@ function CFootEndnote(DocumentController)
AscCommon.extendClass(CFootEndnote, CDocumentContent); AscCommon.extendClass(CFootEndnote, CDocumentContent);
CFootEndnote.prototype.GetRelaitivePageIndex = function(PageAbs) CFootEndnote.prototype.GetRelaitivePageIndex = function(nPageAbs, nColumnAbs)
{ {
// TODO: Переделать с учетом колонок
var StartPageAbs = this.Get_StartPage_Absolute(); var StartPageAbs = this.Get_StartPage_Absolute();
var PagesCount = this.Get_PagesCount(); var PagesCount = this.Get_PagesCount();
return Math.max(0, Math.min(PagesCount - 1, PageAbs - StartPageAbs)); return Math.max(0, Math.min(PagesCount - 1, nPageAbs - StartPageAbs));
}; };
CFootEndnote.prototype.Write_ToBinary2 = function(Writer) CFootEndnote.prototype.Write_ToBinary2 = function(Writer)
{ {
......
...@@ -254,25 +254,27 @@ CFootnotesController.prototype.Draw = function(nPageAbs, pGraphics) ...@@ -254,25 +254,27 @@ CFootnotesController.prototype.Draw = function(nPageAbs, pGraphics)
}; };
/** /**
* Сдвигаем все рассчитанные позиции на заданной странице. * Сдвигаем все рассчитанные позиции на заданной странице.
* @param {number} nPageIndex * @param {number} nPageAbs
* @param {number} nColumnAbs
* @param {number} dX * @param {number} dX
* @param {number} dY * @param {number} dY
*/ */
CFootnotesController.prototype.Shift = function(nPageIndex, dX, dY) CFootnotesController.prototype.Shift = function(nPageAbs, nColumnAbs, dX, dY)
{ {
if (true === this.Is_EmptyPage(nPageIndex)) var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
if (!oColumn)
return; return;
if (null !== this.SeparatorFootnote && null !== this.Pages[nPageIndex].SeparatorRecalculateObject) if (null !== this.SeparatorFootnote && null !== oColumn.SeparatorRecalculateObject)
{ {
this.SeparatorFootnote.Load_RecalculateObject(this.Pages[nPageIndex].SeparatorRecalculateObject); this.SeparatorFootnote.Load_RecalculateObject(oColumn.SeparatorRecalculateObject);
this.SeparatorFootnote.Shift(0, dX, dY); this.SeparatorFootnote.Shift(0, dX, dY);
this.Pages[nPageIndex].SeparatorRecalculateObject = this.SeparatorFootnote.Save_RecalculateObject(); oColumn.SeparatorRecalculateObject = this.SeparatorFootnote.Save_RecalculateObject();
} }
for (var nIndex = 0; nIndex < this.Pages[nPageIndex].Elements.length; ++nIndex) for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{ {
var Footnote = this.Pages[nPageIndex].Elements[nIndex]; var Footnote = oColumn.Elements[nIndex];
Footnote.Shift(0, dX, dY); Footnote.Shift(0, dX, dY);
} }
}; };
...@@ -293,6 +295,7 @@ CFootnotesController.prototype.AddFootnoteToPage = function(nPageAbs, nColumnAbs ...@@ -293,6 +295,7 @@ CFootnotesController.prototype.AddFootnoteToPage = function(nPageAbs, nColumnAbs
/** /**
* Убираем заданную сноску со страницы при пересчетею.. * Убираем заданную сноску со страницы при пересчетею..
* @param {number} nPageAbs * @param {number} nPageAbs
* @param {number} nColumnAbs
* @param {CFootEndnote} oFootnote * @param {CFootEndnote} oFootnote
*/ */
CFootnotesController.prototype.RemoveFootnoteFromPage = function(nPageAbs, nColumnAbs, oFootnote) CFootnotesController.prototype.RemoveFootnoteFromPage = function(nPageAbs, nColumnAbs, oFootnote)
...@@ -374,7 +377,7 @@ CFootnotesController.prototype.OnContentReDraw = function(StartPageAbs, EndPageA ...@@ -374,7 +377,7 @@ CFootnotesController.prototype.OnContentReDraw = function(StartPageAbs, EndPageA
* @param {number} nPageIndex * @param {number} nPageIndex
* @returns {boolean} * @returns {boolean}
*/ */
CFootnotesController.prototype.Is_EmptyPage = function(nPageIndex) CFootnotesController.prototype.IsEmptyPage = function(nPageIndex)
{ {
var oPage = this.Pages[nPageIndex]; var oPage = this.Pages[nPageIndex];
if (!oPage) if (!oPage)
...@@ -469,25 +472,44 @@ CFootnotesController.prototype.GetNearestPos = function(X, Y, PageAbs, bAnchor, ...@@ -469,25 +472,44 @@ CFootnotesController.prototype.GetNearestPos = function(X, Y, PageAbs, bAnchor,
* Проверяем попадание в сноски на заданной странице. * Проверяем попадание в сноски на заданной странице.
* @param X * @param X
* @param Y * @param Y
* @param PageAbs * @param nPageAbs
* @returns {boolean} * @returns {boolean}
*/ */
CFootnotesController.prototype.CheckHitInFootnote = function(X, Y, PageAbs) CFootnotesController.prototype.CheckHitInFootnote = function(X, Y, nPageAbs)
{ {
if (true === this.Is_EmptyPage(PageAbs)) if (true === this.IsEmptyPage(nPageAbs))
return false; return false;
var Page = this.Pages[PageAbs]; var oPage = this.Pages[nPageAbs];
for (var nIndex = 0; nIndex < Page.Elements.length; ++nIndex) var oColumn = null;
for (var nColumnIndex = 0, nColumnsCount = oPage.Columns.length; nColumnIndex < nColumnsCount; ++nColumnIndex)
{ {
var Footnote = Page.Elements[nIndex]; if (nColumnIndex < nColumnsCount - 1)
var Bounds = Footnote.Get_PageBounds(0); {
if (X < (oPage.Columns[nColumnIndex].XLimit + oPage.Columns[nColumnIndex + 1].X) / 2)
{
oColumn = oPage.Columns[nColumnIndex];
break;
}
}
else
{
oColumn = oPage.Columns[nColumnIndex];
}
}
if (!oColumn)
return false;
for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{
var oFootnote = oColumn.Elements[nIndex];
var oBounds = oFootnote.Get_PageBounds(0);
if (Bounds.Top <= Y) if (oBounds.Top <= Y)
return true; return true;
} }
return false; return false;
}; };
CFootnotesController.prototype.GetAllParagraphs = function(Props, ParaArray) CFootnotesController.prototype.GetAllParagraphs = function(Props, ParaArray)
...@@ -724,33 +746,54 @@ CFootnotesController.prototype.private_GetPageColumn = function(nPageAbs, nColum ...@@ -724,33 +746,54 @@ CFootnotesController.prototype.private_GetPageColumn = function(nPageAbs, nColum
if (!oPage) if (!oPage)
return null; return null;
var oColumn = oPage.Columns[nColumnAbs] var oColumn = oPage.Columns[nColumnAbs];
if (!oColumn) if (!oColumn)
return null; return null;
return oColumn; return oColumn;
}; };
CFootnotesController.prototype.private_GetFootnoteOnPageByXY = function(X, Y, PageAbs) CFootnotesController.prototype.private_GetFootnoteOnPageByXY = function(X, Y, nPageAbs)
{ {
if (true === this.Is_EmptyPage(PageAbs)) if (true === this.IsEmptyPage(nPageAbs))
return null; return null;
var Page = this.Pages[PageAbs]; var oPage = this.Pages[nPageAbs];
for (var nIndex = Page.Elements.length - 1; nIndex >= 0; --nIndex) var oColumn = null;
var nColumnIndex = 0;
for (var nColumnsCount = oPage.Columns.length; nColumnIndex < nColumnsCount; ++nColumnIndex)
{ {
var Footnote = Page.Elements[nIndex]; if (nColumnIndex < nColumnsCount - 1)
var Bounds = Footnote.Get_PageBounds(0); {
if (X < (oPage.Columns[nColumnIndex].XLimit + oPage.Columns[nColumnIndex + 1].X) / 2)
{
oColumn = oPage.Columns[nColumnIndex];
break;
}
}
else
{
oColumn = oPage.Columns[nColumnIndex];
break;
}
}
if (!oColumn)
return null;
if (Bounds.Top <= Y || 0 === nIndex) for (var nIndex = oColumn.Elements.length - 1; nIndex >= 0; --nIndex)
{
var oFootnote = oColumn.Elements[nIndex];
var oBounds = oFootnote.Get_PageBounds(0);
if (oBounds.Top <= Y || 0 === nIndex)
return { return {
Footnote : Footnote, Footnote : oFootnote,
Index : nIndex, Index : nIndex,
Page : PageAbs Page : nPageAbs,
Column : nColumnIndex
}; };
} }
return null; return null;
}; };
CFootnotesController.prototype.private_GetFootnoteByXY = function(X, Y, PageAbs) CFootnotesController.prototype.private_GetFootnoteByXY = function(X, Y, PageAbs)
...@@ -783,8 +826,8 @@ CFootnotesController.prototype.private_GetFootnoteByXY = function(X, Y, PageAbs) ...@@ -783,8 +826,8 @@ CFootnotesController.prototype.private_GetFootnoteByXY = function(X, Y, PageAbs)
}; };
CFootnotesController.prototype.private_GetFootnotesRange = function(Start, End) CFootnotesController.prototype.private_GetFootnotesRange = function(Start, End)
{ {
var oResult = []; var oResult = {};
if (Start.Page > End.Page) if (Start.Page > End.Page || (Start.Page === End.Page && Start.Column > End.Column) || (Start.Page === End.Page && Start.Column === End.Column && Start.Index > End.Index))
{ {
var Temp = Start; var Temp = Start;
Start = End; Start = End;
...@@ -793,33 +836,52 @@ CFootnotesController.prototype.private_GetFootnotesRange = function(Start, End) ...@@ -793,33 +836,52 @@ CFootnotesController.prototype.private_GetFootnotesRange = function(Start, End)
if (Start.Page === End.Page) if (Start.Page === End.Page)
{ {
if (Start.Index <= End.Index) this.private_GetFootnotesOnPage(Start.Page, Start.Column, End.Column, Start.Index, End.Index, oResult);
this.private_GetFootnotesOnPage(Start.Page, Start.Index, End.Index, oResult);
else
this.private_GetFootnotesOnPage(Start.Page, End.Index, Start.Index, oResult);
} }
else else
{ {
this.private_GetFootnotesOnPage(Start.Page, Start.Index, -1, oResult); this.private_GetFootnotesOnPage(Start.Page, Start.Column, -1, Start.Index, -1, oResult);
for (var CurPage = Start.Page + 1; CurPage <= End.Page - 1; ++CurPage) for (var CurPage = Start.Page + 1; CurPage <= End.Page - 1; ++CurPage)
{ {
this.private_GetFootnotesOnPage(CurPage, -1, -1, oResult); this.private_GetFootnotesOnPage(CurPage, -1, -1, -1, -1, oResult);
} }
this.private_GetFootnotesOnPage(End.Page, -1, End.Index, oResult); this.private_GetFootnotesOnPage(End.Page, -1, End.Column, -1, End.Index, oResult);
} }
return oResult; return oResult;
}; };
CFootnotesController.prototype.private_GetFootnotesOnPage = function(PageAbs, StartIndex, EndIndex, oFootnotes) CFootnotesController.prototype.private_GetFootnotesOnPage = function(nPageAbs, nColumnStart, nColumnEnd, nStartIndex, nEndIndex, oFootnotes)
{
var oPage = this.Pages[nPageAbs];
if (!oPage)
return;
var _nColumnStart = -1 === nColumnStart ? 0 : nColumnStart;
var _nColumnEnd = -1 === nColumnEnd ? oPage.Columns.length - 1 : nColumnEnd;
var _nStartIndex = -1 === nColumnStart || -1 === nStartIndex ? 0 : nStartIndex;
var _nEndIndex = -1 === nColumnEnd || -1 === nEndIndex ? oPage.Columns[_nColumnEnd].Elements.length - 1 : nEndIndex;
for (var nColIndex = _nColumnStart; nColIndex <= _nColumnEnd; ++nColIndex)
{
var nSIndex = nColIndex === _nColumnStart ? _nStartIndex : 0;
var nEIndex = nColIndex === _nColumnEnd ? _nEndIndex : oPage.Columns[nColIndex].Elements.length - 1;
this.private_GetFootnotesOnPageColumn(nPageAbs, nColIndex, nSIndex, nEIndex, oFootnotes);
}
};
CFootnotesController.prototype.private_GetFootnotesOnPageColumn = function(nPageAbs, nColumnAbs, StartIndex, EndIndex, oFootnotes)
{ {
var Page = this.Pages[PageAbs]; var oColumn = this.private_GetPageColumn(nPageAbs, nColumnAbs);
var _StartIndex = -1 === StartIndex ? 0 : StartIndex; var _StartIndex = -1 === StartIndex ? 0 : StartIndex;
var _EndIndex = -1 === EndIndex ? Page.Elements.length - 1 : EndIndex; var _EndIndex = -1 === EndIndex ? oColumn.Elements.length - 1 : EndIndex;
for (var nIndex = _StartIndex; nIndex <= _EndIndex; ++nIndex) for (var nIndex = _StartIndex; nIndex <= _EndIndex; ++nIndex)
{ {
var oFootnote = Page.Elements[nIndex]; var oFootnote = oColumn.Elements[nIndex];
oFootnotes[oFootnote.Get_Id()] = oFootnote; oFootnotes[oFootnote.Get_Id()] = oFootnote;
} }
}; };
...@@ -2016,19 +2078,23 @@ CFootnotesController.prototype.IsEmptySelection = function(bCheckHidden) ...@@ -2016,19 +2078,23 @@ CFootnotesController.prototype.IsEmptySelection = function(bCheckHidden)
return oFootnote.Selection_IsEmpty(bCheckHidden); return oFootnote.Selection_IsEmpty(bCheckHidden);
}; };
CFootnotesController.prototype.DrawSelectionOnPage = function(PageAbs) CFootnotesController.prototype.DrawSelectionOnPage = function(nPageAbs)
{ {
if (true !== this.Selection.Use || true === this.Is_EmptyPage(PageAbs)) if (true !== this.Selection.Use || true === this.IsEmptyPage(nPageAbs))
return; return;
var Page = this.Pages[PageAbs]; var oPage = this.Pages[nPageAbs];
for (var nIndex = 0, nCount = Page.Elements.length; nIndex < nCount; ++nIndex) for (var nColumnIndex = 0, nColumnsCount = oPage.Columns.length; nColumnIndex < nColumnsCount; ++nColumnIndex)
{ {
var oFootnote = Page.Elements[nIndex]; var oColumn = oPage.Columns[nColumnIndex];
for (var nIndex = 0, nCount = oColumn.Elements.length; nIndex < nCount; ++nIndex)
{
var oFootnote = oColumn.Elements[nIndex];
if (oFootnote === this.Selection.Footnotes[oFootnote.Get_Id()]) if (oFootnote === this.Selection.Footnotes[oFootnote.Get_Id()])
{ {
var PageRel = oFootnote.GetRelaitivePageIndex(PageAbs); var nPageRel = oFootnote.GetRelaitivePageIndex(nPageAbs, nColumnIndex);
oFootnote.Selection_Draw_Page(PageRel); oFootnote.Selection_Draw_Page(nPageRel);
}
} }
} }
}; };
......
...@@ -1872,7 +1872,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu ...@@ -1872,7 +1872,7 @@ Paragraph.prototype.private_RecalculateLineCheckFootnotes = function(CurLine, Cu
else else
{ {
// TODO: Реализовать // TODO: Реализовать
RecalcInfo.Set_PageBreaFlowObjectPageBreakBefore(true); RecalcInfo.Set_PageBreakBefore(true);
this.Parent.Footnotes.RemoveFootnoteFromPage(nPageAbs, nColumnAbs, 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