Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
2bf1c058
Commit
2bf1c058
authored
Oct 25, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New variant with parsing InstrText on the client side.
parent
bf261402
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
31 deletions
+52
-31
word/Editor/Document.js
word/Editor/Document.js
+19
-7
word/Editor/Paragraph/ComplexField.js
word/Editor/Paragraph/ComplexField.js
+31
-22
word/Editor/Paragraph/ComplexFieldInstruction.js
word/Editor/Paragraph/ComplexFieldInstruction.js
+2
-2
No files found.
word/Editor/Document.js
View file @
2bf1c058
...
@@ -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
));
...
...
word/Editor/Paragraph/ComplexField.js
View file @
2bf1c058
...
@@ -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 :
FieldCod
e
// Long :
Valu
e
Writer
.
WriteLong
(
this
.
Type
);
Writer
.
WriteLong
(
this
.
Type
);
Writer
.
WriteLong
(
this
.
FieldCod
e
);
Writer
.
WriteLong
(
this
.
Valu
e
);
};
};
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
.
Instruction
Line
+=
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
;
...
...
word/Editor/Paragraph/ComplexFieldInstruction.js
View file @
2bf1c058
...
@@ -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
.
FieldCod
e
;
return
this
.
Typ
e
;
};
};
/**
/**
...
@@ -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
;
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment