@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,1079 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { isNullOrUndefined, isUndefined } from '@syncfusion/ej2-base';
|
|
13
|
+
import { WCharacterFormat } from './format/character-format';
|
|
14
|
+
import { defaultFont } from './base/constants';
|
|
15
|
+
import { LayoutHelperMethods } from './helper/layout-helper-methods';
|
|
16
|
+
import { CharacterRangeType, FontScriptType } from './base/types';
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
var TextHelper = /** @class */ (function () {
|
|
21
|
+
function TextHelper(documentHelper) {
|
|
22
|
+
this.paragraphMarkInfo = {};
|
|
23
|
+
this._position = 0;
|
|
24
|
+
this.documentHelper = documentHelper;
|
|
25
|
+
var canvas = document.createElement('canvas');
|
|
26
|
+
var ctx = canvas.getContext('2d');
|
|
27
|
+
if (!ctx) {
|
|
28
|
+
throw new Error('Failed to get 2D context');
|
|
29
|
+
}
|
|
30
|
+
this.context = ctx;
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(TextHelper.prototype, "position", {
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* Current position of the fulltext
|
|
36
|
+
*/
|
|
37
|
+
get: function () {
|
|
38
|
+
return this._position;
|
|
39
|
+
},
|
|
40
|
+
set: function (value) {
|
|
41
|
+
this._position = value;
|
|
42
|
+
},
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(TextHelper.prototype, "paragraphMark", {
|
|
47
|
+
get: function () {
|
|
48
|
+
return '¶';
|
|
49
|
+
},
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(TextHelper.prototype, "lineBreakMark", {
|
|
54
|
+
get: function () {
|
|
55
|
+
return '↲';
|
|
56
|
+
},
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
TextHelper.prototype.getEnSpaceCharacter = function () {
|
|
61
|
+
return String.fromCharCode(8194);
|
|
62
|
+
};
|
|
63
|
+
TextHelper.prototype.repeatChar = function (char, count) {
|
|
64
|
+
var text = '';
|
|
65
|
+
for (var i = 0; i < count; i++) {
|
|
66
|
+
text += char;
|
|
67
|
+
}
|
|
68
|
+
return text;
|
|
69
|
+
};
|
|
70
|
+
TextHelper.prototype.getParagraphMarkWidth = function (characterFormat) {
|
|
71
|
+
return this.getParagraphMarkSize(characterFormat).Width;
|
|
72
|
+
};
|
|
73
|
+
TextHelper.prototype.getParagraphMarkSize = function (characterFormat) {
|
|
74
|
+
var format = this.getFormatText(characterFormat);
|
|
75
|
+
if (this.paragraphMarkInfo["" + format]) {
|
|
76
|
+
return this.paragraphMarkInfo["" + format];
|
|
77
|
+
}
|
|
78
|
+
// Gets the text element's width;
|
|
79
|
+
var width = this.getWidth(this.paragraphMark, characterFormat);
|
|
80
|
+
// Calculate the text element's height and baseline offset.
|
|
81
|
+
var textHelper = this.getHeight(characterFormat);
|
|
82
|
+
var textSizeInfo = {
|
|
83
|
+
'Width': width, 'Height': textHelper.Height, 'BaselineOffset': textHelper.BaselineOffset
|
|
84
|
+
};
|
|
85
|
+
if (characterFormat.hidden) {
|
|
86
|
+
return textSizeInfo;
|
|
87
|
+
}
|
|
88
|
+
return this.paragraphMarkInfo["" + format] = textSizeInfo;
|
|
89
|
+
};
|
|
90
|
+
TextHelper.prototype.getTextSize = function (elementBox, characterFormat) {
|
|
91
|
+
// Gets the text element's width;
|
|
92
|
+
var textTrimEndWidth = 0;
|
|
93
|
+
var isRTL = characterFormat.bidi || this.isRTLText(elementBox.text);
|
|
94
|
+
var text = this.setText(elementBox.text, isRTL, characterFormat.bdo);
|
|
95
|
+
if (text === '\r') {
|
|
96
|
+
text = String.fromCharCode(182);
|
|
97
|
+
}
|
|
98
|
+
var nextElement = elementBox.nextElement;
|
|
99
|
+
if (nextElement && elementBox.scriptType !== FontScriptType.Hebrew &&
|
|
100
|
+
this.documentHelper.layout.checkFormatToCombineText(elementBox.characterFormat, nextElement.characterFormat)
|
|
101
|
+
&& !LayoutHelperMethods.startsWith(elementBox.text, ' ') && !LayoutHelperMethods.endsWith(nextElement.text)
|
|
102
|
+
&& elementBox.characterFormat.bidi && nextElement.characterFormat.bidi
|
|
103
|
+
&& elementBox.characterRange === CharacterRangeType.RightToLeft
|
|
104
|
+
&& nextElement.characterRange === CharacterRangeType.RightToLeft) {
|
|
105
|
+
text += '\u200D';
|
|
106
|
+
textTrimEndWidth = this.getWidthWithZWJ(text, '\u200D', nextElement.text, characterFormat, elementBox.scriptType);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
textTrimEndWidth = this.getWidth(text, characterFormat, elementBox.scriptType);
|
|
110
|
+
}
|
|
111
|
+
elementBox.width = textTrimEndWidth;
|
|
112
|
+
// Calculate the text element's height and baseline offset.
|
|
113
|
+
var textHelper = this.getHeight(characterFormat, elementBox.scriptType);
|
|
114
|
+
if (!(this.documentHelper.compatibilityMode === 'Word2003' && elementBox.isColumnBreak)) {
|
|
115
|
+
elementBox.height = textHelper.Height;
|
|
116
|
+
}
|
|
117
|
+
elementBox.baselineOffset = textHelper.BaselineOffset;
|
|
118
|
+
if (elementBox.text[elementBox.text.length - 1] === ' ') {
|
|
119
|
+
textTrimEndWidth = this.getWidth(LayoutHelperMethods.trimEnd(elementBox.text), characterFormat, elementBox.scriptType);
|
|
120
|
+
}
|
|
121
|
+
elementBox.trimEndWidth = textTrimEndWidth;
|
|
122
|
+
return textTrimEndWidth;
|
|
123
|
+
};
|
|
124
|
+
TextHelper.prototype.getHeight = function (characterFormat, scriptType) {
|
|
125
|
+
var fontToRender = this.getFontNameToRender(scriptType, characterFormat);
|
|
126
|
+
// Get character format property as below predefined structure to make it easy to check and retrieve
|
|
127
|
+
// Predefined static structure `[FontName];[FontSize];bold;italic` to maintain as key in the collection
|
|
128
|
+
var key = this.getFormatText(characterFormat, fontToRender);
|
|
129
|
+
if (!isNullOrUndefined(this.documentHelper.heightInfoCollection["" + key])) {
|
|
130
|
+
if (characterFormat.hidden) {
|
|
131
|
+
var heightInfo = __assign({}, this.documentHelper.heightInfoCollection["" + key]);
|
|
132
|
+
if (heightInfo.Height) {
|
|
133
|
+
heightInfo.Height = 0;
|
|
134
|
+
}
|
|
135
|
+
return heightInfo;
|
|
136
|
+
}
|
|
137
|
+
return this.documentHelper.heightInfoCollection["" + key];
|
|
138
|
+
}
|
|
139
|
+
var sizeInfo = this.documentHelper.textMeasureHelper.getHeightInternal(characterFormat, fontToRender);
|
|
140
|
+
this.documentHelper.heightInfoCollection["" + key] = __assign({}, sizeInfo);
|
|
141
|
+
if (characterFormat.hidden) {
|
|
142
|
+
sizeInfo.Height = 0;
|
|
143
|
+
}
|
|
144
|
+
return sizeInfo;
|
|
145
|
+
};
|
|
146
|
+
TextHelper.prototype.getFormatText = function (characterFormat, fontToRender) {
|
|
147
|
+
var formatText = '';
|
|
148
|
+
if (!isNullOrUndefined(fontToRender)) {
|
|
149
|
+
formatText = fontToRender.toLocaleLowerCase();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
formatText = characterFormat.fontFamily.toLocaleLowerCase();
|
|
153
|
+
}
|
|
154
|
+
var isBidi = characterFormat.bidi || characterFormat.complexScript;
|
|
155
|
+
var font = isBidi ? characterFormat.fontSizeBidi : characterFormat.fontSize;
|
|
156
|
+
var bold = isBidi ? characterFormat.boldBidi : characterFormat.bold;
|
|
157
|
+
var italic = isBidi ? characterFormat.italicBidi : characterFormat.italic;
|
|
158
|
+
formatText += ';' + font;
|
|
159
|
+
if (bold) {
|
|
160
|
+
formatText += ';' + 'bold';
|
|
161
|
+
}
|
|
162
|
+
if (italic) {
|
|
163
|
+
formatText += ';' + 'italic';
|
|
164
|
+
}
|
|
165
|
+
return formatText;
|
|
166
|
+
};
|
|
167
|
+
TextHelper.prototype.measureTextExcludingSpaceAtEnd = function (text, characterFormat, scriptType) {
|
|
168
|
+
return this.getWidth(LayoutHelperMethods.trimEnd(text), characterFormat, scriptType);
|
|
169
|
+
};
|
|
170
|
+
TextHelper.prototype.getWidth = function (text, characterFormat, scriptType) {
|
|
171
|
+
if (characterFormat.hidden) {
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
if (text.match('\v')) {
|
|
175
|
+
text.replace('\v', this.lineBreakMark);
|
|
176
|
+
}
|
|
177
|
+
var bold = '';
|
|
178
|
+
var italic = '';
|
|
179
|
+
var fontFamily = '';
|
|
180
|
+
var isBidi = characterFormat.bidi || characterFormat.complexScript;
|
|
181
|
+
var fontSize = isBidi ? characterFormat.fontSizeBidi : characterFormat.fontSize;
|
|
182
|
+
bold = isBidi ? (characterFormat.boldBidi ? 'bold' : '') : (characterFormat.bold ? 'bold' : '');
|
|
183
|
+
italic = isBidi ? (characterFormat.italicBidi ? 'italic' : '') : (characterFormat.italic ? 'italic' : '');
|
|
184
|
+
fontFamily = this.getFontNameToRender(scriptType, characterFormat);
|
|
185
|
+
fontSize = fontSize === 0 ? 0.5 : fontSize / (characterFormat.baselineAlignment === 'Normal' ? 1 : 1.5);
|
|
186
|
+
this.context.font = bold + ' ' + italic + ' ' + fontSize + 'pt' + ' ' + '"' + fontFamily + '"';
|
|
187
|
+
this.context.letterSpacing = characterFormat.characterSpacing + 'pt';
|
|
188
|
+
var kernPairs = /(?:AV|VA|AW|WA|To|Ta|Te|Ty|Yo)/;
|
|
189
|
+
this.context.fontKerning = 'auto';
|
|
190
|
+
if (!characterFormat.isKernFont && kernPairs.test(text)) {
|
|
191
|
+
this.context.fontKerning = 'none';
|
|
192
|
+
}
|
|
193
|
+
var scaleFactor = (characterFormat.scaling / 100);
|
|
194
|
+
if (characterFormat.allCaps) {
|
|
195
|
+
text = text.toUpperCase();
|
|
196
|
+
}
|
|
197
|
+
//ES-853789:For combine character we need to add the base character to get the width of the text.
|
|
198
|
+
if (text === '\u0336') {
|
|
199
|
+
text += 'A';
|
|
200
|
+
}
|
|
201
|
+
return Math.abs(this.context.measureText(text).width * scaleFactor);
|
|
202
|
+
};
|
|
203
|
+
TextHelper.prototype.getWidthWithZWJ = function (firstText, zwj, nextText, characterFormat, scriptType) {
|
|
204
|
+
if (characterFormat.hidden) {
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
// Measure the combined text (accounts for proper Arabic shaping)
|
|
208
|
+
var combinedWidth = this.getWidth(firstText + zwj + nextText, characterFormat, scriptType);
|
|
209
|
+
// Measure only the next text in its isolated form
|
|
210
|
+
var nextTextWidth = this.getWidth(nextText, characterFormat, scriptType);
|
|
211
|
+
// The width of firstText + ZWJ is the difference // This accounts for the connection context
|
|
212
|
+
return combinedWidth - nextTextWidth;
|
|
213
|
+
};
|
|
214
|
+
TextHelper.prototype.setText = function (textToRender, isBidi, bdo, isRender) {
|
|
215
|
+
if (isNullOrUndefined(isRender)) {
|
|
216
|
+
isRender = false;
|
|
217
|
+
}
|
|
218
|
+
if (!isNullOrUndefined(textToRender) && textToRender.length === 0) {
|
|
219
|
+
return '';
|
|
220
|
+
}
|
|
221
|
+
var isRtlText = isBidi;
|
|
222
|
+
if ((!isRtlText && (bdo === 'RTL')) || (isRtlText && (bdo === 'LTR'))) {
|
|
223
|
+
textToRender = LayoutHelperMethods.reverseString(textToRender);
|
|
224
|
+
}
|
|
225
|
+
else if (isRender && isRtlText && LayoutHelperMethods.endsWith(textToRender)) {
|
|
226
|
+
var spaceCount = textToRender.length - LayoutHelperMethods.trimEnd(textToRender).length;
|
|
227
|
+
textToRender = LayoutHelperMethods.addSpace(spaceCount) + LayoutHelperMethods.trimEnd(textToRender);
|
|
228
|
+
}
|
|
229
|
+
return textToRender;
|
|
230
|
+
};
|
|
231
|
+
TextHelper.prototype.measureText = function (text, characterFormat, scriptType) {
|
|
232
|
+
// Gets the text element's width;
|
|
233
|
+
var width = this.getWidth(text, characterFormat, scriptType);
|
|
234
|
+
// Calculate the text element's height and baseline offset.
|
|
235
|
+
var textHelper = this.getHeight(characterFormat, scriptType);
|
|
236
|
+
return {
|
|
237
|
+
'Width': width, 'Height': textHelper.Height, 'BaselineOffset': textHelper.BaselineOffset
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
TextHelper.prototype.updateTextSize = function (elementBox, paragraph) {
|
|
241
|
+
if (elementBox.characterFormat.hidden && paragraph.height === 0) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
var format = new WCharacterFormat(undefined, this.documentHelper);
|
|
245
|
+
var listCharacterFormat = elementBox.listLevel.characterFormat;
|
|
246
|
+
var breakCharacterFormat = paragraph.characterFormat;
|
|
247
|
+
format.fontSize = listCharacterFormat.hasValue('fontSize') ? listCharacterFormat.fontSize : breakCharacterFormat.fontSize;
|
|
248
|
+
format.fontFamily = listCharacterFormat.hasValue('fontFamily') ? listCharacterFormat.fontFamily : breakCharacterFormat.fontFamily;
|
|
249
|
+
var bold = '';
|
|
250
|
+
var italic = '';
|
|
251
|
+
var baselineAlignment = listCharacterFormat.baselineAlignment === 'Normal' ?
|
|
252
|
+
breakCharacterFormat.baselineAlignment : listCharacterFormat.baselineAlignment;
|
|
253
|
+
bold = listCharacterFormat.hasValue('bold') ? listCharacterFormat.bold ? 'bold' : '' : breakCharacterFormat.bold ? 'bold' : '';
|
|
254
|
+
italic = listCharacterFormat.hasValue('italic') ? listCharacterFormat.italic ? 'italic' : ''
|
|
255
|
+
: breakCharacterFormat.italic ? 'italic' : '';
|
|
256
|
+
format.baselineAlignment = baselineAlignment;
|
|
257
|
+
if (bold) {
|
|
258
|
+
format.bold = true;
|
|
259
|
+
}
|
|
260
|
+
if (italic) {
|
|
261
|
+
format.italic = true;
|
|
262
|
+
}
|
|
263
|
+
var isRTL = format.bidi || this.isRTLText(elementBox.text);
|
|
264
|
+
var text = this.setText(elementBox.text, isRTL, format.bdo);
|
|
265
|
+
elementBox.width = this.getWidth(text, format);
|
|
266
|
+
// Calculate the text element's height and baseline offset.
|
|
267
|
+
var textHelper = this.getHeight(format);
|
|
268
|
+
elementBox.height = textHelper.Height;
|
|
269
|
+
elementBox.baselineOffset = textHelper.BaselineOffset;
|
|
270
|
+
format.destroy();
|
|
271
|
+
};
|
|
272
|
+
TextHelper.prototype.containsSpecialCharAlone = function (text) {
|
|
273
|
+
/* eslint-disable */
|
|
274
|
+
var specialChars = '*|.\:[]{}-`\;()@&$#%!~?,' + ' ' + "'";
|
|
275
|
+
for (var i = 0; i < text.length; i++) {
|
|
276
|
+
if (specialChars.indexOf(text.charAt(i)) === -1) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return true;
|
|
281
|
+
};
|
|
282
|
+
TextHelper.prototype.containsNumberAlone = function (text) {
|
|
283
|
+
/* eslint-disable */
|
|
284
|
+
var number = '0123456789';
|
|
285
|
+
if (text === '') {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
for (var i = 0; i < text.length; i++) {
|
|
289
|
+
if (number.indexOf(text.charAt(i)) === -1) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
294
|
+
};
|
|
295
|
+
TextHelper.prototype.containsCombinationText = function (element) {
|
|
296
|
+
/* eslint-disable */
|
|
297
|
+
if (element.text.match(/^[0-9]+$/) && element.paragraph.bidi) {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
TextHelper.prototype.inverseCharacter = function (ch) {
|
|
305
|
+
if (isNullOrUndefined(ch) || ch.length === 0) {
|
|
306
|
+
return ch;
|
|
307
|
+
}
|
|
308
|
+
// If single character, keep existing behavior
|
|
309
|
+
if (ch.length === 1) {
|
|
310
|
+
switch (ch) {
|
|
311
|
+
case '(':
|
|
312
|
+
return ')';
|
|
313
|
+
case ')':
|
|
314
|
+
return '(';
|
|
315
|
+
case '<':
|
|
316
|
+
return '>';
|
|
317
|
+
case '>':
|
|
318
|
+
return '<';
|
|
319
|
+
case '{':
|
|
320
|
+
return '}';
|
|
321
|
+
case '}':
|
|
322
|
+
return '{';
|
|
323
|
+
case '[':
|
|
324
|
+
return ']';
|
|
325
|
+
case ']':
|
|
326
|
+
return '[';
|
|
327
|
+
default:
|
|
328
|
+
return ch;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// For multi-character strings: only inverse when all characters are word-split characters
|
|
332
|
+
var allWordSplit = true;
|
|
333
|
+
for (var i = 0; i < ch.length; i++) {
|
|
334
|
+
if (!this.isWordSplitChar(ch[i])) {
|
|
335
|
+
allWordSplit = false;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (!allWordSplit) {
|
|
340
|
+
return ch;
|
|
341
|
+
}
|
|
342
|
+
// Map each character using single-char inverse and combine
|
|
343
|
+
var result = '';
|
|
344
|
+
for (var i = ch.length - 1; i >= 0; i--) {
|
|
345
|
+
result += this.inverseCharacter(ch[i]);
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
348
|
+
};
|
|
349
|
+
TextHelper.prototype.containsSpecialChar = function (text) {
|
|
350
|
+
var specialChars = '*|.\:[]{}-`\;()@&$#%!~?' + ' ';
|
|
351
|
+
for (var i = 0; i < text.length; i++) {
|
|
352
|
+
if (specialChars.indexOf(text.charAt(i)) !== -1) {
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return false;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* @private
|
|
360
|
+
* @param {string} text - Specifies the text
|
|
361
|
+
* @returns {boolean} - Returns true if given text it right to left.
|
|
362
|
+
*/
|
|
363
|
+
TextHelper.prototype.isRTLText = function (text) {
|
|
364
|
+
var isRTL = false;
|
|
365
|
+
if (!isNullOrUndefined(text)) {
|
|
366
|
+
for (var i = 0; i < text.length; i++) {
|
|
367
|
+
var temp = text[i];
|
|
368
|
+
if ((temp >= String.fromCharCode(1424) && temp <= String.fromCharCode(1535)) ////Script-Hebr, Hebrew characters https://en.wikipedia.org/wiki/Hebrew_alphabet#Unicode_and_HTML (https://en.wikipedia.org/wiki/Hebrew_(Unicode_block))
|
|
369
|
+
|| (temp >= String.fromCharCode(64285) && temp <= String.fromCharCode(64335)) //Script-Hebr, Hebrew Alphabetic Presentation Forms characters https://en.wikipedia.org/wiki/Alphabetic_Presentation_Forms
|
|
370
|
+
|| (temp >= String.fromCharCode(1536) && temp <= String.fromCharCode(1791)) //Arabic - Urdu characters
|
|
371
|
+
|| (temp >= String.fromCharCode(1872) && temp <= String.fromCharCode(1919)) //Arabic - Urdu characters
|
|
372
|
+
|| (temp >= String.fromCharCode(2208) && temp <= String.fromCharCode(2303)) //Arabic characters
|
|
373
|
+
|| (temp >= String.fromCharCode(64336) && temp <= String.fromCharCode(65023)) //Arabic - Urdu characters
|
|
374
|
+
|| (temp >= String.fromCharCode(65136) && temp <= String.fromCharCode(65279)) //Arabic - Urdu characters
|
|
375
|
+
|| (temp >= String.fromCharCode(43392) && temp <= String.fromCharCode(43487)) //Javanese characters
|
|
376
|
+
|| (temp >= String.fromCharCode(1792) && temp <= String.fromCharCode(1871)) //Syriac characters
|
|
377
|
+
|| (temp >= String.fromCharCode(1920) && temp <= String.fromCharCode(1983)) //Thaana characters
|
|
378
|
+
|| (temp >= String.fromCharCode(2112) && temp <= String.fromCharCode(2143)) //Mandiac characters
|
|
379
|
+
|| (temp >= String.fromCharCode(1984) && temp <= String.fromCharCode(2047)) //N'Ko characters
|
|
380
|
+
|| (temp >= String.fromCharCode(2048) && temp <= String.fromCharCode(2111)) //Samaritan characters
|
|
381
|
+
//Tifinag characters
|
|
382
|
+
|| (temp >= String.fromCharCode(11568) && temp <= String.fromCharCode(11647))) {
|
|
383
|
+
isRTL = true;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return isRTL;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* @private
|
|
392
|
+
* @param {string} text - Specifies the text
|
|
393
|
+
* @param {FontScriptType} scriptType - Specifies the script type
|
|
394
|
+
* @returns {boolean} - Returns true if given text is unicode text.
|
|
395
|
+
*/
|
|
396
|
+
TextHelper.prototype.isUnicodeText = function (text, scriptType, isWordBreak) {
|
|
397
|
+
if (isWordBreak === void 0) { isWordBreak = false; }
|
|
398
|
+
var isUnicode = false;
|
|
399
|
+
if (!isNullOrUndefined(text)) {
|
|
400
|
+
for (var i = 0; i < text.length; i++) {
|
|
401
|
+
var temp = text[i];
|
|
402
|
+
if ((temp >= '\u3000' && temp <= '\u30ff') // Japanese characters
|
|
403
|
+
|| (temp >= '\uff00' && temp <= '\uffef') // Full-width roman characters and half-width katakana
|
|
404
|
+
|| (temp >= '\u4e00' && temp <= '\u9faf') //CJK unifed ideographs - Common and uncommon kanji
|
|
405
|
+
|| (temp >= '\u3400' && temp <= '\u4dbf') //CJK unified ideographs Extension A - Rare kanji
|
|
406
|
+
|| ((temp >= '\uac00' && temp <= '\uffef')
|
|
407
|
+
&& !(temp >= '\ufe70' && temp <= '\ufeff')) //Korean Hangul characters, excluding Arabic Presentation Forms (U+FE70-U+FEFF)
|
|
408
|
+
|| (temp >= '\u0d80' && temp <= '\u0dff') //Sinhala characters
|
|
409
|
+
|| (isWordBreak && ((temp >= '\u0590' && temp <= '\u05FF') // Hebrew characters
|
|
410
|
+
|| (temp >= '\u0400' && temp <= '\u04FF') // Cyrillic characters
|
|
411
|
+
|| (temp >= '\u00C0' && temp <= '\u00FF') // Accented Latin characters (Latin-1 Supplement)
|
|
412
|
+
|| (temp >= '\u0100' && temp <= '\u017F') // Latin Extended-A
|
|
413
|
+
|| (temp >= '\u0180' && temp <= '\u024F') // Latin Extended-B
|
|
414
|
+
|| (temp >= '\u1E00' && temp <= '\u1EFF')
|
|
415
|
+
|| (temp >= '\u0E00' && temp <= '\u0E7F') // Thai
|
|
416
|
+
|| (temp >= '\u0600' && temp <= '\u06FF')))) { // Arabic characters
|
|
417
|
+
if (isWordBreak || scriptType !== 0) {
|
|
418
|
+
isUnicode = true;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return isUnicode;
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* @private
|
|
428
|
+
* @param {string} text - Specifies the text
|
|
429
|
+
* @param {Dictionary<TextElementBox, number>} elements - Elements of the text
|
|
430
|
+
* @param {boolean} isAutoWidth
|
|
431
|
+
* @param {boolean} isAllColumnHasAutoWidthType
|
|
432
|
+
*/
|
|
433
|
+
TextHelper.prototype.readWord = function (text, elements, isAutoWidth, isAllowAutoFit, isAllColumnHasAutoWidthType) {
|
|
434
|
+
var pos = this._position;
|
|
435
|
+
var length = text.length;
|
|
436
|
+
var char = '';
|
|
437
|
+
while (pos < length) {
|
|
438
|
+
char = text[pos];
|
|
439
|
+
var isSplitChar = false;
|
|
440
|
+
var code = char.charCodeAt(0);
|
|
441
|
+
// \u2002 -- En Space, \u200C -- Zero Width Non-Joiner
|
|
442
|
+
if (char === '\u2002' || char === '\u200C' || (char === '\u00A0' && !isAutoWidth) || (isAllColumnHasAutoWidthType && (code >= 0x4E00 && code <= 0x9FFF))) {
|
|
443
|
+
isSplitChar = true;
|
|
444
|
+
}
|
|
445
|
+
if ((char === '/' || char === '.' || char === ',' || char === '=' || char === '*' || char === '«' || char === '»' || char === '?' || char === '>' || char === '<') && !isAllColumnHasAutoWidthType && !isAllowAutoFit) {
|
|
446
|
+
isSplitChar = true;
|
|
447
|
+
}
|
|
448
|
+
switch (char) {
|
|
449
|
+
case ' ':
|
|
450
|
+
case '\t':
|
|
451
|
+
case '\n':
|
|
452
|
+
case '\r':
|
|
453
|
+
case '\v':
|
|
454
|
+
case '\f':
|
|
455
|
+
case '\\':
|
|
456
|
+
case ':':
|
|
457
|
+
case '-':
|
|
458
|
+
isSplitChar = true;
|
|
459
|
+
}
|
|
460
|
+
if (isSplitChar) {
|
|
461
|
+
if (char === ' ' && pos < LayoutHelperMethods.trimEnd(text).length && this.isTextContainsNonBreakingSpaceCharacter(text)
|
|
462
|
+
&& this.isNonBreakingCharacterCombinedWithSpace(text, pos)) {
|
|
463
|
+
pos++;
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (pos === this._position || char === '-') {
|
|
467
|
+
pos++;
|
|
468
|
+
}
|
|
469
|
+
var text2 = text.substring(this._position, pos);
|
|
470
|
+
this._position = pos;
|
|
471
|
+
return text2;
|
|
472
|
+
}
|
|
473
|
+
var elementBox = this.getElementBoxOfChar(pos, elements);
|
|
474
|
+
//Check whether character is unicode if it is unicode it reads character from text
|
|
475
|
+
if (this.isUnicodeText(char, elementBox.scriptType, !isAllColumnHasAutoWidthType)) {
|
|
476
|
+
if (pos === this._position) {
|
|
477
|
+
pos++;
|
|
478
|
+
}
|
|
479
|
+
if (pos > this._position) {
|
|
480
|
+
var unicodeText = text.substring(this._position, pos);
|
|
481
|
+
this._position = pos;
|
|
482
|
+
return unicodeText;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
pos++;
|
|
486
|
+
}
|
|
487
|
+
// The remaining text.
|
|
488
|
+
if (pos > this._position) {
|
|
489
|
+
var remainingText = text.substring(this._position, pos);
|
|
490
|
+
this._position = pos;
|
|
491
|
+
return remainingText;
|
|
492
|
+
}
|
|
493
|
+
return '';
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* @private
|
|
497
|
+
* @param {number} pos - Current text position
|
|
498
|
+
* @param {Dictionary<TextElementBox, number>} elements - Elements of the text
|
|
499
|
+
*/
|
|
500
|
+
TextHelper.prototype.getElementBoxOfChar = function (pos, elements) {
|
|
501
|
+
var keys = elements.keys;
|
|
502
|
+
var values = elements.values;
|
|
503
|
+
var low = 0;
|
|
504
|
+
var high = values.length - 1;
|
|
505
|
+
while (low <= high) {
|
|
506
|
+
var mid = Math.floor((low + high) / 2);
|
|
507
|
+
var start = values[mid];
|
|
508
|
+
var element = keys[mid];
|
|
509
|
+
if (pos >= start && pos < start + element.text.length) {
|
|
510
|
+
return element;
|
|
511
|
+
}
|
|
512
|
+
else if (pos < start) {
|
|
513
|
+
high = mid - 1;
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
low = mid + 1;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return undefined;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* @private
|
|
523
|
+
* @param {string} text - Text which contains non-breaking space character.
|
|
524
|
+
*/
|
|
525
|
+
TextHelper.prototype.isTextContainsNonBreakingSpaceCharacter = function (text) {
|
|
526
|
+
return (this.documentHelper.compatibilityMode === 'Word2013' || this.documentHelper.compatibilityMode === 'Word2010') && text.indexOf('\u00A0') >= 0;
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* @private
|
|
530
|
+
* @param {string} text - Text which contains non-breaking space character.
|
|
531
|
+
* @param {number} pos - Position of the empty space character
|
|
532
|
+
*/
|
|
533
|
+
TextHelper.prototype.isNonBreakingCharacterCombinedWithSpace = function (text, pos) {
|
|
534
|
+
for (var i = pos + 1; i < text.length; i++) {
|
|
535
|
+
if (text[i] == '\u00A0')
|
|
536
|
+
return true;
|
|
537
|
+
else if (text[i] == ' ')
|
|
538
|
+
continue;
|
|
539
|
+
else
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
for (var i = pos - 1; i >= 0; i--) {
|
|
543
|
+
if (text[i] == '\u00A0')
|
|
544
|
+
return true;
|
|
545
|
+
else if (text[i] == ' ')
|
|
546
|
+
continue;
|
|
547
|
+
else
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
return false;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* @private
|
|
554
|
+
* @param {string} text - Specifies the text
|
|
555
|
+
* @returns {RtlInfo} - Returns the text info.
|
|
556
|
+
*/
|
|
557
|
+
TextHelper.prototype.getRtlLanguage = function (text) {
|
|
558
|
+
if (isNullOrUndefined(text) || text === '') {
|
|
559
|
+
return { isRtl: false, id: 0 };
|
|
560
|
+
}
|
|
561
|
+
if (text >= String.fromCharCode(1424) && text <= String.fromCharCode(1535)) {
|
|
562
|
+
return { isRtl: true, id: 1 };
|
|
563
|
+
//Arabic - Urdu characters
|
|
564
|
+
}
|
|
565
|
+
else if ((text >= String.fromCharCode(1536) && text <= String.fromCharCode(1791))
|
|
566
|
+
|| (text >= String.fromCharCode(1872) && text <= String.fromCharCode(1919))
|
|
567
|
+
|| (text >= String.fromCharCode(2208) && text <= String.fromCharCode(2303))
|
|
568
|
+
|| (text >= String.fromCharCode(64336) && text <= String.fromCharCode(65023))
|
|
569
|
+
|| (text >= String.fromCharCode(65136) && text <= String.fromCharCode(65279))) {
|
|
570
|
+
return { isRtl: true, id: 2 };
|
|
571
|
+
}
|
|
572
|
+
else if (text >= String.fromCharCode(43392) && text <= String.fromCharCode(43487)) {
|
|
573
|
+
return { isRtl: true, id: 3 };
|
|
574
|
+
}
|
|
575
|
+
else if (text >= String.fromCharCode(1792) && text <= String.fromCharCode(1871)) {
|
|
576
|
+
return { isRtl: true, id: 4 };
|
|
577
|
+
}
|
|
578
|
+
else if (text >= String.fromCharCode(1920) && text <= String.fromCharCode(1983)) {
|
|
579
|
+
return { isRtl: true, id: 5 };
|
|
580
|
+
}
|
|
581
|
+
else if (text >= String.fromCharCode(2112) && text <= String.fromCharCode(2143)) {
|
|
582
|
+
return { isRtl: true, id: 6 };
|
|
583
|
+
}
|
|
584
|
+
else if (text >= String.fromCharCode(1984) && text <= String.fromCharCode(2047)) {
|
|
585
|
+
return { isRtl: true, id: 7 };
|
|
586
|
+
}
|
|
587
|
+
else if (text >= String.fromCharCode(2048) && text <= String.fromCharCode(2111)) {
|
|
588
|
+
return { isRtl: true, id: 8 };
|
|
589
|
+
}
|
|
590
|
+
else if (text >= String.fromCharCode(11568) && text <= String.fromCharCode(11647)) {
|
|
591
|
+
return { isRtl: true, id: 9 };
|
|
592
|
+
}
|
|
593
|
+
return { isRtl: false, id: 0 };
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
596
|
+
* @private
|
|
597
|
+
*/
|
|
598
|
+
TextHelper.prototype.splitTextByConsecutiveLtrAndRtl = function (text, isTextBidi, isRTLLang, characterRangeTypes, isPrevLTRText, hasRTLCharacter, isPrevLTRBidi, isPrevHebrewText) {
|
|
599
|
+
var charTypeIndex = characterRangeTypes.length;
|
|
600
|
+
var splittedText = [];
|
|
601
|
+
if (isNullOrUndefined(text) || text === '') {
|
|
602
|
+
return splittedText;
|
|
603
|
+
}
|
|
604
|
+
var lastLtrIndex = -1;
|
|
605
|
+
var ltrText = '';
|
|
606
|
+
var rtlText = '';
|
|
607
|
+
var wordSplitChars = '';
|
|
608
|
+
var numberText = '';
|
|
609
|
+
var isHebrewText = !isNullOrUndefined(isPrevHebrewText) && isPrevHebrewText.value;
|
|
610
|
+
// A hyphen between two numbers is kept as a single unit when it follows Hebrew text.
|
|
611
|
+
var isHebrewHyphen = function (separator) { return isHebrewText && separator === '-'; };
|
|
612
|
+
var hasNumberWithSeparatorPattern = !isNullOrUndefined(isPrevLTRText.value) && isPrevLTRText.value && isTextBidi && /^\d+(\.\d+)+$/.test(text);
|
|
613
|
+
for (var i = 0; i < text.length; i++) {
|
|
614
|
+
var currentCharacterType = 0;
|
|
615
|
+
var separateEachWordSplitChars = false;
|
|
616
|
+
if ((!isNullOrUndefined(isPrevLTRText.value) ? (!isPrevLTRText.value || (!isNullOrUndefined(isPrevLTRBidi.value) && !isPrevLTRBidi.value && isTextBidi && !hasNumberWithSeparatorPattern)) : isTextBidi) && this.isNumber(text[i])) {
|
|
617
|
+
numberText += text[i];
|
|
618
|
+
currentCharacterType = 4;
|
|
619
|
+
}
|
|
620
|
+
else if (this.isWordSplitChar(text[i])) {
|
|
621
|
+
currentCharacterType = 2;
|
|
622
|
+
if (separateEachWordSplitChars = (isTextBidi || (text.charCodeAt(i) == 32 && wordSplitChars == ''))) {
|
|
623
|
+
wordSplitChars += text[i];
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
wordSplitChars += text[i];
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
else if (this.isRTLText(text[i]) && !this.isNumber(text[i])) {
|
|
630
|
+
isPrevLTRText.value = false;
|
|
631
|
+
hasRTLCharacter.value = true;
|
|
632
|
+
if (!isNullOrUndefined(isPrevHebrewText)) {
|
|
633
|
+
isPrevHebrewText.value = /[\u0590-\u05FF\uFB1D-\uFB4F]/.test(text[i]);
|
|
634
|
+
}
|
|
635
|
+
rtlText += text[i];
|
|
636
|
+
currentCharacterType = 1;
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
isPrevLTRText.value = true;
|
|
640
|
+
isPrevLTRBidi.value = isTextBidi;
|
|
641
|
+
ltrText += text[i];
|
|
642
|
+
}
|
|
643
|
+
if (numberText != '' && currentCharacterType != 4) {
|
|
644
|
+
splittedText.push(numberText);
|
|
645
|
+
characterRangeTypes.push(CharacterRangeType.Number);
|
|
646
|
+
numberText = '';
|
|
647
|
+
}
|
|
648
|
+
if (rtlText != '' && currentCharacterType != 1) {
|
|
649
|
+
splittedText.push(rtlText);
|
|
650
|
+
characterRangeTypes.push(CharacterRangeType.RightToLeft);
|
|
651
|
+
rtlText = '';
|
|
652
|
+
}
|
|
653
|
+
if (ltrText != '' && currentCharacterType != 0) {
|
|
654
|
+
splittedText.push(ltrText);
|
|
655
|
+
lastLtrIndex = splittedText.length - 1;
|
|
656
|
+
characterRangeTypes.push(CharacterRangeType.LeftToRight);
|
|
657
|
+
ltrText = '';
|
|
658
|
+
}
|
|
659
|
+
if (wordSplitChars != '' && (currentCharacterType != 2 || separateEachWordSplitChars)) {
|
|
660
|
+
splittedText.push(wordSplitChars);
|
|
661
|
+
characterRangeTypes.push(CharacterRangeType.WordSplit);
|
|
662
|
+
wordSplitChars = '';
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (numberText != '') {
|
|
666
|
+
splittedText.push(numberText);
|
|
667
|
+
characterRangeTypes.push(CharacterRangeType.Number);
|
|
668
|
+
}
|
|
669
|
+
else if (rtlText != '') {
|
|
670
|
+
splittedText.push(rtlText);
|
|
671
|
+
characterRangeTypes.push(CharacterRangeType.RightToLeft);
|
|
672
|
+
}
|
|
673
|
+
else if (ltrText != '') {
|
|
674
|
+
splittedText.push(ltrText);
|
|
675
|
+
lastLtrIndex = splittedText.length - 1;
|
|
676
|
+
characterRangeTypes.push(CharacterRangeType.LeftToRight);
|
|
677
|
+
}
|
|
678
|
+
else if (wordSplitChars != '') {
|
|
679
|
+
splittedText.push(wordSplitChars);
|
|
680
|
+
characterRangeTypes.push(CharacterRangeType.WordSplit);
|
|
681
|
+
}
|
|
682
|
+
if (hasRTLCharacter.value || (!isNullOrUndefined(isPrevLTRText.value) && !isPrevLTRText.value)) {
|
|
683
|
+
for (var i = 1; i < splittedText.length; i++) {
|
|
684
|
+
//Combines the consecutive LTR, RTL, and Number (Number get combined only if it's splitted by non reversing characters (.,:))
|
|
685
|
+
//along with single in-between word split character.
|
|
686
|
+
var charType = characterRangeTypes[i + charTypeIndex];
|
|
687
|
+
if (charType == CharacterRangeType.WordSplit && splittedText[i].length == 1
|
|
688
|
+
&& i + charTypeIndex + 1 < characterRangeTypes.length
|
|
689
|
+
&& characterRangeTypes[i + charTypeIndex - 1] != CharacterRangeType.WordSplit
|
|
690
|
+
&& (characterRangeTypes[i + charTypeIndex - 1] != CharacterRangeType.Number
|
|
691
|
+
//Else handled to combine consecutive number when text bidi is false and middle word split character is not white space.
|
|
692
|
+
|| TextHelper.isNumberNonReversingCharacter(splittedText[i], isTextBidi)
|
|
693
|
+
|| isHebrewHyphen(splittedText[i]))
|
|
694
|
+
&& characterRangeTypes[i + charTypeIndex - 1] == characterRangeTypes[i + charTypeIndex + 1]) {
|
|
695
|
+
splittedText[i - 1] = splittedText[i - 1] + splittedText[i] + splittedText[i + 1];
|
|
696
|
+
splittedText.splice(i, 1);
|
|
697
|
+
splittedText.splice(i, 1);
|
|
698
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
699
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
700
|
+
i--;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
else if (lastLtrIndex != -1) {
|
|
705
|
+
if (isTextBidi) {
|
|
706
|
+
for (var i = 1; i < lastLtrIndex; i++) {
|
|
707
|
+
//Combines the first and last LTR along with all in-between splited text's.
|
|
708
|
+
var charType = characterRangeTypes[i + charTypeIndex];
|
|
709
|
+
if (charType == CharacterRangeType.WordSplit && i < lastLtrIndex
|
|
710
|
+
&& characterRangeTypes[i + charTypeIndex - 1] == CharacterRangeType.LeftToRight) {
|
|
711
|
+
ltrText = '';
|
|
712
|
+
for (var j = i + 1; j <= lastLtrIndex; j++) {
|
|
713
|
+
ltrText += splittedText[j];
|
|
714
|
+
splittedText.splice(j, 1);
|
|
715
|
+
characterRangeTypes.splice(j + charTypeIndex, 1);
|
|
716
|
+
j--;
|
|
717
|
+
lastLtrIndex--;
|
|
718
|
+
}
|
|
719
|
+
splittedText[i - 1] = splittedText[i - 1] + splittedText[i] + ltrText;
|
|
720
|
+
splittedText.splice(i, 1);
|
|
721
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
722
|
+
i--;
|
|
723
|
+
lastLtrIndex--;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
//Return the input text if text bidi is false.
|
|
729
|
+
splittedText.length = 0;
|
|
730
|
+
splittedText.push(text);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
else if (!isTextBidi) {
|
|
734
|
+
//Return the input text if text bidi is false.
|
|
735
|
+
splittedText.length = 0;
|
|
736
|
+
splittedText.push(text);
|
|
737
|
+
}
|
|
738
|
+
if (isTextBidi) {
|
|
739
|
+
for (var i = 1; i < splittedText.length; i++) {
|
|
740
|
+
//Combines the consecutive LTR, RTL, and Number (Number get combined only if it's splitted by non reversing characters (.,:)
|
|
741
|
+
//or if it's lang attribute is represent a RTL language)
|
|
742
|
+
//along with single in-between number non reversing word split character.
|
|
743
|
+
var charType = characterRangeTypes[i + charTypeIndex];
|
|
744
|
+
if (charType == CharacterRangeType.WordSplit && splittedText[i].length == 1
|
|
745
|
+
&& i + charTypeIndex + 1 < characterRangeTypes.length
|
|
746
|
+
&& characterRangeTypes[i + charTypeIndex - 1] != CharacterRangeType.WordSplit
|
|
747
|
+
&& (characterRangeTypes[i + charTypeIndex - 1] != CharacterRangeType.Number
|
|
748
|
+
|| TextHelper.isNumberNonReversingCharacter(splittedText[i], isTextBidi) || !isRTLLang
|
|
749
|
+
|| isHebrewHyphen(splittedText[i]))
|
|
750
|
+
&& characterRangeTypes[i + charTypeIndex - 1] == characterRangeTypes[i + charTypeIndex + 1]) {
|
|
751
|
+
splittedText[i - 1] = splittedText[i - 1] + splittedText[i] + splittedText[i + 1];
|
|
752
|
+
splittedText.splice(i, 1);
|
|
753
|
+
splittedText.splice(i, 1);
|
|
754
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
755
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
756
|
+
i--;
|
|
757
|
+
}
|
|
758
|
+
//Combines the Number along with single non-word split characters (% $ #).
|
|
759
|
+
else if (charType == CharacterRangeType.WordSplit
|
|
760
|
+
&& characterRangeTypes[i + charTypeIndex - 1] == CharacterRangeType.Number
|
|
761
|
+
&& this.isNonWordSplitCharacter(splittedText[i]) && !isRTLLang) {
|
|
762
|
+
splittedText[i - 1] = splittedText[i - 1] + splittedText[i];
|
|
763
|
+
splittedText.splice(i, 1);
|
|
764
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
765
|
+
i--;
|
|
766
|
+
}
|
|
767
|
+
//Combines the consecutive LTR and Number
|
|
768
|
+
else if (charType == CharacterRangeType.LeftToRight
|
|
769
|
+
&& !(isHebrewText && /\d-\d$/.test(splittedText[i - 1]))
|
|
770
|
+
&& (characterRangeTypes[i + charTypeIndex - 1] == CharacterRangeType.Number
|
|
771
|
+
|| characterRangeTypes[i + charTypeIndex - 1] == CharacterRangeType.LeftToRight)) {
|
|
772
|
+
splittedText[i - 1] = splittedText[i - 1] + splittedText[i];
|
|
773
|
+
characterRangeTypes[i + charTypeIndex - 1] = CharacterRangeType.LeftToRight;
|
|
774
|
+
splittedText.splice(i, 1);
|
|
775
|
+
characterRangeTypes.splice(i + charTypeIndex, 1);
|
|
776
|
+
i--;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return splittedText;
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* @private
|
|
784
|
+
*/
|
|
785
|
+
TextHelper.prototype.isRightToLeftLanguage = function (lang) {
|
|
786
|
+
return (lang == 14337 || lang == 15361 || lang == 5121 || lang == 3073 || lang == 2049 ||
|
|
787
|
+
lang == 11265 || lang == 13313 || lang == 12289 || lang == 4097 || lang == 8193 ||
|
|
788
|
+
lang == 16385 || lang == 1025 || lang == 10241 || lang == 7169 || lang == 9217 || lang == 10655);
|
|
789
|
+
};
|
|
790
|
+
TextHelper.prototype.isNumber = function (ch) {
|
|
791
|
+
if (!isNaN(parseInt(ch, 10))) {
|
|
792
|
+
//This logic works for universal digits 0 to 9.
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
else if (ch >= String.fromCharCode(1632) && ch <= String.fromCharCode(1641)) {
|
|
796
|
+
//This logic works for ARABIC-INDIC DIGIT
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
else if (ch >= String.fromCharCode(1776) && ch <= String.fromCharCode(1785)) {
|
|
800
|
+
//This logic works for EXTENDED ARABIC-INDIC DIGIT
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
//TODO: Extend this for language specific
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
/**
|
|
809
|
+
* @private
|
|
810
|
+
*/
|
|
811
|
+
TextHelper.prototype.isWordSplitChar = function (character) {
|
|
812
|
+
for (var i = 0; i < TextHelper.wordSplitCharacters.length; i++) {
|
|
813
|
+
if (TextHelper.wordSplitCharacters[i] === character) {
|
|
814
|
+
return true;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return false;
|
|
818
|
+
};
|
|
819
|
+
/**
|
|
820
|
+
* @private
|
|
821
|
+
*/
|
|
822
|
+
TextHelper.isNumberNonReversingCharacter = function (character, isTextBidi) {
|
|
823
|
+
for (var i = 0; i < TextHelper.numberNonReversingCharacters.length; i++) {
|
|
824
|
+
var ch = TextHelper.numberNonReversingCharacters[i];
|
|
825
|
+
if (character[0] == ch && (ch.charCodeAt(0) == 47 ? !isTextBidi : true)) {
|
|
826
|
+
return true;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return false;
|
|
830
|
+
};
|
|
831
|
+
/**
|
|
832
|
+
* @private
|
|
833
|
+
*/
|
|
834
|
+
TextHelper.prototype.isNonWordSplitCharacter = function (character) {
|
|
835
|
+
var isNonWordSplitChar = false;
|
|
836
|
+
for (var i = 0; i < character.length; i++) {
|
|
837
|
+
var charCode = character.charCodeAt(i);
|
|
838
|
+
//Consider a (% $ #) as non-word split characters
|
|
839
|
+
if (charCode == 35 || charCode == 36 || charCode == 37) {
|
|
840
|
+
isNonWordSplitChar = true;
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
isNonWordSplitChar = false;
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return isNonWordSplitChar;
|
|
848
|
+
};
|
|
849
|
+
TextHelper.prototype.getFontNameToRender = function (scriptType, charFormat) {
|
|
850
|
+
if (!isNullOrUndefined(scriptType)) {
|
|
851
|
+
if (charFormat.bidi || charFormat.complexScript) {
|
|
852
|
+
return this.getFontNameBidiToRender(scriptType, charFormat);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
if ((this.isEastAsiaScript(scriptType) || (charFormat.fontHintType === 'EastAsia' && scriptType === FontScriptType.SpecialCharacter)) && !isNullOrUndefined(charFormat.fontFamilyFarEast))
|
|
856
|
+
return this.getFontNameEAToRender(scriptType, charFormat);
|
|
857
|
+
else
|
|
858
|
+
return this.getFontNameAsciiToRender(scriptType, charFormat);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
return charFormat.fontFamily;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
/// <summary>
|
|
866
|
+
/// Check whether specified script is EastAsia script or not.
|
|
867
|
+
/// </summary>
|
|
868
|
+
/// <param name="scriptType">Represent a FontScriptType to check.</param>
|
|
869
|
+
/// <returns></returns>
|
|
870
|
+
TextHelper.prototype.isEastAsiaScript = function (scriptType) {
|
|
871
|
+
return scriptType == FontScriptType.Japanese || scriptType == FontScriptType.Korean
|
|
872
|
+
|| scriptType == FontScriptType.Chinese;
|
|
873
|
+
};
|
|
874
|
+
/// <summary>
|
|
875
|
+
/// Get the font name East Asia to render
|
|
876
|
+
/// </summary>
|
|
877
|
+
/// <param name="scriptType">Represent a CharacterRangeType.</param>
|
|
878
|
+
/// <returns>Returns a eastAsia font name to draw the text.</returns>
|
|
879
|
+
TextHelper.prototype.getFontNameEAToRender = function (scriptType, charFormat) {
|
|
880
|
+
var fontName = charFormat.fontFamilyFarEast;
|
|
881
|
+
if (isNullOrUndefined(fontName) || LayoutHelperMethods.isThemeFont(fontName))
|
|
882
|
+
return this.getFontNameFromTheme(charFormat, fontName, scriptType, "EastAsia");
|
|
883
|
+
else
|
|
884
|
+
return fontName;
|
|
885
|
+
};
|
|
886
|
+
TextHelper.prototype.getFontNameAsciiToRender = function (scriptType, charFormat) {
|
|
887
|
+
var fontName = charFormat.fontFamilyAscii;
|
|
888
|
+
if (LayoutHelperMethods.isThemeFont(fontName))
|
|
889
|
+
return this.getFontNameFromTheme(charFormat, fontName, scriptType, "Default");
|
|
890
|
+
else
|
|
891
|
+
return charFormat.fontFamily;
|
|
892
|
+
};
|
|
893
|
+
TextHelper.prototype.getFontNameBidiToRender = function (scriptType, charFormat) {
|
|
894
|
+
//If CharacterFormat.Bidi is true, then font is determined in the order: FontNameBidi, Script-Arab, font scheme(latin, ea, cs), default font (Times New Roman)
|
|
895
|
+
//CharacterRangeType of a text and FontHintType (IdctHint) has no impact in this behavior.
|
|
896
|
+
//Note: Behavior is traced using Word version 1808 (build 10730.20304)
|
|
897
|
+
//Determines the font nmae to used for RTL characters based on its script from direct or font scheme (Document theme file)
|
|
898
|
+
var fontName = charFormat.fontFamilyBidi;
|
|
899
|
+
if (!isNullOrUndefined(fontName) || LayoutHelperMethods.isThemeFont(fontName))
|
|
900
|
+
return this.getFontNameFromTheme(charFormat, fontName, scriptType, "CS");
|
|
901
|
+
else
|
|
902
|
+
return fontName;
|
|
903
|
+
};
|
|
904
|
+
TextHelper.prototype.getFontNameFromTheme = function (charFormat, fontName, scriptType, hintType) {
|
|
905
|
+
var fontScheme;
|
|
906
|
+
if (this.documentHelper.hasThemes && !isNullOrUndefined(this.documentHelper.themes) && !isUndefined(this.documentHelper.themes.fontScheme))
|
|
907
|
+
fontScheme = this.documentHelper.themes.fontScheme;
|
|
908
|
+
if (fontName == "majorAscii" || fontName == "majorBidi" || fontName == "majorEastAsia" || fontName == "majorHAnsi") {
|
|
909
|
+
var majorFontScheme = void 0;
|
|
910
|
+
if (fontScheme != null && fontScheme.majorFontScheme != null) {
|
|
911
|
+
majorFontScheme = fontScheme.majorFontScheme;
|
|
912
|
+
}
|
|
913
|
+
fontName = this.updateFontNameFromTheme(charFormat, majorFontScheme, scriptType, fontName, hintType);
|
|
914
|
+
}
|
|
915
|
+
else if (fontName == "minorAscii" || fontName == "minorBidi" || fontName == "minorEastAsia" || fontName == "minorHAnsi") {
|
|
916
|
+
var minorFontScheme = void 0;
|
|
917
|
+
if (fontScheme != null && fontScheme.majorFontScheme != null) {
|
|
918
|
+
minorFontScheme = fontScheme.minorFontScheme;
|
|
919
|
+
}
|
|
920
|
+
fontName = this.updateFontNameFromTheme(charFormat, minorFontScheme, scriptType, fontName, hintType);
|
|
921
|
+
}
|
|
922
|
+
if (isNullOrUndefined(fontName) || LayoutHelperMethods.isThemeFont(fontName))
|
|
923
|
+
//Gets the default font (Times New Roman)
|
|
924
|
+
fontName = defaultFont;
|
|
925
|
+
return fontName;
|
|
926
|
+
};
|
|
927
|
+
/// <summary>
|
|
928
|
+
/// Update a font name from theme, based on FontHintType.
|
|
929
|
+
/// </summary>
|
|
930
|
+
/// <param name="majorMinorFontScheme"></param>
|
|
931
|
+
/// <param name="scriptType"></param>
|
|
932
|
+
/// <param name="fontName"></param>
|
|
933
|
+
/// <param name="hintType"></param>
|
|
934
|
+
TextHelper.prototype.updateFontNameFromTheme = function (charFormat, majorMinorFontScheme, scriptType, fontName, hintType) {
|
|
935
|
+
//Script-Arab, font scheme(latin, ea, cs), default font (Times New Roman)
|
|
936
|
+
var fontNameFromTheme = "";
|
|
937
|
+
//Gets font from font scheme(latin, ea, cs) of document theme.
|
|
938
|
+
if (majorMinorFontScheme != null && majorMinorFontScheme.fontSchemeList != null
|
|
939
|
+
&& majorMinorFontScheme.fontSchemeList.length > 0) {
|
|
940
|
+
majorMinorFontScheme.fontSchemeList.forEach(function (fontSchemeStruct) {
|
|
941
|
+
if (fontSchemeStruct.name == "cs" && (fontName == "majorBidi" || fontName == "minorBidi"))
|
|
942
|
+
fontNameFromTheme = fontSchemeStruct.typeface;
|
|
943
|
+
else if (fontSchemeStruct.name == "ea" && (fontName == "majorEastAsia" || fontName == "minorEastAsia"))
|
|
944
|
+
fontNameFromTheme = fontSchemeStruct.typeface;
|
|
945
|
+
else if (fontSchemeStruct.name == "latin" && (fontName == "majorAscii" || fontName == "majorHAnsi"
|
|
946
|
+
|| fontName == "minorAscii" || fontName == "minorHAnsi"))
|
|
947
|
+
fontNameFromTheme = fontSchemeStruct.typeface;
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
if (majorMinorFontScheme != null && majorMinorFontScheme.fontTypeface != null) {
|
|
951
|
+
if (hintType == "CS") {
|
|
952
|
+
// //If it's an complex script and "themeFontLang" element has a "bidi" attribute, then we need to locate the font name
|
|
953
|
+
// //from the "theme.xml" for the language specified by the bidi attribute
|
|
954
|
+
// if (charFormat.complexScript && Document != null && Document.Settings.ThemeFontLanguages != null &&
|
|
955
|
+
// Document.Settings.ThemeFontLanguages.HasValue(WCharacterFormat.LidBiKey))
|
|
956
|
+
// {
|
|
957
|
+
// fontName = this.getFontNameWithFontScript(majorMinorFontScheme, Document.Settings.ThemeFontLanguages.LocaleIdBidi, hintType);
|
|
958
|
+
// if (fontName != null)
|
|
959
|
+
// fontNameFromTheme = fontName;
|
|
960
|
+
// }
|
|
961
|
+
//If the font name is mentioned as Ascii or HAnsi, then we need to get the font name from Latin.
|
|
962
|
+
if (!charFormat.complexScript && (!charFormat.bidi && (fontName === "majorAscii" || fontName === "majorHAnsi" || fontName === "minorAscii" || fontName === "minorHAnsi"))
|
|
963
|
+
|| (charFormat.bidi && (fontName === "majorHAnsi" || fontName === "minorHAnsi"))) {
|
|
964
|
+
fontName = fontNameFromTheme;
|
|
965
|
+
}
|
|
966
|
+
//To-Do: Have to implement the font name retrieval behavior, when a bidi attribute is not available in theme.
|
|
967
|
+
else if (majorMinorFontScheme.fontTypeface.containsKey('Arab')) {
|
|
968
|
+
//map(object => object.id).indexOf('c');
|
|
969
|
+
//Gets the Arab-script (language) based font from font scheme (theme)
|
|
970
|
+
fontNameFromTheme = majorMinorFontScheme.fontTypeface.get('Arab');
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
else if (hintType == "EastAsia") {
|
|
974
|
+
if (!isNullOrUndefined(this.documentHelper.themeFontLanguage)) {
|
|
975
|
+
fontName = this.getFontNameWithFontScript(majorMinorFontScheme, this.documentHelper.themeFontLanguage.localeIdFarEast, hintType);
|
|
976
|
+
if (!isNullOrUndefined(fontName)) {
|
|
977
|
+
fontNameFromTheme = fontName;
|
|
978
|
+
}
|
|
979
|
+
//When font information is not available at the file level, Microsoft Word uses the following fonts as the default font for the respective language.
|
|
980
|
+
// else if (isNullOrUndefined(fontNameFromTheme))
|
|
981
|
+
// {
|
|
982
|
+
// LocaleIDs lang = (LocaleIDs)Document.Settings.ThemeFontLanguages.LocaleIdFarEast;
|
|
983
|
+
// if (lang == LocaleIDs.zh_CN)
|
|
984
|
+
// fontNameFromTheme = "SimSun";
|
|
985
|
+
// else if (lang == LocaleIDs.ko_KR)
|
|
986
|
+
// fontNameFromTheme = "Batang";
|
|
987
|
+
// else if (lang == LocaleIDs.ja_JP)
|
|
988
|
+
// fontNameFromTheme = "MS Mincho";
|
|
989
|
+
// }
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
else if (isNullOrUndefined(fontNameFromTheme) && !isNullOrUndefined(this.documentHelper.themeFontLanguage) && (fontName === "minorBidi" || fontName === "majorBidi")) {
|
|
993
|
+
return fontName = this.getFontNameWithFontScript(majorMinorFontScheme, this.documentHelper.themeFontLanguage.localeIdBidi, hintType);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
if (isNullOrUndefined(fontNameFromTheme))
|
|
997
|
+
//Gets the default font (Times New Roman)
|
|
998
|
+
fontNameFromTheme = defaultFont;
|
|
999
|
+
fontName = fontNameFromTheme;
|
|
1000
|
+
return fontName;
|
|
1001
|
+
};
|
|
1002
|
+
// /// <summary>
|
|
1003
|
+
// /// Gets the font name from a theme part for the specified font script.
|
|
1004
|
+
// /// </summary>
|
|
1005
|
+
TextHelper.prototype.getFontNameWithFontScript = function (majorMinorFontScheme, localeID, hintType) {
|
|
1006
|
+
var fontName = null;
|
|
1007
|
+
//To-Do: Should extend this behavior deponds on the localeID.
|
|
1008
|
+
var lang = localeID.toString();
|
|
1009
|
+
var fontTypeFaces = majorMinorFontScheme.fontTypeface;
|
|
1010
|
+
//Gujarati
|
|
1011
|
+
//If lang script is "gu-IN" or "gu", we should retrive the "Gujr" font from a theme part.
|
|
1012
|
+
if ((lang == 'gu_IN' || localeID == 1095) && fontTypeFaces.containsKey("Gujr"))
|
|
1013
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1014
|
+
//Hindi
|
|
1015
|
+
//If lang script is "hi-IN" or "hi", we should retrive the "Deva" font from a theme part.
|
|
1016
|
+
//Marathi
|
|
1017
|
+
//If lang script is "mr-IN" or "mr", we should retrive the "Deva" font from a theme part.
|
|
1018
|
+
else if ((lang == 'hi_IN' || lang == 'mr_IN' || localeID == 1081 || localeID == 1102)
|
|
1019
|
+
&& fontTypeFaces.containsKey("Deva"))
|
|
1020
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1021
|
+
//Korean
|
|
1022
|
+
//If lang script is "ko-KR" or "ko", we should retrive the "Hang" font from a theme part.
|
|
1023
|
+
else if ((lang == 'ko_KR' || localeID == 1042) && fontTypeFaces.containsKey("Hang"))
|
|
1024
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1025
|
+
//Chinese - Simplified
|
|
1026
|
+
//If lang script is "zh-CN", "zh-SG" or "zh", we should retrive the "Hans" font from a theme part.
|
|
1027
|
+
else if ((lang == 'zh_CN' || lang == 'zh_SG' || localeID == 2052) && fontTypeFaces.containsKey("Hans"))
|
|
1028
|
+
fontName = fontTypeFaces.get("Hans");
|
|
1029
|
+
//Chinese - Traditional
|
|
1030
|
+
//If lang script is "zh-TW", "zh-HK", or "zh-MO", we should retrive the "Hant" font from a theme part.
|
|
1031
|
+
else if ((lang == 'zh_TW' || lang == 'zh_HK' || lang == 'zh_MO')
|
|
1032
|
+
&& fontTypeFaces.containsKey("Hant"))
|
|
1033
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1034
|
+
//Japanese
|
|
1035
|
+
//If lang script is "ja-JP" or "ja", we should retrive the "Jpan" font from a theme part.
|
|
1036
|
+
else if ((lang == 'ja_JP' || localeID == 1041) && fontTypeFaces.containsKey("Jpan"))
|
|
1037
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1038
|
+
//Tamil
|
|
1039
|
+
//If lang script is "ta-IN" or "ta", we should retrive the "Taml" font from a theme part.
|
|
1040
|
+
else if ((lang == 'ta_IN' || localeID == 1097) && fontTypeFaces.containsKey("Taml"))
|
|
1041
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1042
|
+
//Telugu
|
|
1043
|
+
//If lang script is "te-IN" or "te", we should retrive the "Telu" font from a theme part.
|
|
1044
|
+
else if ((lang == 'te_IN' || localeID == 1098) && fontTypeFaces.containsKey("Telu"))
|
|
1045
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1046
|
+
//Hebrew
|
|
1047
|
+
//If lang script is "he-IL" or "he", we should retrive the "Hebr" font from a theme part.
|
|
1048
|
+
else if ((lang == 'he_IL' || lang == 'yi_Hebr' || localeID == 1037) && fontTypeFaces.containsKey("Hebr"))
|
|
1049
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1050
|
+
//Thai
|
|
1051
|
+
//If lang script is "th_TH" or "th", we should retrive the "Thai" font from a theme part.
|
|
1052
|
+
else if ((lang == 'th_TH' || localeID == 1054) && fontTypeFaces.containsKey("Thai"))
|
|
1053
|
+
fontName = fontTypeFaces.get("Thai");
|
|
1054
|
+
//Arabic
|
|
1055
|
+
else if (hintType == "CS" && fontTypeFaces.containsKey("Arab"))
|
|
1056
|
+
fontName = fontTypeFaces.get("Arab");
|
|
1057
|
+
return fontName;
|
|
1058
|
+
};
|
|
1059
|
+
TextHelper.prototype.destroy = function () {
|
|
1060
|
+
this.documentHelper = undefined;
|
|
1061
|
+
this.context = undefined;
|
|
1062
|
+
this.paragraphMarkInfo = {};
|
|
1063
|
+
this.paragraphMarkInfo = undefined;
|
|
1064
|
+
};
|
|
1065
|
+
TextHelper.wordSplitCharacters = [String.fromCharCode(32), String.fromCharCode(33), String.fromCharCode(34),
|
|
1066
|
+
String.fromCharCode(35), String.fromCharCode(36), String.fromCharCode(37), String.fromCharCode(38), String.fromCharCode(39),
|
|
1067
|
+
String.fromCharCode(40), String.fromCharCode(41), String.fromCharCode(42), String.fromCharCode(43), String.fromCharCode(44),
|
|
1068
|
+
String.fromCharCode(45), String.fromCharCode(46), String.fromCharCode(47), String.fromCharCode(58), String.fromCharCode(59),
|
|
1069
|
+
String.fromCharCode(60), String.fromCharCode(61), String.fromCharCode(62), String.fromCharCode(63), String.fromCharCode(64),
|
|
1070
|
+
String.fromCharCode(91), String.fromCharCode(92), String.fromCharCode(93), String.fromCharCode(94), String.fromCharCode(95),
|
|
1071
|
+
String.fromCharCode(96), String.fromCharCode(123), String.fromCharCode(124), String.fromCharCode(125), String.fromCharCode(126),
|
|
1072
|
+
String.fromCharCode(1548), String.fromCharCode(1563), String.fromCharCode(8211), String.fromCharCode(8212),
|
|
1073
|
+
String.fromCharCode(8216), String.fromCharCode(8217), String.fromCharCode(8221), String.fromCharCode(12288),
|
|
1074
|
+
String.fromCharCode(8207), String.fromCharCode(169), String.fromCharCode(160)];
|
|
1075
|
+
TextHelper.numberNonReversingCharacters = [String.fromCharCode(44), String.fromCharCode(46), String.fromCharCode(47),
|
|
1076
|
+
String.fromCharCode(58), String.fromCharCode(1548)];
|
|
1077
|
+
return TextHelper;
|
|
1078
|
+
}());
|
|
1079
|
+
export { TextHelper };
|