Commit 7bb23d5b authored by Ilya Kirillov's avatar Ilya Kirillov

Keeping work in complex fields.

parent 1774119b
......@@ -15503,15 +15503,12 @@ CDocument.prototype.AddField = function(nType, oPr)
if (!oParagraph)
return false;
var oField = new CComplexField();
var oRun = new ParaRun();
var oInstr = new ParaInstrText(fieldtype_PAGENUM, oPr);
oRun.Add_ToContent(0, oField.GetBeginChar());
oRun.Add_ToContent(1, oInstr);
oRun.Add_ToContent(2, oField.GetSeparateChar());
var oRun = new ParaRun();
oRun.Add_ToContent(0, new ParaFieldChar(fldchartype_Begin));
oRun.Add_ToContent(1, new ParaInstrText(fieldtype_PAGENUM, oPr));
oRun.Add_ToContent(2, new ParaFieldChar(fldchartype_Separate));
oRun.Add_ToContent(3, new ParaText("1"));
oRun.Add_ToContent(4, oField.GetEndChar());
oRun.Add_ToContent(4, new ParaFieldChar(fldchartype_End));
oParagraph.Add(oRun);
return true;
}
......@@ -15533,6 +15530,19 @@ CDocument.prototype.RegroupComplexFields = function()
this.Content[nIndex].RegroupComplexFields(oRegroupManager);
}
};
CDocument.prototype.UpdateComplexField = function(oField)
{
};
CDocument.prototype.GetCurrentComplexFields = function()
{
var oParagraph = this.GetCurrentParagraph();
if (!oParagraph)
return [];
return oParagraph.GetCurrentComplexFields();
};
function TEST_ADDFIELD()
......
......@@ -12305,6 +12305,16 @@ Paragraph.prototype.RegroupComplexFields = function(oRegroupManager)
this.Content[nIndex].RegroupComplexFields(oRegroupManager);
}
};
Paragraph.prototype.GetCurrentComplexFields = function()
{
var oParaPos = this.Get_ParaContentPos(this.Selection.Use, false, false);
if (!oParaPos)
return [];
var oRun = this.Get_ClassesByPos(oParaPos);
if (!oRun || !(oRun instanceof ParaRun))
return [];
};
var pararecalc_0_All = 0;
var pararecalc_0_None = 1;
......
......@@ -41,13 +41,13 @@ var fldchartype_Begin = 0;
var fldchartype_Separate = 1;
var fldchartype_End = 2;
function ParaFieldChar(Type, ComplexField)
function ParaFieldChar(Type)
{
CRunElementBase.call(this);
this.Use = true;
this.CharType = undefined === Type ? fldchartype_Begin : Type;
this.ComplexField = ComplexField;
this.ComplexField = null;
}
ParaFieldChar.prototype = Object.create(CRunElementBase.prototype);
ParaFieldChar.prototype.constructor = ParaFieldChar;
......@@ -134,9 +134,9 @@ ParaInstrText.prototype.GetFieldCode = function()
function CComplexField()
{
this.BeginChar = new ParaFieldChar(fldchartype_Begin, this);
this.EndChar = new ParaFieldChar(fldchartype_End, this);
this.SeparateChar = new ParaFieldChar(fldchartype_Separate, this);
this.BeginChar = null;
this.EndChar = null;
this.SeparateChar = null;
this.Instruction = "";
}
CComplexField.prototype.ResetInstruction = function()
......
......@@ -1079,6 +1079,25 @@ ParaRun.prototype.private_UpdateCompositeInputPositionsOnRemove = function(Pos,
}
};
ParaRun.prototype.GetLogicDocument = function()
{
if (this.Paragraph && this.Paragraph.LogicDocument)
return this.Paragraph.LogicDocument;
return editor.WordControl.m_oLogicDocument;
};
ParaRun.prototype.private_CheckNeedRegroupComplexFieldsOnChangeContent = function(arrItems)
{
for (var nIndex = 0, nCount = arrItems.length; nIndex < nCount; ++nIndex)
{
if (para_FieldChar === arrItems[nIndex].Type)
{
var oLogicDocument = this.GetLogicDocument();
oLogicDocument.FieldsManager.SetNeedRegroupComplexFields(true);
return;
}
}
};
// Добавляем элемент в позицию с сохранием в историю
ParaRun.prototype.Add_ToContent = function(Pos, Item, UpdatePosition)
......@@ -1089,6 +1108,8 @@ ParaRun.prototype.Add_ToContent = function(Pos, Item, UpdatePosition)
if (true === UpdatePosition)
this.private_UpdatePositionsOnAdd(Pos);
this.private_CheckNeedRegroupComplexFieldsOnChangeContent([Item]);
// Обновляем позиции в NearestPos
var NearPosLen = this.NearPosArray.length;
for ( var Index = 0; Index < NearPosLen; Index++ )
......@@ -1143,6 +1164,8 @@ ParaRun.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition)
this.Content.splice( Pos, Count );
this.private_CheckNeedRegroupComplexFieldsOnChangeContent(DeletedItems);
if (true === UpdatePosition)
this.private_UpdatePositionsOnRemove(Pos, Count);
......@@ -1209,6 +1232,8 @@ ParaRun.prototype.Concat_ToContent = function(NewItems)
// Отмечаем, что надо перемерить элементы в данном ране
this.RecalcInfo.Measure = true;
this.private_CheckNeedRegroupComplexFieldsOnChangeContent(NewItems);
};
// Определим строку и отрезок текущей позиции
......
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