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
fc9c0204
Commit
fc9c0204
authored
Jul 18, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked replacing content control function.
parent
de3dc3e3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
13 deletions
+92
-13
word/Editor/Document.js
word/Editor/Document.js
+19
-0
word/Editor/ParagraphContentBase.js
word/Editor/ParagraphContentBase.js
+12
-0
word/Editor/StructuredDocumentTags/BlockLevel.js
word/Editor/StructuredDocumentTags/BlockLevel.js
+13
-0
word/Editor/StructuredDocumentTags/InlineLevel.js
word/Editor/StructuredDocumentTags/InlineLevel.js
+5
-0
word/api.js
word/api.js
+43
-13
No files found.
word/Editor/Document.js
View file @
fc9c0204
...
...
@@ -15328,6 +15328,25 @@ CDocument.prototype.GetContentControl = function(Id)
{
return
this
.
TableId
.
Get_ById
(
Id
);
};
CDocument
.
prototype
.
ClearContentControl
=
function
(
Id
)
{
var
oContentControl
=
this
.
TableId
.
Get_ById
(
Id
);
if
(
!
oContentControl
)
return
null
;
this
.
RemoveSelection
();
if
(
oContentControl
.
GetContentControlType
&&
(
AscCommonWord
.
sdttype_BlockLevel
===
oContentControl
.
GetContentControlType
()
||
AscCommonWord
.
sdttype_InlineLevel
===
oContentControl
.
GetContentControlType
()))
{
oContentControl
.
ClearContentControl
();
oContentControl
.
SetThisElementCurrent
();
oContentControl
.
MoveCursorToStartPos
();
}
return
oContentControl
;
};
CDocument
.
prototype
.
GetAllSignatures
=
function
()
{
return
this
.
DrawingObjects
.
getAllSignatures
();
...
...
word/Editor/ParagraphContentBase.js
View file @
fc9c0204
...
...
@@ -2762,6 +2762,18 @@ CParagraphContentWithParagraphLikeContent.prototype.SelectThisElement = function
return
true
;
};
CParagraphContentWithParagraphLikeContent
.
prototype
.
SetThisElementCurrent
=
function
()
{
var
ContentPos
=
this
.
Paragraph
.
Get_PosByElement
(
this
);
if
(
!
ContentPos
)
return
;
var
StartPos
=
ContentPos
.
Copy
();
this
.
Get_StartPos
(
StartPos
,
StartPos
.
Get_Depth
()
+
1
);
this
.
Paragraph
.
Set_ParaContentPos
(
StartPos
,
true
,
-
1
,
-
1
);
this
.
Paragraph
.
Document_SetThisElementCurrent
(
false
);
};
CParagraphContentWithParagraphLikeContent
.
prototype
.
GetSelectedContentControls
=
function
(
arrContentControls
)
{
if
(
true
===
this
.
Selection
.
Use
)
...
...
word/Editor/StructuredDocumentTags/BlockLevel.js
View file @
fc9c0204
...
...
@@ -932,6 +932,10 @@ CBlockLevelSdt.prototype.SelectContentControl = function()
this
.
SelectAll
(
1
);
this
.
Set_CurrentElement
(
false
,
0
,
this
.
Content
);
};
CBlockLevelSdt
.
prototype
.
SetThisElementCurrent
=
function
()
{
this
.
Set_CurrentElement
(
false
,
0
,
this
.
Content
);
};
CBlockLevelSdt
.
prototype
.
RemoveContentControlWrapper
=
function
()
{
if
(
!
this
.
Parent
)
...
...
@@ -1071,6 +1075,15 @@ CBlockLevelSdt.prototype.Restart_CheckSpelling = function()
{
this
.
Content
.
Restart_CheckSpelling
();
};
CBlockLevelSdt
.
prototype
.
ClearContentControl
=
function
()
{
var
oPara
=
new
Paragraph
(
this
.
LogicDocument
.
Get_DrawingDocument
(),
this
.
Content
);
oPara
.
Correct_Content
();
this
.
Content
.
Add_ToContent
(
0
,
oPara
);
this
.
Content
.
Remove_FromContent
(
1
,
this
.
Content
.
Get_ElementsCount
()
-
1
);
this
.
Content
.
MoveCursorToStartPos
(
false
);
};
//--------------------------------------------------------export--------------------------------------------------------
window
[
'
AscCommonWord
'
]
=
window
[
'
AscCommonWord
'
]
||
{};
window
[
'
AscCommonWord
'
].
CBlockLevelSdt
=
CBlockLevelSdt
;
...
...
word/Editor/StructuredDocumentTags/InlineLevel.js
View file @
fc9c0204
...
...
@@ -491,6 +491,11 @@ CInlineLevelSdt.prototype.GetSelectedContentControls = function(arrContentContro
arrContentControls
.
push
(
this
);
CParagraphContentWithParagraphLikeContent
.
prototype
.
GetSelectedContentControls
.
call
(
this
,
arrContentControls
);
};
CInlineLevelSdt
.
prototype
.
ClearContentControl
=
function
()
{
this
.
Add_ToContent
(
0
,
new
ParaRun
(
this
.
GetParagraph
(),
false
));
this
.
Remove_FromContent
(
1
,
this
.
Content
.
length
-
1
);
};
//--------------------------------------------------------export--------------------------------------------------------
window
[
'
AscCommonWord
'
]
=
window
[
'
AscCommonWord
'
]
||
{};
window
[
'
AscCommonWord
'
].
CInlineLevelSdt
=
CInlineLevelSdt
;
...
...
word/api.js
View file @
fc9c0204
...
...
@@ -434,20 +434,36 @@
while
(
this
.
current
<
this
.
documents
.
length
)
// no recursion
{
if
(
false
===
LogicDocument
.
Document_Is_SelectionLocked
(
AscCommon
.
changestype_Document_Content_Add
))
var
_current
=
this
.
documents
[
this
.
current
];
var
_isLocked
=
false
;
if
((
_current
[
"
Url
"
]
!==
undefined
||
_current
[
"
Script
"
]
!==
undefined
)
&&
undefined
!==
_current
[
"
Props
"
][
"
InternalId
"
])
{
var
_current
=
this
.
documents
[
this
.
current
];
var
_internalId
=
_current
[
"
Props
"
][
"
InternalId
"
];
var
_contentControl
=
g_oTableId
.
Get_ById
(
_internalId
);
_isLocked
=
LogicDocument
.
Document_Is_SelectionLocked
(
AscCommon
.
changestype_None
,
{
Type
:
AscCommon
.
changestype_2_ElementsArray_and_Type
,
Elements
:
[
_contentControl
],
CheckType
:
AscCommon
.
changestype_Document_Content_Add
});
}
else
{
_isLocked
=
LogicDocument
.
Document_Is_SelectionLocked
(
AscCommon
.
changestype_Document_Content_Add
);
}
if
(
false
===
_isLocked
)
{
var
_content_control_pr
;
var
_blockStd
;
var
_isReplaced
=
false
;
if
(
_current
[
"
Url
"
]
!==
undefined
||
_current
[
"
Script
"
]
!==
undefined
)
{
_blockStd
=
null
;
if
(
undefined
!==
_current
[
"
Props
"
][
"
InternalId
"
])
{
// remove block sdt
LogicDocument
.
SelectContentControl
(
_current
[
"
Props
"
][
"
InternalId
"
]);
LogicDocument
.
RemoveContentControl
(
_current
[
"
Props
"
][
"
InternalId
"
]);
_blockStd
=
LogicDocument
.
ClearContentControl
(
_current
[
"
Props
"
][
"
InternalId
"
]);
_isReplaced
=
true
;
}
_content_control_pr
=
new
AscCommonWord
.
CContentControlPr
();
...
...
@@ -456,11 +472,15 @@
_content_control_pr
.
Lock
=
AscCommonWord
.
sdtlock_Unlocked
;
_content_control_pr
.
InternalId
=
_current
[
"
Props
"
][
"
InternalId
"
];
var
oCurPara
=
LogicDocument
.
GetCurrentParagraph
();
if
(
oCurPara
&&
!
oCurPara
.
IsCursorAtBegin
())
LogicDocument
.
AddNewParagraph
(
false
,
true
);
if
(
null
===
_blockStd
)
{
var
oCurPara
=
LogicDocument
.
GetCurrentParagraph
();
if
(
oCurPara
&&
!
oCurPara
.
IsCursorAtBegin
())
LogicDocument
.
AddNewParagraph
(
false
,
true
);
_blockStd
=
LogicDocument
.
AddContentControl
(
AscCommonWord
.
sdttype_BlockLevel
);
}
var
_blockStd
=
LogicDocument
.
AddContentControl
(
AscCommonWord
.
sdttype_BlockLevel
);
_blockStd
.
SetContentControlPr
(
_content_control_pr
);
_obj
=
_blockStd
.
GetContentControlPr
();
...
...
@@ -497,12 +517,22 @@
var
_script
=
"
(function(){ var Api = window.g_asc_plugins.api;
\n
"
+
_current
[
"
Script
"
]
+
"
\n
})();
"
;
eval
(
_script
);
if
(
_blockStd
.
Content
.
Get_ElementsCount
()
>
1
)
if
(
_isReplaced
)
{
_blockStd
.
Content
.
Remove_FromContent
(
_blockStd
.
Content
.
Get_ElementsCount
()
-
1
,
1
);
_blockStd
.
MoveCursorToEndPos
(
false
,
false
);
if
(
_blockStd
.
Content
.
Get_ElementsCount
()
>
1
)
_blockStd
.
Content
.
Remove_FromContent
(
_blockStd
.
Content
.
Get_ElementsCount
()
-
1
,
1
);
_blockStd
.
MoveCursorToStartPos
(
false
);
}
else
{
if
(
_blockStd
.
Content
.
Get_ElementsCount
()
>
1
)
{
_blockStd
.
Content
.
Remove_FromContent
(
_blockStd
.
Content
.
Get_ElementsCount
()
-
1
,
1
);
_blockStd
.
MoveCursorToEndPos
(
false
,
false
);
}
LogicDocument
.
MoveCursorRight
(
false
,
false
,
true
);
}
LogicDocument
.
MoveCursorRight
(
false
,
false
,
true
);
var
_worker
=
_api
.
__content_control_worker
;
if
(
_worker
.
documents
[
_worker
.
current
][
"
Props
"
])
...
...
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