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
be268e1d
Commit
be268e1d
authored
May 30, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various embeddings of the content classes of the paragraph in others have been worked out.
parent
1a8664ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
271 deletions
+129
-271
word/Editor/Field.js
word/Editor/Field.js
+27
-86
word/Editor/Hyperlink.js
word/Editor/Hyperlink.js
+27
-102
word/Editor/Paragraph.js
word/Editor/Paragraph.js
+2
-0
word/Editor/ParagraphContentBase.js
word/Editor/ParagraphContentBase.js
+70
-1
word/Editor/StructuredDocumentTags/InlineLevel.js
word/Editor/StructuredDocumentTags/InlineLevel.js
+3
-82
No files found.
word/Editor/Field.js
View file @
be268e1d
...
@@ -123,92 +123,33 @@ ParaField.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition)
...
@@ -123,92 +123,33 @@ ParaField.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition)
};
};
ParaField
.
prototype
.
Add
=
function
(
Item
)
ParaField
.
prototype
.
Add
=
function
(
Item
)
{
{
switch
(
Item
.
Type
)
if
(
para_Field
===
Item
.
Type
)
{
{
case
para_Run
:
// Вместо добавления самого элемента добавляем его содержимое
case
para_Hyperlink
:
var
Count
=
Item
.
Content
.
length
;
{
var
TextPr
=
this
.
Get_FirstTextPr
();
if
(
Count
>
0
)
Item
.
SelectAll
();
{
Item
.
Apply_TextPr
(
TextPr
);
var
CurPos
=
this
.
State
.
ContentPos
;
Item
.
RemoveSelection
();
var
CurItem
=
this
.
Content
[
CurPos
];
var
CurPos
=
this
.
State
.
ContentPos
;
var
CurContentPos
=
new
CParagraphContentPos
();
var
CurItem
=
this
.
Content
[
CurPos
];
CurItem
.
Get_ParaContentPos
(
false
,
false
,
CurContentPos
);
if
(
para_Run
===
CurItem
.
Type
)
{
var
NewItem
=
CurItem
.
Split
(
CurContentPos
,
0
);
var
NewRun
=
CurItem
.
Split2
(
CurItem
.
State
.
ContentPos
);
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
this
.
Add_ToContent
(
CurPos
+
1
,
Item
);
{
this
.
Add_ToContent
(
CurPos
+
2
,
NewRun
);
this
.
Add_ToContent
(
CurPos
+
Index
+
1
,
Item
.
Content
[
Index
],
false
);
}
this
.
State
.
ContentPos
=
CurPos
+
2
;
this
.
Add_ToContent
(
CurPos
+
Count
+
1
,
NewItem
,
false
);
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToStartPos
();
this
.
State
.
ContentPos
=
CurPos
+
Count
;
}
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
();
else
}
CurItem
.
Add
(
Item
);
}
else
break
;
{
}
CParagraphContentWithParagraphLikeContent
.
prototype
.
Add
.
apply
(
this
,
arguments
);
case
para_Math
:
}
{
var
ContentPos
=
new
CParagraphContentPos
();
this
.
Get_ParaContentPos
(
false
,
false
,
ContentPos
);
var
CurPos
=
ContentPos
.
Get
(
0
);
// Ран формула делит на части, а в остальные элементы добавляется целиком
if
(
para_Run
===
this
.
Content
[
CurPos
].
Type
)
{
// Разделяем текущий элемент (возвращается правая часть)
var
NewElement
=
this
.
Content
[
CurPos
].
Split
(
ContentPos
,
1
);
if
(
null
!==
NewElement
)
this
.
Add_ToContent
(
CurPos
+
1
,
NewElement
,
true
);
var
Elem
=
new
ParaMath
();
Elem
.
Root
.
Load_FromMenu
(
Item
.
Menu
,
this
.
Get_Paragraph
());
Elem
.
Root
.
Correct_Content
(
true
);
this
.
Add_ToContent
(
CurPos
+
1
,
Elem
,
true
);
// Перемещаем кусор в конец формулы
this
.
State
.
ContentPos
=
CurPos
+
1
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
(
false
);
}
else
this
.
Content
[
CurPos
].
Add
(
Item
);
break
;
}
case
para_Field
:
{
// Вместо добавления самого элемента добавляем его содержимое
var
Count
=
Item
.
Content
.
length
;
if
(
Count
>
0
)
{
var
CurPos
=
this
.
State
.
ContentPos
;
var
CurItem
=
this
.
Content
[
CurPos
];
var
CurContentPos
=
new
CParagraphContentPos
();
CurItem
.
Get_ParaContentPos
(
false
,
false
,
CurContentPos
);
var
NewItem
=
CurItem
.
Split
(
CurContentPos
,
0
);
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
this
.
Add_ToContent
(
CurPos
+
Index
+
1
,
Item
.
Content
[
Index
],
false
);
}
this
.
Add_ToContent
(
CurPos
+
Count
+
1
,
NewItem
,
false
);
this
.
State
.
ContentPos
=
CurPos
+
Count
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
();
}
break
;
}
default
:
{
this
.
Content
[
this
.
State
.
ContentPos
].
Add
(
Item
);
break
;
}
}
};
};
ParaField
.
prototype
.
Split
=
function
(
ContentPos
,
Depth
)
ParaField
.
prototype
.
Split
=
function
(
ContentPos
,
Depth
)
{
{
...
...
word/Editor/Hyperlink.js
View file @
be268e1d
...
@@ -108,108 +108,33 @@ ParaHyperlink.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition
...
@@ -108,108 +108,33 @@ ParaHyperlink.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition
ParaHyperlink
.
prototype
.
Add
=
function
(
Item
)
ParaHyperlink
.
prototype
.
Add
=
function
(
Item
)
{
{
switch
(
Item
.
Type
)
if
(
para_Hyperlink
===
Item
.
Type
)
{
{
case
para_Run
:
// Вместо добавления самого элемента добавляем его содержимое
case
para_Field
:
var
Count
=
Item
.
Content
.
length
;
case
para_InlineLevelSdt
:
{
if
(
Count
>
0
)
var
TextPr
=
this
.
Get_FirstTextPr
();
{
Item
.
SelectAll
();
var
CurPos
=
this
.
State
.
ContentPos
;
Item
.
Apply_TextPr
(
TextPr
);
var
CurItem
=
this
.
Content
[
CurPos
];
Item
.
RemoveSelection
();
var
CurContentPos
=
new
CParagraphContentPos
();
var
CurPos
=
this
.
State
.
ContentPos
;
CurItem
.
Get_ParaContentPos
(
false
,
false
,
CurContentPos
);
var
CurItem
=
this
.
Content
[
CurPos
];
if
(
para_Run
===
CurItem
.
Type
||
para_Math
===
CurItem
.
Type
)
var
NewItem
=
CurItem
.
Split
(
CurContentPos
,
0
);
{
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
var
ContentPos
=
new
CParagraphContentPos
();
{
this
.
Content
[
CurPos
].
Get_ParaContentPos
(
false
,
false
,
ContentPos
);
this
.
Add_ToContent
(
CurPos
+
Index
+
1
,
Item
.
Content
[
Index
],
false
);
}
// Разделяем текущий элемент (возвращается правая часть)
this
.
Add_ToContent
(
CurPos
+
Count
+
1
,
NewItem
,
false
);
var
NewElement
=
this
.
Content
[
CurPos
].
Split
(
ContentPos
,
0
);
this
.
State
.
ContentPos
=
CurPos
+
Count
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
();
if
(
null
!==
NewElement
)
}
this
.
Add_ToContent
(
CurPos
+
1
,
NewElement
);
}
else
this
.
Add_ToContent
(
CurPos
+
1
,
Item
);
{
CParagraphContentWithParagraphLikeContent
.
prototype
.
Add
.
apply
(
this
,
arguments
);
if
(
para_Field
===
Item
.
Type
)
}
{
this
.
State
.
ContentPos
=
CurPos
+
2
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToStartPos
(
false
);
}
else
{
this
.
State
.
ContentPos
=
CurPos
+
1
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
(
false
);
}
}
else
CurItem
.
Add
(
Item
);
break
;
}
case
para_Math
:
{
var
ContentPos
=
new
CParagraphContentPos
();
this
.
Get_ParaContentPos
(
false
,
false
,
ContentPos
);
var
CurPos
=
ContentPos
.
Get
(
0
);
// Ран формула делит на части, а в остальные элементы добавляется целиком
if
(
para_Run
===
this
.
Content
[
CurPos
].
Type
)
{
// Разделяем текущий элемент (возвращается правая часть)
var
NewElement
=
this
.
Content
[
CurPos
].
Split
(
ContentPos
,
1
);
if
(
null
!==
NewElement
)
this
.
Add_ToContent
(
CurPos
+
1
,
NewElement
,
true
);
var
Elem
=
new
ParaMath
();
Elem
.
Root
.
Load_FromMenu
(
Item
.
Menu
,
this
.
Get_Paragraph
());
Elem
.
Root
.
Correct_Content
(
true
);
this
.
Add_ToContent
(
CurPos
+
1
,
Elem
,
true
);
// Перемещаем кусор в конец формулы
this
.
State
.
ContentPos
=
CurPos
+
1
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
(
false
);
}
else
this
.
Content
[
CurPos
].
Add
(
Item
);
break
;
}
case
para_Hyperlink
:
{
// Вместо добавления самого элемента добавляем его содержимое
var
Count
=
Item
.
Content
.
length
;
if
(
Count
>
0
)
{
var
CurPos
=
this
.
State
.
ContentPos
;
var
CurItem
=
this
.
Content
[
CurPos
];
var
CurContentPos
=
new
CParagraphContentPos
();
CurItem
.
Get_ParaContentPos
(
false
,
false
,
CurContentPos
);
var
NewItem
=
CurItem
.
Split
(
CurContentPos
,
0
);
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
this
.
Add_ToContent
(
CurPos
+
Index
+
1
,
Item
.
Content
[
Index
],
false
);
}
this
.
Add_ToContent
(
CurPos
+
Count
+
1
,
NewItem
,
false
);
this
.
State
.
ContentPos
=
CurPos
+
Count
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
();
}
break
;
}
default
:
{
this
.
Content
[
this
.
State
.
ContentPos
].
Add
(
Item
);
break
;
}
}
};
};
ParaHyperlink
.
prototype
.
Clear_TextPr
=
function
()
ParaHyperlink
.
prototype
.
Clear_TextPr
=
function
()
...
...
word/Editor/Paragraph.js
View file @
be268e1d
...
@@ -3074,6 +3074,7 @@ Paragraph.prototype.Add = function(Item)
...
@@ -3074,6 +3074,7 @@ Paragraph.prototype.Add = function(Item)
}
}
case
para_Field
:
case
para_Field
:
case
para_InlineLevelSdt
:
case
para_InlineLevelSdt
:
case
para_Hyperlink
:
{
{
var
ContentPos
=
this
.
Get_ParaContentPos
(
false
,
false
);
var
ContentPos
=
this
.
Get_ParaContentPos
(
false
,
false
);
var
CurPos
=
ContentPos
.
Get
(
0
);
var
CurPos
=
ContentPos
.
Get
(
0
);
...
@@ -12057,6 +12058,7 @@ Paragraph.prototype.AddContentControl = function(nContentControlType)
...
@@ -12057,6 +12058,7 @@ Paragraph.prototype.AddContentControl = function(nContentControlType)
var
oContentControl
=
new
CInlineLevelSdt
();
var
oContentControl
=
new
CInlineLevelSdt
();
oContentControl
.
Add_ToContent
(
0
,
new
ParaRun
());
oContentControl
.
Add_ToContent
(
0
,
new
ParaRun
());
this
.
Add
(
oContentControl
);
this
.
Add
(
oContentControl
);
oContentControl
.
MoveCursorToStartPos
();
return
oContentControl
;
return
oContentControl
;
};
};
...
...
word/Editor/ParagraphContentBase.js
View file @
be268e1d
...
@@ -2763,7 +2763,76 @@ CParagraphContentWithParagraphLikeContent.prototype.GetSelectedContentControls =
...
@@ -2763,7 +2763,76 @@ CParagraphContentWithParagraphLikeContent.prototype.GetSelectedContentControls =
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
// Функции, которые должны быть реализованы в классах наследниках
// Функции, которые должны быть реализованы в классах наследниках
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
CParagraphContentWithParagraphLikeContent
.
prototype
.
Add
=
function
(
Item
){};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Add
=
function
(
Item
)
{
switch
(
Item
.
Type
)
{
case
para_Run
:
case
para_Hyperlink
:
case
para_InlineLevelSdt
:
case
para_Field
:
{
var
TextPr
=
this
.
Get_FirstTextPr
();
Item
.
SelectAll
();
Item
.
Apply_TextPr
(
TextPr
);
Item
.
RemoveSelection
();
var
CurPos
=
this
.
State
.
ContentPos
;
var
CurItem
=
this
.
Content
[
CurPos
];
if
(
para_Run
===
CurItem
.
Type
)
{
var
NewRun
=
CurItem
.
Split2
(
CurItem
.
State
.
ContentPos
);
this
.
Add_ToContent
(
CurPos
+
1
,
Item
);
this
.
Add_ToContent
(
CurPos
+
2
,
NewRun
);
this
.
State
.
ContentPos
=
CurPos
+
2
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToStartPos
();
}
else
{
CurItem
.
Add
(
Item
);
}
break
;
}
case
para_Math
:
{
var
ContentPos
=
new
CParagraphContentPos
();
this
.
Get_ParaContentPos
(
false
,
false
,
ContentPos
);
var
CurPos
=
ContentPos
.
Get
(
0
);
// Ран формула делит на части, а в остальные элементы добавляется целиком
if
(
para_Run
===
this
.
Content
[
CurPos
].
Type
)
{
// Разделяем текущий элемент (возвращается правая часть)
var
NewElement
=
this
.
Content
[
CurPos
].
Split
(
ContentPos
,
1
);
if
(
null
!==
NewElement
)
this
.
Add_ToContent
(
CurPos
+
1
,
NewElement
,
true
);
var
Elem
=
new
ParaMath
();
Elem
.
Root
.
Load_FromMenu
(
Item
.
Menu
,
this
.
Get_Paragraph
());
Elem
.
Root
.
Correct_Content
(
true
);
this
.
Add_ToContent
(
CurPos
+
1
,
Elem
,
true
);
// Перемещаем кусор в конец формулы
this
.
State
.
ContentPos
=
CurPos
+
1
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
(
false
);
}
else
{
this
.
Content
[
CurPos
].
Add
(
Item
);
}
break
;
}
default
:
{
this
.
Content
[
this
.
State
.
ContentPos
].
Add
(
Item
);
break
;
}
}
};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Undo
=
function
(
Data
){};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Undo
=
function
(
Data
){};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Redo
=
function
(
Data
){};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Redo
=
function
(
Data
){};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Save_Changes
=
function
(
Data
,
Writer
){};
CParagraphContentWithParagraphLikeContent
.
prototype
.
Save_Changes
=
function
(
Data
,
Writer
){};
...
...
word/Editor/StructuredDocumentTags/InlineLevel.js
View file @
be268e1d
...
@@ -94,72 +94,6 @@ CInlineLevelSdt.prototype.Remove_FromContent = function(Pos, Count, UpdatePositi
...
@@ -94,72 +94,6 @@ CInlineLevelSdt.prototype.Remove_FromContent = function(Pos, Count, UpdatePositi
CParagraphContentWithParagraphLikeContent
.
prototype
.
Remove_FromContent
.
apply
(
this
,
arguments
);
CParagraphContentWithParagraphLikeContent
.
prototype
.
Remove_FromContent
.
apply
(
this
,
arguments
);
};
};
CInlineLevelSdt
.
prototype
.
Add
=
function
(
Item
)
{
switch
(
Item
.
Type
)
{
case
para_Run
:
case
para_Hyperlink
:
case
para_InlineLevelSdt
:
case
para_Field
:
{
var
TextPr
=
this
.
Get_FirstTextPr
();
Item
.
SelectAll
();
Item
.
Apply_TextPr
(
TextPr
);
Item
.
RemoveSelection
();
var
CurPos
=
this
.
State
.
ContentPos
;
var
CurItem
=
this
.
Content
[
CurPos
];
if
(
para_Run
===
CurItem
.
Type
)
{
var
NewRun
=
CurItem
.
Split2
(
CurItem
.
State
.
ContentPos
);
this
.
Add_ToContent
(
CurPos
+
1
,
Item
);
this
.
Add_ToContent
(
CurPos
+
2
,
NewRun
);
this
.
State
.
ContentPos
=
CurPos
+
2
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToStartPos
();
}
else
CurItem
.
Add
(
Item
);
break
;
}
case
para_Math
:
{
var
ContentPos
=
new
CParagraphContentPos
();
this
.
Get_ParaContentPos
(
false
,
false
,
ContentPos
);
var
CurPos
=
ContentPos
.
Get
(
0
);
// Ран формула делит на части, а в остальные элементы добавляется целиком
if
(
para_Run
===
this
.
Content
[
CurPos
].
Type
)
{
// Разделяем текущий элемент (возвращается правая часть)
var
NewElement
=
this
.
Content
[
CurPos
].
Split
(
ContentPos
,
1
);
if
(
null
!==
NewElement
)
this
.
Add_ToContent
(
CurPos
+
1
,
NewElement
,
true
);
var
Elem
=
new
ParaMath
();
Elem
.
Root
.
Load_FromMenu
(
Item
.
Menu
,
this
.
Get_Paragraph
());
Elem
.
Root
.
Correct_Content
(
true
);
this
.
Add_ToContent
(
CurPos
+
1
,
Elem
,
true
);
// Перемещаем кусор в конец формулы
this
.
State
.
ContentPos
=
CurPos
+
1
;
this
.
Content
[
this
.
State
.
ContentPos
].
MoveCursorToEndPos
(
false
);
}
else
this
.
Content
[
CurPos
].
Add
(
Item
);
break
;
}
default
:
{
this
.
Content
[
this
.
State
.
ContentPos
].
Add
(
Item
);
break
;
}
}
};
CInlineLevelSdt
.
prototype
.
Split
=
function
(
ContentPos
,
Depth
)
CInlineLevelSdt
.
prototype
.
Split
=
function
(
ContentPos
,
Depth
)
{
{
// Не даем разделять
// Не даем разделять
...
@@ -453,21 +387,10 @@ function TEST_ADD_SDT()
...
@@ -453,21 +387,10 @@ function TEST_ADD_SDT()
oLogicDocument
.
Create_NewHistoryPoint
();
oLogicDocument
.
Create_NewHistoryPoint
();
var
oRun
=
new
ParaRun
();
oRun
.
Add
(
new
ParaText
(
"
S
"
));
oRun
.
Add
(
new
ParaText
(
"
d
"
));
oRun
.
Add
(
new
ParaText
(
"
t
"
));
var
oInlineContentControl
=
oLogicDocument
.
AddContentControl
(
AscCommonWord
.
sdttype_InlineLevel
);
var
oInlineContentControl
=
oLogicDocument
.
AddContentControl
(
AscCommonWord
.
sdttype_InlineLevel
);
oInlineContentControl
.
Add
(
new
ParaText
(
"
S
"
));
// var oInlineContentControl = new CInlineLevelSdt();
oInlineContentControl
.
Add
(
new
ParaText
(
"
d
"
));
oInlineContentControl
.
Add_ToContent
(
0
,
oRun
);
oInlineContentControl
.
Add
(
new
ParaText
(
"
t
"
));
// var oPara = oLogicDocument.GetCurrentParagraph();
// oPara.Add_ToContent(0, new ParaRun());
// oPara.Add_ToContent(1, oInlineContentControl);
oLogicDocument
.
Recalculate
();
oLogicDocument
.
Recalculate
();
oLogicDocument
.
Document_UpdateSelectionState
();
oLogicDocument
.
Document_UpdateSelectionState
();
...
@@ -483,13 +406,11 @@ function TEST_ADD_SDT2()
...
@@ -483,13 +406,11 @@ function TEST_ADD_SDT2()
oLogicDocument
.
Create_NewHistoryPoint
();
oLogicDocument
.
Create_NewHistoryPoint
();
var
oSdt
=
oLogicDocument
.
AddContentControl
(
AscCommonWord
.
sdttype_BlockLevel
);
var
oSdt
=
oLogicDocument
.
AddContentControl
(
AscCommonWord
.
sdttype_BlockLevel
);
oSdt
.
AddToParagraph
(
new
ParaText
(
"
S
"
));
oSdt
.
AddToParagraph
(
new
ParaText
(
"
S
"
));
oSdt
.
AddToParagraph
(
new
ParaText
(
"
d
"
));
oSdt
.
AddToParagraph
(
new
ParaText
(
"
d
"
));
oSdt
.
AddToParagraph
(
new
ParaText
(
"
t
"
));
oSdt
.
AddToParagraph
(
new
ParaText
(
"
t
"
));
oLogicDocument
.
Recalculate
();
oLogicDocument
.
Recalculate
();
oLogicDocument
.
Document_UpdateSelectionState
();
oLogicDocument
.
Document_UpdateSelectionState
();
oLogicDocument
.
Document_UpdateInterfaceState
();
oLogicDocument
.
Document_UpdateInterfaceState
();
...
...
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