@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,1065 @@
|
|
|
1
|
+
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
|
+
import { ZipArchive } from '@syncfusion/ej2-compression';
|
|
3
|
+
import { ElementBox, TextElementBox, ListTextElementBox, ImageElementBox, FieldElementBox } from '../page';
|
|
4
|
+
import { boldProperty, italicProperty, fontSizeProperty, fontFamilyProperty, underlineProperty, underlineColorProperty, fontHintTypeProperty, strikethroughProperty, baselineAlignmentProperty, highlightColorProperty, fontColorProperty, styleNameProperty, bidiProperty, bdoProperty, boldBidiProperty, italicBidiProperty, fontSizeBidiProperty, fontFamilyBidiProperty, allCapsProperty, localeIdBidiProperty, localeIdProperty, complexScriptProperty, fontFamilyAsciiProperty, characterSpacingProperty, scalingProperty, hiddenProperty, fontFamilyFarEastProperty, fontFamilyNonFarEastProperty, bordersProperty, leftIndentProperty, rightIndentProperty, firstLineIndentProperty, textAlignmentProperty, beforeSpacingProperty, afterSpacingProperty, spaceBeforeAutoProperty, spaceAfterAutoProperty, lineSpacingProperty, lineSpacingTypeProperty, outlineLevelProperty, keepLinesTogetherProperty, keepWithNextProperty, contextualSpacingProperty, widowControlProperty, topProperty, leftProperty, rightProperty, bottomProperty, horizontalProperty, verticalProperty, colorProperty, hasNoneStyleProperty, lineStyleProperty, lineWidthProperty, shadowProperty, spaceProperty, localeIdFarEastProperty, ligatureProperty, specVanishProperty } from '../base/keywords';
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
var LayoutHelperMethods = /** @class */ (function () {
|
|
9
|
+
function LayoutHelperMethods() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check if the line widget has image with underline
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
* @param {LineWidget} lineWidget input line widget to check if it has image with underline
|
|
16
|
+
* @returns {boolean} weather line widget has image with underline or not
|
|
17
|
+
*/
|
|
18
|
+
/* eslint-disable */
|
|
19
|
+
LayoutHelperMethods.containsUnderlinedImage = function (lineWidget) {
|
|
20
|
+
var isImageHasUnderline = false;
|
|
21
|
+
for (var i = 0; i < lineWidget.children.length; i++) {
|
|
22
|
+
var elementBox = lineWidget.children[i];
|
|
23
|
+
if (elementBox instanceof TextElementBox || elementBox instanceof ListTextElementBox || elementBox instanceof FieldElementBox) {
|
|
24
|
+
return false; //If line has text, no need to check for underline in image
|
|
25
|
+
}
|
|
26
|
+
else if (elementBox instanceof ImageElementBox) {
|
|
27
|
+
// Check if the image has underline or track changes insertion
|
|
28
|
+
isImageHasUnderline = (elementBox.getAllRevision().length > 0 && elementBox.getRevision(0).revisionType === 'Insertion')
|
|
29
|
+
|| (elementBox.characterFormat && elementBox.characterFormat.underline !== 'None');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return isImageHasUnderline;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Check given string is a valid either roman or arabic number
|
|
36
|
+
*
|
|
37
|
+
* @private
|
|
38
|
+
* @param {string} input input string value to check if it is a number
|
|
39
|
+
* @returns {boolean} weather given string is a number or not
|
|
40
|
+
*/
|
|
41
|
+
LayoutHelperMethods.checkTextFormat = function (input) {
|
|
42
|
+
// Regular expression patterns for Roman and Arabic numerals
|
|
43
|
+
var romanPattern = /^(M{0,3})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i;
|
|
44
|
+
var arabicPattern = /^[0-9]+$/;
|
|
45
|
+
// Check if the input matches either pattern
|
|
46
|
+
if (romanPattern.test(input) || arabicPattern.test(input)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
LayoutHelperMethods.convertRgbToHex = function (value) {
|
|
54
|
+
var hex = value.toString(16);
|
|
55
|
+
return hex.length === 1 ? '0' + hex : hex;
|
|
56
|
+
};
|
|
57
|
+
LayoutHelperMethods.getHighlightColorCode = function (highlightColor) {
|
|
58
|
+
var color = '#ffffff';
|
|
59
|
+
switch (highlightColor) {
|
|
60
|
+
case 'Yellow':
|
|
61
|
+
color = '#ffff00';
|
|
62
|
+
break;
|
|
63
|
+
case 'BrightGreen':
|
|
64
|
+
color = '#00ff00';
|
|
65
|
+
break;
|
|
66
|
+
case 'Turquoise':
|
|
67
|
+
color = '#00ffff';
|
|
68
|
+
break;
|
|
69
|
+
case 'Pink':
|
|
70
|
+
color = '#ff00ff';
|
|
71
|
+
break;
|
|
72
|
+
case 'Blue':
|
|
73
|
+
color = '#0000ff';
|
|
74
|
+
break;
|
|
75
|
+
case 'Red':
|
|
76
|
+
color = '#ff0000';
|
|
77
|
+
break;
|
|
78
|
+
case 'DarkBlue':
|
|
79
|
+
color = '#000080';
|
|
80
|
+
break;
|
|
81
|
+
case 'Teal':
|
|
82
|
+
color = '#008080';
|
|
83
|
+
break;
|
|
84
|
+
case 'Green':
|
|
85
|
+
color = '#008000';
|
|
86
|
+
break;
|
|
87
|
+
case 'Violet':
|
|
88
|
+
color = '#800080';
|
|
89
|
+
break;
|
|
90
|
+
case 'DarkRed':
|
|
91
|
+
color = '#800000';
|
|
92
|
+
break;
|
|
93
|
+
case 'DarkYellow':
|
|
94
|
+
color = '#808000';
|
|
95
|
+
break;
|
|
96
|
+
case 'Gray50':
|
|
97
|
+
color = '#808080';
|
|
98
|
+
break;
|
|
99
|
+
case 'Gray25':
|
|
100
|
+
color = '#c0c0c0';
|
|
101
|
+
break;
|
|
102
|
+
case 'Black':
|
|
103
|
+
color = '#000000';
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return color;
|
|
107
|
+
};
|
|
108
|
+
LayoutHelperMethods.isVeryDark = function (backColor) {
|
|
109
|
+
var backgroundColor = backColor.substring(1);
|
|
110
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
111
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
112
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
113
|
+
var contrast = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
|
114
|
+
return contrast <= 60;
|
|
115
|
+
};
|
|
116
|
+
LayoutHelperMethods.getColor = function (color) {
|
|
117
|
+
if (color.length > 0) {
|
|
118
|
+
if (color[0] === '#') {
|
|
119
|
+
if (color.length > 7) {
|
|
120
|
+
return color.substr(0, 7);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return color;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* @returns {any} returns any type
|
|
128
|
+
* Get the SFDT document from the optimized SFDT.
|
|
129
|
+
* @param {any} json accepts a json file
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
LayoutHelperMethods.getSfdtDocument = function (json) {
|
|
133
|
+
json = (json instanceof Object) ? json : JSON.parse(json);
|
|
134
|
+
if (!isNullOrUndefined(json.sfdt)) {
|
|
135
|
+
var zipArchive = new ZipArchive();
|
|
136
|
+
zipArchive.open(JSON.stringify(json.sfdt));
|
|
137
|
+
var zipItem = zipArchive.items[0];
|
|
138
|
+
var value = new Uint8Array(zipItem.data);
|
|
139
|
+
var str = new TextDecoder('utf-8').decode(value);
|
|
140
|
+
json = JSON.parse(str);
|
|
141
|
+
}
|
|
142
|
+
// json = JSON.parse(this.sanitizeString(JSON.stringify(json)));
|
|
143
|
+
return json;
|
|
144
|
+
};
|
|
145
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
146
|
+
LayoutHelperMethods.indexOfAny = function (text, wordSplitCharacter) {
|
|
147
|
+
var index = undefined;
|
|
148
|
+
for (var j = 0; j < wordSplitCharacter.length; j++) {
|
|
149
|
+
var temp = text.indexOf(wordSplitCharacter[parseInt(j.toString(), 10)]);
|
|
150
|
+
if (temp !== -1 && isNullOrUndefined(index)) {
|
|
151
|
+
index = temp;
|
|
152
|
+
}
|
|
153
|
+
else if (temp !== -1 && temp < index) {
|
|
154
|
+
index = temp;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return isNullOrUndefined(index) ? -1 : index;
|
|
158
|
+
};
|
|
159
|
+
LayoutHelperMethods.convertHexToRgb = function (colorCode) {
|
|
160
|
+
var r;
|
|
161
|
+
var g;
|
|
162
|
+
var b;
|
|
163
|
+
if (colorCode) {
|
|
164
|
+
colorCode = colorCode.replace(/[^0-9A-‌​F]/gi, ''); // To remove # from color code string.
|
|
165
|
+
var colCodeNo = parseInt(colorCode, 16);
|
|
166
|
+
if (colorCode.length === 8) {
|
|
167
|
+
r = (colCodeNo >> 32) & 255;
|
|
168
|
+
g = (colCodeNo >> 16) & 255;
|
|
169
|
+
b = (colCodeNo >> 8) & 255;
|
|
170
|
+
}
|
|
171
|
+
else if (colorCode.length === 6) {
|
|
172
|
+
r = (colCodeNo >> 16) & 255;
|
|
173
|
+
g = (colCodeNo >> 8) & 255;
|
|
174
|
+
b = colCodeNo & 255;
|
|
175
|
+
}
|
|
176
|
+
return { 'r': r, 'g': g, 'b': b };
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
};
|
|
180
|
+
LayoutHelperMethods.convertPointToPixel = function (point) {
|
|
181
|
+
var value = point !== undefined ? point : 0;
|
|
182
|
+
var roundedPoint = LayoutHelperMethods.round(value, 5);
|
|
183
|
+
var pixel = LayoutHelperMethods.round((roundedPoint * 96 / 72), 5);
|
|
184
|
+
return pixel;
|
|
185
|
+
};
|
|
186
|
+
LayoutHelperMethods.convertPixelToPoint = function (pixel) {
|
|
187
|
+
var value = pixel !== undefined ? pixel : 0;
|
|
188
|
+
var point = LayoutHelperMethods.round((value * 72 / 96), 5);
|
|
189
|
+
return point;
|
|
190
|
+
};
|
|
191
|
+
LayoutHelperMethods.isLinkedFieldCharacter = function (inline) {
|
|
192
|
+
if (inline instanceof FieldElementBox && inline.fieldType === 0) {
|
|
193
|
+
return !isNullOrUndefined(inline.fieldEnd);
|
|
194
|
+
}
|
|
195
|
+
else if (inline instanceof FieldElementBox && inline.fieldType === 2) {
|
|
196
|
+
return !isNullOrUndefined(inline.fieldBegin) && !isNullOrUndefined(inline.fieldEnd);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
return !isNullOrUndefined(inline.fieldBegin);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Removes white space in a string.
|
|
204
|
+
*
|
|
205
|
+
* @private
|
|
206
|
+
* @param {string} text - Specifies text to trim.
|
|
207
|
+
* @returns {string} - Returns modified text.
|
|
208
|
+
*/
|
|
209
|
+
LayoutHelperMethods.removeSpace = function (text) {
|
|
210
|
+
if (!isNullOrUndefined(text) && text.length !== 0) {
|
|
211
|
+
for (var i = 0; i < text.length; i++) {
|
|
212
|
+
if (text.charAt(i) === ' ') {
|
|
213
|
+
//replace the space by empty string in string
|
|
214
|
+
text = text.replace(' ', '');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return text;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Trims white space at start of the string.
|
|
222
|
+
*
|
|
223
|
+
* @private
|
|
224
|
+
* @param {string} text - Specifies text to trim.
|
|
225
|
+
* @returns {string} - Returns modified text.
|
|
226
|
+
*/
|
|
227
|
+
LayoutHelperMethods.trimStart = function (text) {
|
|
228
|
+
var i = 0;
|
|
229
|
+
for (i; i < text.length; i++) {
|
|
230
|
+
if (text[parseInt(i.toString(), 10)] !== ' ') {
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return text.substring(i, text.length);
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Trims white space at end of the string.
|
|
238
|
+
*
|
|
239
|
+
* @private
|
|
240
|
+
* @param {string} text - Specifies text to trim.
|
|
241
|
+
* @returns {string} - Returns modified text.
|
|
242
|
+
*/
|
|
243
|
+
LayoutHelperMethods.trimEnd = function (text) {
|
|
244
|
+
var i = text.length - 1;
|
|
245
|
+
for (i; i >= 0; i--) {
|
|
246
|
+
if (text[parseInt(i.toString(), 10)] !== ' ') {
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return text.substring(0, i + 1);
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Checks whether string ends with whitespace.
|
|
254
|
+
*
|
|
255
|
+
* @private
|
|
256
|
+
* @param {string} text - Specifies the text.
|
|
257
|
+
* @returns {boolean} - Returns true if text ends with specified text.
|
|
258
|
+
*/
|
|
259
|
+
LayoutHelperMethods.endsWith = function (text) {
|
|
260
|
+
if (!isNullOrUndefined(text) && text.length !== 0) {
|
|
261
|
+
return text[text.length - 1] === ' ';
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
};
|
|
265
|
+
LayoutHelperMethods.addSpace = function (length) {
|
|
266
|
+
var str = '';
|
|
267
|
+
if (length > 0) {
|
|
268
|
+
for (var i = 0; i < length; i++) {
|
|
269
|
+
str += ' ';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return str;
|
|
273
|
+
};
|
|
274
|
+
LayoutHelperMethods.getBoolValue = function (value) {
|
|
275
|
+
return value ? 1 : 0;
|
|
276
|
+
};
|
|
277
|
+
LayoutHelperMethods.getBoolInfo = function (value, keywordIndex) {
|
|
278
|
+
if (keywordIndex === 1) {
|
|
279
|
+
return this.getBoolValue(value);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
return value;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
LayoutHelperMethods.parseBoolValue = function (value) {
|
|
286
|
+
if (value instanceof String) {
|
|
287
|
+
if (isNullOrUndefined(value) || value === 'f' || value === '0' || value === 'off' || value === 'false') {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/* eslint-disable eqeqeq */
|
|
295
|
+
else {
|
|
296
|
+
if (value == 1) {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
/* eslint-enable eqeqeq */
|
|
305
|
+
LayoutHelperMethods.getBaselineAlignmentEnumValue = function (baselineAlignment) {
|
|
306
|
+
switch (baselineAlignment) {
|
|
307
|
+
case 'Normal':
|
|
308
|
+
return 0;
|
|
309
|
+
case 'Superscript':
|
|
310
|
+
return 1;
|
|
311
|
+
case 'Subscript':
|
|
312
|
+
return 2;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
LayoutHelperMethods.getFontHintTypeEnumValue = function (fontHintType) {
|
|
316
|
+
switch (fontHintType) {
|
|
317
|
+
case 'Default':
|
|
318
|
+
return 0;
|
|
319
|
+
case 'EastAsia':
|
|
320
|
+
return 1;
|
|
321
|
+
case 'CS':
|
|
322
|
+
return 2;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
LayoutHelperMethods.getUnderlineEnumValue = function (underline) {
|
|
326
|
+
switch (underline) {
|
|
327
|
+
case 'None':
|
|
328
|
+
return 0;
|
|
329
|
+
case 'Single':
|
|
330
|
+
return 1;
|
|
331
|
+
case 'Words':
|
|
332
|
+
return 2;
|
|
333
|
+
case 'Double':
|
|
334
|
+
return 3;
|
|
335
|
+
case 'Dotted':
|
|
336
|
+
return 4;
|
|
337
|
+
case 'Thick':
|
|
338
|
+
return 5;
|
|
339
|
+
case 'Dash':
|
|
340
|
+
return 6;
|
|
341
|
+
case 'DashLong':
|
|
342
|
+
return 7;
|
|
343
|
+
case 'DotDash':
|
|
344
|
+
return 8;
|
|
345
|
+
case 'DotDotDash':
|
|
346
|
+
return 9;
|
|
347
|
+
case 'Wavy':
|
|
348
|
+
return 10;
|
|
349
|
+
case 'DottedHeavy':
|
|
350
|
+
return 11;
|
|
351
|
+
case 'DashHeavy':
|
|
352
|
+
return 12;
|
|
353
|
+
case 'DashLongHeavy':
|
|
354
|
+
return 13;
|
|
355
|
+
case 'DotDashHeavy':
|
|
356
|
+
return 14;
|
|
357
|
+
case 'DotDotDashHeavy':
|
|
358
|
+
return 15;
|
|
359
|
+
case 'WavyHeavy':
|
|
360
|
+
return 16;
|
|
361
|
+
case 'WavyDouble':
|
|
362
|
+
return 17;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
/* eslint-disable */
|
|
366
|
+
LayoutHelperMethods.getStrikeThroughEnumValue = function (strikethrough) {
|
|
367
|
+
switch (strikethrough) {
|
|
368
|
+
case 'None':
|
|
369
|
+
return 0;
|
|
370
|
+
case 'SingleStrike':
|
|
371
|
+
return 1;
|
|
372
|
+
case 'DoubleStrike':
|
|
373
|
+
return 2;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
LayoutHelperMethods.getHighlightColorEnumValue = function (highlightColor) {
|
|
377
|
+
switch (highlightColor) {
|
|
378
|
+
case 'NoColor':
|
|
379
|
+
return 0;
|
|
380
|
+
case 'Yellow':
|
|
381
|
+
return 1;
|
|
382
|
+
case 'BrightGreen':
|
|
383
|
+
return 2;
|
|
384
|
+
case 'Turquoise':
|
|
385
|
+
return 3;
|
|
386
|
+
case 'Pink':
|
|
387
|
+
return 4;
|
|
388
|
+
case 'Blue':
|
|
389
|
+
return 5;
|
|
390
|
+
case 'Red':
|
|
391
|
+
return 6;
|
|
392
|
+
case 'DarkBlue':
|
|
393
|
+
return 7;
|
|
394
|
+
case 'Teal':
|
|
395
|
+
return 8;
|
|
396
|
+
case 'Green':
|
|
397
|
+
return 9;
|
|
398
|
+
case 'Violet':
|
|
399
|
+
return 10;
|
|
400
|
+
case 'DarkRed':
|
|
401
|
+
return 11;
|
|
402
|
+
case 'DarkYellow':
|
|
403
|
+
return 12;
|
|
404
|
+
case 'Gray50':
|
|
405
|
+
return 13;
|
|
406
|
+
case 'Gray25':
|
|
407
|
+
return 14;
|
|
408
|
+
case 'Black':
|
|
409
|
+
return 15;
|
|
410
|
+
default:
|
|
411
|
+
return highlightColor;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
LayoutHelperMethods.getBiDirectionalOverride = function (biDirectionalOverride) {
|
|
415
|
+
switch (biDirectionalOverride) {
|
|
416
|
+
case 'None':
|
|
417
|
+
return 0;
|
|
418
|
+
case 'LTR':
|
|
419
|
+
return 1;
|
|
420
|
+
case 'RTL':
|
|
421
|
+
return 2;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
/* eslint-disable */
|
|
425
|
+
LayoutHelperMethods.getOutlineLevelEnumValue = function (outlineLevel) {
|
|
426
|
+
switch (outlineLevel) {
|
|
427
|
+
case 'BodyText':
|
|
428
|
+
return 0;
|
|
429
|
+
case 'Level1':
|
|
430
|
+
return 1;
|
|
431
|
+
case 'Level2':
|
|
432
|
+
return 2;
|
|
433
|
+
case 'Level3':
|
|
434
|
+
return 3;
|
|
435
|
+
case 'Level4':
|
|
436
|
+
return 4;
|
|
437
|
+
case 'Level5':
|
|
438
|
+
return 5;
|
|
439
|
+
case 'Level6':
|
|
440
|
+
return 6;
|
|
441
|
+
case 'Level7':
|
|
442
|
+
return 7;
|
|
443
|
+
case 'Level8':
|
|
444
|
+
return 8;
|
|
445
|
+
case 'Level9':
|
|
446
|
+
return 9;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
/* eslint-disable */
|
|
450
|
+
LayoutHelperMethods.getTextAlignmentEnumValue = function (textAlignment) {
|
|
451
|
+
switch (textAlignment) {
|
|
452
|
+
case 'Left':
|
|
453
|
+
return 0;
|
|
454
|
+
case 'Center':
|
|
455
|
+
return 1;
|
|
456
|
+
case 'Right':
|
|
457
|
+
return 2;
|
|
458
|
+
case 'Justify':
|
|
459
|
+
return 3;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
/* eslint-disable */
|
|
463
|
+
LayoutHelperMethods.getLineStyleEnumValue = function (lineStyle) {
|
|
464
|
+
switch (lineStyle) {
|
|
465
|
+
case 'Single':
|
|
466
|
+
return 0;
|
|
467
|
+
case 'None':
|
|
468
|
+
return 1;
|
|
469
|
+
case 'Dot':
|
|
470
|
+
return 2;
|
|
471
|
+
case 'DashSmallGap':
|
|
472
|
+
return 3;
|
|
473
|
+
case 'DashLargeGap':
|
|
474
|
+
return 4;
|
|
475
|
+
case 'DashDot':
|
|
476
|
+
return 5;
|
|
477
|
+
case 'DashDotDot':
|
|
478
|
+
return 6;
|
|
479
|
+
case 'Double':
|
|
480
|
+
return 7;
|
|
481
|
+
case 'Triple':
|
|
482
|
+
return 8;
|
|
483
|
+
case 'ThinThickSmallGap':
|
|
484
|
+
return 9;
|
|
485
|
+
case 'ThickThinSmallGap':
|
|
486
|
+
return 10;
|
|
487
|
+
case 'ThinThickThinSmallGap':
|
|
488
|
+
return 11;
|
|
489
|
+
case 'ThinThickMediumGap':
|
|
490
|
+
return 12;
|
|
491
|
+
case 'ThickThinMediumGap':
|
|
492
|
+
return 13;
|
|
493
|
+
case 'ThinThickThinMediumGap':
|
|
494
|
+
return 14;
|
|
495
|
+
case 'ThinThickLargeGap':
|
|
496
|
+
return 15;
|
|
497
|
+
case 'ThickThinLargeGap':
|
|
498
|
+
return 16;
|
|
499
|
+
case 'ThinThickThinLargeGap':
|
|
500
|
+
return 17;
|
|
501
|
+
case 'SingleWavy':
|
|
502
|
+
return 18;
|
|
503
|
+
case 'DoubleWavy':
|
|
504
|
+
return 19;
|
|
505
|
+
case 'DashDotStroked':
|
|
506
|
+
return 20;
|
|
507
|
+
case 'Emboss3D':
|
|
508
|
+
return 21;
|
|
509
|
+
case 'Engrave3D':
|
|
510
|
+
return 22;
|
|
511
|
+
case 'Outset':
|
|
512
|
+
return 23;
|
|
513
|
+
case 'Inset':
|
|
514
|
+
return 24;
|
|
515
|
+
case 'Thick':
|
|
516
|
+
return 25;
|
|
517
|
+
case 'Cleared':
|
|
518
|
+
return 26;
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
/* eslint-disable */
|
|
522
|
+
LayoutHelperMethods.getLineSpacingTypeEnumValue = function (lineSpacing) {
|
|
523
|
+
switch (lineSpacing) {
|
|
524
|
+
case 'Multiple':
|
|
525
|
+
return 0;
|
|
526
|
+
case 'AtLeast':
|
|
527
|
+
return 1;
|
|
528
|
+
case 'Exactly':
|
|
529
|
+
return 2;
|
|
530
|
+
case 'Single':
|
|
531
|
+
return 3;
|
|
532
|
+
case 'Double':
|
|
533
|
+
return 4;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
/* eslint-disable */
|
|
537
|
+
LayoutHelperMethods.writeBorder = function (wBorder, keywordIndex) {
|
|
538
|
+
var border = {};
|
|
539
|
+
border[colorProperty[keywordIndex]] = wBorder.hasValue('color') ? wBorder.color : undefined;
|
|
540
|
+
border[hasNoneStyleProperty[keywordIndex]] = wBorder.hasValue('hasNoneStyle') ? LayoutHelperMethods.getBoolInfo(wBorder.hasNoneStyle, keywordIndex) : undefined;
|
|
541
|
+
border[lineStyleProperty[keywordIndex]] = wBorder.hasValue('lineStyle') ?
|
|
542
|
+
keywordIndex == 1 ? this.getLineStyleEnumValue(wBorder.lineStyle) : wBorder.lineStyle : undefined;
|
|
543
|
+
border[lineWidthProperty[keywordIndex]] = wBorder.hasValue('lineWidth') ? wBorder.lineWidth : undefined;
|
|
544
|
+
border[shadowProperty[keywordIndex]] = wBorder.hasValue('shadow') ? LayoutHelperMethods.getBoolInfo(wBorder.shadow, keywordIndex) : undefined;
|
|
545
|
+
border[spaceProperty[keywordIndex]] = wBorder.hasValue('space') ? wBorder.space : undefined;
|
|
546
|
+
return border;
|
|
547
|
+
};
|
|
548
|
+
/* eslint-disable */
|
|
549
|
+
LayoutHelperMethods.writeBorders = function (wBorders, keywordIndex) {
|
|
550
|
+
var borders = {};
|
|
551
|
+
borders[topProperty[keywordIndex]] = this.writeBorder(wBorders.getBorder('top'), keywordIndex);
|
|
552
|
+
borders[leftProperty[keywordIndex]] = this.writeBorder(wBorders.getBorder('left'), keywordIndex);
|
|
553
|
+
borders[rightProperty[keywordIndex]] = this.writeBorder(wBorders.getBorder('right'), keywordIndex);
|
|
554
|
+
borders[bottomProperty[keywordIndex]] = this.writeBorder(wBorders.getBorder('bottom'), keywordIndex);
|
|
555
|
+
borders[horizontalProperty[keywordIndex]] = this.writeBorder(wBorders.getBorder('horizontal'), keywordIndex);
|
|
556
|
+
borders[verticalProperty[keywordIndex]] = this.writeBorder(wBorders.getBorder('vertical'), keywordIndex);
|
|
557
|
+
return borders;
|
|
558
|
+
};
|
|
559
|
+
/* eslint-disable */
|
|
560
|
+
LayoutHelperMethods.writeParagraphFormat = function (paragraphFormat, isInline, format, keywordIndex) {
|
|
561
|
+
keywordIndex = isNullOrUndefined(keywordIndex) ? 0 : keywordIndex;
|
|
562
|
+
paragraphFormat[bordersProperty[keywordIndex]] = this.writeBorders(format.borders, keywordIndex);
|
|
563
|
+
paragraphFormat[leftIndentProperty[keywordIndex]] = isInline ? format.leftIndent : format.getValue('leftIndent');
|
|
564
|
+
paragraphFormat[rightIndentProperty[keywordIndex]] = isInline ? format.rightIndent : format.getValue('rightIndent');
|
|
565
|
+
paragraphFormat[firstLineIndentProperty[keywordIndex]] = isInline ? format.firstLineIndent : format.getValue('firstLineIndent');
|
|
566
|
+
paragraphFormat[textAlignmentProperty[keywordIndex]] = isInline ?
|
|
567
|
+
keywordIndex == 1 ? this.getTextAlignmentEnumValue(format.textAlignment) : format.textAlignment :
|
|
568
|
+
keywordIndex == 1 ? this.getTextAlignmentEnumValue(format.getValue('textAlignment')) : format.getValue('textAlignment');
|
|
569
|
+
paragraphFormat[beforeSpacingProperty[keywordIndex]] = isInline ? format.beforeSpacing : format.getValue('beforeSpacing');
|
|
570
|
+
paragraphFormat[afterSpacingProperty[keywordIndex]] = isInline ? format.afterSpacing : format.getValue('afterSpacing');
|
|
571
|
+
paragraphFormat[spaceBeforeAutoProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.spaceBeforeAuto, keywordIndex) : format.getValue('spaceBeforeAuto');
|
|
572
|
+
paragraphFormat[spaceAfterAutoProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.spaceAfterAuto, keywordIndex) : format.getValue('spaceAfterAuto');
|
|
573
|
+
paragraphFormat[lineSpacingProperty[keywordIndex]] = isInline ? format.lineSpacing : format.getValue('lineSpacing');
|
|
574
|
+
paragraphFormat[lineSpacingTypeProperty[keywordIndex]] = isInline ?
|
|
575
|
+
keywordIndex == 1 ? this.getLineSpacingTypeEnumValue(format.lineSpacingType) : format.lineSpacingType :
|
|
576
|
+
keywordIndex == 1 ? this.getLineSpacingTypeEnumValue(format.getValue('lineSpacingType')) : format.getValue('lineSpacingType');
|
|
577
|
+
paragraphFormat[styleNameProperty[keywordIndex]] = !isNullOrUndefined(format.baseStyle) ? format.baseStyle.name : undefined;
|
|
578
|
+
paragraphFormat[outlineLevelProperty[keywordIndex]] = isInline ?
|
|
579
|
+
keywordIndex == 1 ? this.getOutlineLevelEnumValue(format.outlineLevel) : format.outlineLevel :
|
|
580
|
+
keywordIndex == 1 ? this.getOutlineLevelEnumValue(format.getValue('outlineLevel')) : format.getValue('outlineLevel');
|
|
581
|
+
paragraphFormat[bidiProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.bidi, keywordIndex) : format.getValue('bidi');
|
|
582
|
+
paragraphFormat[keepLinesTogetherProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.keepLinesTogether, keywordIndex) : format.getValue('keepLinesTogether');
|
|
583
|
+
paragraphFormat[keepWithNextProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.keepWithNext, keywordIndex) : format.getValue('keepWithNext');
|
|
584
|
+
paragraphFormat[contextualSpacingProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.contextualSpacing, keywordIndex) : format.getValue('contextualSpacing');
|
|
585
|
+
paragraphFormat[widowControlProperty[keywordIndex]] = isInline ? LayoutHelperMethods.getBoolInfo(format.widowControl, keywordIndex) : format.getValue('widowControl');
|
|
586
|
+
};
|
|
587
|
+
/* eslint-disable */
|
|
588
|
+
LayoutHelperMethods.writeCharacterFormat = function (characterFormat, isInline, format, keywordIndex, isWriteAllValues) {
|
|
589
|
+
keywordIndex = isNullOrUndefined(keywordIndex) ? 0 : keywordIndex;
|
|
590
|
+
characterFormat[boldProperty[keywordIndex]] = isWriteAllValues ? LayoutHelperMethods.getBoolInfo(format.bold, keywordIndex) : isInline ? LayoutHelperMethods.getBoolInfo(format.bold, keywordIndex) : format.getValue('bold');
|
|
591
|
+
characterFormat[italicProperty[keywordIndex]] = isWriteAllValues ? LayoutHelperMethods.getBoolInfo(format.italic, keywordIndex) : isInline ? LayoutHelperMethods.getBoolInfo(format.italic, keywordIndex) : format.getValue('italic');
|
|
592
|
+
characterFormat[fontSizeProperty[keywordIndex]] = isWriteAllValues ? format.fontSize : isInline ? this.toWriteInline(format, 'fontSize') : format.getValue('fontSize');
|
|
593
|
+
characterFormat[fontFamilyProperty[keywordIndex]] = isWriteAllValues ? format.fontFamily : isInline ? this.toWriteInline(format, 'fontFamily') : format.getValue('fontFamily');
|
|
594
|
+
characterFormat[underlineProperty[keywordIndex]] = isWriteAllValues ? format.underline : isInline ?
|
|
595
|
+
keywordIndex == 1 ? LayoutHelperMethods.getUnderlineEnumValue(format.underline) : format.underline :
|
|
596
|
+
keywordIndex == 1 ? LayoutHelperMethods.getUnderlineEnumValue(format.getValue('underline')) : format.getValue('underline');
|
|
597
|
+
characterFormat[underlineColorProperty[keywordIndex]] = isWriteAllValues ? format.underlineColor : isInline ? this.toWriteInline(format, 'underlineColor') : format.getValue('underlineColor');
|
|
598
|
+
characterFormat[fontHintTypeProperty[keywordIndex]] = isWriteAllValues ? format.fontHintType : isInline ?
|
|
599
|
+
keywordIndex == 1 ? LayoutHelperMethods.getFontHintTypeEnumValue(format.fontHintType) : (format.fontHintType) :
|
|
600
|
+
keywordIndex == 1 ? LayoutHelperMethods.getFontHintTypeEnumValue(format.getValue('fontHintType')) : format.getValue('fontHintType');
|
|
601
|
+
characterFormat[strikethroughProperty[keywordIndex]] = isWriteAllValues ? format.strikethrough : isInline ?
|
|
602
|
+
keywordIndex == 1 ? LayoutHelperMethods.getStrikeThroughEnumValue(format.strikethrough) : (format.strikethrough) :
|
|
603
|
+
keywordIndex == 1 ? LayoutHelperMethods.getStrikeThroughEnumValue(format.getValue('strikethrough')) : format.getValue('strikethrough');
|
|
604
|
+
characterFormat[baselineAlignmentProperty[keywordIndex]] = isWriteAllValues ? format.baselineAlignment : isInline ?
|
|
605
|
+
keywordIndex == 1 ? LayoutHelperMethods.getBaselineAlignmentEnumValue(format.baselineAlignment) : (format.baselineAlignment) :
|
|
606
|
+
keywordIndex == 1 ? LayoutHelperMethods.getBaselineAlignmentEnumValue(format.getValue('baselineAlignment')) : format.getValue('baselineAlignment');
|
|
607
|
+
characterFormat[highlightColorProperty[keywordIndex]] = isWriteAllValues ? format.highlightColor : isInline ?
|
|
608
|
+
keywordIndex == 1 ? LayoutHelperMethods.getHighlightColorEnumValue(format.highlightColor) : (format.highlightColor) :
|
|
609
|
+
keywordIndex == 1 ? LayoutHelperMethods.getHighlightColorEnumValue(format.getValue('highlightColor')) : format.getValue('highlightColor');
|
|
610
|
+
characterFormat[fontColorProperty[keywordIndex]] = isWriteAllValues ? format.fontColor : isInline ? this.toWriteInline(format, 'fontColor') : format.getValue('fontColor');
|
|
611
|
+
characterFormat[styleNameProperty[keywordIndex]] = !isNullOrUndefined(format.baseCharStyle) ? format.baseCharStyle.name : undefined;
|
|
612
|
+
characterFormat[bidiProperty[keywordIndex]] = isWriteAllValues ? format.bidi : isInline ? LayoutHelperMethods.getBoolInfo(format.bidi, keywordIndex) : format.getValue('bidi');
|
|
613
|
+
characterFormat[bdoProperty[keywordIndex]] = isWriteAllValues ? format.bdo : isInline ?
|
|
614
|
+
keywordIndex == 1 ? LayoutHelperMethods.getBiDirectionalOverride(format.bdo) : (format.bdo) :
|
|
615
|
+
keywordIndex == 1 ? LayoutHelperMethods.getBiDirectionalOverride(format.getValue('bdo')) : format.getValue('bdo');
|
|
616
|
+
characterFormat[boldBidiProperty[keywordIndex]] = isWriteAllValues ? format.boldBidi : isInline ? LayoutHelperMethods.getBoolInfo(format.boldBidi, keywordIndex) : format.getValue('boldBidi');
|
|
617
|
+
characterFormat[italicBidiProperty[keywordIndex]] = isWriteAllValues ? format.italicBidi : isInline ? LayoutHelperMethods.getBoolInfo(format.italicBidi, keywordIndex) : format.getValue('italicBidi');
|
|
618
|
+
characterFormat[fontSizeBidiProperty[keywordIndex]] = isWriteAllValues ? format.fontSizeBidi : isInline ? format.fontSizeBidi : format.getValue('fontSizeBidi');
|
|
619
|
+
characterFormat[fontFamilyBidiProperty[keywordIndex]] = isWriteAllValues ? format.fontFamilyBidi : isInline ? format.fontFamilyBidi : format.getValue('fontFamilyBidi');
|
|
620
|
+
characterFormat[allCapsProperty[keywordIndex]] = isWriteAllValues ? format.allCaps : isInline ? LayoutHelperMethods.getBoolInfo(format.allCaps, keywordIndex) : format.getValue('allCaps');
|
|
621
|
+
characterFormat[localeIdBidiProperty[keywordIndex]] = isWriteAllValues ? format.localeIdBidi : isInline ? format.localeIdBidi : format.getValue('localeIdBidi');
|
|
622
|
+
characterFormat[ligatureProperty[keywordIndex]] = isWriteAllValues ? format.ligature : isInline ? format.ligature : format.getValue('ligature');
|
|
623
|
+
characterFormat[localeIdProperty[keywordIndex]] = isWriteAllValues ? format.localeIdBidi : isInline ? format.localeIdAscii : format.getValue('localeIdAscii');
|
|
624
|
+
characterFormat[localeIdFarEastProperty[keywordIndex]] = isWriteAllValues ? format.localeIdFarEast : isInline ? format.localeIdFarEast : format.getValue('localeIdFarEast');
|
|
625
|
+
characterFormat[complexScriptProperty[keywordIndex]] = isWriteAllValues ? format.complexScript : isInline ? LayoutHelperMethods.getBoolInfo(format.complexScript, keywordIndex) : format.getValue('complexScript');
|
|
626
|
+
if (format.hasValue('hidden')) {
|
|
627
|
+
characterFormat[hiddenProperty[keywordIndex]] = isWriteAllValues ? format.hidden : isInline ? LayoutHelperMethods.getBoolInfo(format.hidden, keywordIndex) : format.getValue('hidden');
|
|
628
|
+
}
|
|
629
|
+
if (format.hasValue('specVanish')) {
|
|
630
|
+
characterFormat[specVanishProperty[keywordIndex]] = isWriteAllValues ? format.specVanish : isInline ? LayoutHelperMethods.getBoolInfo(format.specVanish, keywordIndex) : format.getValue('specVanish');
|
|
631
|
+
}
|
|
632
|
+
characterFormat[fontFamilyAsciiProperty[keywordIndex]] = isWriteAllValues ? format.fontFamilyAscii : isInline ? this.toWriteInline(format, 'fontFamilyAscii') : format.getValue('fontFamilyAscii');
|
|
633
|
+
characterFormat[fontFamilyNonFarEastProperty[keywordIndex]] = isWriteAllValues ? format.fontFamilyNonFarEast : isInline ? this.toWriteInline(format, 'fontFamilyNonFarEast') : format.getValue('fontFamilyNonFarEast');
|
|
634
|
+
characterFormat[fontFamilyFarEastProperty[keywordIndex]] = isWriteAllValues ? format.fontFamilyFarEast : isInline ? this.toWriteInline(format, 'fontFamilyFarEast') : format.getValue('fontFamilyFarEast');
|
|
635
|
+
characterFormat[characterSpacingProperty[keywordIndex]] = isWriteAllValues ? format.characterSpacing : isInline ? this.toWriteInline(format, 'characterSpacing') : format.getValue('characterSpacing');
|
|
636
|
+
characterFormat[scalingProperty[keywordIndex]] = isWriteAllValues ? format.scaling : isInline ? this.toWriteInline(format, 'scaling') : format.getValue('scaling');
|
|
637
|
+
if (format.hasValue('fontFamily') || isWriteAllValues) {
|
|
638
|
+
if (isNullOrUndefined(characterFormat[fontFamilyAsciiProperty[keywordIndex]])) {
|
|
639
|
+
characterFormat[fontFamilyAsciiProperty[keywordIndex]] = format.fontFamily;
|
|
640
|
+
}
|
|
641
|
+
if (isNullOrUndefined(characterFormat[fontFamilyNonFarEastProperty[keywordIndex]])) {
|
|
642
|
+
characterFormat[fontFamilyNonFarEastProperty[keywordIndex]] = format.fontFamily;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
/// <summary>
|
|
647
|
+
/// To check whether the font name is theme font or not.
|
|
648
|
+
/// </summary>
|
|
649
|
+
/// <param name="fontName">Specify the font name.</param>
|
|
650
|
+
/// <returns>Returns true if the font name is represent a theme font.</returns>
|
|
651
|
+
LayoutHelperMethods.isThemeFont = function (fontName) {
|
|
652
|
+
return (fontName == "majorAscii" || fontName == "majorBidi" || fontName == "majorEastAsia"
|
|
653
|
+
|| fontName == "majorHAnsi" || fontName == "minorAscii" || fontName == "minorBidi" || fontName == "minorEastAsia"
|
|
654
|
+
|| fontName == "minorHAnsi");
|
|
655
|
+
};
|
|
656
|
+
LayoutHelperMethods.toWriteInline = function (format, propertyName) {
|
|
657
|
+
if (!isNullOrUndefined(format.ownerBase) && (format.ownerBase instanceof ElementBox)) {
|
|
658
|
+
return format.hasValue(propertyName) ? format[propertyName] : format.getValue(propertyName);
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
return format[propertyName];
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
/* eslint-enable */
|
|
665
|
+
LayoutHelperMethods.round = function (value, decimalDigits) {
|
|
666
|
+
var temp = value;
|
|
667
|
+
for (var i = 0; i < decimalDigits; i++) {
|
|
668
|
+
temp = temp * 10;
|
|
669
|
+
}
|
|
670
|
+
temp = Math.round(temp);
|
|
671
|
+
for (var i = 0; i < decimalDigits; i++) {
|
|
672
|
+
temp = temp / 10;
|
|
673
|
+
}
|
|
674
|
+
return temp;
|
|
675
|
+
};
|
|
676
|
+
LayoutHelperMethods.reverseString = function (text) {
|
|
677
|
+
if (!isNullOrUndefined(text) && text !== '') {
|
|
678
|
+
// return a new array
|
|
679
|
+
var splitString = text.split('');
|
|
680
|
+
// reverse the new created array
|
|
681
|
+
var reverseString = splitString.reverse();
|
|
682
|
+
// join all elements of the array into a string
|
|
683
|
+
text = reverseString.join('');
|
|
684
|
+
}
|
|
685
|
+
return text;
|
|
686
|
+
};
|
|
687
|
+
LayoutHelperMethods.formatClippedString = function (base64ImageString) {
|
|
688
|
+
var extension = '';
|
|
689
|
+
var formatClippedString = '';
|
|
690
|
+
if (this.startsWith(base64ImageString, 'data:image/svg+xml;base64,')) {
|
|
691
|
+
extension = '.svg';
|
|
692
|
+
formatClippedString = base64ImageString.replace('data:image/svg+xml;base64,', '');
|
|
693
|
+
}
|
|
694
|
+
else if (this.startsWith(base64ImageString, 'data:image/svg+xml;utf8,')) {
|
|
695
|
+
extension = '.svg';
|
|
696
|
+
formatClippedString = base64ImageString.replace('data:image/svg+xml;utf8,', '');
|
|
697
|
+
}
|
|
698
|
+
else if (this.startsWith(base64ImageString, 'data:image/bmp;base64,')) {
|
|
699
|
+
extension = '.bmp';
|
|
700
|
+
formatClippedString = base64ImageString.replace('data:image/bmp;base64,', '');
|
|
701
|
+
}
|
|
702
|
+
else if (this.startsWith(base64ImageString, 'data:image/x-emf;base64,')) {
|
|
703
|
+
extension = '.emf';
|
|
704
|
+
formatClippedString = base64ImageString.replace('data:image/x-emf;base64,', '');
|
|
705
|
+
}
|
|
706
|
+
else if (this.startsWith(base64ImageString, 'data:image/exif;base64,')) {
|
|
707
|
+
extension = '.exif';
|
|
708
|
+
formatClippedString = base64ImageString.replace('data:image/exif;base64,', '');
|
|
709
|
+
}
|
|
710
|
+
else if (this.startsWith(base64ImageString, 'data:image/gif;base64,')) {
|
|
711
|
+
extension = '.gif';
|
|
712
|
+
formatClippedString = base64ImageString.replace('data:image/gif;base64,', '');
|
|
713
|
+
}
|
|
714
|
+
else if (this.startsWith(base64ImageString, 'data:image/icon;base64,')) {
|
|
715
|
+
extension = '.ico';
|
|
716
|
+
formatClippedString = base64ImageString.replace('data:image/icon;base64,', '');
|
|
717
|
+
}
|
|
718
|
+
else if (this.startsWith(base64ImageString, 'data:image/jpeg;base64,')) {
|
|
719
|
+
extension = '.jpeg';
|
|
720
|
+
formatClippedString = base64ImageString.replace('data:image/jpeg;base64,', '');
|
|
721
|
+
}
|
|
722
|
+
else if (this.startsWith(base64ImageString, 'data:image/jpg;base64,')) {
|
|
723
|
+
extension = '.jpg';
|
|
724
|
+
formatClippedString = base64ImageString.replace('data:image/jpg;base64,', '');
|
|
725
|
+
}
|
|
726
|
+
else if (this.startsWith(base64ImageString, 'data:image/png;base64,')) {
|
|
727
|
+
extension = '.png';
|
|
728
|
+
formatClippedString = base64ImageString.replace('data:image/png;base64,', '');
|
|
729
|
+
}
|
|
730
|
+
else if (this.startsWith(base64ImageString, 'data:image/tiff;base64,')) {
|
|
731
|
+
extension = '.tif';
|
|
732
|
+
formatClippedString = base64ImageString.replace('data:image/tiff;base64,', '');
|
|
733
|
+
}
|
|
734
|
+
else if (this.startsWith(base64ImageString, 'data:image/x-wmf;base64,')) {
|
|
735
|
+
extension = '.wmf';
|
|
736
|
+
formatClippedString = base64ImageString.replace('data:image/x-wmf;base64,', '');
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
extension = '.jpeg';
|
|
740
|
+
}
|
|
741
|
+
return { 'extension': extension, 'formatClippedString': formatClippedString };
|
|
742
|
+
};
|
|
743
|
+
/**
|
|
744
|
+
* @private
|
|
745
|
+
* @param {string} sourceString - Source string.
|
|
746
|
+
* @param {string} startString - String to check.
|
|
747
|
+
* @returns {boolean} Returns true if the source string starts with the specified string.
|
|
748
|
+
*/
|
|
749
|
+
LayoutHelperMethods.startsWith = function (sourceString, startString) {
|
|
750
|
+
return startString.length > 0 && sourceString.substring(0, startString.length) === startString;
|
|
751
|
+
};
|
|
752
|
+
LayoutHelperMethods.getUtcDate = function (dateTime) {
|
|
753
|
+
if (isNullOrUndefined(dateTime)) {
|
|
754
|
+
dateTime = new Date();
|
|
755
|
+
}
|
|
756
|
+
return new Date(dateTime.getTime() - dateTime.getTimezoneOffset() * 60000).toISOString();
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* @private
|
|
760
|
+
* @param element - element to be splitted of space
|
|
761
|
+
* @param fromStart - weather to removed space from start or end
|
|
762
|
+
* @returns {Boolean} - is the input element is splitted
|
|
763
|
+
*/
|
|
764
|
+
/* eslint-disable */
|
|
765
|
+
LayoutHelperMethods.splitSpaceInTextElementBox = function (element, fromStart) {
|
|
766
|
+
var elementText = element.text;
|
|
767
|
+
var emptySpace = "";
|
|
768
|
+
if (fromStart) {
|
|
769
|
+
while (LayoutHelperMethods.startsWith(elementText, " ")) {
|
|
770
|
+
emptySpace += ' ';
|
|
771
|
+
elementText = elementText.substring(1);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
while (LayoutHelperMethods.endsWith(elementText)) {
|
|
776
|
+
emptySpace += ' ';
|
|
777
|
+
elementText = elementText.slice(0, -1);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (emptySpace != "") {
|
|
781
|
+
var textBox = new TextElementBox();
|
|
782
|
+
textBox.characterFormat.copyFormat(element.characterFormat);
|
|
783
|
+
textBox.line = element.line;
|
|
784
|
+
var lineChildren = textBox.line.children;
|
|
785
|
+
if (fromStart) {
|
|
786
|
+
element.text = emptySpace;
|
|
787
|
+
textBox.text = elementText;
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
element.text = elementText;
|
|
791
|
+
textBox.text = emptySpace;
|
|
792
|
+
}
|
|
793
|
+
lineChildren.splice(lineChildren.indexOf(element) + 1, 0, textBox);
|
|
794
|
+
if (element.revisionLength > 0) {
|
|
795
|
+
for (var i = 0; i < element.revisionLength; i++) {
|
|
796
|
+
var currentRevision = element.getRevision(i);
|
|
797
|
+
textBox.addRevision(currentRevision);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
/* eslint-disable */
|
|
803
|
+
LayoutHelperMethods.getTextIndexAfterWhitespace = function (text, startIndex) {
|
|
804
|
+
var length = text.length;
|
|
805
|
+
var index = 0;
|
|
806
|
+
index = text.indexOf(' ', startIndex) + 1;
|
|
807
|
+
var nextIndex = index;
|
|
808
|
+
if (nextIndex === 0 || nextIndex === length) {
|
|
809
|
+
return nextIndex;
|
|
810
|
+
}
|
|
811
|
+
while (text[nextIndex] === ' ') {
|
|
812
|
+
nextIndex++;
|
|
813
|
+
if (nextIndex === length) {
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return nextIndex;
|
|
818
|
+
};
|
|
819
|
+
/**
|
|
820
|
+
* @private
|
|
821
|
+
* @param {TextElementBox} textElementBox text element box to split the text based on max text length.
|
|
822
|
+
* @param {LineWidget} lineWidget line widget to add the splitted text element box.
|
|
823
|
+
* @returns {void}
|
|
824
|
+
*/
|
|
825
|
+
LayoutHelperMethods.splitWordByMaxLength = function (textElementBox, lineWidget, isInitialParsing) {
|
|
826
|
+
var text = textElementBox.text;
|
|
827
|
+
var index = 0;
|
|
828
|
+
var textLength = text.length;
|
|
829
|
+
var maxLength = 90;
|
|
830
|
+
var splittedText = '';
|
|
831
|
+
var characterFormat = textElementBox.characterFormat;
|
|
832
|
+
//const revisions: Revision[] = textElementBox.revisions;
|
|
833
|
+
var spanIndex = lineWidget.children.indexOf(textElementBox);
|
|
834
|
+
while (index < textLength) {
|
|
835
|
+
var nextIndex = index + maxLength;
|
|
836
|
+
if (nextIndex > textLength) {
|
|
837
|
+
nextIndex = textLength;
|
|
838
|
+
}
|
|
839
|
+
var spaceIndex = LayoutHelperMethods.getTextIndexAfterWhitespace(text, nextIndex);
|
|
840
|
+
if (spaceIndex === 0 || spaceIndex > textLength) {
|
|
841
|
+
spaceIndex = nextIndex;
|
|
842
|
+
}
|
|
843
|
+
splittedText = text.substring(index, spaceIndex);
|
|
844
|
+
if (index === 0) {
|
|
845
|
+
textElementBox.text = splittedText;
|
|
846
|
+
textElementBox.isWidthUpdated = false;
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
var splittedElement = new TextElementBox();
|
|
850
|
+
splittedElement.text = splittedText;
|
|
851
|
+
splittedElement.line = lineWidget;
|
|
852
|
+
splittedElement.characterFormat.copyFormat(characterFormat);
|
|
853
|
+
if (isInitialParsing) {
|
|
854
|
+
lineWidget.children.push(splittedElement);
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
lineWidget.children.splice(spanIndex + 1, 0, splittedElement);
|
|
858
|
+
spanIndex++;
|
|
859
|
+
}
|
|
860
|
+
if (textElementBox.revisionLength > 0) {
|
|
861
|
+
for (var i = 0; i < textElementBox.revisionLength; i++) {
|
|
862
|
+
splittedElement.addRevision(textElementBox.getRevision(i));
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
index = spaceIndex;
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
return LayoutHelperMethods;
|
|
870
|
+
}());
|
|
871
|
+
export { LayoutHelperMethods };
|
|
872
|
+
/**
|
|
873
|
+
* @private
|
|
874
|
+
*/
|
|
875
|
+
var Point = /** @class */ (function () {
|
|
876
|
+
function Point(xPosition, yPosition) {
|
|
877
|
+
this.xIn = 0;
|
|
878
|
+
this.yIn = 0;
|
|
879
|
+
this.xIn = xPosition;
|
|
880
|
+
this.yIn = yPosition;
|
|
881
|
+
}
|
|
882
|
+
Object.defineProperty(Point.prototype, "x", {
|
|
883
|
+
get: function () {
|
|
884
|
+
return this.xIn;
|
|
885
|
+
},
|
|
886
|
+
set: function (value) {
|
|
887
|
+
this.xIn = value;
|
|
888
|
+
},
|
|
889
|
+
enumerable: true,
|
|
890
|
+
configurable: true
|
|
891
|
+
});
|
|
892
|
+
Object.defineProperty(Point.prototype, "y", {
|
|
893
|
+
get: function () {
|
|
894
|
+
return this.yIn;
|
|
895
|
+
},
|
|
896
|
+
set: function (value) {
|
|
897
|
+
this.yIn = value;
|
|
898
|
+
},
|
|
899
|
+
enumerable: true,
|
|
900
|
+
configurable: true
|
|
901
|
+
});
|
|
902
|
+
Point.prototype.copy = function (point) {
|
|
903
|
+
this.xIn = point.xIn;
|
|
904
|
+
this.yIn = point.yIn;
|
|
905
|
+
};
|
|
906
|
+
/**
|
|
907
|
+
* Destroys the internal objects maintained.
|
|
908
|
+
*
|
|
909
|
+
* @returns {void}
|
|
910
|
+
*/
|
|
911
|
+
Point.prototype.destroy = function () {
|
|
912
|
+
this.xIn = undefined;
|
|
913
|
+
this.yIn = undefined;
|
|
914
|
+
};
|
|
915
|
+
return Point;
|
|
916
|
+
}());
|
|
917
|
+
export { Point };
|
|
918
|
+
/**
|
|
919
|
+
* @private
|
|
920
|
+
*/
|
|
921
|
+
var WrapPosition = /** @class */ (function () {
|
|
922
|
+
function WrapPosition(x, width) {
|
|
923
|
+
this.x = 0;
|
|
924
|
+
this.width = 0;
|
|
925
|
+
this.x = x;
|
|
926
|
+
this.width = width;
|
|
927
|
+
}
|
|
928
|
+
Object.defineProperty(WrapPosition.prototype, "right", {
|
|
929
|
+
get: function () {
|
|
930
|
+
return this.x + this.width;
|
|
931
|
+
},
|
|
932
|
+
enumerable: true,
|
|
933
|
+
configurable: true
|
|
934
|
+
});
|
|
935
|
+
return WrapPosition;
|
|
936
|
+
}());
|
|
937
|
+
export { WrapPosition };
|
|
938
|
+
/**
|
|
939
|
+
* @private
|
|
940
|
+
*/
|
|
941
|
+
var SelectionWidgetInfo = /** @class */ (function () {
|
|
942
|
+
/**
|
|
943
|
+
* @private
|
|
944
|
+
* @param {number} left - left
|
|
945
|
+
* @param {number} width - width
|
|
946
|
+
*/
|
|
947
|
+
function SelectionWidgetInfo(left, width) {
|
|
948
|
+
this.leftIn = 0;
|
|
949
|
+
this.widthIn = 0;
|
|
950
|
+
/**
|
|
951
|
+
* @private
|
|
952
|
+
*/
|
|
953
|
+
this.color = '';
|
|
954
|
+
this.leftIn = left;
|
|
955
|
+
this.widthIn = width;
|
|
956
|
+
}
|
|
957
|
+
Object.defineProperty(SelectionWidgetInfo.prototype, "left", {
|
|
958
|
+
/**
|
|
959
|
+
* @private
|
|
960
|
+
* @returns {number} number
|
|
961
|
+
*/
|
|
962
|
+
get: function () {
|
|
963
|
+
return this.leftIn;
|
|
964
|
+
},
|
|
965
|
+
/**
|
|
966
|
+
* @private
|
|
967
|
+
* @param {number} value - value
|
|
968
|
+
*/
|
|
969
|
+
set: function (value) {
|
|
970
|
+
this.leftIn = value;
|
|
971
|
+
},
|
|
972
|
+
enumerable: true,
|
|
973
|
+
configurable: true
|
|
974
|
+
});
|
|
975
|
+
Object.defineProperty(SelectionWidgetInfo.prototype, "width", {
|
|
976
|
+
/**
|
|
977
|
+
* @private
|
|
978
|
+
* @returns {number} number
|
|
979
|
+
*/
|
|
980
|
+
get: function () {
|
|
981
|
+
return this.widthIn;
|
|
982
|
+
},
|
|
983
|
+
/**
|
|
984
|
+
* @private
|
|
985
|
+
* @param {number} value - value
|
|
986
|
+
*/
|
|
987
|
+
set: function (value) {
|
|
988
|
+
this.widthIn = value;
|
|
989
|
+
},
|
|
990
|
+
enumerable: true,
|
|
991
|
+
configurable: true
|
|
992
|
+
});
|
|
993
|
+
/**
|
|
994
|
+
* @private
|
|
995
|
+
* @returns {void}
|
|
996
|
+
*/
|
|
997
|
+
SelectionWidgetInfo.prototype.destroy = function () {
|
|
998
|
+
this.widthIn = undefined;
|
|
999
|
+
this.leftIn = undefined;
|
|
1000
|
+
this.floatingItems = [];
|
|
1001
|
+
this.floatingItems = undefined;
|
|
1002
|
+
};
|
|
1003
|
+
return SelectionWidgetInfo;
|
|
1004
|
+
}());
|
|
1005
|
+
export { SelectionWidgetInfo };
|
|
1006
|
+
/**
|
|
1007
|
+
* @private
|
|
1008
|
+
*/
|
|
1009
|
+
var SearchWidgetInfo = /** @class */ (function () {
|
|
1010
|
+
/**
|
|
1011
|
+
* @private
|
|
1012
|
+
* @param {number} left - left
|
|
1013
|
+
* @param {number} width - width
|
|
1014
|
+
*/
|
|
1015
|
+
function SearchWidgetInfo(left, width) {
|
|
1016
|
+
/**
|
|
1017
|
+
* @private
|
|
1018
|
+
*/
|
|
1019
|
+
this.leftInternal = 0;
|
|
1020
|
+
/**
|
|
1021
|
+
* @private
|
|
1022
|
+
*/
|
|
1023
|
+
this.widthInternal = 0;
|
|
1024
|
+
this.leftInternal = left;
|
|
1025
|
+
this.widthInternal = width;
|
|
1026
|
+
}
|
|
1027
|
+
Object.defineProperty(SearchWidgetInfo.prototype, "left", {
|
|
1028
|
+
/**
|
|
1029
|
+
* @private
|
|
1030
|
+
* @returns {number} number
|
|
1031
|
+
*/
|
|
1032
|
+
get: function () {
|
|
1033
|
+
return this.leftInternal;
|
|
1034
|
+
},
|
|
1035
|
+
/**
|
|
1036
|
+
* @private
|
|
1037
|
+
* @param {number} value - value
|
|
1038
|
+
*/
|
|
1039
|
+
set: function (value) {
|
|
1040
|
+
this.leftInternal = value;
|
|
1041
|
+
},
|
|
1042
|
+
enumerable: true,
|
|
1043
|
+
configurable: true
|
|
1044
|
+
});
|
|
1045
|
+
Object.defineProperty(SearchWidgetInfo.prototype, "width", {
|
|
1046
|
+
/**
|
|
1047
|
+
* @private
|
|
1048
|
+
* @returns {number} number
|
|
1049
|
+
*/
|
|
1050
|
+
get: function () {
|
|
1051
|
+
return this.widthInternal;
|
|
1052
|
+
},
|
|
1053
|
+
/**
|
|
1054
|
+
* @private
|
|
1055
|
+
* @param {number} value - value
|
|
1056
|
+
*/
|
|
1057
|
+
set: function (value) {
|
|
1058
|
+
this.widthInternal = value;
|
|
1059
|
+
},
|
|
1060
|
+
enumerable: true,
|
|
1061
|
+
configurable: true
|
|
1062
|
+
});
|
|
1063
|
+
return SearchWidgetInfo;
|
|
1064
|
+
}());
|
|
1065
|
+
export { SearchWidgetInfo };
|