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
32f04404
Commit
32f04404
authored
Aug 18, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test functions for working with complex fields.
parent
8e0bb62e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
30 deletions
+194
-30
word/Editor/Document.js
word/Editor/Document.js
+32
-0
word/Editor/Paragraph/ComplexField.js
word/Editor/Paragraph/ComplexField.js
+132
-0
word/Editor/ParagraphContent.js
word/Editor/ParagraphContent.js
+4
-0
word/Editor/Paragraph_Recalculate.js
word/Editor/Paragraph_Recalculate.js
+26
-30
No files found.
word/Editor/Document.js
View file @
32f04404
...
...
@@ -15552,6 +15552,38 @@ CDocument.prototype.IsViewModeInReview = function()
{
return
0
!==
this
.
ViewModeInReview
.
mode
?
true
:
false
;
};
CDocument
.
prototype
.
AddField
=
function
(
nType
,
oPr
)
{
if
(
fieldtype_PAGENUM
===
nType
)
{
var
oParagraph
=
this
.
GetCurrentParagraph
();
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
());
oRun
.
Add_ToContent
(
3
,
new
ParaText
(
"
1
"
));
oRun
.
Add_ToContent
(
3
,
oField
.
GetEndChar
());
oParagraph
.
Add
(
oRun
);
return
true
;
}
return
false
;
};
function
TEST_ADDFIELD
()
{
var
oDocument
=
editor
.
WordControl
.
m_oLogicDocument
;
oDocument
.
Create_NewHistoryPoint
();
oDocument
.
AddField
(
fieldtype_PAGENUM
);
oDocument
.
Recalculate
();
}
function
CDocumentSelectionState
()
{
...
...
word/Editor/Paragraph/ComplexField.js
0 → 100644
View file @
32f04404
/*
* (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: 15.08.2017
* Time: 12:52
*/
var
fldchartype_Begin
=
0
;
var
fldchartype_Separate
=
1
;
var
fldchartype_End
=
2
;
function
ParaFieldChar
(
Type
,
ComplexField
)
{
this
.
CharType
=
undefined
===
Type
?
fldchartype_Begin
:
Type
;
this
.
ComplexField
=
ComplexField
;
}
ParaFieldChar
.
prototype
=
Object
.
create
(
CRunElementBase
.
prototype
);
ParaFieldChar
.
prototype
.
constructor
=
ParaFieldChar
;
ParaFieldChar
.
prototype
.
Type
=
para_FieldChar
;
ParaFieldChar
.
prototype
.
Measure
=
function
(
Context
,
TextPr
)
{
};
ParaFieldChar
.
prototype
.
Draw
=
function
(
X
,
Y
,
Context
)
{
};
ParaFieldChar
.
prototype
.
IsBegin
=
function
()
{
return
(
this
.
CharType
===
fldchartype_Begin
?
true
:
false
);
};
ParaFieldChar
.
prototype
.
IsEnd
=
function
()
{
return
(
this
.
CharType
===
fldchartype_End
?
true
:
false
);
};
ParaFieldChar
.
prototype
.
IsSeparate
=
function
()
{
return
(
this
.
CharType
===
fldchartype_Separate
?
true
:
false
);
};
ParaFieldChar
.
prototype
.
Write_ToBinary
=
function
(
Writer
)
{
};
ParaFieldChar
.
prototype
.
Read_FromBinary
=
function
(
Reader
)
{
};
function
ParaInstrText
(
nType
,
nFlags
)
{
this
.
FieldCode
=
nType
;
this
.
Flags
=
nFlags
;
}
ParaInstrText
.
prototype
=
Object
.
create
(
CRunElementBase
.
prototype
);
ParaInstrText
.
prototype
.
constructor
=
ParaInstrText
;
ParaInstrText
.
prototype
.
Type
=
para_InstrText
;
ParaInstrText
.
prototype
.
Measure
=
function
(
Context
,
TextPr
)
{
};
ParaInstrText
.
prototype
.
Draw
=
function
(
X
,
Y
,
Context
)
{
};
ParaInstrText
.
prototype
.
Write_ToBinary
=
function
(
Writer
)
{
};
ParaInstrText
.
prototype
.
Read_FromBinary
=
function
(
Reader
)
{
};
ParaInstrText
.
prototype
.
GetFieldCode
=
function
()
{
return
this
.
FieldCode
;
};
function
CComplexField
()
{
this
.
BeginChar
=
new
ParaFieldChar
(
fldchartype_Begin
,
this
);
this
.
EndChar
=
new
ParaFieldChar
(
fldchartype_End
,
this
);
this
.
SeparateChar
=
new
ParaFieldChar
(
fldchartype_Separate
,
this
);
this
.
Instruction
=
""
;
}
CComplexField
.
prototype
.
ResetInstruction
=
function
()
{
this
.
Instruction
=
""
;
};
CComplexField
.
prototype
.
AddInstruction
=
function
(
sInstr
)
{
this
.
Instruction
+=
sInstr
;
};
CComplexField
.
prototype
.
ParseInstruction
=
function
()
{
// TODO:
};
CComplexField
.
prototype
.
GetBeginChar
=
function
()
{
return
this
.
BeginChar
;
};
CComplexField
.
prototype
.
GetEndChar
=
function
()
{
return
this
.
EndChar
;
};
CComplexField
.
prototype
.
GetSeparateChar
=
function
()
{
return
this
.
SeparateChar
;
};
\ No newline at end of file
word/Editor/ParagraphContent.js
View file @
32f04404
...
...
@@ -106,6 +106,8 @@ var para_Separator = 0x0041; // Разделить, которы
var
para_ContinuationSeparator
=
0x0042
;
// Большой разделитель, который используется для сносок
var
para_PageCount
=
0x0043
;
// Количество страниц
var
para_InlineLevelSdt
=
0x0044
;
// Внутристроковый контейнер
var
para_FieldChar
=
0x0045
;
var
para_InstrText
=
0x0046
;
var
break_Line
=
0x01
;
var
break_Page
=
0x02
;
...
...
@@ -2022,6 +2024,8 @@ function ParagraphContent_Read_FromBinary(Reader)
case
para_Separator
:
Element
=
new
ParaSeparator
();
break
;
case
para_ContinuationSeparator
:
Element
=
new
ParaContinuationSeparator
();
break
;
case
para_PageCount
:
Element
=
new
ParaPageCount
();
break
;
case
para_FieldChar
:
Element
=
new
ParaFieldChar
();
break
;
case
para_InstrText
:
Element
=
new
ParaInstrText
();
break
;
}
if
(
null
!=
Element
)
...
...
word/Editor/Paragraph_Recalculate.js
View file @
32f04404
...
...
@@ -3156,39 +3156,35 @@ function CParagraphRecalculateStateAlign()
function
CParagraphRecalculateStateInfo
()
{
this
.
Comments
=
[];
this
.
Fields
=
{};
}
CParagraphRecalculateStateInfo
.
prototype
=
CParagraphRecalculateStateInfo
.
prototype
.
Reset
=
function
(
PrevInfo
)
{
Reset
:
function
(
PrevInfo
)
{
if
(
null
!==
PrevInfo
&&
undefined
!==
PrevInfo
)
{
this
.
Comments
=
PrevInfo
.
Comments
;
}
else
{
this
.
Comments
=
[];
}
},
AddComment
:
function
(
Id
)
{
this
.
Comments
.
push
(
Id
);
},
RemoveComment
:
function
(
Id
)
{
var
CommentsLen
=
this
.
Comments
.
length
;
for
(
var
CurPos
=
0
;
CurPos
<
CommentsLen
;
CurPos
++
)
{
if
(
this
.
Comments
[
CurPos
]
===
Id
)
{
this
.
Comments
.
splice
(
CurPos
,
1
);
break
;
}
}
}
if
(
null
!==
PrevInfo
&&
undefined
!==
PrevInfo
)
{
this
.
Comments
=
PrevInfo
.
Comments
;
}
else
{
this
.
Comments
=
[];
}
};
CParagraphRecalculateStateInfo
.
prototype
.
AddComment
=
function
(
Id
)
{
this
.
Comments
.
push
(
Id
);
};
CParagraphRecalculateStateInfo
.
prototype
.
RemoveComment
=
function
(
Id
)
{
var
CommentsLen
=
this
.
Comments
.
length
;
for
(
var
CurPos
=
0
;
CurPos
<
CommentsLen
;
CurPos
++
)
{
if
(
this
.
Comments
[
CurPos
]
===
Id
)
{
this
.
Comments
.
splice
(
CurPos
,
1
);
break
;
}
}
};
function
CParagraphRecalculateObject
()
...
...
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