Commit bfc176f3 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented increasing reference number of footnotes on the page.

parent 8c091faa
......@@ -11307,6 +11307,10 @@ CDocument.prototype.AddFootnote = function()
}
}
};
CDocument.prototype.GetFootnotesController = function()
{
return this.Footnotes;
};
//----------------------------------------------------------------------------------------------------------------------
// Функции, которые вызываются из CLogicDocumentController
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -9777,6 +9777,10 @@ CDocumentContent.prototype.Set_LogicDocument = function(oLogicDocument)
this.Numbering = oLogicDocument.Get_Numbering();
this.DrawingObjects = oLogicDocument.DrawingObjects;
};
CDocumentContent.prototype.Get_LogicDocument = function()
{
return this.LogicDocument;
};
function CDocumentContentStartState(DocContent)
{
......
......@@ -246,6 +246,22 @@ CFootnotesController.prototype.Add_FootnoteOnPage = function(nPageIndex, oFootno
this.Pages[nPageIndex].Elements.push(oFootnote);
};
CFootnotesController.prototype.GetFootnoteNumberOnPage = function(nPageAbs, oFootnote)
{
if (!this.Pages[nPageAbs])
return 1;
if (oFootnote)
{
for (var nIndex = 0, nCount = this.Pages[nPageAbs].Elements.length; nIndex < nCount; ++nIndex)
{
if (oFootnote === this.Pages[nPageAbs].Elements[nIndex])
return nIndex + 1;
}
}
return this.Pages[nPageAbs].Elements.length;
};
/**
* Проверяем, используется заданная сноска в документе.
* @param {string} sFootnoteId
......
......@@ -7576,6 +7576,8 @@ function ParaFootnoteReference(Footnote)
this.Width = 0;
this.WidthVisible = 0;
this.Number = 1;
this.Run = null;
}
AscCommon.extendClass(ParaFootnoteReference, CRunElementBase);
ParaFootnoteReference.prototype.Type = para_FootnoteReference;
......@@ -7614,22 +7616,10 @@ ParaFootnoteReference.prototype.Draw = function(X, Y, Context, PDSE)
Context.m_oContext.setLineDash([]);
}
};
ParaFootnoteReference.prototype.Measure = function(Context, TextPr)
ParaFootnoteReference.prototype.Measure = function(Context, TextPr, MathInfo, Run)
{
Context.SetFontSlot(fontslot_ASCII, vertalign_Koef_Size);
// TODO: Пока делаем обычный вариант с типом Decimal
var X = 0;
var T = Numbering_Number_To_String(this.Number);
for (var nPos = 0; nPos < T.length; ++nPos)
{
var Char = T.charAt(nPos);
X += Context.Measure(Char).Width;
}
var ResultWidth = (Math.max((X + TextPr.Spacing), 0) * TEXTWIDTH_DIVIDER) | 0;
this.Width = ResultWidth;
this.WidthVisible = ResultWidth;
this.Run = Run;
this.private_Measure();
};
ParaFootnoteReference.prototype.Copy = function()
{
......@@ -7651,6 +7641,42 @@ ParaFootnoteReference.prototype.Get_Footnote = function()
{
return this.Footnote;
};
ParaFootnoteReference.prototype.UpdateNumber = function(PageAbs)
{
if (this.Footnote)
{
var oLogicDocument = this.Footnote.Get_LogicDocument();
var oFootnotesController = oLogicDocument.GetFootnotesController();
this.Number = oFootnotesController.GetFootnoteNumberOnPage(PageAbs, this.Footnote);
this.private_Measure();
}
};
ParaFootnoteReference.prototype.private_Measure = function()
{
if (!this.Run)
return;
var oMeasurer = g_oTextMeasurer;
var TextPr = this.Run.Get_CompiledPr(false);
var Theme = this.Run.Get_Paragraph().Get_Theme();
oMeasurer.SetTextPr(TextPr, Theme);
oMeasurer.SetFontSlot(fontslot_ASCII, vertalign_Koef_Size);
// TODO: Пока делаем обычный вариант с типом Decimal
var X = 0;
var T = Numbering_Number_To_String(this.Number);
for (var nPos = 0; nPos < T.length; ++nPos)
{
var Char = T.charAt(nPos);
X += oMeasurer.Measure(Char).Width;
}
var ResultWidth = (Math.max((X + TextPr.Spacing), 0) * TEXTWIDTH_DIVIDER) | 0;
this.Width = ResultWidth;
this.WidthVisible = ResultWidth;
};
/**
* Класс представляющий номер сноски внутри сноски.
......
......@@ -2174,7 +2174,7 @@ ParaRun.prototype.Recalculate_MeasureContent = function()
continue;
}
Item.Measure( g_oTextMeasurer, Pr, InfoMathText );
Item.Measure( g_oTextMeasurer, Pr, InfoMathText, this);
if (para_Drawing === Item.Type)
......@@ -2325,11 +2325,18 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if (para_ContinuationSeparator === ItemType)
Item.Update_Width(PRS);
if (para_FootnoteReference === ItemType)
{
Item.UpdateNumber(Para.Get_AbsolutePage(PRS.Page));
PRS.Add_FootnoteReference(Item, Pos);
}
else if (para_FootnoteRef === ItemType)
{
Item.UpdateNumber(Para.Get_AbsolutePage(PRS.Page));
}
// При проверке, убирается ли слово, мы должны учитывать ширину предшествующих пробелов.
var LetterLen = Item.Width / TEXTWIDTH_DIVIDER;//var LetterLen = Item.Get_Width();
if (para_FootnoteReference === ItemType)
PRS.Add_FootnoteReference(Item, Pos);
if (true !== Word)
{
......
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