@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 0.9.4
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 +1 -1
- package/package.json +33 -18
- package/{src/display → pdfjs/dist}/display_utils.js +344 -139
- package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
- package/pdfjs/dist/get.js +1857 -0
- package/pdfjs/dist/index.js +767 -0
- package/pdfjs/dist/l10n_utils.js +140 -0
- package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
- package/{src/display → pdfjs/dist}/network.js +149 -87
- package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
- package/{src/display → pdfjs/dist}/node_stream.js +133 -98
- package/pdfjs/dist/pdf.js +12778 -0
- package/pdfjs/dist/pdf_link_service.js +638 -0
- package/pdfjs/dist/pdf_rendering_queue.js +199 -0
- package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
- package/pdfjs/dist/pdf_viewer.js +3598 -0
- package/pdfjs/dist/typeof.js +100 -0
- package/pdfjs/dist/ui_utils.js +1033 -0
- package/{src/shared → pdfjs/dist}/util.js +301 -287
- package/pdfjs/dist/worker.js +62813 -0
- package/src/vcf-pdf-viewer.js +77 -27
- package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
- package/theme/material/vcf-pdf-viewer.js +2 -2
- package/src/core/.eslintrc +0 -13
- package/src/core/annotation.js +0 -2948
- package/src/core/arithmetic_decoder.js +0 -182
- package/src/core/ascii_85_stream.js +0 -98
- package/src/core/ascii_hex_stream.js +0 -79
- package/src/core/base_stream.js +0 -110
- package/src/core/bidi.js +0 -438
- package/src/core/calibri_factors.js +0 -308
- package/src/core/catalog.js +0 -1459
- package/src/core/ccitt.js +0 -1062
- package/src/core/ccitt_stream.js +0 -60
- package/src/core/cff_font.js +0 -116
- package/src/core/cff_parser.js +0 -1949
- package/src/core/charsets.js +0 -119
- package/src/core/chunked_stream.js +0 -557
- package/src/core/cmap.js +0 -1039
- package/src/core/colorspace.js +0 -1533
- package/src/core/core_utils.js +0 -464
- package/src/core/crypto.js +0 -1900
- package/src/core/decode_stream.js +0 -170
- package/src/core/decrypt_stream.js +0 -59
- package/src/core/default_appearance.js +0 -99
- package/src/core/document.js +0 -1456
- package/src/core/encodings.js +0 -301
- package/src/core/evaluator.js +0 -4601
- package/src/core/file_spec.js +0 -108
- package/src/core/flate_stream.js +0 -402
- package/src/core/font_renderer.js +0 -882
- package/src/core/fonts.js +0 -3260
- package/src/core/fonts_utils.js +0 -221
- package/src/core/function.js +0 -1257
- package/src/core/glyf.js +0 -706
- package/src/core/glyphlist.js +0 -4558
- package/src/core/helvetica_factors.js +0 -353
- package/src/core/image.js +0 -802
- package/src/core/image_utils.js +0 -291
- package/src/core/jbig2.js +0 -2572
- package/src/core/jbig2_stream.js +0 -73
- package/src/core/jpeg_stream.js +0 -105
- package/src/core/jpg.js +0 -1416
- package/src/core/jpx.js +0 -2343
- package/src/core/jpx_stream.js +0 -87
- package/src/core/liberationsans_widths.js +0 -221
- package/src/core/lzw_stream.js +0 -150
- package/src/core/metadata_parser.js +0 -146
- package/src/core/metrics.js +0 -2970
- package/src/core/murmurhash3.js +0 -139
- package/src/core/myriadpro_factors.js +0 -290
- package/src/core/name_number_tree.js +0 -153
- package/src/core/object_loader.js +0 -149
- package/src/core/opentype_file_builder.js +0 -154
- package/src/core/operator_list.js +0 -734
- package/src/core/parser.js +0 -1416
- package/src/core/pattern.js +0 -985
- package/src/core/pdf_manager.js +0 -217
- package/src/core/predictor_stream.js +0 -238
- package/src/core/primitives.js +0 -402
- package/src/core/ps_parser.js +0 -272
- package/src/core/run_length_stream.js +0 -61
- package/src/core/segoeui_factors.js +0 -308
- package/src/core/standard_fonts.js +0 -817
- package/src/core/stream.js +0 -103
- package/src/core/struct_tree.js +0 -335
- package/src/core/to_unicode_map.js +0 -103
- package/src/core/type1_font.js +0 -421
- package/src/core/type1_parser.js +0 -776
- package/src/core/unicode.js +0 -1649
- package/src/core/worker.js +0 -848
- package/src/core/worker_stream.js +0 -135
- package/src/core/writer.js +0 -278
- package/src/core/xfa/bind.js +0 -652
- package/src/core/xfa/builder.js +0 -207
- package/src/core/xfa/config.js +0 -1926
- package/src/core/xfa/connection_set.js +0 -202
- package/src/core/xfa/data.js +0 -82
- package/src/core/xfa/datasets.js +0 -76
- package/src/core/xfa/factory.js +0 -111
- package/src/core/xfa/fonts.js +0 -181
- package/src/core/xfa/formcalc_lexer.js +0 -385
- package/src/core/xfa/formcalc_parser.js +0 -1340
- package/src/core/xfa/html_utils.js +0 -639
- package/src/core/xfa/layout.js +0 -383
- package/src/core/xfa/locale_set.js +0 -345
- package/src/core/xfa/namespaces.js +0 -81
- package/src/core/xfa/parser.js +0 -184
- package/src/core/xfa/setup.js +0 -38
- package/src/core/xfa/signature.js +0 -40
- package/src/core/xfa/som.js +0 -338
- package/src/core/xfa/stylesheet.js +0 -40
- package/src/core/xfa/template.js +0 -6260
- package/src/core/xfa/text.js +0 -290
- package/src/core/xfa/unknown.js +0 -29
- package/src/core/xfa/utils.js +0 -217
- package/src/core/xfa/xdp.js +0 -59
- package/src/core/xfa/xfa_object.js +0 -1130
- package/src/core/xfa/xhtml.js +0 -543
- package/src/core/xfa_fonts.js +0 -208
- package/src/core/xml_parser.js +0 -507
- package/src/core/xref.js +0 -899
- package/src/display/annotation_layer.js +0 -2107
- package/src/display/annotation_storage.js +0 -113
- package/src/display/api.js +0 -3292
- package/src/display/base_factory.js +0 -180
- package/src/display/canvas.js +0 -2828
- package/src/display/font_loader.js +0 -484
- package/src/display/metadata.js +0 -41
- package/src/display/network_utils.js +0 -100
- package/src/display/node_utils.js +0 -83
- package/src/display/optional_content_config.js +0 -189
- package/src/display/pattern_helper.js +0 -659
- package/src/display/svg.js +0 -1709
- package/src/display/text_layer.js +0 -847
- package/src/display/transport_stream.js +0 -303
- package/src/display/worker_options.js +0 -40
- package/src/display/xfa_layer.js +0 -204
- package/src/doc_helper.js +0 -25
- package/src/images/logo.svg +0 -41
- package/src/interfaces.js +0 -169
- package/src/license_header.js +0 -14
- package/src/license_header_libre.js +0 -21
- package/src/pdf.image_decoders.js +0 -46
- package/src/pdf.js +0 -146
- package/src/pdf.sandbox.external.js +0 -181
- package/src/pdf.sandbox.js +0 -151
- package/src/pdf.scripting.js +0 -25
- package/src/pdf.worker.entry.js +0 -19
- package/src/pdf.worker.js +0 -23
- package/src/scripting_api/aform.js +0 -608
- package/src/scripting_api/app.js +0 -621
- package/src/scripting_api/color.js +0 -129
- package/src/scripting_api/common.js +0 -58
- package/src/scripting_api/console.js +0 -38
- package/src/scripting_api/constants.js +0 -208
- package/src/scripting_api/doc.js +0 -1195
- package/src/scripting_api/error.js +0 -23
- package/src/scripting_api/event.js +0 -232
- package/src/scripting_api/field.js +0 -620
- package/src/scripting_api/fullscreen.js +0 -145
- package/src/scripting_api/initialization.js +0 -223
- package/src/scripting_api/pdf_object.js +0 -24
- package/src/scripting_api/print_params.js +0 -146
- package/src/scripting_api/proxy.js +0 -139
- package/src/scripting_api/thermometer.js +0 -69
- package/src/scripting_api/util.js +0 -581
- package/src/shared/.eslintrc +0 -13
- package/src/shared/cffStandardStrings.js +0 -311
- package/src/shared/compatibility.js +0 -114
- package/src/shared/fonts_utils.js +0 -429
- package/src/shared/is_node.js +0 -27
- package/src/shared/scripting_utils.js +0 -85
- package/src/worker_loader.js +0 -32
|
@@ -1,608 +0,0 @@
|
|
|
1
|
-
/* Copyright 2020 Mozilla Foundation
|
|
2
|
-
*
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { GlobalConstants } from "./constants.js";
|
|
17
|
-
|
|
18
|
-
class AForm {
|
|
19
|
-
constructor(document, app, util, color) {
|
|
20
|
-
this._document = document;
|
|
21
|
-
this._app = app;
|
|
22
|
-
this._util = util;
|
|
23
|
-
this._color = color;
|
|
24
|
-
this._dateFormats = [
|
|
25
|
-
"m/d",
|
|
26
|
-
"m/d/yy",
|
|
27
|
-
"mm/dd/yy",
|
|
28
|
-
"mm/yy",
|
|
29
|
-
"d-mmm",
|
|
30
|
-
"d-mmm-yy",
|
|
31
|
-
"dd-mmm-yy",
|
|
32
|
-
"yy-mm-dd",
|
|
33
|
-
"mmm-yy",
|
|
34
|
-
"mmmm-yy",
|
|
35
|
-
"mmm d, yyyy",
|
|
36
|
-
"mmmm d, yyyy",
|
|
37
|
-
"m/d/yy h:MM tt",
|
|
38
|
-
"m/d/yy HH:MM",
|
|
39
|
-
];
|
|
40
|
-
this._timeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
|
|
41
|
-
|
|
42
|
-
// The e-mail address regex below originates from:
|
|
43
|
-
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
|
|
44
|
-
this._emailRegex = new RegExp(
|
|
45
|
-
"^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+" +
|
|
46
|
-
"@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?" +
|
|
47
|
-
"(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
_mkTargetName(event) {
|
|
52
|
-
return event.target ? `[ ${event.target.name} ]` : "";
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_parseDate(cFormat, cDate) {
|
|
56
|
-
const ddate = Date.parse(cDate);
|
|
57
|
-
if (isNaN(ddate)) {
|
|
58
|
-
try {
|
|
59
|
-
return this._util.scand(cFormat, cDate);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
return new Date(ddate);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
AFMergeChange(event = globalThis.event) {
|
|
69
|
-
if (event.willCommit) {
|
|
70
|
-
return event.value.toString();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return this._app._eventDispatcher.mergeChange(event);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
AFParseDateEx(cString, cOrder) {
|
|
77
|
-
return this._parseDate(cOrder, cString);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
AFExtractNums(str) {
|
|
81
|
-
if (typeof str === "number") {
|
|
82
|
-
return [str];
|
|
83
|
-
}
|
|
84
|
-
if (!str || typeof str !== "string") {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const first = str.charAt(0);
|
|
89
|
-
if (first === "." || first === ",") {
|
|
90
|
-
str = `0${str}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const numbers = str.match(/([0-9]+)/g);
|
|
94
|
-
if (numbers.length === 0) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return numbers;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
AFMakeNumber(str) {
|
|
102
|
-
if (typeof str === "number") {
|
|
103
|
-
return str;
|
|
104
|
-
}
|
|
105
|
-
if (typeof str !== "string") {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
str = str.trim().replace(",", ".");
|
|
110
|
-
const number = parseFloat(str);
|
|
111
|
-
if (isNaN(number) || !isFinite(number)) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
AFMakeArrayFromList(string) {
|
|
119
|
-
if (typeof string === "string") {
|
|
120
|
-
return string.split(/, ?/g);
|
|
121
|
-
}
|
|
122
|
-
return string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
AFNumber_Format(
|
|
126
|
-
nDec,
|
|
127
|
-
sepStyle,
|
|
128
|
-
negStyle,
|
|
129
|
-
currStyle /* unused */,
|
|
130
|
-
strCurrency,
|
|
131
|
-
bCurrencyPrepend
|
|
132
|
-
) {
|
|
133
|
-
const event = globalThis.event;
|
|
134
|
-
if (!event.value) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
let value = this.AFMakeNumber(event.value);
|
|
139
|
-
if (value === null) {
|
|
140
|
-
event.value = "";
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const sign = Math.sign(value);
|
|
145
|
-
const buf = [];
|
|
146
|
-
let hasParen = false;
|
|
147
|
-
|
|
148
|
-
if (sign === -1 && bCurrencyPrepend && negStyle === 0) {
|
|
149
|
-
buf.push("-");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if ((negStyle === 2 || negStyle === 3) && sign === -1) {
|
|
153
|
-
buf.push("(");
|
|
154
|
-
hasParen = true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (bCurrencyPrepend) {
|
|
158
|
-
buf.push(strCurrency);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// sepStyle is an integer in [0;4]
|
|
162
|
-
sepStyle = Math.min(Math.max(0, Math.floor(sepStyle)), 4);
|
|
163
|
-
|
|
164
|
-
buf.push("%,", sepStyle, ".", nDec.toString(), "f");
|
|
165
|
-
|
|
166
|
-
if (!bCurrencyPrepend) {
|
|
167
|
-
buf.push(strCurrency);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (hasParen) {
|
|
171
|
-
buf.push(")");
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (negStyle === 1 || negStyle === 3) {
|
|
175
|
-
event.target.textColor = sign === 1 ? this._color.black : this._color.red;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if ((negStyle !== 0 || bCurrencyPrepend) && sign === -1) {
|
|
179
|
-
value = -value;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const formatStr = buf.join("");
|
|
183
|
-
event.value = this._util.printf(formatStr, value);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
AFNumber_Keystroke(
|
|
187
|
-
nDec /* unused */,
|
|
188
|
-
sepStyle,
|
|
189
|
-
negStyle /* unused */,
|
|
190
|
-
currStyle /* unused */,
|
|
191
|
-
strCurrency /* unused */,
|
|
192
|
-
bCurrencyPrepend /* unused */
|
|
193
|
-
) {
|
|
194
|
-
const event = globalThis.event;
|
|
195
|
-
let value = this.AFMergeChange(event);
|
|
196
|
-
if (!value) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
value = value.trim();
|
|
200
|
-
|
|
201
|
-
let pattern;
|
|
202
|
-
if (sepStyle > 1) {
|
|
203
|
-
// comma sep
|
|
204
|
-
pattern = event.willCommit
|
|
205
|
-
? /^[+-]?([0-9]+(,[0-9]*)?|,[0-9]+)$/
|
|
206
|
-
: /^[+-]?[0-9]*,?[0-9]*$/;
|
|
207
|
-
} else {
|
|
208
|
-
// dot sep
|
|
209
|
-
pattern = event.willCommit
|
|
210
|
-
? /^[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)$/
|
|
211
|
-
: /^[+-]?[0-9]*\.?[0-9]*$/;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (!pattern.test(value)) {
|
|
215
|
-
if (event.willCommit) {
|
|
216
|
-
const err = `${GlobalConstants.IDS_INVALID_VALUE} ${this._mkTargetName(
|
|
217
|
-
event
|
|
218
|
-
)}`;
|
|
219
|
-
this._app.alert(err);
|
|
220
|
-
}
|
|
221
|
-
event.rc = false;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (event.willCommit && sepStyle > 1) {
|
|
225
|
-
event.value = parseFloat(value.replace(",", "."));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
AFPercent_Format(nDec, sepStyle, percentPrepend = false) {
|
|
230
|
-
if (typeof nDec !== "number") {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
if (typeof sepStyle !== "number") {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (nDec < 0) {
|
|
237
|
-
throw new Error("Invalid nDec value in AFPercent_Format");
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const event = globalThis.event;
|
|
241
|
-
if (nDec > 512) {
|
|
242
|
-
event.value = "%";
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
nDec = Math.floor(nDec);
|
|
247
|
-
|
|
248
|
-
// sepStyle is an integer in [0;4]
|
|
249
|
-
sepStyle = Math.min(Math.max(0, Math.floor(sepStyle)), 4);
|
|
250
|
-
|
|
251
|
-
let value = this.AFMakeNumber(event.value);
|
|
252
|
-
if (value === null) {
|
|
253
|
-
event.value = "%";
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const formatStr = `%,${sepStyle}.${nDec}f`;
|
|
258
|
-
value = this._util.printf(formatStr, value * 100);
|
|
259
|
-
|
|
260
|
-
if (percentPrepend) {
|
|
261
|
-
event.value = `%${value}`;
|
|
262
|
-
} else {
|
|
263
|
-
event.value = `${value}%`;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
AFPercent_Keystroke(nDec, sepStyle) {
|
|
268
|
-
this.AFNumber_Keystroke(nDec, sepStyle, 0, 0, "", true);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
AFDate_FormatEx(cFormat) {
|
|
272
|
-
const event = globalThis.event;
|
|
273
|
-
const value = event.value;
|
|
274
|
-
if (!value) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const date = this._parseDate(cFormat, value);
|
|
279
|
-
if (date !== null) {
|
|
280
|
-
event.value = this._util.printd(cFormat, date);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
AFDate_Format(pdf) {
|
|
285
|
-
if (pdf >= 0 && pdf < this._dateFormats.length) {
|
|
286
|
-
this.AFDate_FormatEx(this._dateFormats[pdf]);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
AFDate_KeystrokeEx(cFormat) {
|
|
291
|
-
const event = globalThis.event;
|
|
292
|
-
if (!event.willCommit) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const value = this.AFMergeChange(event);
|
|
297
|
-
if (!value) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (this._parseDate(cFormat, value) === null) {
|
|
302
|
-
const invalid = GlobalConstants.IDS_INVALID_DATE;
|
|
303
|
-
const invalid2 = GlobalConstants.IDS_INVALID_DATE2;
|
|
304
|
-
const err = `${invalid} ${this._mkTargetName(
|
|
305
|
-
event
|
|
306
|
-
)}${invalid2}${cFormat}`;
|
|
307
|
-
this._app.alert(err);
|
|
308
|
-
event.rc = false;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
AFDate_Keystroke(pdf) {
|
|
313
|
-
if (pdf >= 0 && pdf < this._dateFormats.length) {
|
|
314
|
-
this.AFDate_KeystrokeEx(this._dateFormats[pdf]);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
AFRange_Validate(bGreaterThan, nGreaterThan, bLessThan, nLessThan) {
|
|
319
|
-
const event = globalThis.event;
|
|
320
|
-
if (!event.value) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const value = this.AFMakeNumber(event.value);
|
|
325
|
-
if (value === null) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
bGreaterThan = !!bGreaterThan;
|
|
330
|
-
bLessThan = !!bLessThan;
|
|
331
|
-
|
|
332
|
-
if (bGreaterThan) {
|
|
333
|
-
nGreaterThan = this.AFMakeNumber(nGreaterThan);
|
|
334
|
-
if (nGreaterThan === null) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (bLessThan) {
|
|
340
|
-
nLessThan = this.AFMakeNumber(nLessThan);
|
|
341
|
-
if (nLessThan === null) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
let err = "";
|
|
347
|
-
if (bGreaterThan && bLessThan) {
|
|
348
|
-
if (value < nGreaterThan || value > nLessThan) {
|
|
349
|
-
err = this._util.printf(
|
|
350
|
-
GlobalConstants.IDS_GT_AND_LT,
|
|
351
|
-
nGreaterThan,
|
|
352
|
-
nLessThan
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
} else if (bGreaterThan) {
|
|
356
|
-
if (value < nGreaterThan) {
|
|
357
|
-
err = this._util.printf(GlobalConstants.IDS_GREATER_THAN, nGreaterThan);
|
|
358
|
-
}
|
|
359
|
-
} else if (value > nLessThan) {
|
|
360
|
-
err = this._util.printf(GlobalConstants.IDS_LESS_THAN, nLessThan);
|
|
361
|
-
}
|
|
362
|
-
if (err) {
|
|
363
|
-
this._app.alert(err);
|
|
364
|
-
event.rc = false;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
AFSimple(cFunction, nValue1, nValue2) {
|
|
369
|
-
const value1 = this.AFMakeNumber(nValue1);
|
|
370
|
-
if (value1 === null) {
|
|
371
|
-
throw new Error("Invalid nValue1 in AFSimple");
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
const value2 = this.AFMakeNumber(nValue2);
|
|
375
|
-
if (value2 === null) {
|
|
376
|
-
throw new Error("Invalid nValue2 in AFSimple");
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
switch (cFunction) {
|
|
380
|
-
case "AVG":
|
|
381
|
-
return (value1 + value2) / 2;
|
|
382
|
-
case "SUM":
|
|
383
|
-
return value1 + value2;
|
|
384
|
-
case "PRD":
|
|
385
|
-
return value1 * value2;
|
|
386
|
-
case "MIN":
|
|
387
|
-
return Math.min(value1, value2);
|
|
388
|
-
case "MAX":
|
|
389
|
-
return Math.max(value1, value2);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
throw new Error("Invalid cFunction in AFSimple");
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
AFSimple_Calculate(cFunction, cFields) {
|
|
396
|
-
const actions = {
|
|
397
|
-
AVG: args => args.reduce((acc, value) => acc + value, 0) / args.length,
|
|
398
|
-
SUM: args => args.reduce((acc, value) => acc + value, 0),
|
|
399
|
-
PRD: args => args.reduce((acc, value) => acc * value, 1),
|
|
400
|
-
MIN: args =>
|
|
401
|
-
args.reduce((acc, value) => Math.min(acc, value), Number.MAX_VALUE),
|
|
402
|
-
MAX: args =>
|
|
403
|
-
args.reduce((acc, value) => Math.max(acc, value), Number.MIN_VALUE),
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
if (!(cFunction in actions)) {
|
|
407
|
-
throw new TypeError("Invalid function in AFSimple_Calculate");
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
const event = globalThis.event;
|
|
411
|
-
const values = [];
|
|
412
|
-
for (const cField of cFields) {
|
|
413
|
-
const field = this._document.getField(cField);
|
|
414
|
-
const number = this.AFMakeNumber(field.value);
|
|
415
|
-
if (number !== null) {
|
|
416
|
-
values.push(number);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
if (values.length === 0) {
|
|
421
|
-
event.value = cFunction === "PRD" ? 1 : 0;
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const res = actions[cFunction](values);
|
|
426
|
-
event.value = Math.round(1e6 * res) / 1e6;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
AFSpecial_Format(psf) {
|
|
430
|
-
const event = globalThis.event;
|
|
431
|
-
if (!event.value) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
psf = this.AFMakeNumber(psf);
|
|
436
|
-
if (psf === null) {
|
|
437
|
-
throw new Error("Invalid psf in AFSpecial_Format");
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
let formatStr = "";
|
|
441
|
-
switch (psf) {
|
|
442
|
-
case 0:
|
|
443
|
-
formatStr = "99999";
|
|
444
|
-
break;
|
|
445
|
-
case 1:
|
|
446
|
-
formatStr = "99999-9999";
|
|
447
|
-
break;
|
|
448
|
-
case 2:
|
|
449
|
-
if (this._util.printx("9999999999", event.value).length >= 10) {
|
|
450
|
-
formatStr = "(999) 999-9999";
|
|
451
|
-
} else {
|
|
452
|
-
formatStr = "999-9999";
|
|
453
|
-
}
|
|
454
|
-
break;
|
|
455
|
-
case 3:
|
|
456
|
-
formatStr = "999-99-9999";
|
|
457
|
-
break;
|
|
458
|
-
default:
|
|
459
|
-
throw new Error("Invalid psf in AFSpecial_Format");
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
event.value = this._util.printx(formatStr, event.value);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
AFSpecial_KeystrokeEx(cMask) {
|
|
466
|
-
if (!cMask) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
const event = globalThis.event;
|
|
471
|
-
const value = this.AFMergeChange(event);
|
|
472
|
-
const checkers = new Map([
|
|
473
|
-
["9", char => char >= "0" && char <= "9"],
|
|
474
|
-
[
|
|
475
|
-
"A",
|
|
476
|
-
char => ("a" <= char && char <= "z") || ("A" <= char && char <= "Z"),
|
|
477
|
-
],
|
|
478
|
-
[
|
|
479
|
-
"O",
|
|
480
|
-
char =>
|
|
481
|
-
("a" <= char && char <= "z") ||
|
|
482
|
-
("A" <= char && char <= "Z") ||
|
|
483
|
-
("0" <= char && char <= "9"),
|
|
484
|
-
],
|
|
485
|
-
["X", char => true],
|
|
486
|
-
]);
|
|
487
|
-
|
|
488
|
-
function _checkValidity(_value, _cMask) {
|
|
489
|
-
for (let i = 0, ii = value.length; i < ii; i++) {
|
|
490
|
-
const mask = _cMask.charAt(i);
|
|
491
|
-
const char = _value.charAt(i);
|
|
492
|
-
const checker = checkers.get(mask);
|
|
493
|
-
if (checker) {
|
|
494
|
-
if (!checker(char)) {
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
} else if (mask !== char) {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return true;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (!value) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
const err = `${GlobalConstants.IDS_INVALID_VALUE} = "${cMask}"`;
|
|
509
|
-
|
|
510
|
-
if (value.length > cMask.length) {
|
|
511
|
-
this._app.alert(err);
|
|
512
|
-
event.rc = false;
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
if (event.willCommit) {
|
|
517
|
-
if (value.length < cMask.length) {
|
|
518
|
-
this._app.alert(err);
|
|
519
|
-
event.rc = false;
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
if (!_checkValidity(value, cMask)) {
|
|
524
|
-
this._app.alert(err);
|
|
525
|
-
event.rc = false;
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
event.value += cMask.substring(value.length);
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (value.length < cMask.length) {
|
|
533
|
-
cMask = cMask.substring(0, value.length);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
if (!_checkValidity(value, cMask)) {
|
|
537
|
-
this._app.alert(err);
|
|
538
|
-
event.rc = false;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
AFSpecial_Keystroke(psf) {
|
|
543
|
-
const event = globalThis.event;
|
|
544
|
-
if (!event.value) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
psf = this.AFMakeNumber(psf);
|
|
549
|
-
if (psf === null) {
|
|
550
|
-
throw new Error("Invalid psf in AFSpecial_Keystroke");
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
let formatStr;
|
|
554
|
-
switch (psf) {
|
|
555
|
-
case 0:
|
|
556
|
-
formatStr = "99999";
|
|
557
|
-
break;
|
|
558
|
-
case 1:
|
|
559
|
-
formatStr = "99999-9999";
|
|
560
|
-
break;
|
|
561
|
-
case 2:
|
|
562
|
-
const finalLen =
|
|
563
|
-
event.value.length +
|
|
564
|
-
event.change.length +
|
|
565
|
-
event.selStart -
|
|
566
|
-
event.selEnd;
|
|
567
|
-
if (finalLen >= 8) {
|
|
568
|
-
formatStr = "(999) 999-9999";
|
|
569
|
-
} else {
|
|
570
|
-
formatStr = "999-9999";
|
|
571
|
-
}
|
|
572
|
-
break;
|
|
573
|
-
case 3:
|
|
574
|
-
formatStr = "999-99-9999";
|
|
575
|
-
break;
|
|
576
|
-
default:
|
|
577
|
-
throw new Error("Invalid psf in AFSpecial_Keystroke");
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
this.AFSpecial_KeystrokeEx(formatStr);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
AFTime_FormatEx(cFormat) {
|
|
584
|
-
this.AFDate_FormatEx(cFormat);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
AFTime_Format(pdf) {
|
|
588
|
-
if (pdf >= 0 && pdf < this._timeFormats.length) {
|
|
589
|
-
this.AFDate_FormatEx(this._timeFormats[pdf]);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
AFTime_KeystrokeEx(cFormat) {
|
|
594
|
-
this.AFDate_KeystrokeEx(cFormat);
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
AFTime_Keystroke(pdf) {
|
|
598
|
-
if (pdf >= 0 && pdf < this._timeFormats.length) {
|
|
599
|
-
this.AFDate_KeystrokeEx(this._timeFormats[pdf]);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
eMailValidate(str) {
|
|
604
|
-
return this._emailRegex.test(str);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
export { AForm };
|