Commit 2bf1c058 authored by Ilya Kirillov's avatar Ilya Kirillov

New variant with parsing InstrText on the client side.

parent bf261402
......@@ -15652,12 +15652,16 @@ CDocument.prototype.AddField = function(nType, oPr)
if (!oParagraph)
return false;
var nIndex = -1;
var oRun = new ParaRun();
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, this));
oRun.Add_ToContent(3, new ParaText("1"));
oRun.Add_ToContent(4, new ParaFieldChar(fldchartype_End, this));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Begin, this));
oRun.Add_ToContent(++nIndex, new ParaInstrText("P"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("A"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("G"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("E"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Separate, this));
oRun.Add_ToContent(++nIndex, new ParaText("1"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_End, this));
oParagraph.Add(oRun);
return true;
}
......@@ -15670,7 +15674,9 @@ CDocument.prototype.AddField = function(nType, oPr)
var nIndex = -1;
var oRun = new ParaRun();
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Begin, this));
oRun.Add_ToContent(++nIndex, new ParaInstrText(fieldtype_TOC, oPr));
oRun.Add_ToContent(++nIndex, new ParaInstrText("T"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("O"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("C"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Separate, this));
oRun.Add_ToContent(++nIndex, new ParaText("T"));
oRun.Add_ToContent(++nIndex, new ParaText("a"));
......@@ -15703,7 +15709,13 @@ CDocument.prototype.AddField = function(nType, oPr)
var oRun = new ParaRun();
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Begin, this));
oRun.Add_ToContent(++nIndex, new ParaInstrText(fieldtype_PAGEREF, oPr));
oRun.Add_ToContent(++nIndex, new ParaInstrText("P"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("A"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("G"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("E"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("R"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("E"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("F"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Separate, this));
oRun.Add_ToContent(++nIndex, new ParaText("1"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_End, this));
......
......@@ -112,12 +112,13 @@ ParaFieldChar.prototype.GetRun = function()
return this.Run;
};
function ParaInstrText(nType, nFlags)
function ParaInstrText(value)
{
CRunElementBase.call(this);
this.FieldCode = nType;
this.Flags = nFlags;
this.Value = (undefined !== value ? value.charCodeAt(0) : 0x00);
this.Width = 0x00000000 | 0;
this.WidthVisible = 0x00000000 | 0;
this.Run = null;
}
ParaInstrText.prototype = Object.create(CRunElementBase.prototype);
......@@ -132,18 +133,14 @@ ParaInstrText.prototype.Draw = function(X, Y, Context)
ParaInstrText.prototype.Write_ToBinary = function(Writer)
{
// Long : Type
// Long : FieldCode
// Long : Value
Writer.WriteLong(this.Type);
Writer.WriteLong(this.FieldCode);
Writer.WriteLong(this.Value);
};
ParaInstrText.prototype.Read_FromBinary = function(Reader)
{
// Long : FieldCode
this.FieldCode = Reader.GetLong();
};
ParaInstrText.prototype.GetFieldCode = function()
{
return this.FieldCode;
// Long : Value
this.Value = Reader.GetLong();
};
ParaInstrText.prototype.SetRun = function(oRun)
{
......@@ -153,6 +150,10 @@ ParaInstrText.prototype.GetRun = function()
{
return this.Run;
};
ParaInstrText.prototype.GetValue = function()
{
return String.fromCharCode(this.Value);
};
function CComplexField(oLogicDocument)
{
......@@ -160,12 +161,13 @@ function CComplexField(oLogicDocument)
this.BeginChar = null;
this.EndChar = null;
this.SeparateChar = null;
this.InstructionLine = "";
this.Instruction = null;
this.Id = null;
}
CComplexField.prototype.SetInstruction = function(oParaInstr)
{
this.Instruction = oParaInstr;
this.InstructionLine += oParaInstr.GetValue();
};
CComplexField.prototype.GetBeginChar = function()
{
......@@ -186,6 +188,7 @@ CComplexField.prototype.SetBeginChar = function(oChar)
this.BeginChar = oChar;
this.SeparateChar = null;
this.EndChar = null;
this.InstructionLine = "";
};
CComplexField.prototype.SetEndChar = function(oChar)
{
......@@ -202,6 +205,12 @@ CComplexField.prototype.SetSeparateChar = function(oChar)
};
CComplexField.prototype.Update = function()
{
if (!this.Instruction)
{
var oParser = new CFieldInstructionParser();
this.Instruction = oParser.GetInstructionClass(this.InstructionLine);
}
if (!this.Instruction || !this.BeginChar || !this.EndChar || !this.SeparateChar)
return;
......
......@@ -56,7 +56,7 @@ function CFieldInstructionBase()
CFieldInstructionBase.prototype.Type = fieldtype_UNKNOWN;
CFieldInstructionBase.prototype.GetFieldCode = function()
{
return this.FieldCode;
return this.Type;
};
/**
......@@ -120,7 +120,7 @@ function CFieldInstructionTOC()
CFieldInstructionTOC.prototype = Object.create(CFieldInstructionBase.prototype);
CFieldInstructionTOC.prototype.constructor = CFieldInstructionTOC;
CFieldInstructionTOC.prototype.Type = fieldtype_PAGEREF;
CFieldInstructionTOC.prototype.Type = fieldtype_TOC;
/**
......
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