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
976769a1
Commit
976769a1
authored
Oct 30, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented the transition to internal links through a complex field PAGEREF.
parent
239f7231
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
22 deletions
+127
-22
word/Editor/Bookmarks.js
word/Editor/Bookmarks.js
+18
-0
word/Editor/Document.js
word/Editor/Document.js
+31
-7
word/Editor/DocumentContent.js
word/Editor/DocumentContent.js
+23
-7
word/Editor/Paragraph.js
word/Editor/Paragraph.js
+39
-1
word/Editor/Paragraph/ComplexField.js
word/Editor/Paragraph/ComplexField.js
+15
-6
word/Editor/Paragraph/ComplexFieldInstruction.js
word/Editor/Paragraph/ComplexFieldInstruction.js
+1
-1
No files found.
word/Editor/Bookmarks.js
View file @
976769a1
...
...
@@ -113,6 +113,24 @@ CParagraphBookmark.prototype.GetXY = function()
{
return
{
X
:
this
.
X
,
Y
:
this
.
Y
};
};
CParagraphBookmark
.
prototype
.
GoToBookmark
=
function
()
{
var
oParagraph
=
this
.
Paragraph
;
if
(
!
oParagraph
)
return
;
var
oLogicDocument
=
oParagraph
.
LogicDocument
;
if
(
!
oLogicDocument
)
return
;
var
oCurPos
=
oParagraph
.
Get_PosByElement
(
this
);
if
(
!
oCurPos
)
return
;
oLogicDocument
.
RemoveSelection
();
oParagraph
.
Set_ParaContentPos
(
oCurPos
,
false
,
-
1
,
-
1
,
true
);
// Корректировать позицию нужно обязательно
oParagraph
.
Document_SetThisElementCurrent
(
true
);
};
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
...
...
word/Editor/Document.js
View file @
976769a1
...
...
@@ -5312,12 +5312,18 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
if
(
type_Paragraph
===
Item
.
GetType
()
&&
true
===
MouseEvent
.
CtrlKey
)
{
var
Hyperlink
=
Item
.
CheckHyperlink
(
X
,
Y
,
ElementPageIndex
);
if
(
null
!=
Hyperlink
)
var
oHyperlink
=
Item
.
CheckHyperlink
(
X
,
Y
,
ElementPageIndex
);
var
oPageRefLink
=
Item
.
CheckPageRefLink
(
X
,
Y
,
ElementPageIndex
);
if
(
null
!=
oHyperlink
)
{
this
.
Selection
.
Data
=
{
Hyperlink
:
true
,
Value
:
Hyperlink
Hyperlink
:
oHyperlink
};
}
else
if
(
null
!==
oPageRefLink
)
{
this
.
Selection
.
Data
=
{
PageRef
:
oPageRefLink
};
}
}
...
...
@@ -5471,16 +5477,26 @@ CDocument.prototype.Selection_SetEnd = function(X, Y, MouseEvent)
{
this
.
Selection
.
Use
=
false
;
if
(
null
!=
this
.
Selection
.
Data
&&
t
rue
===
t
his
.
Selection
.
Data
.
Hyperlink
)
if
(
null
!=
this
.
Selection
.
Data
&&
this
.
Selection
.
Data
.
Hyperlink
)
{
editor
.
sync_HyperlinkClickCallback
(
this
.
Selection
.
Data
.
Value
.
Get_Value
());
this
.
Selection
.
Data
.
Value
.
Set_Visited
(
true
);
editor
.
sync_HyperlinkClickCallback
(
this
.
Selection
.
Data
.
Hyperlink
.
Get_Value
());
this
.
Selection
.
Data
.
Hyperlink
.
Set_Visited
(
true
);
for
(
var
PageIdx
=
Item
.
Get_StartPage_Absolute
();
PageIdx
<
Item
.
Get_StartPage_Absolute
()
+
Item
.
Pages
.
length
;
PageIdx
++
)
this
.
DrawingDocument
.
OnRecalculatePage
(
PageIdx
,
this
.
Pages
[
PageIdx
]);
this
.
DrawingDocument
.
OnEndRecalculate
(
false
,
true
);
}
else
if
(
null
!==
this
.
Selection
.
Data
&&
this
.
Selection
.
Data
.
PageRef
)
{
var
oInstruction
=
this
.
Selection
.
Data
.
PageRef
.
GetInstruction
();
if
(
oInstruction
&&
fieldtype_PAGEREF
===
oInstruction
.
GetType
())
{
var
oBookmark
=
this
.
BookmarksManager
.
GetBookmarkByName
(
oInstruction
.
GetBookmarkName
());
if
(
oBookmark
)
oBookmark
[
0
].
GoToBookmark
();
}
}
}
else
{
...
...
@@ -15769,6 +15785,14 @@ CDocument.prototype.AddField = function(nType, oPr)
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
ParaInstrText
(
"
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
T
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
e
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
s
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
t
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
\\
"
));
oRun
.
Add_ToContent
(
++
nIndex
,
new
ParaInstrText
(
"
p
"
));
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
));
...
...
word/Editor/DocumentContent.js
View file @
976769a1
...
...
@@ -6520,12 +6520,18 @@ CDocumentContent.prototype.Selection_SetStart = function(X, Y, CurPage, MouseEve
if
(
type_Paragraph
===
Item
.
GetType
()
&&
true
===
MouseEvent
.
CtrlKey
)
{
var
Hyperlink
=
Item
.
CheckHyperlink
(
X
,
Y
,
ElementPageIndex
);
if
(
null
!=
Hyperlink
)
var
oHyperlink
=
Item
.
CheckHyperlink
(
X
,
Y
,
ElementPageIndex
);
var
oPageRefLink
=
Item
.
CheckPageRefLink
(
X
,
Y
,
ElementPageIndex
);
if
(
null
!=
oHyperlink
)
{
this
.
Selection
.
Data
=
{
Hyperlink
:
true
,
Value
:
Hyperlink
Hyperlink
:
oHyperlink
};
}
else
if
(
null
!==
oPageRefLink
)
{
this
.
Selection
.
Data
=
{
PageRef
:
oPageRefLink
};
}
}
...
...
@@ -6652,10 +6658,10 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, MouseEvent
{
this
.
Selection
.
Use
=
false
;
if
(
null
!=
this
.
Selection
.
Data
&&
t
rue
===
t
his
.
Selection
.
Data
.
Hyperlink
)
if
(
null
!=
this
.
Selection
.
Data
&&
this
.
Selection
.
Data
.
Hyperlink
)
{
editor
&&
editor
.
sync_HyperlinkClickCallback
(
this
.
Selection
.
Data
.
Value
.
Get_Value
());
this
.
Selection
.
Data
.
Value
.
Set_Visited
(
true
);
editor
&&
editor
.
sync_HyperlinkClickCallback
(
this
.
Selection
.
Data
.
Hyperlink
.
Get_Value
());
this
.
Selection
.
Data
.
Hyperlink
.
Set_Visited
(
true
);
if
(
this
.
DrawingDocument
.
m_oLogicDocument
)
{
...
...
@@ -6671,6 +6677,16 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, MouseEvent
this
.
DrawingDocument
.
OnEndRecalculate
(
false
,
true
);
}
}
else
if
(
null
!==
this
.
Selection
.
Data
&&
this
.
Selection
.
Data
.
PageRef
)
{
var
oInstruction
=
this
.
Selection
.
Data
.
PageRef
.
GetInstruction
();
if
(
oInstruction
&&
fieldtype_PAGEREF
===
oInstruction
.
GetType
())
{
var
oBookmark
=
this
.
BookmarksManager
.
GetBookmarkByName
(
oInstruction
.
GetBookmarkName
());
if
(
oBookmark
)
oBookmark
[
0
].
GoToBookmark
();
}
}
}
else
{
...
...
word/Editor/Paragraph.js
View file @
976769a1
...
...
@@ -9254,6 +9254,19 @@ Paragraph.prototype.UpdateCursorType = function(X, Y, CurPage)
var
oInfo
=
new
CSelectedElementsInfo
();
this
.
GetElementsInfoByXY
(
oInfo
,
X
,
Y
,
CurPage
);
var
bPageRefLink
=
false
;
var
arrComplexFields
=
this
.
GetComplexFieldsByXY
(
X
,
Y
,
CurPage
);
for
(
var
nIndex
=
0
,
nCount
=
arrComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
var
oComplexField
=
arrComplexFields
[
nIndex
];
var
oInstruction
=
oComplexField
.
GetInstruction
();
if
(
oInstruction
&&
fieldtype_PAGEREF
===
oInstruction
.
GetType
()
&&
oInstruction
.
IsHyperlink
())
{
bPageRefLink
=
true
;
break
;
}
}
var
oContentControl
=
oInfo
.
GetInlineLevelSdt
();
var
oHyperlink
=
oInfo
.
Get_Hyperlink
();
if
(
oContentControl
)
...
...
@@ -9275,7 +9288,7 @@ Paragraph.prototype.UpdateCursorType = function(X, Y, CurPage)
else
MMData
.
Type
=
AscCommon
.
c_oAscMouseMoveDataTypes
.
Common
;
if
(
null
!=
oHyperlink
&&
true
===
AscCommon
.
global_keyboardEvent
.
CtrlKey
)
if
(
(
null
!=
oHyperlink
||
bPageRefLink
)
&&
true
===
AscCommon
.
global_keyboardEvent
.
CtrlKey
)
this
.
DrawingDocument
.
SetCursorType
(
"
pointer
"
,
MMData
);
else
this
.
DrawingDocument
.
SetCursorType
(
"
default
"
,
MMData
);
...
...
@@ -12385,6 +12398,11 @@ Paragraph.prototype.GetComplexFieldsByPos = function(oParaPos, bReturnFieldPos)
this
.
Set_ParaContentPos
(
oCurrentPos
,
false
,
-
1
,
-
1
,
false
);
return
arrComplexFields
;
};
Paragraph
.
prototype
.
GetComplexFieldsByXY
=
function
(
X
,
Y
,
CurPage
,
bReturnFieldPos
)
{
var
SearchPosXY
=
this
.
Get_ParaContentPosByXY
(
X
,
Y
,
CurPage
,
false
,
false
);
return
this
.
GetComplexFieldsByPos
(
SearchPosXY
.
Pos
,
bReturnFieldPos
);
};
Paragraph
.
prototype
.
GetOutlineParagraphs
=
function
(
arrOutline
)
{
var
nOutlineLvl
=
this
.
GetOutlineLvl
();
...
...
@@ -12446,6 +12464,26 @@ Paragraph.prototype.AddBookmarkChar = function(oBookmarkChar, isUseSelection, is
return
true
;
};
/**
* Проверяем есть ли у нас в заданной точке сложное поле типа PAGEREF с флагом hyperlink = true
* @param X
* @param Y
* @param CurPage
* @returns {CComplexField?}
*/
Paragraph
.
prototype
.
CheckPageRefLink
=
function
(
X
,
Y
,
CurPage
)
{
var
arrComplexFields
=
this
.
GetComplexFieldsByXY
(
X
,
Y
,
CurPage
);
for
(
var
nIndex
=
0
,
nCount
=
arrComplexFields
.
length
;
nIndex
<
nCount
;
++
nIndex
)
{
var
oComplexField
=
arrComplexFields
[
nIndex
];
var
oInstruction
=
oComplexField
.
GetInstruction
();
if
(
oInstruction
&&
fieldtype_PAGEREF
===
oInstruction
.
GetType
()
&&
oInstruction
.
IsHyperlink
())
return
oComplexField
;
}
return
null
;
};
var
pararecalc_0_All
=
0
;
var
pararecalc_0_None
=
1
;
...
...
word/Editor/Paragraph/ComplexField.js
View file @
976769a1
...
...
@@ -229,11 +229,7 @@ CComplexField.prototype.SetSeparateChar = function(oChar)
};
CComplexField
.
prototype
.
Update
=
function
()
{
if
(
!
this
.
Instruction
)
{
var
oParser
=
new
CFieldInstructionParser
();
this
.
Instruction
=
oParser
.
GetInstructionClass
(
this
.
InstructionLine
);
}
this
.
private_UpdateInstruction
();
if
(
!
this
.
Instruction
||
!
this
.
BeginChar
||
!
this
.
EndChar
||
!
this
.
SeparateChar
)
return
;
...
...
@@ -243,7 +239,7 @@ CComplexField.prototype.Update = function()
if
(
true
===
this
.
LogicDocument
.
Document_Is_SelectionLocked
(
changestype_Paragraph_Content
))
return
;
var
nFieldCode
=
this
.
Instruction
.
Get
FieldCod
e
();
var
nFieldCode
=
this
.
Instruction
.
Get
Typ
e
();
if
(
fieldtype_PAGENUM
===
nFieldCode
)
{
var
oRun
=
this
.
BeginChar
.
GetRun
();
...
...
@@ -418,6 +414,19 @@ CComplexField.prototype.IsValid = function()
{
return
this
.
IsUse
()
&&
this
.
BeginChar
&&
this
.
SeparateChar
&&
this
.
EndChar
;
};
CComplexField
.
prototype
.
GetInstruction
=
function
()
{
this
.
private_UpdateInstruction
();
return
this
.
Instruction
;
};
CComplexField
.
prototype
.
private_UpdateInstruction
=
function
()
{
if
(
!
this
.
Instruction
&&
this
.
InstructionLine
)
{
var
oParser
=
new
CFieldInstructionParser
();
this
.
Instruction
=
oParser
.
GetInstructionClass
(
this
.
InstructionLine
);
}
};
function
CComplexFieldStatePos
(
oComplexField
,
isFieldCode
)
{
...
...
word/Editor/Paragraph/ComplexFieldInstruction.js
View file @
976769a1
...
...
@@ -54,7 +54,7 @@ function CFieldInstructionBase()
{
}
CFieldInstructionBase
.
prototype
.
Type
=
fieldtype_UNKNOWN
;
CFieldInstructionBase
.
prototype
.
Get
FieldCod
e
=
function
()
CFieldInstructionBase
.
prototype
.
Get
Typ
e
=
function
()
{
return
this
.
Type
;
};
...
...
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