@syncfusion/ej2-docx-renderer 0.0.0-stage → 35.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/base.d.ts +4 -0
- package/base.js +4 -0
- package/dist/ej2-docx-renderer.umd.min.js +2 -0
- package/dist/ej2-docx-renderer.umd.min.js.map +1 -0
- package/dist/es6/ej2-docx-renderer.es2015.js +52432 -0
- package/dist/es6/ej2-docx-renderer.es2015.js.map +1 -0
- package/dist/es6/ej2-docx-renderer.es5.js +54425 -0
- package/dist/es6/ej2-docx-renderer.es5.js.map +1 -0
- package/dist/global/ej2-docx-renderer.min.js +2 -0
- package/dist/global/ej2-docx-renderer.min.js.map +1 -0
- package/dist/global/index.d.ts +5 -0
- package/format.d.ts +4 -0
- package/format.js +4 -0
- package/helper.d.ts +4 -0
- package/helper.js +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/list.d.ts +4 -0
- package/list.js +4 -0
- package/package.json +26 -4
- package/parser.d.ts +4 -0
- package/parser.js +4 -0
- package/src/base/constants.d.ts +2 -0
- package/src/base/constants.js +2 -0
- package/src/base/dictionary.d.ts +52 -0
- package/src/base/dictionary.js +137 -0
- package/src/base/index.d.ts +9 -0
- package/src/base/index.js +9 -0
- package/src/base/keywords.d.ts +422 -0
- package/src/base/keywords.js +422 -0
- package/src/base/types.d.ts +2590 -0
- package/src/base/types.js +1056 -0
- package/src/base/unique-format.d.ts +87 -0
- package/src/base/unique-format.js +858 -0
- package/src/base/unique-formats.d.ts +32 -0
- package/src/base/unique-formats.js +87 -0
- package/src/document-canvas.d.ts +61 -0
- package/src/document-canvas.js +221 -0
- package/src/docx-renderer.d.ts +941 -0
- package/src/docx-renderer.js +2251 -0
- package/src/format/border.d.ts +53 -0
- package/src/format/border.js +600 -0
- package/src/format/borders.d.ts +44 -0
- package/src/format/borders.js +314 -0
- package/src/format/cell-format.d.ts +42 -0
- package/src/format/cell-format.js +309 -0
- package/src/format/character-format.d.ts +152 -0
- package/src/format/character-format.js +1224 -0
- package/src/format/index.d.ts +14 -0
- package/src/format/index.js +14 -0
- package/src/format/list-format.d.ts +32 -0
- package/src/format/list-format.js +238 -0
- package/src/format/paragraph-format.d.ts +103 -0
- package/src/format/paragraph-format.js +854 -0
- package/src/format/row-format.d.ts +119 -0
- package/src/format/row-format.js +545 -0
- package/src/format/section-format.d.ts +89 -0
- package/src/format/section-format.js +689 -0
- package/src/format/shading.d.ts +24 -0
- package/src/format/shading.js +137 -0
- package/src/format/style.d.ts +106 -0
- package/src/format/style.js +286 -0
- package/src/format/table-format.d.ts +51 -0
- package/src/format/table-format.js +395 -0
- package/src/global.js +1 -0
- package/src/helper/document-editor-helper.d.ts +515 -0
- package/src/helper/document-editor-helper.js +1302 -0
- package/src/helper/document-editor-settings.d.ts +293 -0
- package/src/helper/document-editor-settings.js +94 -0
- package/src/helper/index.d.ts +5 -0
- package/src/helper/index.js +5 -0
- package/src/helper/layout-helper-methods.d.ts +539 -0
- package/src/helper/layout-helper-methods.js +1065 -0
- package/src/helper/renderer-hooks.d.ts +74 -0
- package/src/helper/renderer-hooks.js +14 -0
- package/src/helper/revision-helper-methods.d.ts +199 -0
- package/src/helper/revision-helper-methods.js +362 -0
- package/src/index.d.ts +18 -0
- package/src/index.js +18 -0
- package/src/layout-helper.d.ts +190 -0
- package/src/layout-helper.js +1368 -0
- package/src/layout.d.ts +779 -0
- package/src/layout.js +17232 -0
- package/src/list/abstract-list.d.ts +25 -0
- package/src/list/abstract-list.js +67 -0
- package/src/list/index.d.ts +7 -0
- package/src/list/index.js +7 -0
- package/src/list/level-override.d.ts +22 -0
- package/src/list/level-override.js +43 -0
- package/src/list/list-level.d.ts +57 -0
- package/src/list/list-level.js +249 -0
- package/src/list/list.d.ts +30 -0
- package/src/list/list.js +100 -0
- package/src/page.d.ts +4155 -0
- package/src/page.js +11342 -0
- package/src/parser/index.d.ts +1 -0
- package/src/parser/index.js +1 -0
- package/src/parser/sfdt-reader.d.ts +254 -0
- package/src/parser/sfdt-reader.js +4569 -0
- package/src/render.d.ts +226 -0
- package/src/render.js +4222 -0
- package/src/text-helper.d.ts +144 -0
- package/src/text-helper.js +1079 -0
- package/src/text-helpers/index.d.ts +2 -0
- package/src/text-helpers/index.js +2 -0
- package/src/text-helpers/optimized.d.ts +45 -0
- package/src/text-helpers/optimized.js +121 -0
- package/src/text-helpers/regular.d.ts +37 -0
- package/src/text-helpers/regular.js +93 -0
- package/src/themes/font-scheme.d.ts +28 -0
- package/src/themes/font-scheme.js +107 -0
- package/src/themes/index.d.ts +6 -0
- package/src/themes/index.js +6 -0
- package/src/themes/major-minor-font-scheme.d.ts +14 -0
- package/src/themes/major-minor-font-scheme.js +45 -0
- package/src/themes/themes.d.ts +11 -0
- package/src/themes/themes.js +31 -0
- package/src/utility/index.d.ts +1 -0
- package/src/utility/index.js +1 -0
- package/src/utility/path-util.d.ts +133 -0
- package/src/utility/path-util.js +639 -0
- package/text-helpers.d.ts +4 -0
- package/text-helpers.js +4 -0
- package/themes.d.ts +4 -0
- package/themes.js +4 -0
- package/utility.d.ts +4 -0
- package/utility.js +4 -0
|
@@ -0,0 +1,1302 @@
|
|
|
1
|
+
import { Dictionary } from '../base/dictionary';
|
|
2
|
+
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
3
|
+
import { BodyWidget, ElementBox, FieldElementBox, FootnoteElementBox, HeaderFooterWidget, ParagraphWidget, TableCellWidget, TableRowWidget, TableWidget, TextElementBox } from '../page';
|
|
4
|
+
import { ListTextElementBox, ShapeBase, BlockContainer, TextFrame, FootNoteWidget, BookmarkElementBox, ShapeElementBox, WebLayoutHelper } from '../index';
|
|
5
|
+
import { WCharacterFormat } from '../format/character-format';
|
|
6
|
+
import { LayoutHelperMethods, Point, SelectionWidgetInfo } from './index';
|
|
7
|
+
var EditorProperties = /** @class */ (function () {
|
|
8
|
+
function EditorProperties(owner) {
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
this.enableHeaderAndFooter = false;
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
this.isDocumentLoaded = false;
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
this.currentUser = '';
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
this.isRedoing = false;
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
this.isSelectionChangedOnMouseMoved = false;
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
this.isEndnoteElementRemoved = false;
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
this.isFootnoteElementRemoved = false;
|
|
37
|
+
/**
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
this.isFootNoteInsert = false;
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
this.isPaste = false;
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
this.isRemoteAction = false;
|
|
49
|
+
/**
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
this.remotePasteRevision = [];
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
this.chartType = false;
|
|
57
|
+
/**
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
this.pasteImageIndex = undefined;
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
this.isLastParaMarkCopied = false;
|
|
65
|
+
// MarkerInfo[] belongs to editor history
|
|
66
|
+
/**
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
this.revisionData = undefined;
|
|
70
|
+
/**
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
this.isFootNote = false;
|
|
74
|
+
/**
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
this.isAutofitToWindow = false;
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
this.isDeleteOrBackSpace = false;
|
|
82
|
+
/**
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
this.handledEnter = false;
|
|
86
|
+
/**
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
this.isMeasureParaWidth = false;
|
|
90
|
+
/**
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
this.lastElementForPasteIcon = undefined;
|
|
94
|
+
/**
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
this.isTableInsert = false;
|
|
98
|
+
/**
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
this.isInsertingTOC = false;
|
|
102
|
+
/**
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
this.skipChangeDetection = false;
|
|
106
|
+
/**
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
this.enableSpellCheck = false;
|
|
110
|
+
/**
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
this.restrictLayout = false;
|
|
114
|
+
/**
|
|
115
|
+
* Current editor history action. Written by BaseHistoryInfo.action.
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
this.action = undefined;
|
|
121
|
+
/**
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
this.selectedBookmarks = [];
|
|
125
|
+
// maintained in selection.ts
|
|
126
|
+
/**
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
this.isMoveDownOrMoveUp = false;
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
this.editRegionHighlighters = new Dictionary();
|
|
134
|
+
/**
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
this.contentControls = [];
|
|
138
|
+
/**
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
this.contentControleditRegionHighlighters = new Dictionary();
|
|
142
|
+
/**
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
this.searchHighlighters = new Dictionary();
|
|
146
|
+
/**
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
this.selectedWidgets = new Dictionary();
|
|
150
|
+
/**
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
this.formFieldHighlighters = new Dictionary();
|
|
154
|
+
/**
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
this.isCommentSelected = false;
|
|
158
|
+
/**
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
this.isTableMarkerDragging = false;
|
|
162
|
+
//maintained in viewer.ts
|
|
163
|
+
/**
|
|
164
|
+
* @private
|
|
165
|
+
*/
|
|
166
|
+
this.isComposingIME = false;
|
|
167
|
+
//maintained in table helper
|
|
168
|
+
/**
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
this.resizeNode = 0;
|
|
172
|
+
/**
|
|
173
|
+
* Row format of the row that is currently being resized. Only its height is maintained in pixels while resizing.
|
|
174
|
+
*
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
this.resizingRowFormat = undefined;
|
|
178
|
+
//maintained in track-changes.ts
|
|
179
|
+
/**
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
this.hasChanges = false;
|
|
183
|
+
//maintained in comment-review-pane.ts
|
|
184
|
+
/**
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
this.isCommentEditMode = false;
|
|
188
|
+
/**
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
191
|
+
this.currentSelectedComment = undefined;
|
|
192
|
+
this.owner = owner;
|
|
193
|
+
}
|
|
194
|
+
// Moved from selection.ts
|
|
195
|
+
/**
|
|
196
|
+
* Get Next paragraph in block
|
|
197
|
+
*
|
|
198
|
+
* @private
|
|
199
|
+
* @param {BlockWidget} block - block
|
|
200
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
201
|
+
*/
|
|
202
|
+
EditorProperties.prototype.getNextParagraphBlock = function (block) {
|
|
203
|
+
if (block.nextRenderedWidget instanceof ParagraphWidget) {
|
|
204
|
+
return block.nextRenderedWidget;
|
|
205
|
+
}
|
|
206
|
+
else if (block.nextRenderedWidget instanceof TableWidget) {
|
|
207
|
+
return this.owner.getFirstParagraphInFirstCell(block.nextRenderedWidget);
|
|
208
|
+
}
|
|
209
|
+
if (block.containerWidget instanceof TableCellWidget) {
|
|
210
|
+
return this.getNextParagraphCell(block.containerWidget);
|
|
211
|
+
}
|
|
212
|
+
else if (block.containerWidget instanceof BodyWidget) {
|
|
213
|
+
return this.getNextParagraph(block.containerWidget);
|
|
214
|
+
}
|
|
215
|
+
else if (block.containerWidget instanceof HeaderFooterWidget && this.isMoveDownOrMoveUp) {
|
|
216
|
+
return this.getFirstBlockInNextHeaderFooter(block);
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Get Next paragraph from cell
|
|
222
|
+
*
|
|
223
|
+
* @private
|
|
224
|
+
* @param {TableCellWidget} cell - cell
|
|
225
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
226
|
+
*/
|
|
227
|
+
EditorProperties.prototype.getNextParagraphCell = function (cell) {
|
|
228
|
+
if (cell.nextRenderedWidget && cell.nextRenderedWidget instanceof TableCellWidget) {
|
|
229
|
+
if (cell.rowIndex === cell.nextRenderedWidget.rowIndex) {
|
|
230
|
+
cell = cell.nextRenderedWidget;
|
|
231
|
+
if (cell.getSplitWidgets()[0] instanceof TableCellWidget) {
|
|
232
|
+
for (var _i = 0, _a = cell.getSplitWidgets(); _i < _a.length; _i++) {
|
|
233
|
+
var widget = _a[_i];
|
|
234
|
+
cell = widget;
|
|
235
|
+
if (cell.firstChild) {
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
var block = cell.firstChild;
|
|
241
|
+
if (block) {
|
|
242
|
+
return this.owner.getFirstParagraphBlock(block);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return this.getNextParagraphCell(cell);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
cell = cell.nextRenderedWidget;
|
|
250
|
+
return this.getNextParagraphCell(cell);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (cell.nextSplitWidget && cell.nextSplitWidget.childWidgets.length === 0) {
|
|
254
|
+
cell = cell.getSplitWidgets().pop();
|
|
255
|
+
}
|
|
256
|
+
return this.getNextParagraphRow(cell.containerWidget);
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Get next paragraph in bodyWidget
|
|
260
|
+
*
|
|
261
|
+
* @private
|
|
262
|
+
* @param {BodyWidget} section - section
|
|
263
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
264
|
+
*/
|
|
265
|
+
EditorProperties.prototype.getNextParagraph = function (section) {
|
|
266
|
+
if (section.nextRenderedWidget instanceof BodyWidget) {
|
|
267
|
+
var block = section.nextRenderedWidget.childWidgets[0];
|
|
268
|
+
return this.owner.getFirstParagraphBlock(block);
|
|
269
|
+
}
|
|
270
|
+
return undefined;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* @private
|
|
274
|
+
* @param {BlockWidget} block - block
|
|
275
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
276
|
+
*/
|
|
277
|
+
EditorProperties.prototype.getFirstBlockInNextHeaderFooter = function (block) {
|
|
278
|
+
var headerFooter = block.containerWidget;
|
|
279
|
+
var nextBlock;
|
|
280
|
+
if (headerFooter.headerFooterType.indexOf('Header') !== -1) {
|
|
281
|
+
nextBlock = headerFooter.page.footerWidget.firstChild;
|
|
282
|
+
}
|
|
283
|
+
else if (headerFooter.page.nextPage) {
|
|
284
|
+
var nextPage = headerFooter.page.nextPage;
|
|
285
|
+
var headerWidget = nextPage.headerWidget;
|
|
286
|
+
headerWidget.page = nextPage;
|
|
287
|
+
if (nextPage.footerWidget) {
|
|
288
|
+
nextPage.footerWidget.page = nextPage;
|
|
289
|
+
}
|
|
290
|
+
nextBlock = headerWidget.firstChild;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
if (nextBlock instanceof ParagraphWidget) {
|
|
296
|
+
return nextBlock;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
return this.getFirstBlockInFirstCell(nextBlock);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Get next paragraph for row
|
|
304
|
+
*
|
|
305
|
+
* @private
|
|
306
|
+
* @param {BlockWidget} row - row
|
|
307
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
308
|
+
*/
|
|
309
|
+
EditorProperties.prototype.getNextParagraphRow = function (row) {
|
|
310
|
+
if (!isNullOrUndefined(row.nextRenderedWidget)) {
|
|
311
|
+
var cell = row.nextRenderedWidget.childWidgets[0];
|
|
312
|
+
while (cell.childWidgets.length === 0 && !isNullOrUndefined(cell.previousSplitWidget) &&
|
|
313
|
+
!isNullOrUndefined(cell.nextRenderedWidget) && cell.nextRenderedWidget instanceof TableCellWidget) {
|
|
314
|
+
cell = cell.nextRenderedWidget;
|
|
315
|
+
}
|
|
316
|
+
var block = cell.childWidgets[0];
|
|
317
|
+
if (isNullOrUndefined(block)) {
|
|
318
|
+
return this.getNextParagraphCell(cell);
|
|
319
|
+
}
|
|
320
|
+
return this.owner.getFirstParagraphBlock(block);
|
|
321
|
+
}
|
|
322
|
+
return this.getNextParagraphBlock(row.ownerTable);
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* @private
|
|
326
|
+
* @param {TableWidget} table - table
|
|
327
|
+
* @returns {BlockWidget} BlockWidget
|
|
328
|
+
*/
|
|
329
|
+
EditorProperties.prototype.getFirstBlockInFirstCell = function (table) {
|
|
330
|
+
if (table.childWidgets.length > 0) {
|
|
331
|
+
var firstrow = table.childWidgets[0];
|
|
332
|
+
for (var i = 0; i < firstrow.childWidgets.length; i++) {
|
|
333
|
+
var firstcell = firstrow.childWidgets[i];
|
|
334
|
+
if (firstcell.childWidgets.length > 0) {
|
|
335
|
+
return firstcell.childWidgets[0];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return undefined;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Get last paragraph in cell
|
|
343
|
+
*
|
|
344
|
+
* @private
|
|
345
|
+
* @param {TableCellWidget} cell - cell
|
|
346
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
347
|
+
*/
|
|
348
|
+
EditorProperties.prototype.getLastParagraph = function (cell) {
|
|
349
|
+
while (cell.nextSplitWidget) {
|
|
350
|
+
if (cell.nextSplitWidget.childWidgets.length > 0) {
|
|
351
|
+
cell = cell.nextSplitWidget;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
var lastBlock = undefined;
|
|
358
|
+
if (cell.childWidgets.length > 0) {
|
|
359
|
+
lastBlock = cell.lastChild;
|
|
360
|
+
}
|
|
361
|
+
else if (!isNullOrUndefined(cell.previousSplitWidget)) {
|
|
362
|
+
lastBlock = cell.previousSplitWidget.lastChild;
|
|
363
|
+
}
|
|
364
|
+
return this.owner.getLastParagraphBlock(lastBlock);
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Returns field code.
|
|
368
|
+
*
|
|
369
|
+
* @private
|
|
370
|
+
* @param {FieldElementBox} fieldBegin - fieldBegin
|
|
371
|
+
* @param {boolean} isSkipTrim - isSkipTrim
|
|
372
|
+
* @returns {string} string
|
|
373
|
+
*/
|
|
374
|
+
EditorProperties.prototype.getFieldCode = function (fieldBegin, isSkipTrim) {
|
|
375
|
+
var fieldCode = '';
|
|
376
|
+
if (!isNullOrUndefined(fieldBegin) && !(fieldBegin.fieldEnd instanceof FieldElementBox)) {
|
|
377
|
+
return fieldCode;
|
|
378
|
+
}
|
|
379
|
+
var paragraph = fieldBegin.paragraph;
|
|
380
|
+
var endParagraph = fieldBegin.fieldEnd.paragraph;
|
|
381
|
+
if (fieldBegin.fieldSeparator instanceof FieldElementBox) {
|
|
382
|
+
endParagraph = fieldBegin.fieldSeparator.paragraph;
|
|
383
|
+
}
|
|
384
|
+
var startLineIndex = fieldBegin.line.indexInOwner;
|
|
385
|
+
var startIndex = fieldBegin.indexInOwner;
|
|
386
|
+
do {
|
|
387
|
+
fieldCode += this.getFieldCodeInternal(paragraph, startLineIndex, startIndex);
|
|
388
|
+
if (paragraph === endParagraph) {
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
paragraph = this.getNextParagraphBlock(paragraph);
|
|
392
|
+
startLineIndex = 0;
|
|
393
|
+
startIndex = 0;
|
|
394
|
+
} while (paragraph instanceof ParagraphWidget);
|
|
395
|
+
return isSkipTrim ? fieldCode : fieldCode.trim();
|
|
396
|
+
};
|
|
397
|
+
EditorProperties.prototype.getFieldCodeInternal = function (paragraph, startLineIndex, inlineIndex) {
|
|
398
|
+
var fieldCode = '';
|
|
399
|
+
for (var i = startLineIndex; i < paragraph.childWidgets.length; i++) {
|
|
400
|
+
var line = paragraph.childWidgets[i];
|
|
401
|
+
for (var j = inlineIndex; j < line.children.length; j++) {
|
|
402
|
+
var element = line.children[j];
|
|
403
|
+
if (element instanceof TextElementBox) {
|
|
404
|
+
fieldCode += element.text;
|
|
405
|
+
}
|
|
406
|
+
if (element instanceof FieldElementBox
|
|
407
|
+
&& (element.fieldType === 2 || element.fieldType === 1)) {
|
|
408
|
+
return fieldCode;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
inlineIndex = 0;
|
|
412
|
+
}
|
|
413
|
+
return fieldCode;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Get paragraph end position
|
|
417
|
+
*
|
|
418
|
+
* @private
|
|
419
|
+
* @param {ParagraphWidget} widget - widget
|
|
420
|
+
* @returns {Point} Point
|
|
421
|
+
*/
|
|
422
|
+
EditorProperties.prototype.getEndPosition = function (widget) {
|
|
423
|
+
var left = widget.x;
|
|
424
|
+
var top = widget.y;
|
|
425
|
+
var lineWidget = undefined;
|
|
426
|
+
if (widget.childWidgets.length > 0) {
|
|
427
|
+
lineWidget = widget.childWidgets[widget.childWidgets.length - 1];
|
|
428
|
+
if (widget.paragraphFormat.bidi) {
|
|
429
|
+
left = this.getLeft(lineWidget);
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
left += this.getWidth(lineWidget, false);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (!isNullOrUndefined(lineWidget)) {
|
|
436
|
+
top = this.getTop(lineWidget);
|
|
437
|
+
}
|
|
438
|
+
var topMargin = 0;
|
|
439
|
+
var bottomMargin = 0;
|
|
440
|
+
var size = this.getParagraphMarkSize(widget, topMargin, bottomMargin);
|
|
441
|
+
return new Point(left, top + size.topMargin);
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Get Line widget left
|
|
445
|
+
*
|
|
446
|
+
* @private
|
|
447
|
+
* @param {LineWidget} widget - widget
|
|
448
|
+
* @returns {number} number
|
|
449
|
+
*/
|
|
450
|
+
EditorProperties.prototype.getLeft = function (widget) {
|
|
451
|
+
var left = widget.paragraph.x;
|
|
452
|
+
var paragraphFormat = widget.paragraph.paragraphFormat;
|
|
453
|
+
if (this.isParagraphFirstLine(widget) && !paragraphFormat.bidi && !(paragraphFormat.textAlignment === 'Right')) {
|
|
454
|
+
left += LayoutHelperMethods.convertPointToPixel(paragraphFormat.firstLineIndent);
|
|
455
|
+
}
|
|
456
|
+
var renderedElements = widget.renderedElements;
|
|
457
|
+
for (var i = 0; i < renderedElements.length; i++) {
|
|
458
|
+
var element = renderedElements[i];
|
|
459
|
+
if (element instanceof ListTextElementBox && !paragraphFormat.bidi) { //after list implementation
|
|
460
|
+
if (i === 0) {
|
|
461
|
+
left += element.margin.left + element.width;
|
|
462
|
+
if (element.padding) {
|
|
463
|
+
left += element.padding.left;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
left += element.width;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
left += element.margin.left;
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return left;
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* Return line widget width
|
|
479
|
+
* @private
|
|
480
|
+
* @param {LineWidget} widget - widget
|
|
481
|
+
* @param {boolean} includeParagraphMark - includeParagraphMark
|
|
482
|
+
* @returns {number} number
|
|
483
|
+
*/
|
|
484
|
+
EditorProperties.prototype.getWidth = function (widget, includeParagraphMark) {
|
|
485
|
+
var width = 0;
|
|
486
|
+
var paraFormat = widget.paragraph.paragraphFormat;
|
|
487
|
+
if (this.isParagraphFirstLine(widget) && !paraFormat.bidi) {
|
|
488
|
+
width += LayoutHelperMethods.convertPointToPixel(paraFormat.firstLineIndent);
|
|
489
|
+
}
|
|
490
|
+
for (var i = 0; i < widget.children.length; i++) {
|
|
491
|
+
var elementBox = widget.children[i];
|
|
492
|
+
if (elementBox instanceof ShapeBase && elementBox.textWrappingStyle !== 'Inline') {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
width += (elementBox.margin.left + elementBox.width + elementBox.padding.left);
|
|
496
|
+
}
|
|
497
|
+
if (includeParagraphMark && widget.paragraph.childWidgets.indexOf(widget) === widget.paragraph.childWidgets.length - 1
|
|
498
|
+
&& isNullOrUndefined(widget.paragraph.nextSplitWidget)) {
|
|
499
|
+
width += this.owner.textHelper.getParagraphMarkWidth(widget.paragraph.characterFormat);
|
|
500
|
+
}
|
|
501
|
+
return width;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Get line widget top
|
|
505
|
+
* @private
|
|
506
|
+
* @param {LineWidget} widget - widget
|
|
507
|
+
* @returns {number} number
|
|
508
|
+
*/
|
|
509
|
+
EditorProperties.prototype.getTop = function (widget) {
|
|
510
|
+
if (isNullOrUndefined(widget) || isNullOrUndefined(widget.paragraph)) {
|
|
511
|
+
return 0;
|
|
512
|
+
}
|
|
513
|
+
var top = widget.paragraph.y;
|
|
514
|
+
var count = widget.paragraph.childWidgets.indexOf(widget);
|
|
515
|
+
for (var i = 0; i < count; i++) {
|
|
516
|
+
var line = widget.paragraph.childWidgets[i];
|
|
517
|
+
top = (top + line.height + line.marginTop);
|
|
518
|
+
}
|
|
519
|
+
top += widget.marginTop;
|
|
520
|
+
return top;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Get paragraph mark size info
|
|
524
|
+
*
|
|
525
|
+
* @private
|
|
526
|
+
* @param {ParagraphWidget} paragraph - paragraph
|
|
527
|
+
* @param {number} topMargin - topMargin
|
|
528
|
+
* @param {number} bottomMargin - bottomMargin
|
|
529
|
+
* @returns {SizeInfo} SizeInfo
|
|
530
|
+
*/
|
|
531
|
+
EditorProperties.prototype.getParagraphMarkSize = function (paragraph, topMargin, bottomMargin) {
|
|
532
|
+
var size = this.owner.textHelper.getParagraphMarkSize(paragraph.characterFormat);
|
|
533
|
+
var baselineOffset = size.BaselineOffset;
|
|
534
|
+
var maxHeight = size.Height;
|
|
535
|
+
var maxBaselineOffset = baselineOffset;
|
|
536
|
+
if (paragraph instanceof ParagraphWidget) {
|
|
537
|
+
// let paragraphWidget: ParagraphWidget[] = paragraph.renderedElement() as ParagraphWidget[];
|
|
538
|
+
if (paragraph.childWidgets.length > 0) {
|
|
539
|
+
paragraph.childWidgets[0];
|
|
540
|
+
}
|
|
541
|
+
//Gets line spacing.
|
|
542
|
+
var lineSpacing = this.owner.layout.getLineSpacing(paragraph, maxHeight);
|
|
543
|
+
var beforeSpacing = this.owner.layout.getBeforeSpacing(paragraph);
|
|
544
|
+
topMargin = maxBaselineOffset - baselineOffset;
|
|
545
|
+
bottomMargin = maxHeight - maxBaselineOffset - (size.Height - baselineOffset);
|
|
546
|
+
//Updates line spacing, paragraph after/ before spacing and aligns the text to base line offset.
|
|
547
|
+
var lineSpacingType = paragraph.paragraphFormat.lineSpacingType;
|
|
548
|
+
if (lineSpacingType === 'Multiple') {
|
|
549
|
+
if (lineSpacing > maxHeight) {
|
|
550
|
+
bottomMargin += lineSpacing - maxHeight;
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
topMargin += lineSpacing - maxHeight;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
else if (lineSpacingType === 'Exactly') {
|
|
557
|
+
topMargin += lineSpacing - (topMargin + size.Height + bottomMargin);
|
|
558
|
+
}
|
|
559
|
+
else if (lineSpacing > topMargin + size.Height + bottomMargin) {
|
|
560
|
+
topMargin += lineSpacing - (topMargin + size.Height + bottomMargin);
|
|
561
|
+
}
|
|
562
|
+
topMargin += beforeSpacing;
|
|
563
|
+
bottomMargin += this.owner.layout.getAfterSpacing(paragraph);
|
|
564
|
+
}
|
|
565
|
+
return { 'width': size.Width, 'height': size.Height, 'topMargin': topMargin, 'bottomMargin': bottomMargin };
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* @private
|
|
569
|
+
* @param {LineWidget} widget - widget
|
|
570
|
+
* @returns {boolean} boolean
|
|
571
|
+
*/
|
|
572
|
+
EditorProperties.prototype.isParagraphFirstLine = function (widget) {
|
|
573
|
+
if (isNullOrUndefined(widget.paragraph.previousSplitWidget) &&
|
|
574
|
+
widget === widget.paragraph.firstChild) {
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
return false;
|
|
578
|
+
};
|
|
579
|
+
/**
|
|
580
|
+
* @private
|
|
581
|
+
* @param {TableCellWidget} tableCell - tableCell
|
|
582
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
583
|
+
*/
|
|
584
|
+
EditorProperties.prototype.getFirstParagraph = function (tableCell) {
|
|
585
|
+
while (tableCell.previousSplitWidget && tableCell.previousSplitWidget.childWidgets.length > 0) {
|
|
586
|
+
tableCell = tableCell.previousSplitWidget;
|
|
587
|
+
}
|
|
588
|
+
var firstBlock = tableCell.firstChild;
|
|
589
|
+
return this.owner.getFirstParagraphBlock(firstBlock);
|
|
590
|
+
};
|
|
591
|
+
/**
|
|
592
|
+
* @private
|
|
593
|
+
* @param {BlockWidget} block - block
|
|
594
|
+
* @returns {BlockContainer} BlockContainer
|
|
595
|
+
*/
|
|
596
|
+
EditorProperties.prototype.getContainerWidget = function (block) {
|
|
597
|
+
var bodyWidget;
|
|
598
|
+
if (block.containerWidget instanceof TextFrame) {
|
|
599
|
+
bodyWidget = block.containerWidget.containerShape.line.paragraph.bodyWidget;
|
|
600
|
+
}
|
|
601
|
+
else if (block.containerWidget instanceof BlockContainer) {
|
|
602
|
+
if (!isNullOrUndefined(block.containerWidget.containerWidget) &&
|
|
603
|
+
block.containerWidget.containerWidget instanceof FootNoteWidget) {
|
|
604
|
+
bodyWidget = block.containerWidget.containerWidget;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
bodyWidget = block.containerWidget;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
bodyWidget = block.containerWidget;
|
|
612
|
+
while (!(bodyWidget instanceof BlockContainer)) {
|
|
613
|
+
if (bodyWidget instanceof TextFrame) {
|
|
614
|
+
bodyWidget = bodyWidget.containerShape.line.paragraph;
|
|
615
|
+
}
|
|
616
|
+
if (isNullOrUndefined(bodyWidget) || isNullOrUndefined(bodyWidget.containerWidget)) {
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
bodyWidget = bodyWidget.containerWidget;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return bodyWidget;
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* Get next rendered block
|
|
626
|
+
*
|
|
627
|
+
* @private
|
|
628
|
+
* @param {BlockWidget} block - block
|
|
629
|
+
* @returns {BlockWidget} BlockWidget
|
|
630
|
+
*/
|
|
631
|
+
EditorProperties.prototype.getNextRenderedBlock = function (block) {
|
|
632
|
+
if (isNullOrUndefined(block.nextWidget)) {
|
|
633
|
+
return block.nextRenderedWidget;
|
|
634
|
+
}
|
|
635
|
+
return block.nextWidget;
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
638
|
+
* @private
|
|
639
|
+
* @param {BookmarkElementBox} bookmark - bookmark
|
|
640
|
+
* @returns {boolean} boolean
|
|
641
|
+
*/
|
|
642
|
+
EditorProperties.prototype.isRenderBookmarkAtEnd = function (bookmark) {
|
|
643
|
+
var bookmarkElement;
|
|
644
|
+
if (bookmark.bookmarkType === 1) {
|
|
645
|
+
bookmarkElement = bookmark.reference;
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
bookmarkElement = bookmark;
|
|
649
|
+
}
|
|
650
|
+
if (bookmarkElement && isNullOrUndefined(bookmarkElement.properties)) {
|
|
651
|
+
var endCell = bookmarkElement.reference ? bookmarkElement.reference.paragraph.associatedCell : undefined;
|
|
652
|
+
if (isNullOrUndefined(endCell)) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
var lastRow = bookmarkElement.reference ?
|
|
656
|
+
bookmarkElement.reference.paragraph.associatedCell.ownerRow : undefined;
|
|
657
|
+
var lastCell = lastRow ?
|
|
658
|
+
lastRow.childWidgets[lastRow.childWidgets.length - 1] : undefined;
|
|
659
|
+
if (isNullOrUndefined(lastCell)) {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
if (endCell === lastCell && !(bookmark.bookmarkType === 1 &&
|
|
663
|
+
!isNullOrUndefined(bookmark.line) && bookmark.line.children.indexOf(bookmark) !==
|
|
664
|
+
bookmark.line.children.length - 1)) {
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return false;
|
|
672
|
+
};
|
|
673
|
+
/**
|
|
674
|
+
* Add selection highlight
|
|
675
|
+
* @private
|
|
676
|
+
* @param {CanvasRenderingContext2D | DocumentCanvasRenderingContext2D} canvasContext - canvasContext
|
|
677
|
+
* @param {LineWidget} widget - widget
|
|
678
|
+
* @param {number} top - top
|
|
679
|
+
* @param {Page} page - page
|
|
680
|
+
* @returns {void}
|
|
681
|
+
*/
|
|
682
|
+
EditorProperties.prototype.addSelectionHighlight = function (canvasContext, widget, top, page) {
|
|
683
|
+
if (this.selectedWidgets.containsKey(widget)) {
|
|
684
|
+
var height = this.owner.render.getScaledValue(widget.height);
|
|
685
|
+
var widgetInfo = this.selectedWidgets.get(widget);
|
|
686
|
+
var widgetInfoCollection = undefined;
|
|
687
|
+
if (widgetInfo instanceof SelectionWidgetInfo) {
|
|
688
|
+
widgetInfoCollection = [];
|
|
689
|
+
widgetInfoCollection.push(widgetInfo);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
widgetInfoCollection = widgetInfo;
|
|
693
|
+
}
|
|
694
|
+
if (!isNullOrUndefined(widgetInfoCollection)) {
|
|
695
|
+
for (var i = 0; i < widgetInfoCollection.length; i++) {
|
|
696
|
+
var selectedWidgetInfo = widgetInfoCollection[i];
|
|
697
|
+
var width = this.owner.render.getScaledValue(widgetInfoCollection[i].width);
|
|
698
|
+
var left = this.owner.render.getScaledValue(widgetInfoCollection[i].left, 1);
|
|
699
|
+
if (isNullOrUndefined(page)) {
|
|
700
|
+
page = this.getPage(widget.paragraph);
|
|
701
|
+
}
|
|
702
|
+
this.clipSelection(page, this.getPageTop(page));
|
|
703
|
+
if (this.isComposingIME) {
|
|
704
|
+
this.renderDashLine(canvasContext, page, widget, left, top, width, height);
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
canvasContext.clearRect(left, this.owner.render.getScaledValue(top, 2), width, height);
|
|
708
|
+
canvasContext.globalAlpha = 0.4;
|
|
709
|
+
var fillStyle = 'gray';
|
|
710
|
+
if (this.owner.documentEditorSettings.commentSettings &&
|
|
711
|
+
this.owner.documentEditorSettings.commentSettings.highlightCommentsByAuthor) {
|
|
712
|
+
var highlightColor = this.getSelectedCommentHighlightColor();
|
|
713
|
+
if (!isNullOrUndefined(highlightColor)) {
|
|
714
|
+
fillStyle = highlightColor;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
canvasContext.fillStyle = fillStyle;
|
|
718
|
+
canvasContext.fillRect(left, this.owner.render.getScaledValue(top, 2), width, height);
|
|
719
|
+
if (selectedWidgetInfo.floatingItems && selectedWidgetInfo.floatingItems.length > 0) {
|
|
720
|
+
for (var j = 0; j < selectedWidgetInfo.floatingItems.length; j++) {
|
|
721
|
+
var shape = selectedWidgetInfo.floatingItems[j];
|
|
722
|
+
width = this.owner.render.getScaledValue(shape.width);
|
|
723
|
+
left = this.owner.render.getScaledValue(shape.x, 1);
|
|
724
|
+
var shapeTop = this.owner.render.getScaledValue(shape.y, 2);
|
|
725
|
+
canvasContext.fillRect(left, shapeTop, width, this.owner.render.getScaledValue(shape.height));
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
canvasContext.restore();
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Add Selection highlight inside table
|
|
736
|
+
*
|
|
737
|
+
* @private
|
|
738
|
+
* @param {CanvasRenderingContext2D | DocumentCanvasRenderingContext2D} canvasContext - canvasContext
|
|
739
|
+
* @param {TableCellWidget} tableCellWidget - tableCellWidget
|
|
740
|
+
* @param {Page} page - page
|
|
741
|
+
* @returns {void}
|
|
742
|
+
*/
|
|
743
|
+
EditorProperties.prototype.addSelectionHighlightTable = function (canvasContext, tableCellWidget, page) {
|
|
744
|
+
if (this.selectedWidgets.containsKey(tableCellWidget)) {
|
|
745
|
+
var selectedWidgetInfo = this.selectedWidgets.get(tableCellWidget);
|
|
746
|
+
var selectedWidgetInfoCollection = undefined;
|
|
747
|
+
if (selectedWidgetInfo instanceof SelectionWidgetInfo) {
|
|
748
|
+
selectedWidgetInfoCollection = [];
|
|
749
|
+
selectedWidgetInfoCollection.push(selectedWidgetInfo);
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
selectedWidgetInfoCollection = selectedWidgetInfo;
|
|
753
|
+
}
|
|
754
|
+
if (!isNullOrUndefined(selectedWidgetInfoCollection)) {
|
|
755
|
+
for (var i = 0; i < selectedWidgetInfoCollection.length; i++) {
|
|
756
|
+
var left = this.owner.render.getScaledValue(selectedWidgetInfoCollection[i].left, 1);
|
|
757
|
+
var top_1 = this.owner.render.getScaledValue(tableCellWidget.y, 2);
|
|
758
|
+
var width = this.owner.render.getScaledValue(selectedWidgetInfoCollection[i].width);
|
|
759
|
+
var height = this.owner.render.getScaledValue(tableCellWidget.height);
|
|
760
|
+
canvasContext.clearRect(left, top_1, width, height);
|
|
761
|
+
canvasContext.fillStyle = 'gray';
|
|
762
|
+
if (isNullOrUndefined(page)) {
|
|
763
|
+
page = this.getPage(tableCellWidget);
|
|
764
|
+
}
|
|
765
|
+
this.clipSelection(page, this.getPageTop(page));
|
|
766
|
+
canvasContext.fillRect(left, top_1, width, height);
|
|
767
|
+
canvasContext.restore();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* Get page
|
|
774
|
+
* @private
|
|
775
|
+
* @param {Widget} widget - widget
|
|
776
|
+
* @returns {Page} Page
|
|
777
|
+
*/
|
|
778
|
+
EditorProperties.prototype.getPage = function (widget) {
|
|
779
|
+
var page = undefined;
|
|
780
|
+
if (widget.containerWidget instanceof TextFrame) {
|
|
781
|
+
var shape = widget.containerWidget.containerShape;
|
|
782
|
+
if (shape.line) {
|
|
783
|
+
page = this.getPage(shape.line.paragraph);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
else if (widget.containerWidget instanceof BlockContainer) {
|
|
787
|
+
var bodyWidget = widget.containerWidget;
|
|
788
|
+
page = widget.containerWidget.page;
|
|
789
|
+
}
|
|
790
|
+
else if (!isNullOrUndefined(widget.containerWidget)) {
|
|
791
|
+
page = this.getPage(widget.containerWidget);
|
|
792
|
+
}
|
|
793
|
+
return page;
|
|
794
|
+
};
|
|
795
|
+
EditorProperties.prototype.clipSelection = function (page, pageTop) {
|
|
796
|
+
var width;
|
|
797
|
+
var height;
|
|
798
|
+
if (this.owner.viewer instanceof WebLayoutHelper && this.owner.zoomFactor < 1) {
|
|
799
|
+
width = page.boundingRectangle.width / this.owner.zoomFactor;
|
|
800
|
+
height = page.boundingRectangle.height / this.owner.zoomFactor;
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
width = page.boundingRectangle.width * this.owner.zoomFactor;
|
|
804
|
+
height = page.boundingRectangle.height * this.owner.zoomFactor;
|
|
805
|
+
}
|
|
806
|
+
var left = page.boundingRectangle.x;
|
|
807
|
+
this.owner.selectionContext.beginPath();
|
|
808
|
+
this.owner.selectionContext.save();
|
|
809
|
+
this.owner.selectionContext.rect(left - this.owner.viewer.containerLeft, pageTop - this.owner.viewer.containerTop, width, height);
|
|
810
|
+
this.owner.selectionContext.clip();
|
|
811
|
+
};
|
|
812
|
+
EditorProperties.prototype.getSelectedCommentHighlightColor = function () {
|
|
813
|
+
if (!this.isCommentSelected) {
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
var currentSelectedComment = this.currentSelectedComment;
|
|
817
|
+
if (currentSelectedComment && currentSelectedComment.author) {
|
|
818
|
+
var authorColor = this.owner.getAuthorColor(currentSelectedComment.author);
|
|
819
|
+
return this.owner.convertColorToRGBA(authorColor, 0.6);
|
|
820
|
+
}
|
|
821
|
+
return null;
|
|
822
|
+
};
|
|
823
|
+
/**
|
|
824
|
+
* Get Page top
|
|
825
|
+
*
|
|
826
|
+
* @private
|
|
827
|
+
* @param {Page} page - page
|
|
828
|
+
* @returns {number} number
|
|
829
|
+
*/
|
|
830
|
+
EditorProperties.prototype.getPageTop = function (page) {
|
|
831
|
+
if (isNullOrUndefined(page.boundingRectangle)) {
|
|
832
|
+
return 0;
|
|
833
|
+
}
|
|
834
|
+
return (page.boundingRectangle.y - this.owner.viewer.pageGap *
|
|
835
|
+
(this.owner.pages.indexOf(page) + 1)) * this.owner.zoomFactor +
|
|
836
|
+
this.owner.viewer.pageGap * (this.owner.pages.indexOf(page) + 1);
|
|
837
|
+
};
|
|
838
|
+
EditorProperties.prototype.renderDashLine = function (ctx, page, widget, left, top, width, height) {
|
|
839
|
+
var fontColor = this.owner.characterFormat.fontColor;
|
|
840
|
+
var fillColor = fontColor ? LayoutHelperMethods.getColor(fontColor) : '#000000';
|
|
841
|
+
ctx.globalAlpha = 1;
|
|
842
|
+
// Get character format copied from selection format
|
|
843
|
+
var format = this.copyInsertFormat(new WCharacterFormat(undefined, this.owner), false);
|
|
844
|
+
var heightInfo = this.owner.textHelper.getHeight(format);
|
|
845
|
+
var pageTop = this.getPageTop(page);
|
|
846
|
+
var descent = heightInfo.Height - heightInfo.BaselineOffset;
|
|
847
|
+
top = this.owner.render.getUnderlineYPosition(widget) + top + 4 - descent;
|
|
848
|
+
this.owner.render.renderDashLine(ctx, left, (pageTop - this.owner.viewer.containerTop) +
|
|
849
|
+
(top * this.owner.zoomFactor), width, fillColor, true);
|
|
850
|
+
};
|
|
851
|
+
/**
|
|
852
|
+
* Get next text inline
|
|
853
|
+
* @private
|
|
854
|
+
* @param {ElementBox} inline - inline
|
|
855
|
+
* @returns {ElementBox} ElementBox
|
|
856
|
+
*/
|
|
857
|
+
EditorProperties.prototype.getNextTextElement = function (inline) {
|
|
858
|
+
if (inline.nextNode instanceof TextElementBox) {
|
|
859
|
+
return inline.nextNode;
|
|
860
|
+
}
|
|
861
|
+
if (!isNullOrUndefined(inline.nextNode)) {
|
|
862
|
+
return this.getNextTextElement(inline.nextNode);
|
|
863
|
+
}
|
|
864
|
+
return undefined;
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* @private
|
|
868
|
+
* @param {ElementBox} inline - inline
|
|
869
|
+
* @returns {ElementBox} ElementBox
|
|
870
|
+
*/
|
|
871
|
+
EditorProperties.prototype.getPreviousTextElement = function (inline) {
|
|
872
|
+
if (inline.previousNode instanceof TextElementBox) {
|
|
873
|
+
return inline.previousNode;
|
|
874
|
+
}
|
|
875
|
+
if (!isNullOrUndefined(inline.previousNode)) {
|
|
876
|
+
return this.getPreviousTextElement(inline.previousNode);
|
|
877
|
+
}
|
|
878
|
+
return undefined;
|
|
879
|
+
};
|
|
880
|
+
/**
|
|
881
|
+
* @private
|
|
882
|
+
* @param {BlockWidget} block - block
|
|
883
|
+
* @param {boolean} isAutoList - isAutoList
|
|
884
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
885
|
+
*/
|
|
886
|
+
EditorProperties.prototype.getPreviousParagraphBlock = function (block, isAutoList) {
|
|
887
|
+
if (block.previousRenderedWidget instanceof ParagraphWidget) {
|
|
888
|
+
return block.previousRenderedWidget;
|
|
889
|
+
}
|
|
890
|
+
else if (block.previousRenderedWidget instanceof TableWidget) {
|
|
891
|
+
return this.owner.getLastParagraphInLastCell((block.previousRenderedWidget));
|
|
892
|
+
}
|
|
893
|
+
if (block.containerWidget instanceof TableCellWidget) {
|
|
894
|
+
return this.getPreviousParagraphCell((block.containerWidget));
|
|
895
|
+
}
|
|
896
|
+
else if (block.containerWidget instanceof BodyWidget) {
|
|
897
|
+
return this.getPreviousParagraph(block.containerWidget);
|
|
898
|
+
}
|
|
899
|
+
else if (block.containerWidget instanceof HeaderFooterWidget && this.isMoveDownOrMoveUp && !isAutoList) {
|
|
900
|
+
return this.getLastBlockInPreviousHeaderFooter(block);
|
|
901
|
+
}
|
|
902
|
+
return undefined;
|
|
903
|
+
};
|
|
904
|
+
/**
|
|
905
|
+
* Get previous paragraph from cell
|
|
906
|
+
* @private
|
|
907
|
+
* @param {TableCellWidget} cell - cell
|
|
908
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
909
|
+
*/
|
|
910
|
+
EditorProperties.prototype.getPreviousParagraphCell = function (cell) {
|
|
911
|
+
if (!isNullOrUndefined(cell.previousRenderedWidget) && cell.previousRenderedWidget instanceof TableCellWidget) {
|
|
912
|
+
cell = cell.previousRenderedWidget;
|
|
913
|
+
var block = cell.lastChild;
|
|
914
|
+
return this.owner.getLastParagraphBlock(block);
|
|
915
|
+
}
|
|
916
|
+
return this.getPreviousParagraphRow(cell.ownerRow);
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Get previous paragraph from row
|
|
920
|
+
* @private
|
|
921
|
+
* @param {TableRowWidget} row - row
|
|
922
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
923
|
+
*/
|
|
924
|
+
EditorProperties.prototype.getPreviousParagraphRow = function (row) {
|
|
925
|
+
if (!isNullOrUndefined(row.previousRenderedWidget)) {
|
|
926
|
+
var cell = row.previousRenderedWidget.lastChild;
|
|
927
|
+
var block = cell.lastChild ? cell.lastChild :
|
|
928
|
+
(cell.previousSplitWidget).lastChild;
|
|
929
|
+
return this.owner.getLastParagraphBlock(block);
|
|
930
|
+
}
|
|
931
|
+
return this.getPreviousParagraphBlock(row.ownerTable);
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* @private
|
|
935
|
+
* @param {BodyWidget} section - section
|
|
936
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
937
|
+
*/
|
|
938
|
+
EditorProperties.prototype.getPreviousParagraph = function (section) {
|
|
939
|
+
if (section.previousRenderedWidget instanceof BodyWidget) {
|
|
940
|
+
var bodyWidget = section.previousRenderedWidget;
|
|
941
|
+
var block = bodyWidget.childWidgets[bodyWidget.childWidgets.length - 1];
|
|
942
|
+
return this.owner.getLastParagraphBlock(block);
|
|
943
|
+
}
|
|
944
|
+
return undefined;
|
|
945
|
+
};
|
|
946
|
+
/**
|
|
947
|
+
* @private
|
|
948
|
+
* @param {BlockWidget} block - block
|
|
949
|
+
* @returns {ParagraphWidget} ParagraphWidget
|
|
950
|
+
*/
|
|
951
|
+
EditorProperties.prototype.getLastBlockInPreviousHeaderFooter = function (block) {
|
|
952
|
+
var headerFooter = block.containerWidget;
|
|
953
|
+
var previousBlock;
|
|
954
|
+
if (headerFooter.headerFooterType.indexOf('Footer') !== -1) {
|
|
955
|
+
previousBlock = headerFooter.page.headerWidget.lastChild;
|
|
956
|
+
}
|
|
957
|
+
else if (headerFooter.page.previousPage) {
|
|
958
|
+
var previousPage = headerFooter.page.previousPage;
|
|
959
|
+
var footerWidget = previousPage.footerWidget;
|
|
960
|
+
footerWidget.page = previousPage;
|
|
961
|
+
if (previousPage.headerWidget) {
|
|
962
|
+
previousPage.headerWidget.page = previousPage;
|
|
963
|
+
}
|
|
964
|
+
previousBlock = footerWidget.lastChild;
|
|
965
|
+
}
|
|
966
|
+
else {
|
|
967
|
+
return undefined;
|
|
968
|
+
}
|
|
969
|
+
if (previousBlock instanceof ParagraphWidget) {
|
|
970
|
+
return previousBlock;
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
return this.getFirstBlockInFirstCell(previousBlock);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* Returns true if the paragraph has toc style.
|
|
978
|
+
* @private
|
|
979
|
+
* @param {ParagraphWidget} paragraph - paragraph
|
|
980
|
+
* @returns {boolean} boolean
|
|
981
|
+
*/
|
|
982
|
+
EditorProperties.prototype.isTocStyle = function (paragraph) {
|
|
983
|
+
var style = paragraph.paragraphFormat.baseStyle;
|
|
984
|
+
return (style !== undefined && (style.name.toLowerCase().indexOf('toc') !== -1));
|
|
985
|
+
};
|
|
986
|
+
// Moved from editor.ts
|
|
987
|
+
/**
|
|
988
|
+
* Rebinds cloned table revisions to the revision id dictionary.
|
|
989
|
+
* The track-changes pane is updated by the editor after this returns.
|
|
990
|
+
*
|
|
991
|
+
* @private
|
|
992
|
+
* @param {TableWidget} table - table
|
|
993
|
+
* @param {boolean} canConstructRevision - canConstructRevision
|
|
994
|
+
* @returns {void}
|
|
995
|
+
*/
|
|
996
|
+
EditorProperties.prototype.constructRevisionsForTable = function (table, canConstructRevision) {
|
|
997
|
+
for (var i = 0; i < table.childWidgets.length; i++) {
|
|
998
|
+
var rowWidget = table.childWidgets[i];
|
|
999
|
+
if (canConstructRevision) {
|
|
1000
|
+
if (this.canConstructRevision(rowWidget.rowFormat)) {
|
|
1001
|
+
this.constructRevisionFromID(rowWidget.rowFormat);
|
|
1002
|
+
}
|
|
1003
|
+
for (var rowIndex = 0; rowIndex < rowWidget.childWidgets.length; rowIndex++) {
|
|
1004
|
+
var cellWidget = rowWidget.childWidgets[rowIndex];
|
|
1005
|
+
for (var paraIndex = 0; paraIndex < cellWidget.childWidgets.length; paraIndex++) {
|
|
1006
|
+
if (cellWidget.childWidgets[paraIndex] instanceof ParagraphWidget) {
|
|
1007
|
+
this.constructRevisionsForBlock(cellWidget.childWidgets[paraIndex], canConstructRevision);
|
|
1008
|
+
}
|
|
1009
|
+
else if (cellWidget.childWidgets[paraIndex] instanceof TableWidget) {
|
|
1010
|
+
this.constructRevisionsForTable(cellWidget.childWidgets[paraIndex], true);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
EditorProperties.prototype.canConstructRevision = function (item) {
|
|
1018
|
+
if ((item.revisionLength > 0 && (isNullOrUndefined(item.getRevision(0).ownerNode) ||
|
|
1019
|
+
item.getRevision(0).getRange().length === 0)) || item.removedIds.length > 0) {
|
|
1020
|
+
return true;
|
|
1021
|
+
}
|
|
1022
|
+
return false;
|
|
1023
|
+
};
|
|
1024
|
+
EditorProperties.prototype.constructRevisionsForBlock = function (paragraph, canConstructRevision) {
|
|
1025
|
+
for (var lineIndex = 0; lineIndex < paragraph.childWidgets.length; lineIndex++) {
|
|
1026
|
+
var lineWidget = paragraph.childWidgets[lineIndex];
|
|
1027
|
+
for (var elementIndex = 0; elementIndex < lineWidget.children.length; elementIndex++) {
|
|
1028
|
+
if (canConstructRevision) {
|
|
1029
|
+
if (lineWidget.children[elementIndex] instanceof ElementBox && this.canConstructRevision(lineWidget.children[elementIndex])) {
|
|
1030
|
+
this.constructRevisionFromID(lineWidget.children[elementIndex]);
|
|
1031
|
+
}
|
|
1032
|
+
if (lineWidget.children[elementIndex] instanceof FootnoteElementBox) {
|
|
1033
|
+
this.constructRevisionForFootnote(lineWidget.children[elementIndex], canConstructRevision);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
if (this.canConstructRevision(paragraph.characterFormat)) {
|
|
1039
|
+
this.constructRevisionFromID(paragraph.characterFormat);
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
EditorProperties.prototype.constructRevisionForFootnote = function (footnote, canConstructRevision) {
|
|
1043
|
+
for (var i = 0; i < footnote.bodyWidget.childWidgets.length; i++) {
|
|
1044
|
+
if (footnote.bodyWidget.childWidgets[i] instanceof ParagraphWidget) {
|
|
1045
|
+
this.constructRevisionsForBlock(footnote.bodyWidget.childWidgets[i], canConstructRevision);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
/**
|
|
1050
|
+
* @private
|
|
1051
|
+
* @param {ElementBox | WCharacterFormat | WRowFormat} insertElement - insertElement
|
|
1052
|
+
* @returns {void}
|
|
1053
|
+
*/
|
|
1054
|
+
EditorProperties.prototype.constructRevisionFromID = function (insertElement) {
|
|
1055
|
+
if (insertElement.removedIds.length > 0) {
|
|
1056
|
+
for (var i = 0; i < insertElement.removedIds.length; i++) {
|
|
1057
|
+
if (this.owner.revisionsInternal.containsKey(insertElement.removedIds[i])) {
|
|
1058
|
+
var revisionToInclude = this.owner.revisionsInternal.get(insertElement.removedIds[i]);
|
|
1059
|
+
revisionToInclude.ownerNode = insertElement instanceof ElementBox ? insertElement.paragraph : insertElement;
|
|
1060
|
+
insertElement.addRevision(revisionToInclude);
|
|
1061
|
+
if (!isNullOrUndefined(this.owner.hooks.onRevisionConstructed)) {
|
|
1062
|
+
this.owner.hooks.onRevisionConstructed(revisionToInclude, insertElement);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
insertElement.removedIds = [];
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1069
|
+
for (var i = 0; i < insertElement.revisionLength; i++) {
|
|
1070
|
+
var currentRevision = insertElement.getRevision(i);
|
|
1071
|
+
if (this.owner.revisionsInternal.containsKey(currentRevision.revisionID)) {
|
|
1072
|
+
currentRevision = this.owner.revisionsInternal.get(currentRevision.revisionID);
|
|
1073
|
+
currentRevision.ownerNode = insertElement instanceof ElementBox ? insertElement.paragraph : insertElement;
|
|
1074
|
+
insertElement.removeRevision(i);
|
|
1075
|
+
insertElement.insertRevisionAt(i, currentRevision);
|
|
1076
|
+
if (!isNullOrUndefined(this.owner.hooks.onRevisionConstructed)) {
|
|
1077
|
+
this.owner.hooks.onRevisionConstructed(currentRevision, insertElement);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
/**
|
|
1084
|
+
* Copies to format.
|
|
1085
|
+
* @private
|
|
1086
|
+
* @param {WCharacterFormat} format - format
|
|
1087
|
+
* @param {boolean} copy - copy
|
|
1088
|
+
* @param {ParagraphWidget} widget - widget
|
|
1089
|
+
* @returns {WCharacterFormat} WCharacterFormat
|
|
1090
|
+
*/
|
|
1091
|
+
EditorProperties.prototype.copyInsertFormat = function (format, copy, widget) {
|
|
1092
|
+
var insertFormat = widget ? new WCharacterFormat(widget, this.owner) :
|
|
1093
|
+
new WCharacterFormat(undefined, this.owner);
|
|
1094
|
+
var sFormat = this.owner.selectionCharacterFormat;
|
|
1095
|
+
if (isNullOrUndefined(sFormat)) {
|
|
1096
|
+
return copy ? insertFormat : format;
|
|
1097
|
+
}
|
|
1098
|
+
if (copy) {
|
|
1099
|
+
insertFormat.copyFormat(format);
|
|
1100
|
+
}
|
|
1101
|
+
if (!isNullOrUndefined(sFormat.bidi) && format.bidi !== sFormat.bidi) {
|
|
1102
|
+
insertFormat.bidi = sFormat.bidi;
|
|
1103
|
+
}
|
|
1104
|
+
if (!isNullOrUndefined(sFormat.bold) && format.bold !== sFormat.bold) {
|
|
1105
|
+
insertFormat.bold = sFormat.bold;
|
|
1106
|
+
}
|
|
1107
|
+
if (!isNullOrUndefined(sFormat.italic) && format.italic !== sFormat.italic) {
|
|
1108
|
+
insertFormat.italic = sFormat.italic;
|
|
1109
|
+
}
|
|
1110
|
+
if (sFormat.fontSize > 0 && format.fontSize !== sFormat.fontSize) {
|
|
1111
|
+
insertFormat.fontSize = sFormat.fontSize;
|
|
1112
|
+
}
|
|
1113
|
+
if (!isNullOrUndefined(sFormat.fontFamily) && format.fontFamily !== sFormat.fontFamily) {
|
|
1114
|
+
insertFormat.fontFamily = sFormat.fontFamily;
|
|
1115
|
+
}
|
|
1116
|
+
if (!isNullOrUndefined(sFormat.highlightColor) && format.highlightColor !== sFormat.highlightColor) {
|
|
1117
|
+
insertFormat.highlightColor = sFormat.highlightColor;
|
|
1118
|
+
}
|
|
1119
|
+
if (!isNullOrUndefined(sFormat.baselineAlignment) && format.baselineAlignment !== sFormat.baselineAlignment) {
|
|
1120
|
+
insertFormat.baselineAlignment = sFormat.baselineAlignment;
|
|
1121
|
+
}
|
|
1122
|
+
if (!isNullOrUndefined(sFormat.fontColor) && format.fontColor !== sFormat.fontColor) {
|
|
1123
|
+
insertFormat.fontColor = sFormat.fontColor;
|
|
1124
|
+
}
|
|
1125
|
+
if (!isNullOrUndefined(sFormat.underline) && format.underline !== sFormat.underline) {
|
|
1126
|
+
insertFormat.underline = sFormat.underline;
|
|
1127
|
+
}
|
|
1128
|
+
if (!isNullOrUndefined(sFormat.strikethrough) && format.strikethrough !== sFormat.strikethrough) {
|
|
1129
|
+
insertFormat.strikethrough = sFormat.strikethrough;
|
|
1130
|
+
}
|
|
1131
|
+
if (!isNullOrUndefined(sFormat.boldBidi) && format.boldBidi !== sFormat.boldBidi) {
|
|
1132
|
+
insertFormat.boldBidi = sFormat.boldBidi;
|
|
1133
|
+
}
|
|
1134
|
+
if (!isNullOrUndefined(sFormat.italicBidi) && format.italicBidi !== sFormat.italicBidi) {
|
|
1135
|
+
insertFormat.italicBidi = sFormat.italicBidi;
|
|
1136
|
+
}
|
|
1137
|
+
if (sFormat.fontSizeBidi > 0 && format.fontSizeBidi !== sFormat.fontSizeBidi) {
|
|
1138
|
+
insertFormat.fontSizeBidi = sFormat.fontSizeBidi;
|
|
1139
|
+
}
|
|
1140
|
+
return insertFormat;
|
|
1141
|
+
};
|
|
1142
|
+
/**
|
|
1143
|
+
* @private
|
|
1144
|
+
* @param {Widget} widget - widget
|
|
1145
|
+
* @param {boolean} isBookmark - isBookmark
|
|
1146
|
+
* @param {boolean} isContentControl - isContentControl
|
|
1147
|
+
* @param {boolean} isEditRange - isEditRange
|
|
1148
|
+
* @returns {void}
|
|
1149
|
+
*/
|
|
1150
|
+
EditorProperties.prototype.removeFieldInWidget = function (widget, isBookmark, isContentControl, isEditRange) {
|
|
1151
|
+
if (isNullOrUndefined(isBookmark)) {
|
|
1152
|
+
isBookmark = false;
|
|
1153
|
+
}
|
|
1154
|
+
for (var i = 0; i < widget.childWidgets.length; i++) {
|
|
1155
|
+
this.removeFieldInBlock(widget.childWidgets[i], isBookmark, isContentControl, isEditRange);
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
/**
|
|
1159
|
+
* @private
|
|
1160
|
+
* @param {BlockWidget} block - block
|
|
1161
|
+
* @param {boolean} isBookmark - isBookmark
|
|
1162
|
+
* @param {boolean} isContentControl - isContentControl
|
|
1163
|
+
* @param {boolean} isEditRange - isEditRange
|
|
1164
|
+
* @returns {void}
|
|
1165
|
+
*/
|
|
1166
|
+
EditorProperties.prototype.removeFieldInBlock = function (block, isBookmark, isContentControl, isEditRange) {
|
|
1167
|
+
if (block instanceof TableWidget) {
|
|
1168
|
+
if (block.wrapTextAround && !isNullOrUndefined(block.bodyWidget)) {
|
|
1169
|
+
var index = block.bodyWidget.floatingElements.indexOf(block);
|
|
1170
|
+
if (index !== -1) {
|
|
1171
|
+
block.bodyWidget.floatingElements.splice(index, 1);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
this.removeFieldTable(block, isBookmark, isContentControl, isEditRange);
|
|
1175
|
+
}
|
|
1176
|
+
else if (block instanceof TableRowWidget) {
|
|
1177
|
+
for (var i = 0; i < block.childWidgets.length; i++) {
|
|
1178
|
+
this.removeFieldInWidget(block.childWidgets[i], isBookmark, isContentControl, isEditRange);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
this.removeField(block, isBookmark, isContentControl, isEditRange);
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
EditorProperties.prototype.removeFieldTable = function (table, isBookmark, isContentControl, isEditRange) {
|
|
1186
|
+
for (var i = 0; i < table.childWidgets.length; i++) {
|
|
1187
|
+
var row = table.childWidgets[i];
|
|
1188
|
+
for (var j = 0; j < row.childWidgets.length; j++) {
|
|
1189
|
+
this.removeFieldInWidget(row.childWidgets[j], isBookmark, isContentControl, isEditRange);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* @private
|
|
1195
|
+
* @param {BlockWidget} block - block
|
|
1196
|
+
* @param {boolean} isBookmark - isBookmark
|
|
1197
|
+
* @param {boolean} isContentControl - isContentControl
|
|
1198
|
+
* @param {boolean} isEditRange - isEditRange
|
|
1199
|
+
* @returns {void}
|
|
1200
|
+
*/
|
|
1201
|
+
EditorProperties.prototype.removeField = function (block, isBookmark, isContentControl, isEditRange) {
|
|
1202
|
+
var collection = this.owner.fields;
|
|
1203
|
+
if (isBookmark) {
|
|
1204
|
+
collection = this.owner.bookmarks.keys;
|
|
1205
|
+
}
|
|
1206
|
+
else if (isContentControl) {
|
|
1207
|
+
collection = this.owner.contentControlCollection;
|
|
1208
|
+
}
|
|
1209
|
+
if (block.floatingElements.length > 0) {
|
|
1210
|
+
for (var z = 0; z < block.floatingElements.length; z++) {
|
|
1211
|
+
var inline = block.floatingElements[z];
|
|
1212
|
+
if (inline instanceof ShapeElementBox && inline.textFrame && inline.textFrame.childWidgets.length > 0) {
|
|
1213
|
+
for (var i = 0; i < inline.textFrame.childWidgets.length; i++) {
|
|
1214
|
+
var block_1 = inline.textFrame.childWidgets[i];
|
|
1215
|
+
this.removeFieldInBlock(block_1, isBookmark, isContentControl);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
this.removeAutoShape(inline);
|
|
1219
|
+
z--;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
for (var i = 0; i < collection.length; i++) {
|
|
1223
|
+
var element = isBookmark ?
|
|
1224
|
+
this.owner.bookmarks.get(collection[i]) : collection[i];
|
|
1225
|
+
if (element.line.paragraph === block || (element instanceof BookmarkElementBox &&
|
|
1226
|
+
!isNullOrUndefined(element.reference) && element.reference.line.paragraph === block)) {
|
|
1227
|
+
// Bookmark condition removed check in document editor component
|
|
1228
|
+
if (isContentControl) {
|
|
1229
|
+
this.owner.contentControlCollection.splice(i, 1);
|
|
1230
|
+
}
|
|
1231
|
+
else {
|
|
1232
|
+
this.owner.fields.splice(i, 1);
|
|
1233
|
+
if (this.owner.formFields.indexOf(element) !== -1) {
|
|
1234
|
+
this.owner.formFields.splice(this.owner.formFields.indexOf(element), 1);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
i--;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
if (this.owner.footnoteCollection.length > 0) {
|
|
1241
|
+
for (var i = 0; i < this.owner.footnoteCollection.length; i++) {
|
|
1242
|
+
var element = this.owner.footnoteCollection[i];
|
|
1243
|
+
if (element.line.paragraph === block) {
|
|
1244
|
+
if (element.paragraph.bodyWidget.page.footnoteWidget) {
|
|
1245
|
+
var footnote = element.paragraph.bodyWidget.page.footnoteWidget;
|
|
1246
|
+
for (var j = 0; j < footnote.bodyWidgets.length; j++) {
|
|
1247
|
+
if (element === (footnote.bodyWidgets[j]).footNoteReference) {
|
|
1248
|
+
footnote.height -= (footnote.bodyWidgets[j]).height;
|
|
1249
|
+
footnote.bodyWidgets.splice(j, 1);
|
|
1250
|
+
j--;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (footnote.bodyWidgets.length === 0) {
|
|
1254
|
+
element.paragraph.bodyWidget.page.footnoteWidget = undefined;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
this.owner.footnoteCollection.splice(i, 1);
|
|
1258
|
+
i--;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
if (this.owner.endnoteCollection.length > 0) {
|
|
1263
|
+
for (var i = 0; i < this.owner.endnoteCollection.length; i++) {
|
|
1264
|
+
var element = this.owner.endnoteCollection[i];
|
|
1265
|
+
if (element.line.paragraph === block) {
|
|
1266
|
+
if (element.paragraph.bodyWidget.page.endnoteWidget) {
|
|
1267
|
+
var endnote = element.paragraph.bodyWidget.page.endnoteWidget;
|
|
1268
|
+
for (var j = 0; j < endnote.bodyWidgets.length; j++) {
|
|
1269
|
+
if (element === (endnote.bodyWidgets[j]).footNoteReference) {
|
|
1270
|
+
endnote.height -= (endnote.bodyWidgets[j]).height;
|
|
1271
|
+
endnote.bodyWidgets.splice(j, 1);
|
|
1272
|
+
j--;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (endnote.bodyWidgets.length === 0) {
|
|
1276
|
+
element.paragraph.bodyWidget.page.endnoteWidget = undefined;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
this.owner.endnoteCollection.splice(i, 1);
|
|
1280
|
+
i--;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
EditorProperties.prototype.removeAutoShape = function (inline) {
|
|
1286
|
+
var shapeIndex = inline.line.paragraph.floatingElements.indexOf(inline);
|
|
1287
|
+
var floatingElementIndex = inline.line.paragraph.bodyWidget.floatingElements.indexOf(inline);
|
|
1288
|
+
if (floatingElementIndex > -1) {
|
|
1289
|
+
inline.line.paragraph.bodyWidget.floatingElements.splice(floatingElementIndex, 1);
|
|
1290
|
+
}
|
|
1291
|
+
inline.line.paragraph.floatingElements.splice(shapeIndex, 1);
|
|
1292
|
+
};
|
|
1293
|
+
/**
|
|
1294
|
+
* @private
|
|
1295
|
+
* @returns {void}
|
|
1296
|
+
*/
|
|
1297
|
+
EditorProperties.prototype.destroy = function () {
|
|
1298
|
+
this.owner = undefined;
|
|
1299
|
+
};
|
|
1300
|
+
return EditorProperties;
|
|
1301
|
+
}());
|
|
1302
|
+
export { EditorProperties };
|