Commit bbbf26f1 authored by Ilya Kirillov's avatar Ilya Kirillov

Added hotkeys for testing the work with complex fields.

parent 4b3aa0dd
......@@ -6934,6 +6934,25 @@ CDocument.prototype.OnKeyDown = function(e)
bUpdateSelection = false;
bRetValue = keydownresult_PreventAll;
}
else if (e.KeyCode === 112 && true === e.CtrlKey)
{
// TODO: Добавлено для теста
this.Create_NewHistoryPoint();
this.AddField(fieldtype_PAGENUM);
this.Recalculate();
bRetValue = keydownresult_PreventAll;
}
else if (e.KeyCode === 113 && true === e.CtrlKey)
{
// TODO: Добавлено для теста
var arrFields = this.GetComplexFieldsByContentPos(this.GetContentPosition(false));
if (arrFields && arrFields.length > 0)
this.UpdateComplexField(arrFields[arrFields.length - 1]);
bRetValue = keydownresult_PreventAll;
}
else if (e.KeyCode == 121 && true === e.ShiftKey) // Shift + F10 - контекстное меню
{
var X_abs, Y_abs, oPosition, ConvertedPos;
......@@ -15565,11 +15584,11 @@ CDocument.prototype.AddField = function(nType, oPr)
return false;
var oRun = new ParaRun();
oRun.Add_ToContent(0, new ParaFieldChar(fldchartype_Begin));
oRun.Add_ToContent(0, new ParaFieldChar(fldchartype_Begin, this));
oRun.Add_ToContent(1, new ParaInstrText(fieldtype_PAGENUM, oPr));
oRun.Add_ToContent(2, new ParaFieldChar(fldchartype_Separate));
oRun.Add_ToContent(2, new ParaFieldChar(fldchartype_Separate, this));
oRun.Add_ToContent(3, new ParaText("1"));
oRun.Add_ToContent(4, new ParaFieldChar(fldchartype_End));
oRun.Add_ToContent(4, new ParaFieldChar(fldchartype_End, this));
oParagraph.Add(oRun);
return true;
}
......@@ -15616,21 +15635,10 @@ CDocument.prototype.GetComplexFieldsByContentPos = function(oDocPos)
return [];
var arrComplexFields = oCurrentParagraph.GetCurrentComplexFields();
console.log(arrComplexFields);
this.SetContentPosition(oCurrentDocPos, 0, 0);
};
function TEST_ADDFIELD()
{
var oDocument = editor.WordControl.m_oLogicDocument;
oDocument.Create_NewHistoryPoint();
oDocument.AddField(fieldtype_PAGENUM);
oDocument.Recalculate();
}
return arrComplexFields;
};
function CDocumentSelectionState()
{
......
......@@ -12308,14 +12308,17 @@ Paragraph.prototype.AddContentControl = function(nContentControlType)
};
Paragraph.prototype.GetCurrentComplexFields = function()
{
var oInfo = this.GetEndInfoByPage(-1);
var arrComplexFields = [];
for (var nIndex = 0, nCount = oInfo.ComplexFields.length; nIndex < nCount; ++nIndex)
var oInfo = this.GetEndInfoByPage(-1);
if (oInfo)
{
var oComplexField = oInfo.ComplexFields[nIndex].ComplexField;
if (oComplexField.IsUse())
arrComplexFields.push(oComplexField);
for (var nIndex = 0, nCount = oInfo.ComplexFields.length; nIndex < nCount; ++nIndex)
{
var oComplexField = oInfo.ComplexFields[nIndex].ComplexField;
if (oComplexField.IsUse())
arrComplexFields.push(oComplexField);
}
}
var nEndPos = Math.min(this.CurPos.ContentPos, this.Content.length - 1);
......
......@@ -41,14 +41,15 @@ var fldchartype_Begin = 0;
var fldchartype_Separate = 1;
var fldchartype_End = 2;
function ParaFieldChar(Type)
function ParaFieldChar(Type, LogicDocument)
{
CRunElementBase.call(this);
this.Use = true;
this.CharType = undefined === Type ? fldchartype_Begin : Type;
this.ComplexField = (this.CharType === fldchartype_Begin) ? new CComplexField() : null;
this.Run = null;
this.LogicDocument = LogicDocument;
this.Use = true;
this.CharType = undefined === Type ? fldchartype_Begin : Type;
this.ComplexField = (this.CharType === fldchartype_Begin) ? new CComplexField(LogicDocument) : null;
this.Run = null;
}
ParaFieldChar.prototype = Object.create(CRunElementBase.prototype);
ParaFieldChar.prototype.constructor = ParaFieldChar;
......@@ -98,6 +99,9 @@ ParaFieldChar.prototype.Read_FromBinary = function(Reader)
{
// Long : CharType
this.CharType = Reader.GetLong();
this.LogicDocument = editor.WordControl.m_oLogicDocument;
this.ComplexField = (this.CharType === fldchartype_Begin) ? new CComplexField(this.LogicDocument) : null;
};
ParaFieldChar.prototype.SetRun = function(oRun)
{
......
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