@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,620 +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 { createActionsMap, FieldType, getFieldType } from "./common.js";
|
|
17
|
-
import { Color } from "./color.js";
|
|
18
|
-
import { PDFObject } from "./pdf_object.js";
|
|
19
|
-
|
|
20
|
-
class Field extends PDFObject {
|
|
21
|
-
constructor(data) {
|
|
22
|
-
super(data);
|
|
23
|
-
this.alignment = data.alignment || "left";
|
|
24
|
-
this.borderStyle = data.borderStyle || "";
|
|
25
|
-
this.buttonAlignX = data.buttonAlignX || 50;
|
|
26
|
-
this.buttonAlignY = data.buttonAlignY || 50;
|
|
27
|
-
this.buttonFitBounds = data.buttonFitBounds;
|
|
28
|
-
this.buttonPosition = data.buttonPosition;
|
|
29
|
-
this.buttonScaleHow = data.buttonScaleHow;
|
|
30
|
-
this.ButtonScaleWhen = data.buttonScaleWhen;
|
|
31
|
-
this.calcOrderIndex = data.calcOrderIndex;
|
|
32
|
-
this.charLimit = data.charLimit;
|
|
33
|
-
this.comb = data.comb;
|
|
34
|
-
this.commitOnSelChange = data.commitOnSelChange;
|
|
35
|
-
this.currentValueIndices = data.currentValueIndices;
|
|
36
|
-
this.defaultStyle = data.defaultStyle;
|
|
37
|
-
this.defaultValue = data.defaultValue;
|
|
38
|
-
this.doNotScroll = data.doNotScroll;
|
|
39
|
-
this.doNotSpellCheck = data.doNotSpellCheck;
|
|
40
|
-
this.delay = data.delay;
|
|
41
|
-
this.display = data.display;
|
|
42
|
-
this.doc = data.doc.wrapped;
|
|
43
|
-
this.editable = data.editable;
|
|
44
|
-
this.exportValues = data.exportValues;
|
|
45
|
-
this.fileSelect = data.fileSelect;
|
|
46
|
-
this.hidden = data.hidden;
|
|
47
|
-
this.highlight = data.highlight;
|
|
48
|
-
this.lineWidth = data.lineWidth;
|
|
49
|
-
this.multiline = data.multiline;
|
|
50
|
-
this.multipleSelection = !!data.multipleSelection;
|
|
51
|
-
this.name = data.name;
|
|
52
|
-
this.password = data.password;
|
|
53
|
-
this.print = data.print;
|
|
54
|
-
this.radiosInUnison = data.radiosInUnison;
|
|
55
|
-
this.readonly = data.readonly;
|
|
56
|
-
this.rect = data.rect;
|
|
57
|
-
this.required = data.required;
|
|
58
|
-
this.richText = data.richText;
|
|
59
|
-
this.richValue = data.richValue;
|
|
60
|
-
this.rotation = data.rotation;
|
|
61
|
-
this.style = data.style;
|
|
62
|
-
this.submitName = data.submitName;
|
|
63
|
-
this.textFont = data.textFont;
|
|
64
|
-
this.textSize = data.textSize;
|
|
65
|
-
this.type = data.type;
|
|
66
|
-
this.userName = data.userName;
|
|
67
|
-
|
|
68
|
-
// Private
|
|
69
|
-
this._actions = createActionsMap(data.actions);
|
|
70
|
-
this._browseForFileToSubmit = data.browseForFileToSubmit || null;
|
|
71
|
-
this._buttonCaption = null;
|
|
72
|
-
this._buttonIcon = null;
|
|
73
|
-
this._children = null;
|
|
74
|
-
this._currentValueIndices = data.currentValueIndices || 0;
|
|
75
|
-
this._document = data.doc;
|
|
76
|
-
this._fieldPath = data.fieldPath;
|
|
77
|
-
this._fillColor = data.fillColor || ["T"];
|
|
78
|
-
this._isChoice = Array.isArray(data.items);
|
|
79
|
-
this._items = data.items || [];
|
|
80
|
-
this._page = data.page || 0;
|
|
81
|
-
this._strokeColor = data.strokeColor || ["G", 0];
|
|
82
|
-
this._textColor = data.textColor || ["G", 0];
|
|
83
|
-
this._value = data.value || "";
|
|
84
|
-
this._kidIds = data.kidIds || null;
|
|
85
|
-
this._fieldType = getFieldType(this._actions);
|
|
86
|
-
this._siblings = data.siblings || null;
|
|
87
|
-
|
|
88
|
-
this._globalEval = data.globalEval;
|
|
89
|
-
this._appObjects = data.appObjects;
|
|
90
|
-
|
|
91
|
-
this.valueAsString = data.valueAsString || this._value;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
get currentValueIndices() {
|
|
95
|
-
if (!this._isChoice) {
|
|
96
|
-
return 0;
|
|
97
|
-
}
|
|
98
|
-
return this._currentValueIndices;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
set currentValueIndices(indices) {
|
|
102
|
-
if (!this._isChoice) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (!Array.isArray(indices)) {
|
|
106
|
-
indices = [indices];
|
|
107
|
-
}
|
|
108
|
-
if (
|
|
109
|
-
!indices.every(
|
|
110
|
-
i =>
|
|
111
|
-
typeof i === "number" &&
|
|
112
|
-
Number.isInteger(i) &&
|
|
113
|
-
i >= 0 &&
|
|
114
|
-
i < this.numItems
|
|
115
|
-
)
|
|
116
|
-
) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
indices.sort();
|
|
121
|
-
|
|
122
|
-
if (this.multipleSelection) {
|
|
123
|
-
this._currentValueIndices = indices;
|
|
124
|
-
this._value = [];
|
|
125
|
-
indices.forEach(i => {
|
|
126
|
-
this._value.push(this._items[i].displayValue);
|
|
127
|
-
});
|
|
128
|
-
} else {
|
|
129
|
-
if (indices.length > 0) {
|
|
130
|
-
indices = indices.splice(1, indices.length - 1);
|
|
131
|
-
this._currentValueIndices = indices[0];
|
|
132
|
-
this._value = this._items[this._currentValueIndices];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
this._send({ id: this._id, indices });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
get fillColor() {
|
|
139
|
-
return this._fillColor;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
set fillColor(color) {
|
|
143
|
-
if (Color._isValidColor(color)) {
|
|
144
|
-
this._fillColor = color;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
get bgColor() {
|
|
149
|
-
return this.fillColor;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
set bgColor(color) {
|
|
153
|
-
this.fillColor = color;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
get numItems() {
|
|
157
|
-
if (!this._isChoice) {
|
|
158
|
-
throw new Error("Not a choice widget");
|
|
159
|
-
}
|
|
160
|
-
return this._items.length;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
set numItems(_) {
|
|
164
|
-
throw new Error("field.numItems is read-only");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
get strokeColor() {
|
|
168
|
-
return this._strokeColor;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
set strokeColor(color) {
|
|
172
|
-
if (Color._isValidColor(color)) {
|
|
173
|
-
this._strokeColor = color;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
get borderColor() {
|
|
178
|
-
return this.strokeColor;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
set borderColor(color) {
|
|
182
|
-
this.strokeColor = color;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
get page() {
|
|
186
|
-
return this._page;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
set page(_) {
|
|
190
|
-
throw new Error("field.page is read-only");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
get textColor() {
|
|
194
|
-
return this._textColor;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
set textColor(color) {
|
|
198
|
-
if (Color._isValidColor(color)) {
|
|
199
|
-
this._textColor = color;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
get fgColor() {
|
|
204
|
-
return this.textColor;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
set fgColor(color) {
|
|
208
|
-
this.textColor = color;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
get value() {
|
|
212
|
-
return this._value;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
set value(value) {
|
|
216
|
-
if (value === "") {
|
|
217
|
-
this._value = "";
|
|
218
|
-
} else if (typeof value === "string") {
|
|
219
|
-
switch (this._fieldType) {
|
|
220
|
-
case FieldType.number:
|
|
221
|
-
case FieldType.percent:
|
|
222
|
-
value = parseFloat(value);
|
|
223
|
-
if (!isNaN(value)) {
|
|
224
|
-
this._value = value;
|
|
225
|
-
}
|
|
226
|
-
break;
|
|
227
|
-
default:
|
|
228
|
-
this._value = value;
|
|
229
|
-
}
|
|
230
|
-
} else {
|
|
231
|
-
this._value = value;
|
|
232
|
-
}
|
|
233
|
-
if (this._isChoice) {
|
|
234
|
-
if (this.multipleSelection) {
|
|
235
|
-
const values = new Set(value);
|
|
236
|
-
this._currentValueIndices.length = 0;
|
|
237
|
-
this._items.forEach(({ displayValue }, i) => {
|
|
238
|
-
if (values.has(displayValue)) {
|
|
239
|
-
this._currentValueIndices.push(i);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
} else {
|
|
243
|
-
this._currentValueIndices = this._items.findIndex(
|
|
244
|
-
({ displayValue }) => value === displayValue
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
get valueAsString() {
|
|
251
|
-
if (this._valueAsString === undefined) {
|
|
252
|
-
this._valueAsString = this._value ? this._value.toString() : "";
|
|
253
|
-
}
|
|
254
|
-
return this._valueAsString;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
set valueAsString(val) {
|
|
258
|
-
this._valueAsString = val ? val.toString() : "";
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
browseForFileToSubmit() {
|
|
262
|
-
if (this._browseForFileToSubmit) {
|
|
263
|
-
// TODO: implement this function on Firefox side
|
|
264
|
-
// we can use nsIFilePicker but open method is async.
|
|
265
|
-
// Maybe it's possible to use a html input (type=file) too.
|
|
266
|
-
this._browseForFileToSubmit();
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
buttonGetCaption(nFace = 0) {
|
|
271
|
-
if (this._buttonCaption) {
|
|
272
|
-
return this._buttonCaption[nFace];
|
|
273
|
-
}
|
|
274
|
-
return "";
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
buttonGetIcon(nFace = 0) {
|
|
278
|
-
if (this._buttonIcon) {
|
|
279
|
-
return this._buttonIcon[nFace];
|
|
280
|
-
}
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
buttonImportIcon(cPath = null, nPave = 0) {
|
|
285
|
-
/* Not implemented */
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
buttonSetCaption(cCaption, nFace = 0) {
|
|
289
|
-
if (!this._buttonCaption) {
|
|
290
|
-
this._buttonCaption = ["", "", ""];
|
|
291
|
-
}
|
|
292
|
-
this._buttonCaption[nFace] = cCaption;
|
|
293
|
-
// TODO: send to the annotation layer
|
|
294
|
-
// Right now the button is drawn on the canvas using its appearance so
|
|
295
|
-
// update the caption means redraw...
|
|
296
|
-
// We should probably have an html button for this annotation.
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
buttonSetIcon(oIcon, nFace = 0) {
|
|
300
|
-
if (!this._buttonIcon) {
|
|
301
|
-
this._buttonIcon = [null, null, null];
|
|
302
|
-
}
|
|
303
|
-
this._buttonIcon[nFace] = oIcon;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
checkThisBox(nWidget, bCheckIt = true) {}
|
|
307
|
-
|
|
308
|
-
clearItems() {
|
|
309
|
-
if (!this._isChoice) {
|
|
310
|
-
throw new Error("Not a choice widget");
|
|
311
|
-
}
|
|
312
|
-
this._items = [];
|
|
313
|
-
this._send({ id: this._id, clear: null });
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
deleteItemAt(nIdx = null) {
|
|
317
|
-
if (!this._isChoice) {
|
|
318
|
-
throw new Error("Not a choice widget");
|
|
319
|
-
}
|
|
320
|
-
if (!this.numItems) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (nIdx === null) {
|
|
325
|
-
// Current selected item.
|
|
326
|
-
nIdx = Array.isArray(this._currentValueIndices)
|
|
327
|
-
? this._currentValueIndices[0]
|
|
328
|
-
: this._currentValueIndices;
|
|
329
|
-
nIdx = nIdx || 0;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (nIdx < 0 || nIdx >= this.numItems) {
|
|
333
|
-
nIdx = this.numItems - 1;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
this._items.splice(nIdx, 1);
|
|
337
|
-
if (Array.isArray(this._currentValueIndices)) {
|
|
338
|
-
let index = this._currentValueIndices.findIndex(i => i >= nIdx);
|
|
339
|
-
if (index !== -1) {
|
|
340
|
-
if (this._currentValueIndices[index] === nIdx) {
|
|
341
|
-
this._currentValueIndices.splice(index, 1);
|
|
342
|
-
}
|
|
343
|
-
for (const ii = this._currentValueIndices.length; index < ii; index++) {
|
|
344
|
-
--this._currentValueIndices[index];
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
348
|
-
if (this._currentValueIndices === nIdx) {
|
|
349
|
-
this._currentValueIndices = this.numItems > 0 ? 0 : -1;
|
|
350
|
-
} else if (this._currentValueIndices > nIdx) {
|
|
351
|
-
--this._currentValueIndices;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
this._send({ id: this._id, remove: nIdx });
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
getItemAt(nIdx = -1, bExportValue = false) {
|
|
359
|
-
if (!this._isChoice) {
|
|
360
|
-
throw new Error("Not a choice widget");
|
|
361
|
-
}
|
|
362
|
-
if (nIdx < 0 || nIdx >= this.numItems) {
|
|
363
|
-
nIdx = this.numItems - 1;
|
|
364
|
-
}
|
|
365
|
-
const item = this._items[nIdx];
|
|
366
|
-
return bExportValue ? item.exportValue : item.displayValue;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
getArray() {
|
|
370
|
-
if (this._kidIds) {
|
|
371
|
-
return this._kidIds.map(id => this._appObjects[id].wrapped);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (this._children === null) {
|
|
375
|
-
this._children = this._document.obj._getChildren(this._fieldPath);
|
|
376
|
-
}
|
|
377
|
-
return this._children;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
getLock() {
|
|
381
|
-
return undefined;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
isBoxChecked(nWidget) {
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
isDefaultChecked(nWidget) {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
insertItemAt(cName, cExport = undefined, nIdx = 0) {
|
|
393
|
-
if (!this._isChoice) {
|
|
394
|
-
throw new Error("Not a choice widget");
|
|
395
|
-
}
|
|
396
|
-
if (!cName) {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (nIdx < 0 || nIdx > this.numItems) {
|
|
401
|
-
nIdx = this.numItems;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
if (this._items.some(({ displayValue }) => displayValue === cName)) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (cExport === undefined) {
|
|
409
|
-
cExport = cName;
|
|
410
|
-
}
|
|
411
|
-
const data = { displayValue: cName, exportValue: cExport };
|
|
412
|
-
this._items.splice(nIdx, 0, data);
|
|
413
|
-
if (Array.isArray(this._currentValueIndices)) {
|
|
414
|
-
let index = this._currentValueIndices.findIndex(i => i >= nIdx);
|
|
415
|
-
if (index !== -1) {
|
|
416
|
-
for (const ii = this._currentValueIndices.length; index < ii; index++) {
|
|
417
|
-
++this._currentValueIndices[index];
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
} else if (this._currentValueIndices >= nIdx) {
|
|
421
|
-
++this._currentValueIndices;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
this._send({ id: this._id, insert: { index: nIdx, ...data } });
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
setAction(cTrigger, cScript) {
|
|
428
|
-
if (typeof cTrigger !== "string" || typeof cScript !== "string") {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
if (!(cTrigger in this._actions)) {
|
|
432
|
-
this._actions[cTrigger] = [];
|
|
433
|
-
}
|
|
434
|
-
this._actions[cTrigger].push(cScript);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
setFocus() {
|
|
438
|
-
this._send({ id: this._id, focus: true });
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
setItems(oArray) {
|
|
442
|
-
if (!this._isChoice) {
|
|
443
|
-
throw new Error("Not a choice widget");
|
|
444
|
-
}
|
|
445
|
-
this._items.length = 0;
|
|
446
|
-
for (const element of oArray) {
|
|
447
|
-
let displayValue, exportValue;
|
|
448
|
-
if (Array.isArray(element)) {
|
|
449
|
-
displayValue = element[0]?.toString() || "";
|
|
450
|
-
exportValue = element[1]?.toString() || "";
|
|
451
|
-
} else {
|
|
452
|
-
displayValue = exportValue = element?.toString() || "";
|
|
453
|
-
}
|
|
454
|
-
this._items.push({ displayValue, exportValue });
|
|
455
|
-
}
|
|
456
|
-
this._currentValueIndices = 0;
|
|
457
|
-
|
|
458
|
-
this._send({ id: this._id, items: this._items });
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
setLock() {}
|
|
462
|
-
|
|
463
|
-
signatureGetModifications() {}
|
|
464
|
-
|
|
465
|
-
signatureGetSeedValue() {}
|
|
466
|
-
|
|
467
|
-
signatureInfo() {}
|
|
468
|
-
|
|
469
|
-
signatureSetSeedValue() {}
|
|
470
|
-
|
|
471
|
-
signatureSign() {}
|
|
472
|
-
|
|
473
|
-
signatureValidate() {}
|
|
474
|
-
|
|
475
|
-
_isButton() {
|
|
476
|
-
return false;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
_runActions(event) {
|
|
480
|
-
const eventName = event.name;
|
|
481
|
-
if (!this._actions.has(eventName)) {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const actions = this._actions.get(eventName);
|
|
486
|
-
try {
|
|
487
|
-
for (const action of actions) {
|
|
488
|
-
// Action evaluation must happen in the global scope
|
|
489
|
-
this._globalEval(action);
|
|
490
|
-
}
|
|
491
|
-
} catch (error) {
|
|
492
|
-
event.rc = false;
|
|
493
|
-
throw error;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
return true;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
class RadioButtonField extends Field {
|
|
501
|
-
constructor(otherButtons, data) {
|
|
502
|
-
super(data);
|
|
503
|
-
|
|
504
|
-
this.exportValues = [this.exportValues];
|
|
505
|
-
this._radioIds = [this._id];
|
|
506
|
-
this._radioActions = [this._actions];
|
|
507
|
-
|
|
508
|
-
for (const radioData of otherButtons) {
|
|
509
|
-
this.exportValues.push(radioData.exportValues);
|
|
510
|
-
this._radioIds.push(radioData.id);
|
|
511
|
-
this._radioActions.push(createActionsMap(radioData.actions));
|
|
512
|
-
if (this._value === radioData.exportValues) {
|
|
513
|
-
this._id = radioData.id;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
get value() {
|
|
519
|
-
return this._value;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
set value(value) {
|
|
523
|
-
if (value === null || value === undefined) {
|
|
524
|
-
this._value = "";
|
|
525
|
-
}
|
|
526
|
-
const i = this.exportValues.indexOf(value);
|
|
527
|
-
if (0 <= i && i < this._radioIds.length) {
|
|
528
|
-
this._id = this._radioIds[i];
|
|
529
|
-
this._value = value;
|
|
530
|
-
} else if (value === "Off" && this._radioIds.length === 2) {
|
|
531
|
-
const nextI = (1 + this._radioIds.indexOf(this._id)) % 2;
|
|
532
|
-
this._id = this._radioIds[nextI];
|
|
533
|
-
this._value = this.exportValues[nextI];
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
checkThisBox(nWidget, bCheckIt = true) {
|
|
538
|
-
if (nWidget < 0 || nWidget >= this._radioIds.length || !bCheckIt) {
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
this._id = this._radioIds[nWidget];
|
|
543
|
-
this._value = this.exportValues[nWidget];
|
|
544
|
-
this._send({ id: this._id, value: this._value });
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
isBoxChecked(nWidget) {
|
|
548
|
-
return (
|
|
549
|
-
nWidget >= 0 &&
|
|
550
|
-
nWidget < this._radioIds.length &&
|
|
551
|
-
this._id === this._radioIds[nWidget]
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
isDefaultChecked(nWidget) {
|
|
556
|
-
return (
|
|
557
|
-
nWidget >= 0 &&
|
|
558
|
-
nWidget < this.exportValues.length &&
|
|
559
|
-
this.defaultValue === this.exportValues[nWidget]
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
_getExportValue(state) {
|
|
564
|
-
const i = this._radioIds.indexOf(this._id);
|
|
565
|
-
return this.exportValues[i];
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
_runActions(event) {
|
|
569
|
-
const i = this._radioIds.indexOf(this._id);
|
|
570
|
-
this._actions = this._radioActions[i];
|
|
571
|
-
return super._runActions(event);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
_isButton() {
|
|
575
|
-
return true;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
class CheckboxField extends RadioButtonField {
|
|
580
|
-
get value() {
|
|
581
|
-
return this._value;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
set value(value) {
|
|
585
|
-
if (!value || value === "Off") {
|
|
586
|
-
this._value = "Off";
|
|
587
|
-
} else {
|
|
588
|
-
super.value = value;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
_getExportValue(state) {
|
|
593
|
-
return state ? super._getExportValue(state) : "Off";
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
isBoxChecked(nWidget) {
|
|
597
|
-
if (this._value === "Off") {
|
|
598
|
-
return false;
|
|
599
|
-
}
|
|
600
|
-
return super.isBoxChecked(nWidget);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
isDefaultChecked(nWidget) {
|
|
604
|
-
if (this.defaultValue === "Off") {
|
|
605
|
-
return this._value === "Off";
|
|
606
|
-
}
|
|
607
|
-
return super.isDefaultChecked(nWidget);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
checkThisBox(nWidget, bCheckIt = true) {
|
|
611
|
-
if (nWidget < 0 || nWidget >= this._radioIds.length) {
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
this._id = this._radioIds[nWidget];
|
|
615
|
-
this._value = bCheckIt ? this.exportValues[nWidget] : "Off";
|
|
616
|
-
this._send({ id: this._id, value: this._value });
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
export { CheckboxField, Field, RadioButtonField };
|