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
be71d4a0
Commit
be71d4a0
authored
Apr 27, 2017
by
Ilya Kirillov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented function for adding a ContentControl into the current cursor position.
parent
582f6f25
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
145 additions
and
80 deletions
+145
-80
word/Editor/Document.js
word/Editor/Document.js
+21
-22
word/Editor/DocumentContent.js
word/Editor/DocumentContent.js
+47
-52
word/Editor/DocumentContentBase.js
word/Editor/DocumentContentBase.js
+34
-0
word/Editor/DocumentContentElementBase.js
word/Editor/DocumentContentElementBase.js
+3
-0
word/Editor/DocumentControllerBase.js
word/Editor/DocumentControllerBase.js
+4
-0
word/Editor/DrawingsController.js
word/Editor/DrawingsController.js
+4
-0
word/Editor/Footnotes.js
word/Editor/Footnotes.js
+5
-0
word/Editor/HeaderFooterController.js
word/Editor/HeaderFooterController.js
+6
-0
word/Editor/LogicDocumentController.js
word/Editor/LogicDocumentController.js
+4
-0
word/Editor/StructuredDocumentTags/BlockLevel.js
word/Editor/StructuredDocumentTags/BlockLevel.js
+12
-6
word/Editor/Table.js
word/Editor/Table.js
+5
-0
No files found.
word/Editor/Document.js
View file @
be71d4a0
...
...
@@ -7404,20 +7404,14 @@ CDocument.prototype.Get_NearestPos = function(PageNum, X, Y, bAnchor, Drawing)
var
ElementPageIndex
=
this
.
private_GetElementPageIndexByXY
(
ContentPos
,
X
,
Y
,
PageNum
);
return
this
.
Content
[
ContentPos
].
GetNearestPos
(
ElementPageIndex
,
X
,
Y
,
bAnchor
,
Drawing
);
};
CDocument
.
prototype
.
Internal_Content_Add
=
function
(
Position
,
NewObject
,
bCheck
Table
)
CDocument
.
prototype
.
Internal_Content_Add
=
function
(
Position
,
NewObject
,
bCheck
LastElement
)
{
// Position = this.Content.length допускается
if
(
Position
<
0
||
Position
>
this
.
Content
.
length
)
return
;
var
PrevObj
=
this
.
Content
[
Position
-
1
];
var
NextObj
=
this
.
Content
[
Position
];
if
(
"
undefined
"
==
typeof
(
PrevObj
))
PrevObj
=
null
;
if
(
"
undefined
"
==
typeof
(
NextObj
))
NextObj
=
null
;
var
PrevObj
=
this
.
Content
[
Position
-
1
]
?
this
.
Content
[
Position
-
1
]
:
null
;
var
NextObj
=
this
.
Content
[
Position
]
?
this
.
Content
[
Position
]
:
null
;
this
.
private_RecalculateNumbering
([
NewObject
]);
this
.
History
.
Add
(
new
CChangesDocumentAddItem
(
this
,
Position
,
[
NewObject
]));
...
...
@@ -7438,28 +7432,22 @@ CDocument.prototype.Internal_Content_Add = function(Position, NewObject, bCheckT
// Проверим последний параграф
this
.
Check_SectionLastParagraph
();
// Проверим, что последний элемент
не таблица
if
(
false
!=
bCheckTable
&&
type_Table
==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
())
// Проверим, что последний элемент
- параграф
if
(
false
!=
=
bCheckLastElement
&&
type_Paragraph
!
==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
())
this
.
Internal_Content_Add
(
this
.
Content
.
length
,
new
Paragraph
(
this
.
DrawingDocument
,
this
));
// Запоминаем, что нам нужно произвести переиндексацию элементов
this
.
private_ReindexContent
(
Position
);
};
CDocument
.
prototype
.
Internal_Content_Remove
=
function
(
Position
,
Count
,
bC
orrectionCheck
)
CDocument
.
prototype
.
Internal_Content_Remove
=
function
(
Position
,
Count
,
bC
heckLastElement
)
{
var
ChangePos
=
-
1
;
if
(
Position
<
0
||
Position
>=
this
.
Content
.
length
||
Count
<=
0
)
return
-
1
;
var
PrevObj
=
this
.
Content
[
Position
-
1
];
var
NextObj
=
this
.
Content
[
Position
+
Count
];
if
(
"
undefined
"
==
typeof
(
PrevObj
))
PrevObj
=
null
;
if
(
"
undefined
"
==
typeof
(
NextObj
))
NextObj
=
null
;
var
PrevObj
=
this
.
Content
[
Position
-
1
]
?
this
.
Content
[
Position
-
1
]
:
null
;
var
NextObj
=
this
.
Content
[
Position
+
Count
]
?
this
.
Content
[
Position
+
Count
]
:
null
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
...
...
@@ -7476,8 +7464,8 @@ CDocument.prototype.Internal_Content_Remove = function(Position, Count, bCorrect
if
(
null
!=
NextObj
)
NextObj
.
Set_DocumentPrev
(
PrevObj
);
// Проверим, что последний параграф
if
(
false
!==
bC
orrectionCheck
&&
(
this
.
Content
.
length
<=
0
||
type_Paragraph
!==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
()))
// Проверим, что последний
элемент -
параграф
if
(
false
!==
bC
heckLastElement
&&
(
this
.
Content
.
length
<=
0
||
type_Paragraph
!==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
()))
this
.
Internal_Content_Add
(
this
.
Content
.
length
,
new
Paragraph
(
this
.
DrawingDocument
,
this
));
// Обновим информацию о секциях
...
...
@@ -15030,6 +15018,10 @@ CDocument.prototype.controller_GetCurrentSectionPr = function()
var
nContentPos
=
this
.
CurPos
.
ContentPos
;
return
this
.
SectionsInfo
.
Get_SectPr
(
nContentPos
).
SectPr
;
};
CDocument
.
prototype
.
controller_AddContentControl
=
function
()
{
this
.
private_AddContentControl
();
};
//----------------------------------------------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------------------------------------------
...
...
@@ -15225,6 +15217,13 @@ CDocument.prototype.OnContentControlTrackEnd = function(Id, NearestPos, isCopy)
}
}
};
CDocument
.
prototype
.
AddContentControl
=
function
()
{
if
(
true
===
this
.
IsSelectionUse
())
this
.
RemoveBeforePaste
();
this
.
Controller
.
AddContentControl
();
};
function
CDocumentSelectionState
()
{
...
...
word/Editor/DocumentContent.js
View file @
be71d4a0
...
...
@@ -7209,75 +7209,63 @@ CDocumentContent.prototype.private_CheckCurPage = function()
}
}
};
CDocumentContent
.
prototype
.
Internal_Content_Add
=
function
(
Position
,
NewObject
,
bCheckTable
)
CDocumentContent
.
prototype
.
Internal_Content_Add
=
function
(
Position
,
NewObject
,
bCheckLastElement
)
{
// Position = this.Content.length допускается
if
(
Position
<
0
||
Position
>
this
.
Content
.
length
)
return
;
var
PrevObj
=
this
.
Content
[
Position
-
1
];
var
NextObj
=
this
.
Content
[
Position
];
if
(
"
undefined
"
==
typeof
(
PrevObj
))
PrevObj
=
null
;
// Position = this.Content.length допускается
if
(
Position
<
0
||
Position
>
this
.
Content
.
length
)
return
;
if
(
"
undefined
"
==
typeof
(
NextObj
))
NextObj
=
null
;
var
PrevObj
=
this
.
Content
[
Position
-
1
]
?
this
.
Content
[
Position
-
1
]
:
null
;
var
NextObj
=
this
.
Content
[
Position
]
?
this
.
Content
[
Position
]
:
null
;
this
.
private_RecalculateNumbering
([
NewObject
]);
History
.
Add
(
new
CChangesDocumentContentAddItem
(
this
,
Position
,
[
NewObject
]));
this
.
Content
.
splice
(
Position
,
0
,
NewObject
);
NewObject
.
Set_Parent
(
this
);
NewObject
.
Set_DocumentNext
(
NextObj
);
NewObject
.
Set_DocumentPrev
(
PrevObj
);
this
.
private_RecalculateNumbering
([
NewObject
]);
History
.
Add
(
new
CChangesDocumentContentAddItem
(
this
,
Position
,
[
NewObject
]));
this
.
Content
.
splice
(
Position
,
0
,
NewObject
);
NewObject
.
Set_Parent
(
this
);
NewObject
.
Set_DocumentNext
(
NextObj
);
NewObject
.
Set_DocumentPrev
(
PrevObj
);
if
(
null
!=
PrevObj
)
PrevObj
.
Set_DocumentNext
(
NewObject
);
if
(
null
!=
PrevObj
)
PrevObj
.
Set_DocumentNext
(
NewObject
);
if
(
null
!=
NextObj
)
NextObj
.
Set_DocumentPrev
(
NewObject
);
if
(
null
!=
NextObj
)
NextObj
.
Set_DocumentPrev
(
NewObject
);
if
(
Position
<=
this
.
CurPos
.
TableMove
)
this
.
CurPos
.
TableMove
++
;
if
(
Position
<=
this
.
CurPos
.
TableMove
)
this
.
CurPos
.
TableMove
++
;
// Проверим, что последний элемент не таблица
if
(
false
!=
bCheckTable
&&
type_Table
==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
())
this
.
Internal_Content_Add
(
this
.
Content
.
length
,
new
Paragraph
(
this
.
DrawingDocument
,
this
,
this
.
bPresentation
===
true
));
// Проверим, что последний элемент - параграф
if
(
false
!=
bCheckLastElement
&&
type_Paragraph
!
==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
())
this
.
Internal_Content_Add
(
this
.
Content
.
length
,
new
Paragraph
(
this
.
DrawingDocument
,
this
,
this
.
bPresentation
===
true
));
this
.
private_ReindexContent
(
Position
);
this
.
private_ReindexContent
(
Position
);
};
CDocumentContent
.
prototype
.
Internal_Content_Remove
=
function
(
Position
,
Count
,
bCorrectionCheck
)
CDocumentContent
.
prototype
.
Internal_Content_Remove
=
function
(
Position
,
Count
,
bCheckLastElement
)
{
if
(
Position
<
0
||
Position
>=
this
.
Content
.
length
||
Count
<=
0
)
return
;
var
PrevObj
=
this
.
Content
[
Position
-
1
];
var
NextObj
=
this
.
Content
[
Position
+
Count
];
if
(
"
undefined
"
==
typeof
(
PrevObj
))
PrevObj
=
null
;
if
(
Position
<
0
||
Position
>=
this
.
Content
.
length
||
Count
<=
0
)
return
;
if
(
"
undefined
"
==
typeof
(
NextObj
))
NextObj
=
null
;
var
PrevObj
=
this
.
Content
[
Position
-
1
]
?
this
.
Content
[
Position
-
1
]
:
null
;
var
NextObj
=
this
.
Content
[
Position
+
Count
]
?
this
.
Content
[
Position
+
Count
]
:
null
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
this
.
Content
[
Position
+
Index
].
PreDelete
();
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
this
.
Content
[
Position
+
Index
].
PreDelete
();
History
.
Add
(
new
CChangesDocumentContentRemoveItem
(
this
,
Position
,
this
.
Content
.
slice
(
Position
,
Position
+
Count
)));
var
Elements
=
this
.
Content
.
splice
(
Position
,
Count
);
this
.
private_RecalculateNumbering
(
Elements
);
History
.
Add
(
new
CChangesDocumentContentRemoveItem
(
this
,
Position
,
this
.
Content
.
slice
(
Position
,
Position
+
Count
)));
var
Elements
=
this
.
Content
.
splice
(
Position
,
Count
);
this
.
private_RecalculateNumbering
(
Elements
);
if
(
null
!=
PrevObj
)
PrevObj
.
Set_DocumentNext
(
NextObj
);
if
(
null
!=
PrevObj
)
PrevObj
.
Set_DocumentNext
(
NextObj
);
if
(
null
!=
NextObj
)
NextObj
.
Set_DocumentPrev
(
PrevObj
);
if
(
null
!=
NextObj
)
NextObj
.
Set_DocumentPrev
(
PrevObj
);
// Проверим, что последний элемент не таблица
if
(
false
!==
bCorrectionCheck
&&
(
this
.
Content
.
length
<=
0
||
type_Table
==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
()))
this
.
Internal_Content_Add
(
this
.
Content
.
length
,
new
Paragraph
(
this
.
DrawingDocument
,
this
,
this
.
bPresentation
===
true
));
// Проверим, что последний элемент - параграф
if
(
false
!==
bCheckLastElement
&&
(
this
.
Content
.
length
<=
0
||
type_Paragraph
!
==
this
.
Content
[
this
.
Content
.
length
-
1
].
GetType
()))
this
.
Internal_Content_Add
(
this
.
Content
.
length
,
new
Paragraph
(
this
.
DrawingDocument
,
this
,
this
.
bPresentation
===
true
));
this
.
private_ReindexContent
(
Position
);
this
.
private_ReindexContent
(
Position
);
};
CDocumentContent
.
prototype
.
Clear_ContentChanges
=
function
()
{
...
...
@@ -8490,6 +8478,13 @@ CDocumentContent.prototype.IsSelectedAll = function()
return
false
;
};
CDocumentContent
.
prototype
.
AddContentControl
=
function
()
{
if
(
docpostype_DrawingObjects
===
this
.
CurPos
.
Type
)
this
.
DrawingObjects
.
AddContentControl
();
else
this
.
private_AddContentControl
();
};
function
CDocumentContentStartState
(
DocContent
)
...
...
word/Editor/DocumentContentBase.js
View file @
be71d4a0
...
...
@@ -695,4 +695,38 @@ CDocumentContentBase.prototype.private_Remove = function(Count, bOnlyText, bRemo
CDocumentContentBase
.
prototype
.
IsBlockLevelSdtContent
=
function
()
{
return
false
;
};
CDocumentContentBase
.
prototype
.
private_AddContentControl
=
function
()
{
// Селекта быть не должно при выполнении данной функции, поэтому не проверяем
var
oElement
=
this
.
Content
[
this
.
CurPos
.
ContentPos
];
if
(
type_Paragraph
===
oElement
.
GetType
())
{
var
oSdt
=
new
CBlockLevelSdt
(
editor
.
WordControl
.
m_oLogicDocument
,
this
);
if
(
oElement
.
IsCursorAtEnd
())
{
this
.
Internal_Content_Add
(
this
.
CurPos
.
ContentPos
+
1
,
oSdt
);
this
.
CurPos
.
ContentPos
=
this
.
CurPos
.
ContentPos
+
1
;
}
else
if
(
oElement
.
IsCursorAtBegin
())
{
this
.
Internal_Content_Add
(
this
.
CurPos
.
ContentPos
,
oSdt
);
}
else
{
var
oNewParagraph
=
new
Paragraph
(
this
.
DrawingDocument
,
this
);
oElement
.
Split
(
oNewParagraph
);
this
.
Internal_Content_Add
(
this
.
CurPos
.
ContentPos
+
1
,
oSdt
);
this
.
Internal_Content_Add
(
this
.
CurPos
.
ContentPos
+
2
,
oNewParagraph
);
this
.
CurPos
.
ContentPos
=
this
.
CurPos
.
ContentPos
+
1
;
}
oSdt
.
MoveCursorToStartPos
(
false
);
}
else
{
oElement
.
AddContentControl
();
}
};
\ No newline at end of file
word/Editor/DocumentContentElementBase.js
View file @
be71d4a0
...
...
@@ -571,6 +571,9 @@ CDocumentContentElementBase.prototype.GetSelectionAnchorPos = function()
{
return
null
;
};
CDocumentContentElementBase
.
prototype
.
AddContentControl
=
function
()
{
};
//----------------------------------------------------------------------------------------------------------------------
// Функции для работы с номерами страниц
//----------------------------------------------------------------------------------------------------------------------
...
...
word/Editor/DocumentControllerBase.js
View file @
be71d4a0
...
...
@@ -732,3 +732,7 @@ CDocumentControllerBase.prototype.GetCurrentSectionPr = function(){return null;}
* Отличие от RemoveSelection в том, что сбрасываем селект с текста, но не сбрасываем с автофигур
*/
CDocumentControllerBase
.
prototype
.
RemoveTextSelection
=
function
(){};
/**
* Добавляем класс CBlockLevelSdt в текущую позицию курсора.
*/
CDocumentControllerBase
.
prototype
.
AddContentControl
=
function
(){};
\ No newline at end of file
word/Editor/DrawingsController.js
View file @
be71d4a0
...
...
@@ -516,4 +516,8 @@ CDrawingsController.prototype.GetCurrentSectionPr = function()
CDrawingsController
.
prototype
.
RemoveTextSelection
=
function
()
{
this
.
DrawingObjects
.
removeTextSelection
();
};
CDrawingsController
.
prototype
.
AddContentControl
=
function
()
{
this
.
DrawingObjects
.
AddContentControl
();
};
\ No newline at end of file
word/Editor/Footnotes.js
View file @
be71d4a0
...
...
@@ -3218,6 +3218,11 @@ CFootnotesController.prototype.ResetRecalculateCache = function()
this
.
Footnote
[
Id
].
Reset_RecalculateCache
();
}
};
CFootnotesController
.
prototype
.
AddContentControl
=
function
()
{
if
(
this
.
CurFootnote
)
this
.
CurFootnote
.
AddContentControl
();
};
function
CFootEndnotePageColumn
()
...
...
word/Editor/HeaderFooterController.js
View file @
be71d4a0
...
...
@@ -481,4 +481,10 @@ CHdrFtrController.prototype.RemoveTextSelection = function()
var
CurHdrFtr
=
this
.
HdrFtr
.
CurHdrFtr
;
if
(
null
!=
CurHdrFtr
)
return
CurHdrFtr
.
Content
.
RemoveTextSelection
();
};
CHdrFtrController
.
prototype
.
AddContentControl
=
function
()
{
var
CurHdrFtr
=
this
.
HdrFtr
.
CurHdrFtr
;
if
(
null
!=
CurHdrFtr
)
return
CurHdrFtr
.
Content
.
AddContentControl
();
};
\ No newline at end of file
word/Editor/LogicDocumentController.js
View file @
be71d4a0
...
...
@@ -378,3 +378,7 @@ CLogicDocumentController.prototype.RemoveTextSelection = function()
{
return
this
.
RemoveSelection
();
};
CLogicDocumentController
.
prototype
.
AddContentControl
=
function
()
{
return
this
.
LogicDocument
.
controller_AddContentControl
();
};
\ No newline at end of file
word/Editor/StructuredDocumentTags/BlockLevel.js
View file @
be71d4a0
...
...
@@ -596,6 +596,10 @@ CBlockLevelSdt.prototype.DrawContentControlsTrack = function(isHover)
oDrawingDocument
.
OnDrawContentControl
(
this
.
GetId
(),
isHover
?
c_oContentControlTrack
.
Hover
:
c_oContentControlTrack
.
In
,
arrRects
);
};
CBlockLevelSdt
.
prototype
.
AddContentControl
=
function
()
{
this
.
Content
.
AddContentControl
();
};
//----------------------------------------------------------------------------------------------------------------------
CBlockLevelSdt
.
prototype
.
Is_HdrFtr
=
function
(
bReturnHdrFtr
)
{
...
...
@@ -754,11 +758,13 @@ function TEST_ADD_SDT()
oLogicDocument
.
Create_NewHistoryPoint
();
var
oSdt
=
new
CBlockLevelSdt
(
oLogicDocument
,
oLogicDocument
);
o
Sdt
.
Cont
ent
.
AddToParagraph
(
new
ParaText
(
"
S
"
));
o
Sdt
.
Cont
ent
.
AddToParagraph
(
new
ParaText
(
"
d
"
));
o
Sdt
.
Cont
ent
.
AddToParagraph
(
new
ParaText
(
"
t
"
));
oLogicDocument
.
AddContentControl
(
);
o
LogicDocum
ent
.
AddToParagraph
(
new
ParaText
(
"
S
"
));
o
LogicDocum
ent
.
AddToParagraph
(
new
ParaText
(
"
d
"
));
o
LogicDocum
ent
.
AddToParagraph
(
new
ParaText
(
"
t
"
));
oLogicDocument
.
Internal_Content_Add
(
1
,
oSdt
);
oLogicDocument
.
Recalculate_FromStart
();
oLogicDocument
.
Recalculate
();
oLogicDocument
.
Document_UpdateSelectionState
();
oLogicDocument
.
Document_UpdateInterfaceState
();
oLogicDocument
.
Document_UpdateRulersState
();
}
\ No newline at end of file
word/Editor/Table.js
View file @
be71d4a0
...
...
@@ -11999,6 +11999,11 @@ CTable.prototype.GetTableProps = function()
{
return
this
.
Get_Props
();
};
CTable
.
prototype
.
AddContentControl
=
function
()
{
if
(
this
.
CurCell
)
this
.
CurCell
.
Content
.
AddContentControl
();
};
//----------------------------------------------------------------------------------------------------------------------
// Класс CTableLook
//----------------------------------------------------------------------------------------------------------------------
...
...
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