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
7a3689de
Commit
7a3689de
authored
Oct 24, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new class CFieldInstructionParser to parse complex fields instruction.
parent
403c18ad
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
308 additions
and
28 deletions
+308
-28
build/configs/webexcel.json
build/configs/webexcel.json
+1
-0
build/configs/webpowerpoint.json
build/configs/webpowerpoint.json
+1
-0
build/configs/webword.json
build/configs/webword.json
+1
-0
word/Editor/Document.js
word/Editor/Document.js
+47
-21
word/Editor/Field.js
word/Editor/Field.js
+0
-7
word/Editor/Paragraph/ComplexField.js
word/Editor/Paragraph/ComplexField.js
+7
-0
word/Editor/Paragraph/ComplexFieldInstruction.js
word/Editor/Paragraph/ComplexFieldInstruction.js
+251
-0
No files found.
build/configs/webexcel.json
View file @
7a3689de
...
...
@@ -152,6 +152,7 @@
"../word/Editor/Paragraph/ParaTextPrChanges.js"
,
"../word/Editor/Paragraph/ParaDrawing.js"
,
"../word/Editor/Paragraph/ParaDrawingChanges.js"
,
"../word/Editor/Paragraph/ComplexFieldInstruction.js"
,
"../word/Editor/Paragraph/ComplexField.js"
,
"../word/Editor/Hyperlink.js"
,
"../word/Editor/HyperlinkChanges.js"
,
...
...
build/configs/webpowerpoint.json
View file @
7a3689de
...
...
@@ -148,6 +148,7 @@
"../word/Editor/Paragraph/ParaTextPrChanges.js"
,
"../word/Editor/Paragraph/ParaDrawing.js"
,
"../word/Editor/Paragraph/ParaDrawingChanges.js"
,
"../word/Editor/Paragraph/ComplexFieldInstruction.js"
,
"../word/Editor/Paragraph/ComplexField.js"
,
"../word/Editor/Hyperlink.js"
,
"../word/Editor/HyperlinkChanges.js"
,
...
...
build/configs/webword.json
View file @
7a3689de
...
...
@@ -122,6 +122,7 @@
"../word/Editor/Paragraph/ParaTextPrChanges.js"
,
"../word/Editor/Paragraph/ParaDrawing.js"
,
"../word/Editor/Paragraph/ParaDrawingChanges.js"
,
"../word/Editor/Paragraph/ComplexFieldInstruction.js"
,
"../word/Editor/Paragraph/ComplexField.js"
,
"../word/Editor/Hyperlink.js"
,
"../word/Editor/HyperlinkChanges.js"
,
...
...
word/Editor/Document.js
View file @
7a3689de
...
...
@@ -6976,6 +6976,14 @@ CDocument.prototype.OnKeyDown = function(e)
bRetValue
=
keydownresult_PreventAll
;
}
else
if
(
e
.
KeyCode
===
114
&&
true
===
e
.
CtrlKey
)
{
this
.
Create_NewHistoryPoint
();
this
.
AddField
(
fieldtype_PAGEREF
);
this
.
Recalculate
();
bRetValue
=
keydownresult_PreventAll
;
}
else
if
(
e
.
KeyCode
==
121
&&
true
===
e
.
ShiftKey
)
// Shift + F10 - контекстное меню
{
var
X_abs
,
Y_abs
,
oPosition
,
ConvertedPos
;
...
...
@@ -15659,28 +15667,46 @@ 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_TOC
,
oPr
));
oRun
.
Add_ToContent
(
2
,
new
ParaFieldChar
(
fldchartype_Separate
,
this
));
oRun
.
Add_ToContent
(
3
,
new
ParaText
(
"
T
"
));
oRun
.
Add_ToContent
(
4
,
new
ParaText
(
"
a
"
));
oRun
.
Add_ToContent
(
5
,
new
ParaText
(
"
b
"
));
oRun
.
Add_ToContent
(
6
,
new
ParaText
(
"
l
"
));
oRun
.
Add_ToContent
(
7
,
new
ParaText
(
"
e
"
));
oRun
.
Add_ToContent
(
8
,
new
ParaSpace
());
oRun
.
Add_ToContent
(
9
,
new
ParaText
(
"
o
"
));
oRun
.
Add_ToContent
(
10
,
new
ParaText
(
"
f
"
));
oRun
.
Add_ToContent
(
11
,
new
ParaSpace
());
oRun
.
Add_ToContent
(
12
,
new
ParaText
(
"
C
"
));
oRun
.
Add_ToContent
(
13
,
new
ParaText
(
"
o
"
));
oRun
.
Add_ToContent
(
14
,
new
ParaText
(
"
n
"
));
oRun
.
Add_ToContent
(
15
,
new
ParaText
(
"
t
"
));
oRun
.
Add_ToContent
(
16
,
new
ParaText
(
"
e
"
));
oRun
.
Add_ToContent
(
17
,
new
ParaText
(
"
n
"
));
oRun
.
Add_ToContent
(
18
,
new
ParaText
(
"
t
"
));
oRun
.
Add_ToContent
(
19
,
new
ParaText
(
"
s
"
));
oRun
.
Add_ToContent
(
20
,
new
ParaFieldChar
(
fldchartype_End
,
this
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaFieldChar
(
fldchartype_Begin
,
this
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
fieldtype_TOC
,
oPr
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaFieldChar
(
fldchartype_Separate
,
this
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
T
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
a
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
b
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
l
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
e
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaSpace
());
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
o
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
f
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaSpace
());
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
C
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
o
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
n
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
t
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
e
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
n
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
t
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaText
(
"
s
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaFieldChar
(
fldchartype_End
,
this
));
oParagraph
.
Add
(
oRun
);
return
true
;
}
else
if
(
fieldtype_PAGEREF
===
nType
)
{
var
oParagraph
=
this
.
GetCurrentParagraph
();
if
(
!
oParagraph
)
return
false
;
var
nIndex
=
-
1
;
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
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
;
}
...
...
word/Editor/Field.js
View file @
7a3689de
...
...
@@ -35,13 +35,6 @@
// Import
var
History
=
AscCommon
.
History
;
var
fieldtype_UNKNOWN
=
0x0000
;
var
fieldtype_MERGEFIELD
=
0x0001
;
var
fieldtype_PAGENUM
=
0x0002
;
var
fieldtype_PAGECOUNT
=
0x0003
;
var
fieldtype_FORMTEXT
=
0x0004
;
var
fieldtype_TOC
=
0x0005
;
/**
*
* @param FieldType
...
...
word/Editor/Paragraph/ComplexField.js
View file @
7a3689de
...
...
@@ -259,7 +259,14 @@ CComplexField.prototype.Update = function()
this
.
LogicDocument
.
Insert_Content
(
oSelectedContent
,
oNearPos
);
this
.
LogicDocument
.
Recalculate
();
}
else
if
(
fieldtype_PAGEREF
===
nFieldCode
)
{
this
.
LogicDocument
.
Create_NewHistoryPoint
();
this
.
LogicDocument
.
GetBookmarksManager
();
this
.
LogicDocument
.
Recalculate
();
}
};
CComplexField
.
prototype
.
private_SelectFieldValue
=
function
()
...
...
word/Editor/Paragraph/ComplexFieldInstruction.js
0 → 100644
View file @
7a3689de
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"
use strict
"
;
/**
* User: Ilja.Kirillov
* Date: 20.10.2017
* Time: 15:46
*/
var
fieldtype_UNKNOWN
=
0x0000
;
var
fieldtype_MERGEFIELD
=
0x0001
;
var
fieldtype_PAGENUM
=
0x0002
;
var
fieldtype_PAGE
=
fieldtype_PAGENUM
;
var
fieldtype_PAGECOUNT
=
0x0003
;
var
fieldtype_FORMTEXT
=
0x0004
;
var
fieldtype_TOC
=
0x0005
;
var
fieldtype_PAGEREF
=
0x0006
;
/**
* Базовый класс для инструкции сложного поля.
* @constructor
*/
function
CFieldInstructionBase
()
{
}
CFieldInstructionBase
.
prototype
.
Type
=
fieldtype_UNKNOWN
;
CFieldInstructionBase
.
prototype
.
GetFieldCode
=
function
()
{
return
this
.
FieldCode
;
};
/**
* PAGE field
* @constructor
*/
function
CFieldInstructionPAGE
()
{
CFieldInstructionBase
.
call
(
this
);
}
CFieldInstructionPAGE
.
prototype
=
Object
.
create
(
CFieldInstructionBase
.
prototype
);
CFieldInstructionPAGE
.
prototype
.
constructor
=
CFieldInstructionPAGE
;
CFieldInstructionPAGE
.
prototype
.
Type
=
fieldtype_PAGE
;
/**
* PAGEREF field
* @constructor
*/
function
CFieldInstructionPAGEREF
(
sBookmarkName
,
isHyperlink
,
isPositionRelative
)
{
CFieldInstructionBase
.
call
(
this
);
this
.
BookmarkName
=
sBookmarkName
?
sBookmarkName
:
""
;
this
.
Hyperlink
=
isHyperlink
?
true
:
false
;
this
.
PosRelative
=
isPositionRelative
?
true
:
false
;
}
CFieldInstructionPAGEREF
.
prototype
=
Object
.
create
(
CFieldInstructionBase
.
prototype
);
CFieldInstructionPAGEREF
.
prototype
.
constructor
=
CFieldInstructionPAGEREF
;
CFieldInstructionPAGEREF
.
prototype
.
Type
=
fieldtype_PAGEREF
;
CFieldInstructionPAGEREF
.
prototype
.
SetHyperlink
=
function
(
isHyperlink
)
{
this
.
Hyperlink
=
isHyperlink
?
true
:
false
;
};
CFieldInstructionPAGEREF
.
prototype
.
SetPositionRelative
=
function
(
isPosRel
)
{
this
.
PosRelative
=
isPosRel
?
true
:
false
;
};
CFieldInstructionPAGEREF
.
prototype
.
IsHyperlink
=
function
()
{
return
this
.
Hyperlink
;
};
CFieldInstructionPAGEREF
.
prototype
.
IsPositionRelative
=
function
()
{
return
this
.
PosRelative
;
};
CFieldInstructionPAGEREF
.
prototype
.
GetBookmarkName
=
function
()
{
return
this
.
BookmarkName
;
};
/**
* TOC field
* @constructor
*/
function
CFieldInstructionTOC
()
{
CFieldInstructionBase
.
call
(
this
);
}
CFieldInstructionTOC
.
prototype
=
Object
.
create
(
CFieldInstructionBase
.
prototype
);
CFieldInstructionTOC
.
prototype
.
constructor
=
CFieldInstructionTOC
;
CFieldInstructionTOC
.
prototype
.
Type
=
fieldtype_PAGEREF
;
/**
* Класс для разбора строки с инструкцией
* @constructor
*/
function
CFieldInstructionParser
()
{
this
.
Line
=
""
;
this
.
Pos
=
0
;
this
.
Buffer
=
""
;
this
.
Result
=
null
;
}
CFieldInstructionParser
.
prototype
.
GetInstructionClass
=
function
(
sLine
)
{
this
.
Line
=
sLine
;
this
.
Pos
=
0
;
this
.
Buffer
=
""
;
this
.
Result
=
null
;
this
.
private_Parse
();
return
this
.
Result
;
};
CFieldInstructionParser
.
prototype
.
private_Parse
=
function
()
{
if
(
!
this
.
private_ReadNext
())
return
;
switch
(
this
.
Buffer
.
toUpperCase
())
{
case
"
PAGE
"
:
this
.
private_ReadPAGE
();
break
;
case
"
PAGEREF
"
:
this
.
private_ReadPAGEREF
();
break
;
case
"
TOC
"
:
this
.
private_ReadTOC
();
break
;
}
};
CFieldInstructionParser
.
prototype
.
private_ReadNext
=
function
()
{
var
nLen
=
this
.
Line
.
length
,
bWord
=
false
;
this
.
Buffer
=
""
;
while
(
this
.
Pos
<
nLen
)
{
var
nCharCode
=
this
.
Line
.
charCodeAt
(
this
.
Pos
);
if
(
32
===
nCharCode
||
9
===
nCharCode
)
{
if
(
bWord
)
return
true
;
}
else
{
this
.
Buffer
+=
this
.
Line
.
charAt
(
this
.
Pos
);
bWord
=
true
;
}
this
.
Pos
++
;
}
if
(
bWord
)
return
true
;
return
false
;
};
CFieldInstructionParser
.
prototype
.
private_IsSwitch
=
function
()
{
return
this
.
Buffer
.
charAt
(
0
)
===
'
\\
'
;
};
CFieldInstructionParser
.
prototype
.
private_ReadGeneralFormatSwitch
=
function
()
{
if
(
!
this
.
private_IsSwitch
()
||
this
.
Buffer
.
charAt
(
1
)
!==
'
*
'
)
return
;
if
(
!
this
.
private_ReadNext
()
||
this
.
private_IsSwitch
())
return
;
// TODO: Тут надо прочитать поле
console
.
log
(
"
General switch:
"
+
this
.
Buffer
);
};
CFieldInstructionParser
.
prototype
.
private_ReadPAGE
=
function
()
{
this
.
Result
=
new
CFieldInstructionPAGE
();
// Zero or more general-formatting-switches
while
(
this
.
private_ReadNext
())
{
if
(
this
.
private_IsSwitch
())
this
.
private_ReadGeneralFormatSwitch
();
}
};
CFieldInstructionParser
.
prototype
.
private_ReadPAGEREF
=
function
()
{
var
sBookmarkName
=
null
;
var
isHyperlink
=
false
,
isPageRel
=
false
;
var
isSwitch
=
false
,
isBookmark
=
false
;
while
(
this
.
private_ReadNext
())
{
if
(
this
.
private_IsSwitch
())
{
isSwitch
=
true
;
if
(
'
p
'
===
this
.
Buffer
.
charAt
(
1
))
isPageRel
=
true
;
else
if
(
'
h
'
===
this
.
Buffer
.
charAt
(
1
))
isHyperlink
=
true
;
}
else
if
(
!
isSwitch
&&
!
isBookmark
)
{
sBookmarkName
=
this
.
Buffer
;
isBookmark
=
true
;
}
}
this
.
Result
=
new
CFieldInstructionPAGEREF
(
sBookmarkName
,
isHyperlink
,
isPageRel
);
};
CFieldInstructionParser
.
prototype
.
private_ReadTOC
=
function
()
{
// TODO: Реализовать
this
.
Result
=
new
CFieldInstructionTOC
();
};
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