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