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
9c89ef15
Commit
9c89ef15
authored
Sep 26, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented moving the cursor through complex fields with left/right arrows.
parent
49473f06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
19 deletions
+177
-19
word/Editor/Paragraph.js
word/Editor/Paragraph.js
+107
-11
word/Editor/ParagraphContentBase.js
word/Editor/ParagraphContentBase.js
+2
-2
word/Editor/Run.js
word/Editor/Run.js
+68
-6
No files found.
word/Editor/Paragraph.js
View file @
9c89ef15
...
...
@@ -4446,6 +4446,8 @@ Paragraph.prototype.Get_PageStartPos = function(CurPage)
};
Paragraph
.
prototype
.
Get_LeftPos
=
function
(
SearchPos
,
ContentPos
)
{
SearchPos
.
InitComplexFields
(
this
.
GetComplexFieldsByPos
(
ContentPos
,
true
));
var
Depth
=
0
;
var
CurPos
=
ContentPos
.
Get
(
Depth
);
...
...
@@ -4481,6 +4483,8 @@ Paragraph.prototype.Get_LeftPos = function(SearchPos, ContentPos)
};
Paragraph
.
prototype
.
Get_RightPos
=
function
(
SearchPos
,
ContentPos
,
StepEnd
)
{
SearchPos
.
InitComplexFields
(
this
.
GetComplexFieldsByPos
(
ContentPos
,
true
));
var
Depth
=
0
;
var
CurPos
=
ContentPos
.
Get
(
Depth
);
...
...
@@ -4517,6 +4521,8 @@ Paragraph.prototype.Get_RightPos = function(SearchPos, ContentPos, StepEnd)
};
Paragraph
.
prototype
.
Get_WordStartPos
=
function
(
SearchPos
,
ContentPos
)
{
SearchPos
.
InitComplexFields
(
this
.
GetComplexFieldsByPos
(
ContentPos
,
true
));
var
Depth
=
0
;
var
CurPos
=
ContentPos
.
Get
(
Depth
);
...
...
@@ -4552,6 +4558,8 @@ Paragraph.prototype.Get_WordStartPos = function(SearchPos, ContentPos)
};
Paragraph
.
prototype
.
Get_WordEndPos
=
function
(
SearchPos
,
ContentPos
,
StepEnd
)
{
SearchPos
.
InitComplexFields
(
this
.
GetComplexFieldsByPos
(
ContentPos
,
true
));
var
Depth
=
0
;
var
CurPos
=
ContentPos
.
Get
(
Depth
);
...
...
@@ -12306,7 +12314,7 @@ Paragraph.prototype.AddContentControl = function(nContentControlType)
return
oContentControl
;
}
};
Paragraph
.
prototype
.
GetCurrentComplexFields
=
function
()
Paragraph
.
prototype
.
GetCurrentComplexFields
=
function
(
bReturnFieldPos
)
{
var
arrComplexFields
=
[];
...
...
@@ -12317,7 +12325,12 @@ Paragraph.prototype.GetCurrentComplexFields = function()
{
var
oComplexField
=
oInfo
.
ComplexFields
[
nIndex
].
ComplexField
;
if
(
oComplexField
.
IsUse
())
arrComplexFields
.
push
(
oComplexField
);
{
if
(
bReturnFieldPos
)
arrComplexFields
.
push
(
oInfo
.
ComplexFields
[
nIndex
]);
else
arrComplexFields
.
push
(
oComplexField
);
}
}
}
...
...
@@ -12325,11 +12338,19 @@ Paragraph.prototype.GetCurrentComplexFields = function()
for
(
var
nIndex
=
0
;
nIndex
<=
nEndPos
;
++
nIndex
)
{
if
(
this
.
Content
[
nIndex
].
GetCurrentComplexFields
)
this
.
Content
[
nIndex
].
GetCurrentComplexFields
(
arrComplexFields
,
nIndex
===
nEndPos
);
this
.
Content
[
nIndex
].
GetCurrentComplexFields
(
arrComplexFields
,
nIndex
===
nEndPos
,
bReturnFieldPos
);
}
return
arrComplexFields
;
};
Paragraph
.
prototype
.
GetComplexFieldsByPos
=
function
(
oParaPos
,
bReturnFieldPos
)
{
var
oCurrentPos
=
this
.
Get_ParaContentPos
(
false
);
this
.
Set_ParaContentPos
(
oParaPos
,
false
,
-
1
,
-
1
,
false
);
var
arrComplexFields
=
this
.
GetCurrentComplexFields
(
bReturnFieldPos
);
this
.
Set_ParaContentPos
(
oCurrentPos
,
false
,
-
1
,
-
1
,
false
);
return
arrComplexFields
;
};
var
pararecalc_0_All
=
0
;
var
pararecalc_0_None
=
1
;
...
...
@@ -13121,7 +13142,7 @@ function CParagraphSearchPos()
this
.
CheckAnchors
=
false
;
this
.
C
heckComplexFields
=
false
;
this
.
C
omplexFields
=
[]
;
}
CParagraphSearchPos
.
prototype
.
SetCheckAnchors
=
function
(
bCheck
)
{
...
...
@@ -13131,25 +13152,100 @@ CParagraphSearchPos.prototype.IsCheckAnchors = function()
{
return
this
.
CheckAnchors
;
};
CParagraphSearchPos
.
prototype
.
SetCheckComplexFields
=
function
(
isCheck
)
CParagraphSearchPos
.
prototype
.
ProcessComplexFieldChar
=
function
(
nDirection
,
oFieldChar
)
{
this
.
CheckComplexFields
=
isCheck
;
if
(
!
oFieldChar
||
!
oFieldChar
.
IsUse
())
return
;
if
(
nDirection
>
0
)
{
var
oComplexField
=
oFieldChar
.
GetComplexField
();
if
(
oFieldChar
.
IsBegin
())
{
this
.
ComplexFields
.
push
(
new
CComplexFieldStatePos
(
oComplexField
,
true
));
}
else
if
(
oFieldChar
.
IsSeparate
())
{
for
(
var
nIndex
=
0
,
nCount
=
this
.
ComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
if
(
oComplexField
===
this
.
ComplexFields
[
nIndex
].
ComplexField
)
{
this
.
ComplexFields
[
nIndex
].
SetFieldCode
(
false
);
break
;
}
}
}
else
if
(
oFieldChar
.
IsEnd
())
{
for
(
var
nIndex
=
0
,
nCount
=
this
.
ComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
if
(
oComplexField
===
this
.
ComplexFields
[
nIndex
].
ComplexField
)
{
this
.
ComplexFields
.
splice
(
nIndex
,
1
);
break
;
}
}
}
}
else
{
var
oComplexField
=
oFieldChar
.
GetComplexField
();
if
(
oFieldChar
.
IsEnd
())
{
this
.
ComplexFields
.
push
(
new
CComplexFieldStatePos
(
oComplexField
,
false
));
}
else
if
(
oFieldChar
.
IsSeparate
())
{
for
(
var
nIndex
=
0
,
nCount
=
this
.
ComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
if
(
oComplexField
===
this
.
ComplexFields
[
nIndex
].
ComplexField
)
{
this
.
ComplexFields
[
nIndex
].
SetFieldCode
(
true
);
break
;
}
}
}
else
if
(
oFieldChar
.
IsBegin
())
{
for
(
var
nIndex
=
0
,
nCount
=
this
.
ComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
if
(
oComplexField
===
this
.
ComplexFields
[
nIndex
].
ComplexField
)
{
this
.
ComplexFields
.
splice
(
nIndex
,
1
);
break
;
}
}
}
}
};
CParagraphSearchPos
.
prototype
.
I
sCheckComplexFields
=
function
(
)
CParagraphSearchPos
.
prototype
.
I
nitComplexFields
=
function
(
arrComplexFields
)
{
return
this
.
Check
ComplexFields
;
this
.
ComplexFields
=
arr
ComplexFields
;
};
CParagraphSearchPos
.
prototype
.
ProcessComplexFieldChar
=
function
(
nDirection
,
oChar
)
CParagraphSearchPos
.
prototype
.
IsComplexField
=
function
(
)
{
return
(
this
.
ComplexFields
.
length
>
0
?
true
:
false
);
};
CParagraphSearchPos
.
prototype
.
IsComplexFieldCode
=
function
()
{
if
(
!
this
.
IsComplexField
())
return
false
;
for
(
var
nIndex
=
0
,
nCount
=
this
.
ComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
if
(
this
.
ComplexFields
[
nIndex
].
IsFieldCode
())
return
true
;
}
return
false
;
};
CParagraphSearchPos
.
prototype
.
IsComplexFieldValue
=
function
()
{
return
false
;
if
(
!
this
.
IsComplexField
()
||
this
.
IsComplexFieldCode
())
return
false
;
return
true
;
};
function
CParagraphSearchPosXY
()
...
...
word/Editor/ParagraphContentBase.js
View file @
9c89ef15
...
...
@@ -2966,13 +2966,13 @@ CParagraphContentWithParagraphLikeContent.prototype.PreDelete = function()
this
.
Content
[
nIndex
].
PreDelete
();
}
};
CParagraphContentWithParagraphLikeContent
.
prototype
.
GetCurrentComplexFields
=
function
(
arrComplexFields
,
isCurrent
)
CParagraphContentWithParagraphLikeContent
.
prototype
.
GetCurrentComplexFields
=
function
(
arrComplexFields
,
isCurrent
,
isFieldPos
)
{
var
nEndPos
=
isCurrent
?
this
.
State
.
ContentPos
:
this
.
Content
.
length
-
1
;
for
(
var
nIndex
=
0
;
nIndex
<=
nEndPos
;
++
nIndex
)
{
if
(
this
.
Content
[
nIndex
]
&&
this
.
Content
[
nIndex
].
GetCurrentComplexFields
)
this
.
Content
[
nIndex
].
GetCurrentComplexFields
(
arrComplexFields
,
isCurrent
&&
nIndex
===
nEndPos
);
this
.
Content
[
nIndex
].
GetCurrentComplexFields
(
arrComplexFields
,
isCurrent
&&
nIndex
===
nEndPos
,
isFieldPos
);
}
};
//----------------------------------------------------------------------------------------------------------------------
...
...
word/Editor/Run.js
View file @
9c89ef15
...
...
@@ -5527,12 +5527,25 @@ ParaRun.prototype.Get_LeftPos = function(SearchPos, ContentPos, Depth, UseConten
{
var
CurPos
=
true
===
UseContentPos
?
ContentPos
.
Get
(
Depth
)
:
this
.
Content
.
length
;
var
isFieldCode
=
SearchPos
.
IsComplexFieldCode
();
var
isFieldValue
=
SearchPos
.
IsComplexFieldValue
();
while
(
true
)
{
CurPos
--
;
var
Item
=
this
.
Content
[
CurPos
];
if
(
CurPos
>=
0
&&
para_FieldChar
===
Item
.
Type
)
{
SearchPos
.
ProcessComplexFieldChar
(
-
1
,
Item
);
isFieldCode
=
SearchPos
.
IsComplexFieldCode
();
isFieldValue
=
SearchPos
.
IsComplexFieldValue
();
}
if
(
CurPos
>=
0
&&
isFieldCode
)
continue
;
if
(
CurPos
<
0
||
(
!
(
para_Drawing
===
Item
.
Type
&&
false
===
Item
.
Is_Inline
()
&&
false
===
SearchPos
.
IsCheckAnchors
())
&&
!
(
para_FootnoteReference
===
Item
.
Type
&&
true
===
Item
.
IsCustomMarkFollows
())))
break
;
}
...
...
@@ -5548,6 +5561,9 @@ ParaRun.prototype.Get_RightPos = function(SearchPos, ContentPos, Depth, UseConte
{
var
CurPos
=
(
true
===
UseContentPos
?
ContentPos
.
Get
(
Depth
)
:
0
);
var
isFieldCode
=
SearchPos
.
IsComplexFieldCode
();
var
isFieldValue
=
SearchPos
.
IsComplexFieldValue
();
var
Count
=
this
.
Content
.
length
;
while
(
true
)
{
...
...
@@ -5563,6 +5579,17 @@ ParaRun.prototype.Get_RightPos = function(SearchPos, ContentPos, Depth, UseConte
var
PrevItem
=
this
.
Content
[
CurPos
-
1
];
var
PrevItemType
=
PrevItem
.
Type
;
if
(
para_FieldChar
===
PrevItem
.
Type
)
{
SearchPos
.
ProcessComplexFieldChar
(
1
,
PrevItem
);
isFieldCode
=
SearchPos
.
IsComplexFieldCode
();
isFieldValue
=
SearchPos
.
IsComplexFieldValue
();
}
if
(
isFieldCode
)
return
;
if
((
true
!==
StepEnd
&&
para_End
===
PrevItemType
)
||
(
para_Drawing
===
PrevItemType
&&
false
===
PrevItem
.
Is_Inline
()
&&
false
===
SearchPos
.
IsCheckAnchors
())
||
(
para_FootnoteReference
===
PrevItemType
&&
true
===
PrevItem
.
IsCustomMarkFollows
()))
return
;
...
...
@@ -5576,6 +5603,16 @@ ParaRun.prototype.Get_RightPos = function(SearchPos, ContentPos, Depth, UseConte
var
Item
=
this
.
Content
[
CurPos
-
1
];
var
ItemType
=
Item
.
Type
;
if
(
para_FieldChar
===
Item
.
Type
)
{
SearchPos
.
ProcessComplexFieldChar
(
1
,
Item
);
isFieldCode
=
SearchPos
.
IsComplexFieldCode
();
isFieldValue
=
SearchPos
.
IsComplexFieldValue
();
}
if
(
isFieldCode
)
continue
;
if
(
!
(
true
!==
StepEnd
&&
para_End
===
ItemType
)
&&
!
(
para_Drawing
===
Item
.
Type
&&
false
===
Item
.
Is_Inline
())
&&
!
(
para_FootnoteReference
===
Item
.
Type
&&
true
===
Item
.
IsCustomMarkFollows
()))
...
...
@@ -9369,7 +9406,7 @@ ParaRun.prototype.GetLineByPosition = function(nPos)
ParaRun
.
prototype
.
PreDelete
=
function
()
{
};
ParaRun
.
prototype
.
GetCurrentComplexFields
=
function
(
arrComplexFields
,
isCurrent
)
ParaRun
.
prototype
.
GetCurrentComplexFields
=
function
(
arrComplexFields
,
isCurrent
,
isFieldPos
)
{
var
nEndPos
=
isCurrent
?
this
.
State
.
ContentPos
:
this
.
Content
.
length
;
for
(
var
nPos
=
0
;
nPos
<
nEndPos
;
++
nPos
)
...
...
@@ -9378,15 +9415,40 @@ ParaRun.prototype.GetCurrentComplexFields = function(arrComplexFields, isCurrent
if
(
oItem
.
Type
!==
para_FieldChar
)
continue
;
if
(
oItem
.
IsBegin
()
)
if
(
isFieldPos
)
{
arrComplexFields
.
push
(
oItem
.
GetComplexField
());
var
oComplexField
=
oItem
.
GetComplexField
();
if
(
oItem
.
IsBegin
())
{
arrComplexFields
.
push
(
new
CComplexFieldStatePos
(
oComplexField
,
true
));
}
else
if
(
oItem
.
IsSeparate
())
{
if
(
arrComplexFields
.
length
>
0
)
{
arrComplexFields
[
arrComplexFields
.
length
-
1
].
SetFieldCode
(
false
)
}
}
else
if
(
oItem
.
IsEnd
())
{
if
(
arrComplexFields
.
length
>
0
)
{
arrComplexFields
.
splice
(
arrComplexFields
.
length
-
1
,
1
);
}
}
}
else
if
(
oItem
.
IsEnd
())
else
{
if
(
arrComplexFields
.
length
>
0
)
if
(
oItem
.
IsBegin
()
)
{
arrComplexFields
.
splice
(
arrComplexFields
.
length
-
1
,
1
);
arrComplexFields
.
push
(
oItem
.
GetComplexField
());
}
else
if
(
oItem
.
IsEnd
())
{
if
(
arrComplexFields
.
length
>
0
)
{
arrComplexFields
.
splice
(
arrComplexFields
.
length
-
1
,
1
);
}
}
}
}
...
...
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