@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
package/src/core/xfa/xhtml.js
DELETED
|
@@ -1,543 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021 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 {
|
|
17
|
-
$acceptWhitespace,
|
|
18
|
-
$childrenToHTML,
|
|
19
|
-
$clean,
|
|
20
|
-
$content,
|
|
21
|
-
$extra,
|
|
22
|
-
$getChildren,
|
|
23
|
-
$globalData,
|
|
24
|
-
$nodeName,
|
|
25
|
-
$onText,
|
|
26
|
-
$pushGlyphs,
|
|
27
|
-
$text,
|
|
28
|
-
$toHTML,
|
|
29
|
-
XmlObject,
|
|
30
|
-
} from "./xfa_object.js";
|
|
31
|
-
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
|
32
|
-
import { fixTextIndent, measureToString, setFontFamily } from "./html_utils.js";
|
|
33
|
-
import { getMeasurement, HTMLResult, stripQuotes } from "./utils.js";
|
|
34
|
-
|
|
35
|
-
const XHTML_NS_ID = NamespaceIds.xhtml.id;
|
|
36
|
-
|
|
37
|
-
const VALID_STYLES = new Set([
|
|
38
|
-
"color",
|
|
39
|
-
"font",
|
|
40
|
-
"font-family",
|
|
41
|
-
"font-size",
|
|
42
|
-
"font-stretch",
|
|
43
|
-
"font-style",
|
|
44
|
-
"font-weight",
|
|
45
|
-
"margin",
|
|
46
|
-
"margin-bottom",
|
|
47
|
-
"margin-left",
|
|
48
|
-
"margin-right",
|
|
49
|
-
"margin-top",
|
|
50
|
-
"letter-spacing",
|
|
51
|
-
"line-height",
|
|
52
|
-
"orphans",
|
|
53
|
-
"page-break-after",
|
|
54
|
-
"page-break-before",
|
|
55
|
-
"page-break-inside",
|
|
56
|
-
"tab-interval",
|
|
57
|
-
"tab-stop",
|
|
58
|
-
"text-align",
|
|
59
|
-
"text-decoration",
|
|
60
|
-
"text-indent",
|
|
61
|
-
"vertical-align",
|
|
62
|
-
"widows",
|
|
63
|
-
"kerning-mode",
|
|
64
|
-
"xfa-font-horizontal-scale",
|
|
65
|
-
"xfa-font-vertical-scale",
|
|
66
|
-
"xfa-spacerun",
|
|
67
|
-
"xfa-tab-stops",
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
|
-
const StyleMapping = new Map([
|
|
71
|
-
["page-break-after", "breakAfter"],
|
|
72
|
-
["page-break-before", "breakBefore"],
|
|
73
|
-
["page-break-inside", "breakInside"],
|
|
74
|
-
["kerning-mode", value => (value === "none" ? "none" : "normal")],
|
|
75
|
-
[
|
|
76
|
-
"xfa-font-horizontal-scale",
|
|
77
|
-
value =>
|
|
78
|
-
`scaleX(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`,
|
|
79
|
-
],
|
|
80
|
-
[
|
|
81
|
-
"xfa-font-vertical-scale",
|
|
82
|
-
value =>
|
|
83
|
-
`scaleY(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`,
|
|
84
|
-
],
|
|
85
|
-
["xfa-spacerun", ""],
|
|
86
|
-
["xfa-tab-stops", ""],
|
|
87
|
-
[
|
|
88
|
-
"font-size",
|
|
89
|
-
(value, original) => {
|
|
90
|
-
value = original.fontSize = getMeasurement(value);
|
|
91
|
-
return measureToString(0.99 * value);
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
["letter-spacing", value => measureToString(getMeasurement(value))],
|
|
95
|
-
["line-height", value => measureToString(getMeasurement(value))],
|
|
96
|
-
["margin", value => measureToString(getMeasurement(value))],
|
|
97
|
-
["margin-bottom", value => measureToString(getMeasurement(value))],
|
|
98
|
-
["margin-left", value => measureToString(getMeasurement(value))],
|
|
99
|
-
["margin-right", value => measureToString(getMeasurement(value))],
|
|
100
|
-
["margin-top", value => measureToString(getMeasurement(value))],
|
|
101
|
-
["text-indent", value => measureToString(getMeasurement(value))],
|
|
102
|
-
["font-family", value => value],
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
const spacesRegExp = /\s+/g;
|
|
106
|
-
const crlfRegExp = /[\r\n]+/g;
|
|
107
|
-
|
|
108
|
-
function mapStyle(styleStr, fontFinder) {
|
|
109
|
-
const style = Object.create(null);
|
|
110
|
-
if (!styleStr) {
|
|
111
|
-
return style;
|
|
112
|
-
}
|
|
113
|
-
const original = Object.create(null);
|
|
114
|
-
for (const [key, value] of styleStr.split(";").map(s => s.split(":", 2))) {
|
|
115
|
-
const mapping = StyleMapping.get(key);
|
|
116
|
-
if (mapping === "") {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
let newValue = value;
|
|
120
|
-
if (mapping) {
|
|
121
|
-
if (typeof mapping === "string") {
|
|
122
|
-
newValue = mapping;
|
|
123
|
-
} else {
|
|
124
|
-
newValue = mapping(value, original);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (key.endsWith("scale")) {
|
|
128
|
-
if (style.transform) {
|
|
129
|
-
style.transform = `${style[key]} ${newValue}`;
|
|
130
|
-
} else {
|
|
131
|
-
style.transform = newValue;
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] =
|
|
135
|
-
newValue;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (style.fontFamily) {
|
|
140
|
-
setFontFamily(
|
|
141
|
-
{
|
|
142
|
-
typeface: style.fontFamily,
|
|
143
|
-
weight: style.fontWeight || "normal",
|
|
144
|
-
posture: style.fontStyle || "normal",
|
|
145
|
-
size: original.fontSize || 0,
|
|
146
|
-
},
|
|
147
|
-
fontFinder,
|
|
148
|
-
style
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
fixTextIndent(style);
|
|
153
|
-
return style;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function checkStyle(node) {
|
|
157
|
-
if (!node.style) {
|
|
158
|
-
return "";
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Remove any non-allowed keys.
|
|
162
|
-
return node.style
|
|
163
|
-
.trim()
|
|
164
|
-
.split(/\s*;\s*/)
|
|
165
|
-
.filter(s => !!s)
|
|
166
|
-
.map(s => s.split(/\s*:\s*/, 2))
|
|
167
|
-
.filter(([key, value]) => {
|
|
168
|
-
if (key === "font-family") {
|
|
169
|
-
node[$globalData].usedTypefaces.add(value);
|
|
170
|
-
}
|
|
171
|
-
return VALID_STYLES.has(key);
|
|
172
|
-
})
|
|
173
|
-
.map(kv => kv.join(":"))
|
|
174
|
-
.join(";");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const NoWhites = new Set(["body", "html"]);
|
|
178
|
-
|
|
179
|
-
class XhtmlObject extends XmlObject {
|
|
180
|
-
constructor(attributes, name) {
|
|
181
|
-
super(XHTML_NS_ID, name);
|
|
182
|
-
this.style = attributes.style || "";
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
[$clean](builder) {
|
|
186
|
-
super[$clean](builder);
|
|
187
|
-
this.style = checkStyle(this);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
[$acceptWhitespace]() {
|
|
191
|
-
return !NoWhites.has(this[$nodeName]);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
[$onText](str) {
|
|
195
|
-
str = str.replace(crlfRegExp, "");
|
|
196
|
-
if (!this.style.includes("xfa-spacerun:yes")) {
|
|
197
|
-
str = str.replace(spacesRegExp, " ");
|
|
198
|
-
}
|
|
199
|
-
if (str) {
|
|
200
|
-
this[$content] += str;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
[$pushGlyphs](measure, mustPop = true) {
|
|
205
|
-
const xfaFont = Object.create(null);
|
|
206
|
-
const margin = {
|
|
207
|
-
top: NaN,
|
|
208
|
-
bottom: NaN,
|
|
209
|
-
left: NaN,
|
|
210
|
-
right: NaN,
|
|
211
|
-
};
|
|
212
|
-
let lineHeight = null;
|
|
213
|
-
for (const [key, value] of this.style
|
|
214
|
-
.split(";")
|
|
215
|
-
.map(s => s.split(":", 2))) {
|
|
216
|
-
switch (key) {
|
|
217
|
-
case "font-family":
|
|
218
|
-
xfaFont.typeface = stripQuotes(value);
|
|
219
|
-
break;
|
|
220
|
-
case "font-size":
|
|
221
|
-
xfaFont.size = getMeasurement(value);
|
|
222
|
-
break;
|
|
223
|
-
case "font-weight":
|
|
224
|
-
xfaFont.weight = value;
|
|
225
|
-
break;
|
|
226
|
-
case "font-style":
|
|
227
|
-
xfaFont.posture = value;
|
|
228
|
-
break;
|
|
229
|
-
case "letter-spacing":
|
|
230
|
-
xfaFont.letterSpacing = getMeasurement(value);
|
|
231
|
-
break;
|
|
232
|
-
case "margin":
|
|
233
|
-
const values = value.split(/ \t/).map(x => getMeasurement(x));
|
|
234
|
-
switch (values.length) {
|
|
235
|
-
case 1:
|
|
236
|
-
margin.top =
|
|
237
|
-
margin.bottom =
|
|
238
|
-
margin.left =
|
|
239
|
-
margin.right =
|
|
240
|
-
values[0];
|
|
241
|
-
break;
|
|
242
|
-
case 2:
|
|
243
|
-
margin.top = margin.bottom = values[0];
|
|
244
|
-
margin.left = margin.right = values[1];
|
|
245
|
-
break;
|
|
246
|
-
case 3:
|
|
247
|
-
margin.top = values[0];
|
|
248
|
-
margin.bottom = values[2];
|
|
249
|
-
margin.left = margin.right = values[1];
|
|
250
|
-
break;
|
|
251
|
-
case 4:
|
|
252
|
-
margin.top = values[0];
|
|
253
|
-
margin.left = values[1];
|
|
254
|
-
margin.bottom = values[2];
|
|
255
|
-
margin.right = values[3];
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
break;
|
|
259
|
-
case "margin-top":
|
|
260
|
-
margin.top = getMeasurement(value);
|
|
261
|
-
break;
|
|
262
|
-
case "margin-bottom":
|
|
263
|
-
margin.bottom = getMeasurement(value);
|
|
264
|
-
break;
|
|
265
|
-
case "margin-left":
|
|
266
|
-
margin.left = getMeasurement(value);
|
|
267
|
-
break;
|
|
268
|
-
case "margin-right":
|
|
269
|
-
margin.right = getMeasurement(value);
|
|
270
|
-
break;
|
|
271
|
-
case "line-height":
|
|
272
|
-
lineHeight = getMeasurement(value);
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
measure.pushData(xfaFont, margin, lineHeight);
|
|
278
|
-
|
|
279
|
-
if (this[$content]) {
|
|
280
|
-
measure.addString(this[$content]);
|
|
281
|
-
} else {
|
|
282
|
-
for (const child of this[$getChildren]()) {
|
|
283
|
-
if (child[$nodeName] === "#text") {
|
|
284
|
-
measure.addString(child[$content]);
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
child[$pushGlyphs](measure);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (mustPop) {
|
|
292
|
-
measure.popFont();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
[$toHTML](availableSpace) {
|
|
297
|
-
const children = [];
|
|
298
|
-
this[$extra] = {
|
|
299
|
-
children,
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
this[$childrenToHTML]({});
|
|
303
|
-
|
|
304
|
-
if (children.length === 0 && !this[$content]) {
|
|
305
|
-
return HTMLResult.EMPTY;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return HTMLResult.success({
|
|
309
|
-
name: this[$nodeName],
|
|
310
|
-
attributes: {
|
|
311
|
-
href: this.href,
|
|
312
|
-
style: mapStyle(this.style, this[$globalData].fontFinder),
|
|
313
|
-
},
|
|
314
|
-
children,
|
|
315
|
-
value: this[$content] || "",
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
class A extends XhtmlObject {
|
|
321
|
-
constructor(attributes) {
|
|
322
|
-
super(attributes, "a");
|
|
323
|
-
this.href = attributes.href || "";
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
class B extends XhtmlObject {
|
|
328
|
-
constructor(attributes) {
|
|
329
|
-
super(attributes, "b");
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
[$pushGlyphs](measure) {
|
|
333
|
-
measure.pushFont({ weight: "bold" });
|
|
334
|
-
super[$pushGlyphs](measure);
|
|
335
|
-
measure.popFont();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
class Body extends XhtmlObject {
|
|
340
|
-
constructor(attributes) {
|
|
341
|
-
super(attributes, "body");
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
[$toHTML](availableSpace) {
|
|
345
|
-
const res = super[$toHTML](availableSpace);
|
|
346
|
-
const { html } = res;
|
|
347
|
-
if (!html) {
|
|
348
|
-
return HTMLResult.EMPTY;
|
|
349
|
-
}
|
|
350
|
-
html.name = "div";
|
|
351
|
-
html.attributes.class = ["xfaRich"];
|
|
352
|
-
return res;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
class Br extends XhtmlObject {
|
|
357
|
-
constructor(attributes) {
|
|
358
|
-
super(attributes, "br");
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
[$text]() {
|
|
362
|
-
return "\n";
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
[$pushGlyphs](measure) {
|
|
366
|
-
measure.addString("\n");
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
[$toHTML](availableSpace) {
|
|
370
|
-
return HTMLResult.success({
|
|
371
|
-
name: "br",
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
class Html extends XhtmlObject {
|
|
377
|
-
constructor(attributes) {
|
|
378
|
-
super(attributes, "html");
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
[$toHTML](availableSpace) {
|
|
382
|
-
const children = [];
|
|
383
|
-
this[$extra] = {
|
|
384
|
-
children,
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
this[$childrenToHTML]({});
|
|
388
|
-
if (children.length === 0) {
|
|
389
|
-
return HTMLResult.success({
|
|
390
|
-
name: "div",
|
|
391
|
-
attributes: {
|
|
392
|
-
class: ["xfaRich"],
|
|
393
|
-
style: {},
|
|
394
|
-
},
|
|
395
|
-
value: this[$content] || "",
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (children.length === 1) {
|
|
400
|
-
const child = children[0];
|
|
401
|
-
if (child.attributes && child.attributes.class.includes("xfaRich")) {
|
|
402
|
-
return HTMLResult.success(child);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return HTMLResult.success({
|
|
407
|
-
name: "div",
|
|
408
|
-
attributes: {
|
|
409
|
-
class: ["xfaRich"],
|
|
410
|
-
style: {},
|
|
411
|
-
},
|
|
412
|
-
children,
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
class I extends XhtmlObject {
|
|
418
|
-
constructor(attributes) {
|
|
419
|
-
super(attributes, "i");
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
[$pushGlyphs](measure) {
|
|
423
|
-
measure.pushFont({ posture: "italic" });
|
|
424
|
-
super[$pushGlyphs](measure);
|
|
425
|
-
measure.popFont();
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
class Li extends XhtmlObject {
|
|
430
|
-
constructor(attributes) {
|
|
431
|
-
super(attributes, "li");
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
class Ol extends XhtmlObject {
|
|
436
|
-
constructor(attributes) {
|
|
437
|
-
super(attributes, "ol");
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
class P extends XhtmlObject {
|
|
442
|
-
constructor(attributes) {
|
|
443
|
-
super(attributes, "p");
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
[$pushGlyphs](measure) {
|
|
447
|
-
super[$pushGlyphs](measure, /* mustPop = */ false);
|
|
448
|
-
measure.addString("\n");
|
|
449
|
-
measure.addPara();
|
|
450
|
-
measure.popFont();
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
[$text]() {
|
|
454
|
-
return super[$text]() + "\n";
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
class Span extends XhtmlObject {
|
|
459
|
-
constructor(attributes) {
|
|
460
|
-
super(attributes, "span");
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
class Sub extends XhtmlObject {
|
|
465
|
-
constructor(attributes) {
|
|
466
|
-
super(attributes, "sub");
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
class Sup extends XhtmlObject {
|
|
471
|
-
constructor(attributes) {
|
|
472
|
-
super(attributes, "sup");
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
class Ul extends XhtmlObject {
|
|
477
|
-
constructor(attributes) {
|
|
478
|
-
super(attributes, "ul");
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
class XhtmlNamespace {
|
|
483
|
-
static [$buildXFAObject](name, attributes) {
|
|
484
|
-
if (XhtmlNamespace.hasOwnProperty(name)) {
|
|
485
|
-
return XhtmlNamespace[name](attributes);
|
|
486
|
-
}
|
|
487
|
-
return undefined;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
static a(attributes) {
|
|
491
|
-
return new A(attributes);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
static b(attributes) {
|
|
495
|
-
return new B(attributes);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
static body(attributes) {
|
|
499
|
-
return new Body(attributes);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
static br(attributes) {
|
|
503
|
-
return new Br(attributes);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
static html(attributes) {
|
|
507
|
-
return new Html(attributes);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
static i(attributes) {
|
|
511
|
-
return new I(attributes);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
static li(attributes) {
|
|
515
|
-
return new Li(attributes);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
static ol(attributes) {
|
|
519
|
-
return new Ol(attributes);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
static p(attributes) {
|
|
523
|
-
return new P(attributes);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
static span(attributes) {
|
|
527
|
-
return new Span(attributes);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
static sub(attributes) {
|
|
531
|
-
return new Sub(attributes);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
static sup(attributes) {
|
|
535
|
-
return new Sup(attributes);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
static ul(attributes) {
|
|
539
|
-
return new Ul(attributes);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
export { XhtmlNamespace };
|