Commit 872a522c authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented adding a footnote with custom mark.

parent 264d0000
......@@ -11425,7 +11425,7 @@ CDocument.prototype.GotoFootnotesOnPage = function(nPageIndex)
return true;
};
CDocument.prototype.AddFootnote = function()
CDocument.prototype.AddFootnote = function(sText)
{
var nDocPosType = this.Get_DocPosType();
if (docpostype_Content !== nDocPosType && docpostype_Footnotes !== nDocPosType)
......@@ -11442,17 +11442,43 @@ CDocument.prototype.AddFootnote = function()
var oFootnote = this.Footnotes.CreateFootnote();
var oParagraph = oFootnote.Get_ElementByIndex(0);
oParagraph.Style_Add(oStyles.GetDefaultFootnoteText());
var oRun = new ParaRun(oParagraph, false);
oRun.Set_RStyle(oStyles.GetDefaultFootnoteReference());
oRun.Add_ToContent(0, new ParaFootnoteRef(oFootnote));
oParagraph.Add_ToContent(0, oRun);
oRun = new ParaRun(oParagraph, false);
oRun.Add_ToContent(0, new ParaSpace());
oParagraph.Add_ToContent(1, oRun);
oFootnote.Cursor_MoveToEndPos(false);
this.Paragraph_Add(new ParaFootnoteReference(oFootnote));
if (sText)
{
oParagraph.Style_Add(oStyles.GetDefaultFootnoteText());
var oRun = new ParaRun(oParagraph, false);
oRun.Set_RStyle(oStyles.GetDefaultFootnoteReference());
for (var nIndex = 0, nLen = sText.length; nIndex < nLen; ++nIndex)
{
var nChar = sText.charAt(nIndex);
if (" " === nChar)
oRun.Add_ToContent(nIndex, new ParaSpace(), true);
else
oRun.Add_ToContent(nIndex, new ParaText(nChar), true);
}
oParagraph.Add_ToContent(0, oRun);
oRun = new ParaRun(oParagraph, false);
oRun.Add_ToContent(0, new ParaSpace());
oParagraph.Add_ToContent(1, oRun);
oFootnote.Cursor_MoveToEndPos(false);
this.Paragraph_Add(new ParaFootnoteReference(oFootnote, true, sText));
}
else
{
oParagraph.Style_Add(oStyles.GetDefaultFootnoteText());
var oRun = new ParaRun(oParagraph, false);
oRun.Set_RStyle(oStyles.GetDefaultFootnoteReference());
oRun.Add_ToContent(0, new ParaFootnoteRef(oFootnote));
oParagraph.Add_ToContent(0, oRun);
oRun = new ParaRun(oParagraph, false);
oRun.Add_ToContent(0, new ParaSpace());
oParagraph.Add_ToContent(1, oRun);
oFootnote.Cursor_MoveToEndPos(false);
this.Paragraph_Add(new ParaFootnoteReference(oFootnote));
}
this.Set_DocPosType(docpostype_Footnotes);
this.Footnotes.Set_CurrentElement(true, 0, oFootnote);
......
......@@ -7567,13 +7567,15 @@ ParaPresentationNumbering.prototype =
* Класс представляющий ссылку на сноску.
* @param {CFootEndnote} Footnote - Ссылка на сноску.
* @param {string} CustomMark
* @param {string?} CustomText
* @constructor
* @extends {CRunElementBase}
*/
function ParaFootnoteReference(Footnote, CustomMark)
function ParaFootnoteReference(Footnote, CustomMark, CustomText)
{
this.Footnote = Footnote;
this.CustomMark = CustomMark ? CustomMark : undefined;
this.CustomText = CustomText ? CustomText : undefined;
this.Width = 0;
this.WidthVisible = 0;
......@@ -7748,6 +7750,10 @@ ParaFootnoteReference.prototype.IsCustomMarkFollows = function()
{
return (true === this.CustomMark ? true : false);
};
ParaFootnoteReference.prototype.GetCustomText = function()
{
return this.CustomText;
};
/**
* Класс представляющий номер сноски внутри сноски.
......
......@@ -444,7 +444,7 @@ ParaRun.prototype.Add = function(Item, bMath)
if (para_Run === PrevElement.Type && DstReviewType === PrevElement.Get_ReviewType() && true === this.Pr.Is_Equal(PrevElement.Pr) && PrevElement.ReviewInfo && true === PrevElement.ReviewInfo.Is_CurrentUser())
{
PrevElement.State.ContentPos = PrevElement.Content.length;
PrevElement.Add_ToContent(PrevElement.Content.length, Item, true);
PrevElement.private_AddItemToRun(PrevElement.Content.length, Item);
PrevElement.Make_ThisElementCurrent();
return;
}
......@@ -456,7 +456,7 @@ ParaRun.prototype.Add = function(Item, bMath)
if (para_Run === NextElement.Type && DstReviewType === NextElement.Get_ReviewType() && true === this.Pr.Is_Equal(NextElement.Pr) && NextElement.ReviewInfo && true === NextElement.ReviewInfo.Is_CurrentUser())
{
NextElement.State.ContentPos = 0;
NextElement.Add_ToContent(0, Item, true);
NextElement.private_AddItemToRun(0, Item);
NextElement.Make_ThisElementCurrent();
return;
}
......@@ -466,7 +466,7 @@ ParaRun.prototype.Add = function(Item, bMath)
var NewRun = new ParaRun(this.Paragraph, bMath);
NewRun.Set_Pr(this.Pr.Copy());
NewRun.Set_ReviewType(DstReviewType);
NewRun.Add_ToContent(0, Item, true);
NewRun.private_AddItemToRun(0, Item);
if (0 === CurPos)
Parent.Add_ToContent(RunPos, NewRun);
......@@ -492,7 +492,7 @@ ParaRun.prototype.Add = function(Item, bMath)
{
var NewRun = new ParaRun(this.Paragraph, bMath);
NewRun.Set_Pr(this.Pr.Copy());
NewRun.Add_ToContent(0, Item, true);
NewRun.private_AddItemToRun(0, Item);
// Ищем данный элемент в родительском классе
var RunPos = this.private_GetPosInParent(this.Parent);
......@@ -500,7 +500,9 @@ ParaRun.prototype.Add = function(Item, bMath)
this.Parent.Internal_Content_Add(RunPos, NewRun, true);
}
else
this.Add_ToContent(this.State.ContentPos, Item, true);
{
this.private_AddItemToRun(this.State.ContentPos, Item);
}
};
ParaRun.prototype.private_SplitRunInCurPos = function()
......@@ -550,6 +552,29 @@ ParaRun.prototype.private_IsCurPosNearFootnoteReference = function()
return false;
};
ParaRun.prototype.private_AddItemToRun = function(nPos, Item)
{
if (para_FootnoteReference === Item.Type && true === Item.IsCustomMarkFollows() && undefined !== Item.GetCustomText())
{
this.Add_ToContent(nPos, Item, true);
var sCustomText = Item.GetCustomText();
for (var nIndex = 0, nLen = sCustomText.length; nIndex < nLen; ++nIndex)
{
var nChar = sCustomText.charAt(nIndex);
if (" " === nChar)
this.Add_ToContent(nPos + 1 + nIndex, new ParaSpace(), true);
else
this.Add_ToContent(nPos + 1 + nIndex, new ParaText(nChar), true);
}
}
else
{
this.Add_ToContent(nPos, Item, true);
}
};
ParaRun.prototype.Remove = function(Direction, bOnAddText)
{
......
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