Commit ffe1a082 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented adding a footnote to document.

parent cbe51d70
...@@ -6503,6 +6503,15 @@ CDocument.prototype.OnKeyDown = function(e) ...@@ -6503,6 +6503,15 @@ CDocument.prototype.OnKeyDown = function(e)
bRetValue = keydownresult_PreventAll; bRetValue = keydownresult_PreventAll;
} }
} }
else if (e.KeyCode == 70 && false === editor.isViewMode && true === e.CtrlKey)
{
// TODO: Заменить хоткей для сноски, или проверить можно ли использовать Ctrl+Alt
if (true === e.AltKey)
{
this.AddFootnote();
bRetValue = keydownresult_PreventAll;
}
}
else if (e.KeyCode == 73 && false === editor.isViewMode && true === e.CtrlKey) // Ctrl + I - делаем текст наклонным else if (e.KeyCode == 73 && false === editor.isViewMode && true === e.CtrlKey) // Ctrl + I - делаем текст наклонным
{ {
var TextPr = this.Get_Paragraph_TextPr(); var TextPr = this.Get_Paragraph_TextPr();
...@@ -6630,44 +6639,6 @@ CDocument.prototype.OnKeyDown = function(e) ...@@ -6630,44 +6639,6 @@ CDocument.prototype.OnKeyDown = function(e)
bUpdateSelection = false; bUpdateSelection = false;
bRetValue = keydownresult_PreventAll; bRetValue = keydownresult_PreventAll;
} }
// --> TEST
// else if (113 === e.KeyCode)
// {
// this.History.Create_NewPoint();
// var oFootnote = this.Footnotes.Create_Footnote();
//
// oFootnote.Paragraph_Add(new ParaFootnoteRef(oFootnote));
// oFootnote.Paragraph_Add(new ParaSpace());
// oFootnote.Paragraph_Add(new ParaText("F"));
// oFootnote.Paragraph_Add(new ParaText("o"));
// oFootnote.Paragraph_Add(new ParaText("o"));
// oFootnote.Paragraph_Add(new ParaText("t"));
// oFootnote.Paragraph_Add(new ParaText("n"));
// oFootnote.Paragraph_Add(new ParaText("o"));
// oFootnote.Paragraph_Add(new ParaText("t"));
// oFootnote.Paragraph_Add(new ParaText("e"));
//
// this.Paragraph_Add(new ParaFootnoteReference(oFootnote));
// bRetValue = keydownresult_PreventAll;
// }
// else if (114 === e.KeyCode)
// {
// this.History.Create_NewPoint();
// this.Paragraph_Add(new ParaSeparator());
// bRetValue = keydownresult_PreventAll;
// }
// else if (115 === e.KeyCode)
// {
// this.History.Create_NewPoint();
// this.Paragraph_Add(new ParaContinuationSeparator());
// bRetValue = keydownresult_PreventAll;
// }
// else if (116 === e.KeyCode)
// {
// this.Goto_FootnotesOnPage(0);
// bRetValue = keydownresult_PreventAll;
// }
// TEST <--
else if (e.KeyCode == 121 && true === e.ShiftKey) // Shift + F10 - контекстное меню else if (e.KeyCode == 121 && true === e.ShiftKey) // Shift + F10 - контекстное меню
{ {
var X_abs, Y_abs, oPosition, ConvertedPos; var X_abs, Y_abs, oPosition, ConvertedPos;
...@@ -11234,6 +11205,35 @@ CDocument.prototype.Get_FootnotesList = function(oFirstFootnote, oLastFootnote) ...@@ -11234,6 +11205,35 @@ CDocument.prototype.Get_FootnotesList = function(oFirstFootnote, oLastFootnote)
return oEngine.GetRange(); return oEngine.GetRange();
}; };
CDocument.prototype.AddFootnote = function()
{
var nDocPosType = this.Get_DocPosType();
if (docpostype_Content !== nDocPosType && docpostype_Footnotes !== nDocPosType)
return;
if (false === this.Document_Is_SelectionLocked(changestype_Paragraph_Content))
{
this.History.Create_NewPoint();
var nDocPosType = this.Get_DocPosType();
if (docpostype_Content === nDocPosType)
{
var oFootnote = this.Footnotes.Create_Footnote();
oFootnote.Paragraph_Add(new ParaFootnoteRef(oFootnote));
oFootnote.Paragraph_Add(new ParaSpace());
oFootnote.Cursor_MoveToEndPos(false);
this.Paragraph_Add(new ParaFootnoteReference(oFootnote));
this.Set_DocPosType(docpostype_Footnotes);
this.Footnotes.Set_CurrentElement(true, 0, oFootnote);
}
else if (docpostype_Footnotes === nDocPosType)
{
this.Footnotes.AddFootnoteRef();
this.Recalculate();
}
}
};
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции, которые вызываются из CLogicDocumentController // Функции, которые вызываются из CLogicDocumentController
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
......
...@@ -605,6 +605,20 @@ CFootnotesController.prototype.Set_CurrentElement = function(bUpdateStates, Page ...@@ -605,6 +605,20 @@ CFootnotesController.prototype.Set_CurrentElement = function(bUpdateStates, Page
} }
} }
}; };
CFootnotesController.prototype.AddFootnoteRef = function()
{
if (true !== this.private_IsOnFootnoteSelected() || null === this.CurFootnote)
return;
var oFootnote = this.CurFootnote;
var oParagraph = oFootnote.Get_FirstParagraph();
if (!oParagraph)
return;
var oRun = new ParaRun(oParagraph, false);
oRun.Add_ToContent(0, new ParaFootnoteRef(oFootnote), false);
oParagraph.Add_ToContent(0, oRun);
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Private area // Private area
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
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