2021-02-01 23:12:19 +09:00
|
|
|
/* Copyright 2021 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {
|
2021-06-03 02:14:41 +09:00
|
|
|
$acceptWhitespace,
|
2021-05-19 18:09:21 +09:00
|
|
|
$addHTML,
|
2021-02-25 03:05:04 +09:00
|
|
|
$appendChild,
|
2021-03-19 18:11:40 +09:00
|
|
|
$childrenToHTML,
|
2021-06-17 03:15:24 +09:00
|
|
|
$clean,
|
2021-06-21 23:02:33 +09:00
|
|
|
$cleanPage,
|
2021-02-01 23:12:19 +09:00
|
|
|
$content,
|
2021-03-19 18:11:40 +09:00
|
|
|
$extra,
|
2021-02-01 23:12:19 +09:00
|
|
|
$finalize,
|
2021-05-19 18:09:21 +09:00
|
|
|
$flushHTML,
|
|
|
|
$getAvailableSpace,
|
|
|
|
$getChildren,
|
2021-06-12 00:49:13 +09:00
|
|
|
$getContainedChildren,
|
2021-05-19 18:09:21 +09:00
|
|
|
$getNextPage,
|
2021-03-19 18:11:40 +09:00
|
|
|
$getParent,
|
2021-06-12 00:49:13 +09:00
|
|
|
$getSubformParent,
|
2021-06-16 23:02:41 +09:00
|
|
|
$getTemplateRoot,
|
2021-06-20 21:03:59 +09:00
|
|
|
$globalData,
|
2021-02-25 03:05:04 +09:00
|
|
|
$hasItem,
|
|
|
|
$hasSettableValue,
|
2021-05-19 18:09:21 +09:00
|
|
|
$ids,
|
2021-06-06 23:28:22 +09:00
|
|
|
$isCDATAXml,
|
2021-06-16 23:02:41 +09:00
|
|
|
$isSplittable,
|
2021-02-01 23:12:19 +09:00
|
|
|
$isTransparent,
|
2021-06-21 23:02:33 +09:00
|
|
|
$isUsable,
|
2021-02-01 23:12:19 +09:00
|
|
|
$namespaceId,
|
|
|
|
$nodeName,
|
|
|
|
$onChild,
|
2021-06-03 02:14:41 +09:00
|
|
|
$onText,
|
2021-02-25 03:05:04 +09:00
|
|
|
$removeChild,
|
2021-05-19 18:09:21 +09:00
|
|
|
$searchNode,
|
2021-02-18 18:32:25 +09:00
|
|
|
$setSetAttributes,
|
2021-02-25 03:05:04 +09:00
|
|
|
$setValue,
|
2021-05-19 18:09:21 +09:00
|
|
|
$text,
|
2021-03-19 18:11:40 +09:00
|
|
|
$toHTML,
|
2021-03-25 21:02:39 +09:00
|
|
|
$toStyle,
|
2021-03-19 18:11:40 +09:00
|
|
|
$uid,
|
2021-02-01 23:12:19 +09:00
|
|
|
ContentObject,
|
|
|
|
Option01,
|
|
|
|
OptionObject,
|
|
|
|
StringObject,
|
|
|
|
XFAObject,
|
|
|
|
XFAObjectArray,
|
|
|
|
} from "./xfa_object.js";
|
2021-02-25 03:05:04 +09:00
|
|
|
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
2021-06-16 23:02:41 +09:00
|
|
|
import {
|
|
|
|
addHTML,
|
|
|
|
checkDimensions,
|
|
|
|
flushHTML,
|
|
|
|
getAvailableSpace,
|
|
|
|
} from "./layout.js";
|
2021-03-26 00:54:36 +09:00
|
|
|
import {
|
2021-05-19 18:09:21 +09:00
|
|
|
computeBbox,
|
2021-06-03 02:14:41 +09:00
|
|
|
createWrapper,
|
2021-05-19 18:09:21 +09:00
|
|
|
fixDimensions,
|
|
|
|
fixTextIndent,
|
2021-06-20 22:38:58 +09:00
|
|
|
isPrintOnly,
|
2021-03-26 00:54:36 +09:00
|
|
|
layoutClass,
|
2021-05-19 18:09:21 +09:00
|
|
|
layoutText,
|
2021-03-26 00:54:36 +09:00
|
|
|
measureToString,
|
2021-06-21 01:56:14 +09:00
|
|
|
setAccess,
|
2021-06-23 18:10:20 +09:00
|
|
|
setFontFamily,
|
2021-06-16 23:02:41 +09:00
|
|
|
setMinMaxDimensions,
|
2021-03-26 00:54:36 +09:00
|
|
|
toStyle,
|
|
|
|
} from "./html_utils.js";
|
2021-02-01 23:12:19 +09:00
|
|
|
import {
|
|
|
|
getBBox,
|
|
|
|
getColor,
|
|
|
|
getFloat,
|
|
|
|
getInteger,
|
|
|
|
getKeyword,
|
|
|
|
getMeasurement,
|
|
|
|
getRatio,
|
|
|
|
getRelevant,
|
|
|
|
getStringOption,
|
2021-05-19 18:09:21 +09:00
|
|
|
HTMLResult,
|
2021-02-01 23:12:19 +09:00
|
|
|
} from "./utils.js";
|
2021-05-22 19:23:09 +09:00
|
|
|
import { stringToBytes, Util, warn } from "../../shared/util.js";
|
2021-05-19 18:09:21 +09:00
|
|
|
import { searchNode } from "./som.js";
|
2021-02-01 23:12:19 +09:00
|
|
|
|
|
|
|
const TEMPLATE_NS_ID = NamespaceIds.template.id;
|
2021-06-05 03:10:35 +09:00
|
|
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
2021-02-01 23:12:19 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
// In case of lr-tb (and rl-tb) layouts, we try:
|
|
|
|
// - to put the container at the end of a line
|
|
|
|
// - and if it fails we try on the next line.
|
|
|
|
// If both tries failed then it's up to the parent
|
|
|
|
// to handle the situation.
|
|
|
|
const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
// It's possible to have a bug in the layout and so as
|
|
|
|
// a consequence we could loop for ever in Template::toHTML()
|
|
|
|
// so in order to avoid that (and avoid a OOM crash) we break
|
|
|
|
// the loop after having MAX_EMPTY_PAGES empty pages.
|
|
|
|
const MAX_EMPTY_PAGES = 3;
|
|
|
|
|
2021-02-25 03:05:04 +09:00
|
|
|
function _setValue(templateNode, value) {
|
|
|
|
if (!templateNode.value) {
|
|
|
|
const nodeValue = new Value({});
|
|
|
|
templateNode[$appendChild](nodeValue);
|
|
|
|
templateNode.value = nodeValue;
|
|
|
|
}
|
|
|
|
templateNode.value[$setValue](value);
|
|
|
|
}
|
|
|
|
|
2021-06-12 00:49:13 +09:00
|
|
|
function* getContainedChildren(node) {
|
|
|
|
for (const child of node[$getChildren]()) {
|
|
|
|
if (child instanceof SubformSet) {
|
|
|
|
yield* child[$getContainedChildren]();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
yield child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 16:58:56 +09:00
|
|
|
function valueToHtml(value) {
|
|
|
|
return HTMLResult.success({
|
|
|
|
name: "span",
|
|
|
|
attributes: {
|
|
|
|
class: ["xfaRich"],
|
|
|
|
style: Object.create(null),
|
|
|
|
},
|
|
|
|
value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-01 23:12:19 +09:00
|
|
|
class AppearanceFilter extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "appearanceFilter");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Arc extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "arc", /* hasChildren = */ true);
|
|
|
|
this.circular = getInteger({
|
|
|
|
data: attributes.circular,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.startAngle = getFloat({
|
|
|
|
data: attributes.startAngle,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.sweepAngle = getFloat({
|
|
|
|
data: attributes.sweepAngle,
|
|
|
|
defaultValue: 360,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.edge = null;
|
|
|
|
this.fill = null;
|
|
|
|
}
|
2021-06-05 03:10:35 +09:00
|
|
|
|
|
|
|
[$toHTML]() {
|
|
|
|
const edge = this.edge ? this.edge : new Edge({});
|
|
|
|
const edgeStyle = edge[$toStyle]();
|
|
|
|
const style = Object.create(null);
|
|
|
|
if (this.fill) {
|
|
|
|
Object.assign(style, this.fill[$toStyle]());
|
|
|
|
} else {
|
|
|
|
style.fill = "transparent";
|
|
|
|
}
|
2021-06-20 22:45:54 +09:00
|
|
|
style.strokeWidth = measureToString(
|
|
|
|
edge.presence === "visible" ? Math.round(edge.thickness) : 0
|
|
|
|
);
|
2021-06-05 03:10:35 +09:00
|
|
|
style.stroke = edgeStyle.color;
|
|
|
|
let arc;
|
|
|
|
const attributes = {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
style: {
|
|
|
|
position: "absolute",
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (this.startAngle === 0 && this.sweepAngle === 360) {
|
|
|
|
arc = {
|
|
|
|
name: "ellipse",
|
|
|
|
attributes: {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
cx: "50%",
|
|
|
|
cy: "50%",
|
|
|
|
rx: "50%",
|
|
|
|
ry: "50%",
|
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
const startAngle = (this.startAngle * Math.PI) / 180;
|
|
|
|
const sweepAngle = (this.sweepAngle * Math.PI) / 180;
|
|
|
|
const largeArc = this.sweepAngle - this.startAngle > 180 ? 1 : 0;
|
|
|
|
const [x1, y1, x2, y2] = [
|
|
|
|
50 * (1 + Math.cos(startAngle)),
|
|
|
|
50 * (1 - Math.sin(startAngle)),
|
|
|
|
50 * (1 + Math.cos(sweepAngle)),
|
|
|
|
50 * (1 - Math.sin(sweepAngle)),
|
|
|
|
];
|
|
|
|
|
|
|
|
arc = {
|
|
|
|
name: "path",
|
|
|
|
attributes: {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
|
|
|
|
vectorEffect: "non-scaling-stroke",
|
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.assign(attributes, {
|
|
|
|
viewBox: "0 0 100 100",
|
|
|
|
preserveAspectRatio: "none",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLResult.success({
|
|
|
|
name: "svg",
|
|
|
|
children: [arc],
|
|
|
|
attributes,
|
|
|
|
});
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Area extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "area", /* hasChildren = */ true);
|
|
|
|
this.colSpan = getInteger({
|
|
|
|
data: attributes.colSpan,
|
|
|
|
defaultValue: 1,
|
2021-05-19 18:09:21 +09:00
|
|
|
validate: n => n >= 1 || n === -1,
|
2021-02-01 23:12:19 +09:00
|
|
|
});
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.x = getMeasurement(attributes.x, "0pt");
|
|
|
|
this.y = getMeasurement(attributes.y, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.area = new XFAObjectArray();
|
|
|
|
this.draw = new XFAObjectArray();
|
|
|
|
this.exObject = new XFAObjectArray();
|
|
|
|
this.exclGroup = new XFAObjectArray();
|
|
|
|
this.field = new XFAObjectArray();
|
|
|
|
this.subform = new XFAObjectArray();
|
|
|
|
this.subformSet = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
|
2021-06-12 00:49:13 +09:00
|
|
|
*[$getContainedChildren]() {
|
|
|
|
// This function is overriden in order to fake that subforms under
|
|
|
|
// this set are in fact under parent subform.
|
|
|
|
yield* getContainedChildren(this);
|
|
|
|
}
|
|
|
|
|
2021-02-01 23:12:19 +09:00
|
|
|
[$isTransparent]() {
|
|
|
|
return true;
|
|
|
|
}
|
2021-03-26 00:54:36 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$addHTML](html, bbox) {
|
|
|
|
const [x, y, w, h] = bbox;
|
|
|
|
this[$extra].width = Math.max(this[$extra].width, x + w);
|
|
|
|
this[$extra].height = Math.max(this[$extra].height, y + h);
|
|
|
|
|
|
|
|
this[$extra].children.push(html);
|
|
|
|
}
|
2021-03-26 00:54:36 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$getAvailableSpace]() {
|
|
|
|
return this[$extra].availableSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
[$toHTML](availableSpace) {
|
|
|
|
// TODO: incomplete.
|
2021-03-26 00:54:36 +09:00
|
|
|
const style = toStyle(this, "position");
|
|
|
|
const attributes = {
|
|
|
|
style,
|
|
|
|
id: this[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaArea"],
|
2021-03-26 00:54:36 +09:00
|
|
|
};
|
|
|
|
|
2021-06-20 22:38:58 +09:00
|
|
|
if (isPrintOnly(this)) {
|
|
|
|
attributes.class.push("xfaPrintOnly");
|
|
|
|
}
|
|
|
|
|
2021-03-26 00:54:36 +09:00
|
|
|
if (this.name) {
|
|
|
|
attributes.xfaName = this.name;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const children = [];
|
|
|
|
this[$extra] = {
|
|
|
|
children,
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
availableSpace,
|
|
|
|
};
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
const result = this[$childrenToHTML]({
|
|
|
|
filter: new Set([
|
|
|
|
"area",
|
|
|
|
"draw",
|
|
|
|
"field",
|
|
|
|
"exclGroup",
|
|
|
|
"subform",
|
|
|
|
"subformSet",
|
|
|
|
]),
|
|
|
|
include: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!result.success) {
|
|
|
|
if (result.isBreak()) {
|
|
|
|
return result;
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
// Nothing to propose for the element which doesn't fit the
|
|
|
|
// available space.
|
|
|
|
delete this[$extra];
|
2021-06-14 01:57:51 +09:00
|
|
|
return HTMLResult.FAILURE;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
style.width = measureToString(this[$extra].width);
|
|
|
|
style.height = measureToString(this[$extra].height);
|
2021-03-26 00:54:36 +09:00
|
|
|
|
|
|
|
const html = {
|
|
|
|
name: "div",
|
|
|
|
attributes,
|
|
|
|
children,
|
|
|
|
};
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const bbox = [this.x, this.y, this[$extra].width, this[$extra].height];
|
|
|
|
delete this[$extra];
|
|
|
|
|
|
|
|
return HTMLResult.success(html, bbox);
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Assist extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "assist", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.role = attributes.role || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.speak = null;
|
|
|
|
this.toolTip = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Barcode extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "barcode", /* hasChildren = */ true);
|
|
|
|
this.charEncoding = getKeyword({
|
|
|
|
data: attributes.charEncoding
|
|
|
|
? attributes.charEncoding.toLowerCase()
|
|
|
|
: "",
|
|
|
|
defaultValue: "",
|
|
|
|
validate: k =>
|
|
|
|
[
|
|
|
|
"utf-8",
|
|
|
|
"big-five",
|
|
|
|
"fontspecific",
|
|
|
|
"gbk",
|
|
|
|
"gb-18030",
|
|
|
|
"gb-2312",
|
|
|
|
"ksc-5601",
|
|
|
|
"none",
|
|
|
|
"shift-jis",
|
|
|
|
"ucs-2",
|
|
|
|
"utf-16",
|
|
|
|
].includes(k) || k.match(/iso-8859-[0-9]{2}/),
|
|
|
|
});
|
|
|
|
this.checksum = getStringOption(attributes.checksum, [
|
|
|
|
"none",
|
|
|
|
"1mod10",
|
|
|
|
"1mod10_1mod11",
|
|
|
|
"2mod10",
|
|
|
|
"auto",
|
|
|
|
]);
|
|
|
|
this.dataColumnCount = getInteger({
|
|
|
|
data: attributes.dataColumnCount,
|
|
|
|
defaultValue: -1,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.dataLength = getInteger({
|
|
|
|
data: attributes.dataLength,
|
|
|
|
defaultValue: -1,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.dataPrep = getStringOption(attributes.dataPrep, [
|
|
|
|
"none",
|
|
|
|
"flateCompress",
|
|
|
|
]);
|
|
|
|
this.dataRowCount = getInteger({
|
|
|
|
data: attributes.dataRowCount,
|
|
|
|
defaultValue: -1,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.endChar = attributes.endChar || "";
|
|
|
|
this.errorCorrectionLevel = getInteger({
|
|
|
|
data: attributes.errorCorrectionLevel,
|
|
|
|
defaultValue: -1,
|
|
|
|
validate: x => x >= 0 && x <= 8,
|
|
|
|
});
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.moduleHeight = getMeasurement(attributes.moduleHeight, "5mm");
|
|
|
|
this.moduleWidth = getMeasurement(attributes.moduleWidth, "0.25mm");
|
|
|
|
this.printCheckDigit = getInteger({
|
|
|
|
data: attributes.printCheckDigit,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.rowColumnRatio = getRatio(attributes.rowColumnRatio);
|
|
|
|
this.startChar = attributes.startChar || "";
|
|
|
|
this.textLocation = getStringOption(attributes.textLocation, [
|
|
|
|
"below",
|
|
|
|
"above",
|
|
|
|
"aboveEmbedded",
|
|
|
|
"belowEmbedded",
|
|
|
|
"none",
|
|
|
|
]);
|
|
|
|
this.truncate = getInteger({
|
|
|
|
data: attributes.truncate,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.type = getStringOption(
|
|
|
|
attributes.type ? attributes.type.toLowerCase() : "",
|
|
|
|
[
|
|
|
|
"aztec",
|
|
|
|
"codabar",
|
|
|
|
"code2of5industrial",
|
|
|
|
"code2of5interleaved",
|
|
|
|
"code2of5matrix",
|
|
|
|
"code2of5standard",
|
|
|
|
"code3of9",
|
|
|
|
"code3of9extended",
|
|
|
|
"code11",
|
|
|
|
"code49",
|
|
|
|
"code93",
|
|
|
|
"code128",
|
|
|
|
"code128a",
|
|
|
|
"code128b",
|
|
|
|
"code128c",
|
|
|
|
"code128sscc",
|
|
|
|
"datamatrix",
|
|
|
|
"ean8",
|
|
|
|
"ean8add2",
|
|
|
|
"ean8add5",
|
|
|
|
"ean13",
|
|
|
|
"ean13add2",
|
|
|
|
"ean13add5",
|
|
|
|
"ean13pwcd",
|
|
|
|
"fim",
|
|
|
|
"logmars",
|
|
|
|
"maxicode",
|
|
|
|
"msi",
|
|
|
|
"pdf417",
|
|
|
|
"pdf417macro",
|
|
|
|
"plessey",
|
|
|
|
"postauscust2",
|
|
|
|
"postauscust3",
|
|
|
|
"postausreplypaid",
|
|
|
|
"postausstandard",
|
|
|
|
"postukrm4scc",
|
|
|
|
"postusdpbc",
|
|
|
|
"postusimb",
|
|
|
|
"postusstandard",
|
|
|
|
"postus5zip",
|
|
|
|
"qrcode",
|
|
|
|
"rfid",
|
|
|
|
"rss14",
|
|
|
|
"rss14expanded",
|
|
|
|
"rss14limited",
|
|
|
|
"rss14stacked",
|
|
|
|
"rss14stackedomni",
|
|
|
|
"rss14truncated",
|
|
|
|
"telepen",
|
|
|
|
"ucc128",
|
|
|
|
"ucc128random",
|
|
|
|
"ucc128sscc",
|
|
|
|
"upca",
|
|
|
|
"upcaadd2",
|
|
|
|
"upcaadd5",
|
|
|
|
"upcapwcd",
|
|
|
|
"upce",
|
|
|
|
"upceadd2",
|
|
|
|
"upceadd5",
|
|
|
|
"upcean2",
|
|
|
|
"upcean5",
|
|
|
|
"upsmaxicode",
|
|
|
|
]
|
|
|
|
);
|
|
|
|
this.upsMode = getStringOption(attributes.upsMode, [
|
|
|
|
"usCarrier",
|
|
|
|
"internationalCarrier",
|
|
|
|
"secureSymbol",
|
|
|
|
"standardSymbol",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.wideNarrowRatio = getRatio(attributes.wideNarrowRatio);
|
|
|
|
this.encrypt = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Bind extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "bind", /* hasChildren = */ true);
|
|
|
|
this.match = getStringOption(attributes.match, [
|
|
|
|
"once",
|
|
|
|
"dataRef",
|
|
|
|
"global",
|
|
|
|
"none",
|
|
|
|
]);
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.picture = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BindItems extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "bindItems");
|
|
|
|
this.connection = attributes.connection || "";
|
|
|
|
this.labelRef = attributes.labelRef || "";
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.valueRef = attributes.valueRef || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Bookend extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "bookend");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.leader = attributes.leader || "";
|
|
|
|
this.trailer = attributes.trailer || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BooleanElement extends Option01 {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "boolean");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(this[$content] === 1);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Border extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "border", /* hasChildren = */ true);
|
|
|
|
this.break = getStringOption(attributes.break, ["close", "open"]);
|
|
|
|
this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.corner = new XFAObjectArray(4);
|
|
|
|
this.edge = new XFAObjectArray(4);
|
|
|
|
this.extras = null;
|
|
|
|
this.fill = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
[$toStyle]() {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: incomplete.
|
2021-03-26 00:54:36 +09:00
|
|
|
const edges = this.edge.children.slice();
|
|
|
|
if (edges.length < 4) {
|
|
|
|
const defaultEdge = edges[edges.length - 1] || new Edge({});
|
|
|
|
for (let i = edges.length; i < 4; i++) {
|
|
|
|
edges.push(defaultEdge);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const edgeStyles = edges.map(node => {
|
|
|
|
const style = node[$toStyle]();
|
|
|
|
style.color = style.color || "#000000";
|
|
|
|
return style;
|
|
|
|
});
|
2021-06-03 02:14:41 +09:00
|
|
|
|
|
|
|
const widths = edges.map(edge => edge.thickness);
|
|
|
|
const insets = [0, 0, 0, 0];
|
2021-03-31 22:42:21 +09:00
|
|
|
if (this.margin) {
|
2021-06-03 02:14:41 +09:00
|
|
|
insets[0] = this.margin.topInset;
|
|
|
|
insets[1] = this.margin.rightInset;
|
|
|
|
insets[2] = this.margin.bottomInset;
|
|
|
|
insets[3] = this.margin.leftInset;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-06-03 02:14:41 +09:00
|
|
|
this[$extra] = { widths, insets };
|
|
|
|
// TODO: hand.
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
const style = Object.create(null);
|
|
|
|
if (this.margin) {
|
|
|
|
Object.assign(style, this.margin[$toStyle]());
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
if (this.fill) {
|
|
|
|
Object.assign(style, this.fill[$toStyle]());
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.corner.children.some(node => node.radius !== 0)) {
|
|
|
|
const cornerStyles = this.corner.children.map(node => node[$toStyle]());
|
2021-03-31 22:42:21 +09:00
|
|
|
if (cornerStyles.length === 2 || cornerStyles.length === 3) {
|
|
|
|
const last = cornerStyles[cornerStyles.length - 1];
|
|
|
|
for (let i = cornerStyles.length; i < 4; i++) {
|
|
|
|
cornerStyles.push(last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
style.borderRadius = cornerStyles.map(s => s.radius).join(" ");
|
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
switch (this.presence) {
|
|
|
|
case "invisible":
|
|
|
|
case "hidden":
|
|
|
|
style.borderStyle = "";
|
|
|
|
break;
|
|
|
|
case "inactive":
|
|
|
|
style.borderStyle = "none";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
style.borderStyle = edgeStyles.map(s => s.style).join(" ");
|
|
|
|
break;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
style.borderWidth = edgeStyles.map(s => s.width).join(" ");
|
|
|
|
style.borderColor = edgeStyles.map(s => s.color).join(" ");
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
return style;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Break extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "break", /* hasChildren = */ true);
|
|
|
|
this.after = getStringOption(attributes.after, [
|
|
|
|
"auto",
|
|
|
|
"contentArea",
|
|
|
|
"pageArea",
|
|
|
|
"pageEven",
|
|
|
|
"pageOdd",
|
|
|
|
]);
|
|
|
|
this.afterTarget = attributes.afterTarget || "";
|
|
|
|
this.before = getStringOption(attributes.before, [
|
|
|
|
"auto",
|
|
|
|
"contentArea",
|
|
|
|
"pageArea",
|
|
|
|
"pageEven",
|
|
|
|
"pageOdd",
|
|
|
|
]);
|
|
|
|
this.beforeTarget = attributes.beforeTarget || "";
|
|
|
|
this.bookendLeader = attributes.bookendLeader || "";
|
|
|
|
this.bookendTrailer = attributes.bookendTrailer || "";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.overflowLeader = attributes.overflowLeader || "";
|
|
|
|
this.overflowTarget = attributes.overflowTarget || "";
|
|
|
|
this.overflowTrailer = attributes.overflowTrailer || "";
|
|
|
|
this.startNew = getInteger({
|
|
|
|
data: attributes.startNew,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BreakAfter extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "breakAfter", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.leader = attributes.leader || "";
|
|
|
|
this.startNew = getInteger({
|
|
|
|
data: attributes.startNew,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
this.targetType = getStringOption(attributes.targetType, [
|
|
|
|
"auto",
|
|
|
|
"contentArea",
|
|
|
|
"pageArea",
|
|
|
|
"pageEven",
|
|
|
|
"pageOdd",
|
|
|
|
]);
|
|
|
|
this.trailer = attributes.trailer || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.script = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BreakBefore extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "breakBefore", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.leader = attributes.leader || "";
|
|
|
|
this.startNew = getInteger({
|
|
|
|
data: attributes.startNew,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
this.targetType = getStringOption(attributes.targetType, [
|
|
|
|
"auto",
|
|
|
|
"contentArea",
|
|
|
|
"pageArea",
|
|
|
|
"pageEven",
|
|
|
|
"pageOdd",
|
|
|
|
]);
|
|
|
|
this.trailer = attributes.trailer || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.script = null;
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
[$toHTML](availableSpace) {
|
|
|
|
this[$extra] = {};
|
|
|
|
return HTMLResult.FAILURE;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Button extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "button", /* hasChildren = */ true);
|
|
|
|
this.highlight = getStringOption(attributes.highlight, [
|
|
|
|
"inverted",
|
|
|
|
"none",
|
|
|
|
"outline",
|
|
|
|
"push",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: highlight.
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "button",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
id: this[$uid],
|
|
|
|
class: ["xfaButton"],
|
2021-03-31 22:42:21 +09:00
|
|
|
style: {},
|
|
|
|
},
|
2021-05-19 18:09:21 +09:00
|
|
|
children: [],
|
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Calculate extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "calculate", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.override = getStringOption(attributes.override, [
|
|
|
|
"disabled",
|
|
|
|
"error",
|
|
|
|
"ignore",
|
|
|
|
"warning",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.message = null;
|
|
|
|
this.script = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Caption extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "caption", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.placement = getStringOption(attributes.placement, [
|
|
|
|
"left",
|
|
|
|
"bottom",
|
|
|
|
"inline",
|
|
|
|
"right",
|
|
|
|
"top",
|
|
|
|
]);
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.reserve = getMeasurement(attributes.reserve);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.font = null;
|
|
|
|
this.margin = null;
|
|
|
|
this.para = null;
|
|
|
|
this.value = null;
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$setValue](value) {
|
|
|
|
_setValue(this, value);
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: incomplete.
|
|
|
|
if (!this.value) {
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const value = this.value[$toHTML](availableSpace).html;
|
2021-03-31 22:42:21 +09:00
|
|
|
if (!value) {
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
const children = [];
|
|
|
|
if (typeof value === "string") {
|
|
|
|
children.push({
|
|
|
|
name: "#text",
|
|
|
|
value,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
children.push(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
const style = toStyle(this, "font", "margin", "para", "visibility");
|
|
|
|
switch (this.placement) {
|
|
|
|
case "left":
|
|
|
|
case "right":
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.reserve > 0) {
|
|
|
|
style.width = measureToString(this.reserve);
|
|
|
|
} else {
|
|
|
|
style.minWidth = measureToString(this.reserve);
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
case "top":
|
|
|
|
case "bottom":
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.reserve > 0) {
|
|
|
|
style.height = measureToString(this.reserve);
|
|
|
|
} else {
|
|
|
|
style.minHeight = measureToString(this.reserve);
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "div",
|
|
|
|
attributes: {
|
|
|
|
style,
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaCaption"],
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
|
|
|
children,
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Certificate extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "certificate");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Certificates extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "certificates", /* hasChildren = */ true);
|
|
|
|
this.credentialServerPolicy = getStringOption(
|
|
|
|
attributes.credentialServerPolicy,
|
|
|
|
["optional", "required"]
|
|
|
|
);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.url = attributes.url || "";
|
|
|
|
this.urlPolicy = attributes.urlPolicy || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.encryption = null;
|
|
|
|
this.issuers = null;
|
|
|
|
this.keyUsage = null;
|
|
|
|
this.oids = null;
|
|
|
|
this.signing = null;
|
|
|
|
this.subjectDNs = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class CheckButton extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "checkButton", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.mark = getStringOption(attributes.mark, [
|
|
|
|
"default",
|
|
|
|
"check",
|
|
|
|
"circle",
|
|
|
|
"cross",
|
|
|
|
"diamond",
|
|
|
|
"square",
|
|
|
|
"star",
|
|
|
|
]);
|
|
|
|
this.shape = getStringOption(attributes.shape, ["square", "round"]);
|
|
|
|
this.size = getMeasurement(attributes.size, "10pt");
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-05-28 00:44:55 +09:00
|
|
|
// TODO: border, shape and mark.
|
|
|
|
|
|
|
|
const style = toStyle("margin");
|
2021-03-31 22:42:21 +09:00
|
|
|
const size = measureToString(this.size);
|
|
|
|
|
|
|
|
style.width = style.height = size;
|
|
|
|
|
2021-05-28 00:44:55 +09:00
|
|
|
let type;
|
|
|
|
let className;
|
|
|
|
let groupId;
|
|
|
|
let id;
|
|
|
|
const fieldId = this[$getParent]()[$getParent]()[$uid];
|
|
|
|
const container = this[$getParent]()[$getParent]()[$getParent]();
|
|
|
|
if (container instanceof ExclGroup) {
|
|
|
|
groupId = container[$uid];
|
|
|
|
type = "radio";
|
|
|
|
className = "xfaRadio";
|
|
|
|
id = `${fieldId}-radio`;
|
2021-03-31 22:42:21 +09:00
|
|
|
} else {
|
2021-05-28 00:44:55 +09:00
|
|
|
type = "checkbox";
|
|
|
|
className = "xfaCheckbox";
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const input = {
|
|
|
|
name: "input",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: [className],
|
2021-05-28 00:44:55 +09:00
|
|
|
style,
|
2021-05-24 20:42:42 +09:00
|
|
|
fieldId,
|
2021-05-28 00:44:55 +09:00
|
|
|
type,
|
2021-05-19 18:09:21 +09:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-05-28 00:44:55 +09:00
|
|
|
if (id) {
|
|
|
|
input.attributes.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groupId) {
|
|
|
|
input.attributes.name = groupId;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "label",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaLabel"],
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
2021-05-28 00:44:55 +09:00
|
|
|
children: [input],
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class ChoiceList extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "choiceList", /* hasChildren = */ true);
|
|
|
|
this.commitOn = getStringOption(attributes.commitOn, ["select", "exit"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.open = getStringOption(attributes.open, [
|
|
|
|
"userControl",
|
|
|
|
"always",
|
|
|
|
"multiSelect",
|
|
|
|
"onEntry",
|
|
|
|
]);
|
|
|
|
this.textEntry = getInteger({
|
|
|
|
data: attributes.textEntry,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: incomplete.
|
|
|
|
const style = toStyle(this, "border", "margin");
|
2021-05-19 18:09:21 +09:00
|
|
|
const ui = this[$getParent]();
|
|
|
|
const field = ui[$getParent]();
|
|
|
|
const children = [];
|
|
|
|
|
|
|
|
if (field.items.children.length > 0) {
|
|
|
|
const displayed = field.items.children[0][$toHTML]().html;
|
|
|
|
const values = field.items.children[1]
|
|
|
|
? field.items.children[1][$toHTML]().html
|
|
|
|
: [];
|
|
|
|
|
|
|
|
for (let i = 0, ii = displayed.length; i < ii; i++) {
|
|
|
|
children.push({
|
|
|
|
name: "option",
|
|
|
|
attributes: {
|
|
|
|
value: values[i] || displayed[i],
|
|
|
|
},
|
|
|
|
value: displayed[i],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const selectAttributes = {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaSelect"],
|
2021-05-24 20:42:42 +09:00
|
|
|
fieldId: this[$getParent]()[$getParent]()[$uid],
|
2021-05-19 18:09:21 +09:00
|
|
|
style,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (this.open === "multiSelect") {
|
|
|
|
selectAttributes.multiple = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "label",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaLabel"],
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
name: "select",
|
2021-05-19 18:09:21 +09:00
|
|
|
children,
|
|
|
|
attributes: selectAttributes,
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
|
|
|
],
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Color extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "color", /* hasChildren = */ true);
|
|
|
|
this.cSpace = getStringOption(attributes.cSpace, ["SRGB"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
2021-05-19 18:09:21 +09:00
|
|
|
this.value = attributes.value ? getColor(attributes.value) : "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$hasSettableValue]() {
|
|
|
|
return false;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle]() {
|
2021-05-19 18:09:21 +09:00
|
|
|
return this.value
|
|
|
|
? Util.makeHexColor(this.value.r, this.value.g, this.value.b)
|
|
|
|
: null;
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Comb extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "comb");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.numberOfCells = getInteger({
|
|
|
|
data: attributes.numberOfCells,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Connect extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "connect", /* hasChildren = */ true);
|
|
|
|
this.connection = attributes.connection || "";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.usage = getStringOption(attributes.usage, [
|
|
|
|
"exportAndImport",
|
|
|
|
"exportOnly",
|
|
|
|
"importOnly",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.picture = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ContentArea extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "contentArea", /* hasChildren = */ true);
|
|
|
|
this.h = getMeasurement(attributes.h);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.w = getMeasurement(attributes.w);
|
2021-03-31 22:42:21 +09:00
|
|
|
this.x = getMeasurement(attributes.x, "0pt");
|
|
|
|
this.y = getMeasurement(attributes.y, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-19 18:11:40 +09:00
|
|
|
// TODO: incomplete.
|
|
|
|
const left = measureToString(this.x);
|
|
|
|
const top = measureToString(this.y);
|
|
|
|
|
|
|
|
const style = {
|
|
|
|
position: "absolute",
|
|
|
|
left,
|
|
|
|
top,
|
|
|
|
width: measureToString(this.w),
|
|
|
|
height: measureToString(this.h),
|
|
|
|
};
|
2021-06-20 22:38:58 +09:00
|
|
|
|
|
|
|
const classNames = ["xfaContentarea"];
|
|
|
|
|
|
|
|
if (isPrintOnly(this)) {
|
|
|
|
classNames.push("xfaPrintOnly");
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-03-19 18:11:40 +09:00
|
|
|
name: "div",
|
|
|
|
children: [],
|
|
|
|
attributes: {
|
|
|
|
style,
|
2021-06-20 22:38:58 +09:00
|
|
|
class: classNames,
|
2021-03-19 18:11:40 +09:00
|
|
|
id: this[$uid],
|
|
|
|
},
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Corner extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "corner", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.inverted = getInteger({
|
|
|
|
data: attributes.inverted,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.join = getStringOption(attributes.join, ["square", "round"]);
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.radius = getMeasurement(attributes.radius);
|
|
|
|
this.stroke = getStringOption(attributes.stroke, [
|
|
|
|
"solid",
|
|
|
|
"dashDot",
|
|
|
|
"dashDotDot",
|
|
|
|
"dashed",
|
|
|
|
"dotted",
|
|
|
|
"embossed",
|
|
|
|
"etched",
|
|
|
|
"lowered",
|
|
|
|
"raised",
|
|
|
|
]);
|
|
|
|
this.thickness = getMeasurement(attributes.thickness, "0.5pt");
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
[$toStyle]() {
|
|
|
|
// In using CSS it's only possible to handle radius
|
|
|
|
// (at least with basic css).
|
|
|
|
// Is there a real use (interest ?) of all these properties ?
|
|
|
|
// Maybe it's possible to implement them using svg and border-image...
|
|
|
|
// TODO: implement all the missing properties.
|
|
|
|
const style = toStyle(this, "visibility");
|
2021-06-05 03:10:35 +09:00
|
|
|
style.radius = measureToString(this.join === "square" ? 0 : this.radius);
|
2021-03-31 22:42:21 +09:00
|
|
|
return style;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
class DateElement extends ContentObject {
|
2021-02-01 23:12:19 +09:00
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "date");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
2021-06-11 16:58:56 +09:00
|
|
|
const date = this[$content].trim();
|
|
|
|
this[$content] = date ? new Date(date) : null;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(this[$content] ? this[$content].toString() : "");
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class DateTime extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "dateTime");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
2021-06-11 16:58:56 +09:00
|
|
|
const date = this[$content].trim();
|
|
|
|
this[$content] = date ? new Date(date) : null;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(this[$content] ? this[$content].toString() : "");
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class DateTimeEdit extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "dateTimeEdit", /* hasChildren = */ true);
|
|
|
|
this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, [
|
|
|
|
"auto",
|
|
|
|
"off",
|
|
|
|
"on",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.picker = getStringOption(attributes.picker, ["host", "none"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.comb = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: incomplete.
|
|
|
|
// When the picker is host we should use type=date for the input
|
|
|
|
// but we need to put the buttons outside the text-field.
|
|
|
|
const style = toStyle(this, "border", "font", "margin");
|
|
|
|
const html = {
|
|
|
|
name: "input",
|
|
|
|
attributes: {
|
|
|
|
type: "text",
|
2021-05-24 20:42:42 +09:00
|
|
|
fieldId: this[$getParent]()[$getParent]()[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaTextfield"],
|
2021-03-31 22:42:21 +09:00
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "label",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaLabel"],
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
|
|
|
children: [html],
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Decimal extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "decimal");
|
|
|
|
this.fracDigits = getInteger({
|
|
|
|
data: attributes.fracDigits,
|
|
|
|
defaultValue: 2,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.leadDigits = getInteger({
|
|
|
|
data: attributes.leadDigits,
|
|
|
|
defaultValue: -1,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
|
|
|
const number = parseFloat(this[$content].trim());
|
|
|
|
this[$content] = isNaN(number) ? null : number;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$content] !== null ? this[$content].toString() : ""
|
|
|
|
);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class DefaultUi extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "defaultUi", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Desc extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "desc", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.boolean = new XFAObjectArray();
|
|
|
|
this.date = new XFAObjectArray();
|
|
|
|
this.dateTime = new XFAObjectArray();
|
|
|
|
this.decimal = new XFAObjectArray();
|
|
|
|
this.exData = new XFAObjectArray();
|
|
|
|
this.float = new XFAObjectArray();
|
|
|
|
this.image = new XFAObjectArray();
|
|
|
|
this.integer = new XFAObjectArray();
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
this.time = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DigestMethod extends OptionObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "digestMethod", [
|
|
|
|
"",
|
|
|
|
"SHA1",
|
|
|
|
"SHA256",
|
|
|
|
"SHA512",
|
|
|
|
"RIPEMD160",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DigestMethods extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "digestMethods", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.digestMethod = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Draw extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "draw", /* hasChildren = */ true);
|
|
|
|
this.anchorType = getStringOption(attributes.anchorType, [
|
|
|
|
"topLeft",
|
|
|
|
"bottomCenter",
|
|
|
|
"bottomLeft",
|
|
|
|
"bottomRight",
|
|
|
|
"middleCenter",
|
|
|
|
"middleLeft",
|
|
|
|
"middleRight",
|
|
|
|
"topCenter",
|
|
|
|
"topRight",
|
|
|
|
]);
|
|
|
|
this.colSpan = getInteger({
|
|
|
|
data: attributes.colSpan,
|
|
|
|
defaultValue: 1,
|
2021-05-19 18:09:21 +09:00
|
|
|
validate: n => n >= 1 || n === -1,
|
2021-02-01 23:12:19 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
this.h = attributes.h ? getMeasurement(attributes.h) : "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.hAlign = getStringOption(attributes.hAlign, [
|
|
|
|
"left",
|
|
|
|
"center",
|
|
|
|
"justify",
|
|
|
|
"justifyAll",
|
|
|
|
"radix",
|
|
|
|
"right",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.locale = attributes.locale || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.maxH = getMeasurement(attributes.maxH, "0pt");
|
|
|
|
this.maxW = getMeasurement(attributes.maxW, "0pt");
|
|
|
|
this.minH = getMeasurement(attributes.minH, "0pt");
|
|
|
|
this.minW = getMeasurement(attributes.minW, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
2021-03-25 21:02:39 +09:00
|
|
|
this.rotate = getInteger({
|
2021-02-01 23:12:19 +09:00
|
|
|
data: attributes.rotate,
|
|
|
|
defaultValue: 0,
|
2021-03-25 21:02:39 +09:00
|
|
|
validate: x => x % 90 === 0,
|
2021-02-01 23:12:19 +09:00
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.w = attributes.w ? getMeasurement(attributes.w) : "";
|
|
|
|
this.x = getMeasurement(attributes.x, "0pt");
|
|
|
|
this.y = getMeasurement(attributes.y, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.assist = null;
|
|
|
|
this.border = null;
|
|
|
|
this.caption = null;
|
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.font = null;
|
|
|
|
this.keep = null;
|
|
|
|
this.margin = null;
|
|
|
|
this.para = null;
|
|
|
|
this.traversal = null;
|
|
|
|
this.ui = null;
|
|
|
|
this.value = null;
|
|
|
|
this.setProperty = new XFAObjectArray();
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$setValue](value) {
|
|
|
|
_setValue(this, value);
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-05 03:10:35 +09:00
|
|
|
if (this.presence === "hidden" || this.presence === "inactive") {
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixDimensions(this);
|
|
|
|
|
2021-06-15 02:16:42 +09:00
|
|
|
if ((this.w === "" || this.h === "") && this.value) {
|
2021-06-21 00:39:54 +09:00
|
|
|
let marginH = 0;
|
|
|
|
let marginV = 0;
|
|
|
|
if (this.margin) {
|
|
|
|
marginH = this.margin.leftInset + this.margin.rightInset;
|
|
|
|
marginV = this.margin.topInset + this.margin.bottomInset;
|
|
|
|
}
|
|
|
|
|
2021-06-15 02:16:42 +09:00
|
|
|
const maxWidth = this.w === "" ? availableSpace.width : this.w;
|
2021-06-20 21:03:59 +09:00
|
|
|
const fontFinder = this[$globalData].fontFinder;
|
2021-06-15 02:16:42 +09:00
|
|
|
let font = this.font;
|
|
|
|
if (!font) {
|
|
|
|
let parent = this[$getParent]();
|
|
|
|
while (!(parent instanceof Template)) {
|
|
|
|
if (parent.font) {
|
|
|
|
font = parent.font;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
parent = parent[$getParent]();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let height = null;
|
|
|
|
let width = null;
|
|
|
|
if (
|
|
|
|
this.value.exData &&
|
|
|
|
this.value.exData[$content] &&
|
|
|
|
this.value.exData.contentType === "text/html"
|
|
|
|
) {
|
|
|
|
const res = layoutText(
|
|
|
|
this.value.exData[$content],
|
|
|
|
font,
|
2021-06-20 21:03:59 +09:00
|
|
|
fontFinder,
|
2021-06-15 02:16:42 +09:00
|
|
|
maxWidth
|
|
|
|
);
|
|
|
|
width = res.width;
|
|
|
|
height = res.height;
|
|
|
|
} else {
|
|
|
|
const text = this.value[$text]();
|
|
|
|
if (text) {
|
2021-06-20 21:03:59 +09:00
|
|
|
const res = layoutText(text, font, fontFinder, maxWidth);
|
2021-06-15 02:16:42 +09:00
|
|
|
width = res.width;
|
|
|
|
height = res.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width !== null && this.w === "") {
|
2021-06-21 00:39:54 +09:00
|
|
|
this.w = width + marginH;
|
2021-06-15 02:16:42 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (height !== null && this.h === "") {
|
2021-06-21 00:39:54 +09:00
|
|
|
this.h = height + marginV;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
if (!checkDimensions(this, availableSpace)) {
|
|
|
|
return HTMLResult.FAILURE;
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
const style = toStyle(
|
|
|
|
this,
|
|
|
|
"font",
|
2021-03-26 00:54:36 +09:00
|
|
|
"hAlign",
|
2021-03-25 21:02:39 +09:00
|
|
|
"dimensions",
|
|
|
|
"position",
|
2021-03-31 22:42:21 +09:00
|
|
|
"presence",
|
2021-03-25 21:02:39 +09:00
|
|
|
"rotate",
|
2021-03-26 00:54:36 +09:00
|
|
|
"anchorType",
|
2021-06-03 02:14:41 +09:00
|
|
|
"border",
|
|
|
|
"margin"
|
2021-03-25 21:02:39 +09:00
|
|
|
);
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
setMinMaxDimensions(this, style);
|
|
|
|
|
2021-05-28 18:17:38 +09:00
|
|
|
const classNames = ["xfaDraw"];
|
2021-03-25 21:02:39 +09:00
|
|
|
if (this.font) {
|
2021-05-28 18:17:38 +09:00
|
|
|
classNames.push("xfaFont");
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
2021-06-20 22:38:58 +09:00
|
|
|
if (isPrintOnly(this)) {
|
|
|
|
classNames.push("xfaPrintOnly");
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
const attributes = {
|
|
|
|
style,
|
|
|
|
id: this[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: classNames,
|
2021-03-25 21:02:39 +09:00
|
|
|
};
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
if (this.name) {
|
|
|
|
attributes.xfaName = this.name;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const html = {
|
2021-03-25 21:02:39 +09:00
|
|
|
name: "div",
|
|
|
|
attributes,
|
|
|
|
children: [],
|
|
|
|
};
|
2021-03-26 00:54:36 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const bbox = computeBbox(this, html, availableSpace);
|
|
|
|
|
|
|
|
const value = this.value ? this.value[$toHTML](availableSpace).html : null;
|
2021-03-26 00:54:36 +09:00
|
|
|
if (value === null) {
|
2021-06-03 02:14:41 +09:00
|
|
|
return HTMLResult.success(createWrapper(this, html), bbox);
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
html.children.push(value);
|
2021-06-05 03:10:35 +09:00
|
|
|
if (value.attributes.class && value.attributes.class.includes("xfaRich")) {
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.h === "") {
|
|
|
|
style.height = "auto";
|
|
|
|
}
|
|
|
|
if (this.w === "") {
|
|
|
|
style.width = "auto";
|
|
|
|
}
|
|
|
|
if (this.para) {
|
|
|
|
// By definition exData are external data so para
|
|
|
|
// has no effect on it.
|
|
|
|
attributes.style.display = "flex";
|
|
|
|
attributes.style.flexDirection = "column";
|
|
|
|
switch (this.para.vAlign) {
|
|
|
|
case "top":
|
|
|
|
attributes.style.justifyContent = "start";
|
|
|
|
break;
|
|
|
|
case "bottom":
|
|
|
|
attributes.style.justifyContent = "end";
|
|
|
|
break;
|
|
|
|
case "middle":
|
|
|
|
attributes.style.justifyContent = "center";
|
|
|
|
break;
|
|
|
|
}
|
2021-03-26 00:54:36 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const paraStyle = this.para[$toStyle]();
|
|
|
|
if (!value.attributes.style) {
|
|
|
|
value.attributes.style = paraStyle;
|
|
|
|
} else {
|
|
|
|
for (const [key, val] of Object.entries(paraStyle)) {
|
|
|
|
if (!(key in value.attributes.style)) {
|
|
|
|
value.attributes.style[key] = val;
|
|
|
|
}
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
return HTMLResult.success(createWrapper(this, html), bbox);
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Edge extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "edge", /* hasChildren = */ true);
|
|
|
|
this.cap = getStringOption(attributes.cap, ["square", "butt", "round"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.stroke = getStringOption(attributes.stroke, [
|
|
|
|
"solid",
|
|
|
|
"dashDot",
|
|
|
|
"dashDotDot",
|
|
|
|
"dashed",
|
|
|
|
"dotted",
|
|
|
|
"embossed",
|
|
|
|
"etched",
|
|
|
|
"lowered",
|
|
|
|
"raised",
|
|
|
|
]);
|
2021-06-03 02:14:41 +09:00
|
|
|
this.thickness = getMeasurement(attributes.thickness, "0.5pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
[$toStyle]() {
|
|
|
|
// TODO: dashDot & dashDotDot.
|
|
|
|
const style = toStyle(this, "visibility");
|
|
|
|
Object.assign(style, {
|
|
|
|
linecap: this.cap,
|
2021-06-03 02:14:41 +09:00
|
|
|
width: measureToString(this.thickness),
|
2021-05-19 18:09:21 +09:00
|
|
|
color: this.color ? this.color[$toStyle]() : "#000000",
|
2021-03-31 22:42:21 +09:00
|
|
|
style: "",
|
|
|
|
});
|
|
|
|
|
|
|
|
if (this.presence !== "visible") {
|
|
|
|
style.style = "none";
|
|
|
|
} else {
|
|
|
|
switch (this.stroke) {
|
|
|
|
case "solid":
|
|
|
|
style.style = "solid";
|
|
|
|
break;
|
|
|
|
case "dashDot":
|
|
|
|
style.style = "dashed";
|
|
|
|
break;
|
|
|
|
case "dashDotDot":
|
|
|
|
style.style = "dashed";
|
|
|
|
break;
|
|
|
|
case "dashed":
|
|
|
|
style.style = "dashed";
|
|
|
|
break;
|
|
|
|
case "dotted":
|
|
|
|
style.style = "dotted";
|
|
|
|
break;
|
|
|
|
case "embossed":
|
|
|
|
style.style = "ridge";
|
|
|
|
break;
|
|
|
|
case "etched":
|
|
|
|
style.style = "groove";
|
|
|
|
break;
|
|
|
|
case "lowered":
|
|
|
|
style.style = "inset";
|
|
|
|
break;
|
|
|
|
case "raised":
|
|
|
|
style.style = "outset";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return style;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Encoding extends OptionObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encoding", [
|
|
|
|
"adbe.x509.rsa_sha1",
|
|
|
|
"adbe.pkcs7.detached",
|
|
|
|
"adbe.pkcs7.sha1",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Encodings extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encodings", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.encoding = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Encrypt extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encrypt", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.certificate = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EncryptData extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encryptData", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.operation = getStringOption(attributes.operation, [
|
|
|
|
"encrypt",
|
|
|
|
"decrypt",
|
|
|
|
]);
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.filter = null;
|
|
|
|
this.manifest = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Encryption extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encryption", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.certificate = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EncryptionMethod extends OptionObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encryptionMethod", [
|
|
|
|
"",
|
|
|
|
"AES256-CBC",
|
|
|
|
"TRIPLEDES-CBC",
|
|
|
|
"AES128-CBC",
|
|
|
|
"AES192-CBC",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EncryptionMethods extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "encryptionMethods", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.encryptionMethod = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Event extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "event", /* hasChildren = */ true);
|
|
|
|
this.activity = getStringOption(attributes.activity, [
|
|
|
|
"click",
|
|
|
|
"change",
|
|
|
|
"docClose",
|
|
|
|
"docReady",
|
|
|
|
"enter",
|
|
|
|
"exit",
|
|
|
|
"full",
|
|
|
|
"indexChange",
|
|
|
|
"initialize",
|
|
|
|
"mouseDown",
|
|
|
|
"mouseEnter",
|
|
|
|
"mouseExit",
|
|
|
|
"mouseUp",
|
|
|
|
"postExecute",
|
|
|
|
"postOpen",
|
|
|
|
"postPrint",
|
|
|
|
"postSave",
|
|
|
|
"postSign",
|
|
|
|
"postSubmit",
|
|
|
|
"preExecute",
|
|
|
|
"preOpen",
|
|
|
|
"prePrint",
|
|
|
|
"preSave",
|
|
|
|
"preSign",
|
|
|
|
"preSubmit",
|
|
|
|
"ready",
|
|
|
|
"validationState",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.listen = getStringOption(attributes.listen, [
|
|
|
|
"refOnly",
|
|
|
|
"refAndDescendents",
|
|
|
|
]);
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
|
|
|
|
// One-of properties
|
|
|
|
this.encryptData = null;
|
|
|
|
this.execute = null;
|
|
|
|
this.script = null;
|
|
|
|
this.signData = null;
|
|
|
|
this.submit = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ExData extends ContentObject {
|
2021-02-25 03:05:04 +09:00
|
|
|
constructor(attributes) {
|
2021-02-01 23:12:19 +09:00
|
|
|
super(TEMPLATE_NS_ID, "exData");
|
|
|
|
this.contentType = attributes.contentType || "";
|
|
|
|
this.href = attributes.href || "";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.maxLength = getInteger({
|
|
|
|
data: attributes.maxLength,
|
|
|
|
defaultValue: -1,
|
|
|
|
validate: x => x >= -1,
|
|
|
|
});
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.rid = attributes.rid || "";
|
|
|
|
this.transferEncoding = getStringOption(attributes.transferEncoding, [
|
|
|
|
"none",
|
|
|
|
"base64",
|
|
|
|
"package",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
2021-06-06 23:28:22 +09:00
|
|
|
[$isCDATAXml]() {
|
|
|
|
return this.contentType === "text/html";
|
|
|
|
}
|
|
|
|
|
2021-02-01 23:12:19 +09:00
|
|
|
[$onChild](child) {
|
|
|
|
if (
|
|
|
|
this.contentType === "text/html" &&
|
|
|
|
child[$namespaceId] === NamespaceIds.xhtml.id
|
|
|
|
) {
|
|
|
|
this[$content] = child;
|
2021-02-18 18:32:25 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.contentType === "text/xml") {
|
2021-02-01 23:12:19 +09:00
|
|
|
this[$content] = child;
|
2021-02-18 18:32:25 +09:00
|
|
|
return true;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-02-18 18:32:25 +09:00
|
|
|
|
|
|
|
return false;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-03-26 00:54:36 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-26 00:54:36 +09:00
|
|
|
if (this.contentType !== "text/html" || !this[$content]) {
|
|
|
|
// TODO: fix other cases.
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return this[$content][$toHTML](availableSpace);
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class ExObject extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "exObject", /* hasChildren = */ true);
|
|
|
|
this.archive = attributes.archive || "";
|
|
|
|
this.classId = attributes.classId || "";
|
|
|
|
this.codeBase = attributes.codeBase || "";
|
|
|
|
this.codeType = attributes.codeType || "";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.boolean = new XFAObjectArray();
|
|
|
|
this.date = new XFAObjectArray();
|
|
|
|
this.dateTime = new XFAObjectArray();
|
|
|
|
this.decimal = new XFAObjectArray();
|
|
|
|
this.exData = new XFAObjectArray();
|
|
|
|
this.exObject = new XFAObjectArray();
|
|
|
|
this.float = new XFAObjectArray();
|
|
|
|
this.image = new XFAObjectArray();
|
|
|
|
this.integer = new XFAObjectArray();
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
this.time = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ExclGroup extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "exclGroup", /* hasChildren = */ true);
|
|
|
|
this.access = getStringOption(attributes.access, [
|
|
|
|
"open",
|
|
|
|
"nonInteractive",
|
|
|
|
"protected",
|
|
|
|
"readOnly",
|
|
|
|
]);
|
|
|
|
this.accessKey = attributes.accessKey || "";
|
|
|
|
this.anchorType = getStringOption(attributes.anchorType, [
|
|
|
|
"topLeft",
|
|
|
|
"bottomCenter",
|
|
|
|
"bottomLeft",
|
|
|
|
"bottomRight",
|
|
|
|
"middleCenter",
|
|
|
|
"middleLeft",
|
|
|
|
"middleRight",
|
|
|
|
"topCenter",
|
|
|
|
"topRight",
|
|
|
|
]);
|
|
|
|
this.colSpan = getInteger({
|
|
|
|
data: attributes.colSpan,
|
|
|
|
defaultValue: 1,
|
2021-05-19 18:09:21 +09:00
|
|
|
validate: n => n >= 1 || n === -1,
|
2021-02-01 23:12:19 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
this.h = attributes.h ? getMeasurement(attributes.h) : "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.hAlign = getStringOption(attributes.hAlign, [
|
|
|
|
"left",
|
|
|
|
"center",
|
|
|
|
"justify",
|
|
|
|
"justifyAll",
|
|
|
|
"radix",
|
|
|
|
"right",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.layout = getStringOption(attributes.layout, [
|
|
|
|
"position",
|
|
|
|
"lr-tb",
|
|
|
|
"rl-row",
|
|
|
|
"rl-tb",
|
|
|
|
"row",
|
|
|
|
"table",
|
|
|
|
"tb",
|
|
|
|
]);
|
2021-03-31 22:42:21 +09:00
|
|
|
this.maxH = getMeasurement(attributes.maxH, "0pt");
|
|
|
|
this.maxW = getMeasurement(attributes.maxW, "0pt");
|
|
|
|
this.minH = getMeasurement(attributes.minH, "0pt");
|
|
|
|
this.minW = getMeasurement(attributes.minW, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.w = attributes.w ? getMeasurement(attributes.w) : "";
|
|
|
|
this.x = getMeasurement(attributes.x, "0pt");
|
|
|
|
this.y = getMeasurement(attributes.y, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.assist = null;
|
|
|
|
this.bind = null;
|
|
|
|
this.border = null;
|
|
|
|
this.calculate = null;
|
|
|
|
this.caption = null;
|
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
this.para = null;
|
|
|
|
this.traversal = null;
|
|
|
|
this.validate = null;
|
|
|
|
this.connect = new XFAObjectArray();
|
|
|
|
this.event = new XFAObjectArray();
|
|
|
|
this.field = new XFAObjectArray();
|
|
|
|
this.setProperty = new XFAObjectArray();
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$hasSettableValue]() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
[$setValue](value) {
|
|
|
|
for (const field of this.field.children) {
|
|
|
|
if (!field.value) {
|
|
|
|
const nodeValue = new Value({});
|
|
|
|
field[$appendChild](nodeValue);
|
|
|
|
field.value = nodeValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nodeBoolean = new BooleanElement({});
|
|
|
|
nodeBoolean[$content] = 0;
|
|
|
|
|
|
|
|
for (const item of field.items.children) {
|
|
|
|
if (item[$hasItem](value)) {
|
|
|
|
nodeBoolean[$content] = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
field.value[$setValue](nodeBoolean);
|
|
|
|
}
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
[$isSplittable]() {
|
|
|
|
// We cannot cache the result here because the contentArea
|
|
|
|
// can change.
|
|
|
|
const root = this[$getTemplateRoot]();
|
|
|
|
const contentArea = root[$extra].currentContentArea;
|
|
|
|
if (contentArea && Math.max(this.minH, this.h || 0) >= contentArea.h) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.layout === "position") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const parentLayout = this[$getParent]().layout;
|
|
|
|
if (parentLayout && parentLayout.includes("row")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$flushHTML]() {
|
|
|
|
return flushHTML(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
[$addHTML](html, bbox) {
|
|
|
|
addHTML(this, html, bbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
[$getAvailableSpace]() {
|
|
|
|
return getAvailableSpace(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
[$toHTML](availableSpace) {
|
|
|
|
if (
|
|
|
|
this.presence === "hidden" ||
|
|
|
|
this.presence === "inactive" ||
|
|
|
|
this.h === 0 ||
|
|
|
|
this.w === 0
|
|
|
|
) {
|
|
|
|
return HTMLResult.EMPTY;
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
fixDimensions(this);
|
|
|
|
|
|
|
|
const children = [];
|
2021-03-25 21:02:39 +09:00
|
|
|
const attributes = {
|
|
|
|
id: this[$uid],
|
2021-06-21 01:56:14 +09:00
|
|
|
class: [],
|
2021-03-25 21:02:39 +09:00
|
|
|
};
|
|
|
|
|
2021-06-21 01:56:14 +09:00
|
|
|
setAccess(this, attributes.class);
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (!this[$extra]) {
|
|
|
|
this[$extra] = Object.create(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.assign(this[$extra], {
|
|
|
|
children,
|
|
|
|
attributes,
|
|
|
|
attempt: 0,
|
|
|
|
availableSpace,
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
prevHeight: 0,
|
|
|
|
currentWidth: 0,
|
2021-03-25 21:02:39 +09:00
|
|
|
});
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
if (!checkDimensions(this, availableSpace)) {
|
|
|
|
return HTMLResult.FAILURE;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
availableSpace = {
|
|
|
|
width: this.w === "" ? availableSpace.width : this.w,
|
|
|
|
height: this.h === "" ? availableSpace.height : this.h,
|
|
|
|
};
|
|
|
|
|
|
|
|
const filter = new Set(["field"]);
|
|
|
|
|
|
|
|
if (this.layout === "row") {
|
|
|
|
const columnWidths = this[$getParent]().columnWidths;
|
|
|
|
if (Array.isArray(columnWidths) && columnWidths.length > 0) {
|
|
|
|
this[$extra].columnWidths = columnWidths;
|
|
|
|
this[$extra].currentColumn = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const style = toStyle(
|
|
|
|
this,
|
|
|
|
"anchorType",
|
|
|
|
"dimensions",
|
|
|
|
"position",
|
|
|
|
"presence",
|
2021-06-03 02:14:41 +09:00
|
|
|
"border",
|
|
|
|
"margin",
|
2021-05-19 18:09:21 +09:00
|
|
|
"hAlign"
|
|
|
|
);
|
2021-05-28 18:17:38 +09:00
|
|
|
const classNames = ["xfaExclgroup"];
|
2021-05-19 18:09:21 +09:00
|
|
|
const cl = layoutClass(this);
|
|
|
|
if (cl) {
|
2021-05-28 18:17:38 +09:00
|
|
|
classNames.push(cl);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-20 22:38:58 +09:00
|
|
|
if (isPrintOnly(this)) {
|
|
|
|
classNames.push("xfaPrintOnly");
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
attributes.style = style;
|
2021-06-03 02:14:41 +09:00
|
|
|
attributes.class = classNames;
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
if (this.name) {
|
|
|
|
attributes.xfaName = this.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
let failure;
|
|
|
|
if (this.layout === "lr-tb" || this.layout === "rl-tb") {
|
|
|
|
for (
|
|
|
|
;
|
|
|
|
this[$extra].attempt < MAX_ATTEMPTS_FOR_LRTB_LAYOUT;
|
|
|
|
this[$extra].attempt++
|
|
|
|
) {
|
2021-06-14 01:57:51 +09:00
|
|
|
const result = this[$childrenToHTML]({
|
|
|
|
filter,
|
|
|
|
include: true,
|
|
|
|
});
|
|
|
|
if (result.success) {
|
2021-05-19 18:09:21 +09:00
|
|
|
break;
|
|
|
|
}
|
2021-06-14 01:57:51 +09:00
|
|
|
if (result.isBreak()) {
|
|
|
|
return result;
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
failure = this[$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT;
|
2021-05-19 18:09:21 +09:00
|
|
|
} else {
|
2021-06-14 01:57:51 +09:00
|
|
|
const result = this[$childrenToHTML]({
|
2021-05-19 18:09:21 +09:00
|
|
|
filter,
|
|
|
|
include: true,
|
|
|
|
});
|
2021-06-14 01:57:51 +09:00
|
|
|
failure = !result.success;
|
|
|
|
if (failure && result.isBreak()) {
|
|
|
|
return result;
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (failure) {
|
2021-06-16 23:02:41 +09:00
|
|
|
if (this[$isSplittable]()) {
|
2021-06-03 02:14:41 +09:00
|
|
|
delete this[$extra];
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
let marginH = 0;
|
|
|
|
let marginV = 0;
|
|
|
|
if (this.margin) {
|
|
|
|
marginH = this.margin.leftInset + this.margin.rightInset;
|
|
|
|
marginV = this.margin.topInset + this.margin.bottomInset;
|
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
const width = Math.max(this[$extra].width + marginH, this.w || 0);
|
|
|
|
const height = Math.max(this[$extra].height + marginV, this.h || 0);
|
|
|
|
const bbox = [this.x, this.y, width, height];
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.w === "") {
|
2021-06-16 23:02:41 +09:00
|
|
|
style.width = measureToString(width);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
if (this.h === "") {
|
2021-06-16 23:02:41 +09:00
|
|
|
style.height = measureToString(height);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
const html = {
|
2021-03-25 21:02:39 +09:00
|
|
|
name: "div",
|
|
|
|
attributes,
|
|
|
|
children,
|
|
|
|
};
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
delete this[$extra];
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
return HTMLResult.success(createWrapper(this, html), bbox);
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Execute extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "execute");
|
|
|
|
this.connection = attributes.connection || "";
|
|
|
|
this.executeType = getStringOption(attributes.executeType, [
|
|
|
|
"import",
|
|
|
|
"remerge",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.runAt = getStringOption(attributes.runAt, [
|
|
|
|
"client",
|
|
|
|
"both",
|
|
|
|
"server",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Extras extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "extras", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.boolean = new XFAObjectArray();
|
|
|
|
this.date = new XFAObjectArray();
|
|
|
|
this.dateTime = new XFAObjectArray();
|
|
|
|
this.decimal = new XFAObjectArray();
|
|
|
|
this.exData = new XFAObjectArray();
|
|
|
|
this.extras = new XFAObjectArray();
|
|
|
|
this.float = new XFAObjectArray();
|
|
|
|
this.image = new XFAObjectArray();
|
|
|
|
this.integer = new XFAObjectArray();
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
this.time = new XFAObjectArray();
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
// (Spec) The XFA template grammar defines the extras and desc elements,
|
|
|
|
// which can be used to add human-readable or machine-readable
|
|
|
|
// data to a template.
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Field extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "field", /* hasChildren = */ true);
|
|
|
|
this.access = getStringOption(attributes.access, [
|
|
|
|
"open",
|
|
|
|
"nonInteractive",
|
|
|
|
"protected",
|
|
|
|
"readOnly",
|
|
|
|
]);
|
|
|
|
this.accessKey = attributes.accessKey || "";
|
|
|
|
this.anchorType = getStringOption(attributes.anchorType, [
|
|
|
|
"topLeft",
|
|
|
|
"bottomCenter",
|
|
|
|
"bottomLeft",
|
|
|
|
"bottomRight",
|
|
|
|
"middleCenter",
|
|
|
|
"middleLeft",
|
|
|
|
"middleRight",
|
|
|
|
"topCenter",
|
|
|
|
"topRight",
|
|
|
|
]);
|
|
|
|
this.colSpan = getInteger({
|
|
|
|
data: attributes.colSpan,
|
|
|
|
defaultValue: 1,
|
2021-05-19 18:09:21 +09:00
|
|
|
validate: n => n >= 1 || n === -1,
|
2021-02-01 23:12:19 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
this.h = attributes.h ? getMeasurement(attributes.h) : "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.hAlign = getStringOption(attributes.hAlign, [
|
|
|
|
"left",
|
|
|
|
"center",
|
|
|
|
"justify",
|
|
|
|
"justifyAll",
|
|
|
|
"radix",
|
|
|
|
"right",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.locale = attributes.locale || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.maxH = getMeasurement(attributes.maxH, "0pt");
|
|
|
|
this.maxW = getMeasurement(attributes.maxW, "0pt");
|
|
|
|
this.minH = getMeasurement(attributes.minH, "0pt");
|
|
|
|
this.minW = getMeasurement(attributes.minW, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
2021-03-25 21:02:39 +09:00
|
|
|
this.rotate = getInteger({
|
|
|
|
data: attributes.rotate,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x % 90 === 0,
|
|
|
|
});
|
2021-02-01 23:12:19 +09:00
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.w = attributes.w ? getMeasurement(attributes.w) : "";
|
|
|
|
this.x = getMeasurement(attributes.x, "0pt");
|
|
|
|
this.y = getMeasurement(attributes.y, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.assist = null;
|
|
|
|
this.bind = null;
|
|
|
|
this.border = null;
|
|
|
|
this.calculate = null;
|
|
|
|
this.caption = null;
|
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.font = null;
|
|
|
|
this.format = null;
|
2021-02-25 03:05:04 +09:00
|
|
|
// For a choice list, one list is used to have display entries
|
|
|
|
// and the other for the exported values
|
2021-02-01 23:12:19 +09:00
|
|
|
this.items = new XFAObjectArray(2);
|
|
|
|
this.keep = null;
|
|
|
|
this.margin = null;
|
|
|
|
this.para = null;
|
|
|
|
this.traversal = null;
|
|
|
|
this.ui = null;
|
|
|
|
this.validate = null;
|
|
|
|
this.value = null;
|
|
|
|
this.bindItems = new XFAObjectArray();
|
|
|
|
this.connect = new XFAObjectArray();
|
|
|
|
this.event = new XFAObjectArray();
|
|
|
|
this.setProperty = new XFAObjectArray();
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$setValue](value) {
|
|
|
|
_setValue(this, value);
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
|
|
|
if (
|
|
|
|
!this.ui ||
|
|
|
|
this.presence === "hidden" ||
|
|
|
|
this.presence === "inactive" ||
|
|
|
|
this.h === 0 ||
|
|
|
|
this.w === 0
|
|
|
|
) {
|
|
|
|
return HTMLResult.EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixDimensions(this);
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
if (!checkDimensions(this, availableSpace)) {
|
|
|
|
return HTMLResult.FAILURE;
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
const style = toStyle(
|
|
|
|
this,
|
|
|
|
"font",
|
|
|
|
"dimensions",
|
|
|
|
"position",
|
|
|
|
"rotate",
|
2021-03-31 22:42:21 +09:00
|
|
|
"anchorType",
|
2021-03-26 00:54:36 +09:00
|
|
|
"presence",
|
2021-06-03 02:14:41 +09:00
|
|
|
"margin",
|
2021-05-19 18:09:21 +09:00
|
|
|
"hAlign"
|
2021-03-25 21:02:39 +09:00
|
|
|
);
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
setMinMaxDimensions(this, style);
|
|
|
|
|
2021-05-28 18:17:38 +09:00
|
|
|
const classNames = ["xfaField"];
|
2021-03-31 22:42:21 +09:00
|
|
|
// If no font, font properties are inherited.
|
2021-03-25 21:02:39 +09:00
|
|
|
if (this.font) {
|
2021-05-28 18:17:38 +09:00
|
|
|
classNames.push("xfaFont");
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
|
|
|
|
2021-06-20 22:38:58 +09:00
|
|
|
if (isPrintOnly(this)) {
|
|
|
|
classNames.push("xfaPrintOnly");
|
|
|
|
}
|
|
|
|
|
2021-03-25 21:02:39 +09:00
|
|
|
const attributes = {
|
|
|
|
style,
|
|
|
|
id: this[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: classNames,
|
2021-03-25 21:02:39 +09:00
|
|
|
};
|
|
|
|
|
2021-06-21 01:56:14 +09:00
|
|
|
setAccess(this, classNames);
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
if (this.name) {
|
|
|
|
attributes.xfaName = this.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const children = [];
|
2021-06-03 02:14:41 +09:00
|
|
|
const html = {
|
2021-03-25 21:02:39 +09:00
|
|
|
name: "div",
|
|
|
|
attributes,
|
2021-03-31 22:42:21 +09:00
|
|
|
children,
|
2021-03-25 21:02:39 +09:00
|
|
|
};
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
const borderStyle = this.border ? this.border[$toStyle]() : null;
|
2021-05-19 18:09:21 +09:00
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
const bbox = computeBbox(this, html, availableSpace);
|
2021-05-19 18:09:21 +09:00
|
|
|
const ui = this.ui ? this.ui[$toHTML]().html : null;
|
2021-03-31 22:42:21 +09:00
|
|
|
if (!ui) {
|
2021-06-03 02:14:41 +09:00
|
|
|
Object.assign(style, borderStyle);
|
|
|
|
return HTMLResult.success(createWrapper(this, html), bbox);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ui.attributes.style) {
|
|
|
|
ui.attributes.style = Object.create(null);
|
|
|
|
}
|
2021-06-03 02:14:41 +09:00
|
|
|
|
|
|
|
if (this.ui.button) {
|
|
|
|
Object.assign(ui.attributes.style, borderStyle);
|
|
|
|
} else {
|
|
|
|
Object.assign(style, borderStyle);
|
|
|
|
}
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
children.push(ui);
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.value) {
|
|
|
|
if (this.ui.imageEdit) {
|
|
|
|
ui.children.push(this.value[$toHTML]().html);
|
2021-06-03 02:14:41 +09:00
|
|
|
} else if (!this.ui.button) {
|
2021-06-14 18:33:03 +09:00
|
|
|
let value = "";
|
|
|
|
if (this.value.exData) {
|
|
|
|
value = this.value.exData[$text]();
|
|
|
|
} else {
|
|
|
|
const htmlValue = this.value[$toHTML]().html;
|
|
|
|
if (htmlValue !== null) {
|
|
|
|
value = htmlValue.value;
|
|
|
|
}
|
|
|
|
}
|
2021-06-14 20:07:00 +09:00
|
|
|
if (this.ui.textEdit && this.value.text && this.value.text.maxChars) {
|
|
|
|
ui.children[0].attributes.maxLength = this.value.text.maxChars;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (value) {
|
|
|
|
if (ui.children[0].name === "textarea") {
|
2021-06-11 16:58:56 +09:00
|
|
|
ui.children[0].attributes.textContent = value;
|
2021-05-19 18:09:21 +09:00
|
|
|
} else {
|
2021-06-11 16:58:56 +09:00
|
|
|
ui.children[0].attributes.value = value;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const caption = this.caption ? this.caption[$toHTML]().html : null;
|
2021-03-31 22:42:21 +09:00
|
|
|
if (!caption) {
|
2021-06-21 23:02:33 +09:00
|
|
|
if (ui.attributes.class) {
|
|
|
|
// Even if no caption this class will help to center the ui.
|
|
|
|
ui.attributes.class.push("xfaLeft");
|
|
|
|
}
|
2021-06-03 02:14:41 +09:00
|
|
|
return HTMLResult.success(createWrapper(this, html), bbox);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
if (this.ui.button) {
|
2021-03-31 22:42:21 +09:00
|
|
|
if (caption.name === "div") {
|
|
|
|
caption.name = "span";
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
ui.children.push(caption);
|
|
|
|
return HTMLResult.success(html, bbox);
|
2021-06-10 22:30:19 +09:00
|
|
|
} else if (this.ui.checkButton) {
|
|
|
|
caption.attributes.class[0] = "xfaCaptionForCheckButton";
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
if (!ui.attributes.class) {
|
|
|
|
ui.attributes.class = [];
|
|
|
|
}
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
switch (this.caption.placement) {
|
|
|
|
case "left":
|
2021-06-10 22:30:19 +09:00
|
|
|
ui.children.splice(0, 0, caption);
|
2021-06-03 02:14:41 +09:00
|
|
|
ui.attributes.class.push("xfaLeft");
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
case "right":
|
2021-06-10 22:30:19 +09:00
|
|
|
ui.children.push(caption);
|
|
|
|
ui.attributes.class.push("xfaLeft");
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
case "top":
|
2021-06-10 22:30:19 +09:00
|
|
|
ui.children.splice(0, 0, caption);
|
2021-06-03 02:14:41 +09:00
|
|
|
ui.attributes.class.push("xfaTop");
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
case "bottom":
|
2021-06-10 22:30:19 +09:00
|
|
|
ui.children.push(caption);
|
|
|
|
ui.attributes.class.push("xfaTop");
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
case "inline":
|
2021-06-03 02:14:41 +09:00
|
|
|
// TODO;
|
2021-06-10 05:13:43 +09:00
|
|
|
ui.attributes.class.push("xfaLeft");
|
2021-03-31 22:42:21 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
return HTMLResult.success(createWrapper(this, html), bbox);
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Fill extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "fill", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
|
2021-03-31 22:42:21 +09:00
|
|
|
// One-of properties or none
|
2021-02-01 23:12:19 +09:00
|
|
|
this.linear = null;
|
|
|
|
this.pattern = null;
|
|
|
|
this.radial = null;
|
|
|
|
this.solid = null;
|
|
|
|
this.stipple = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle]() {
|
2021-05-19 18:09:21 +09:00
|
|
|
const parent = this[$getParent]();
|
2021-06-12 01:03:19 +09:00
|
|
|
const style = Object.create(null);
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
let propName = "color";
|
|
|
|
if (parent instanceof Border) {
|
|
|
|
propName = "background";
|
|
|
|
}
|
2021-06-12 01:03:19 +09:00
|
|
|
if (parent instanceof Rectangle || parent instanceof Arc) {
|
2021-06-05 03:10:35 +09:00
|
|
|
propName = "fill";
|
2021-06-12 01:03:19 +09:00
|
|
|
style.fill = "transparent";
|
2021-06-05 03:10:35 +09:00
|
|
|
}
|
2021-06-12 01:03:19 +09:00
|
|
|
|
2021-03-25 21:02:39 +09:00
|
|
|
for (const name of Object.getOwnPropertyNames(this)) {
|
|
|
|
if (name === "extras" || name === "color") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const obj = this[name];
|
|
|
|
if (!(obj instanceof XFAObject)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
style[propName] = obj[$toStyle](this.color);
|
|
|
|
return style;
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
|
|
|
|
2021-03-26 00:54:36 +09:00
|
|
|
if (this.color) {
|
2021-05-19 18:09:21 +09:00
|
|
|
style[propName] = this.color[$toStyle]();
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return style;
|
2021-03-25 21:02:39 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Filter extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "filter", /* hasChildren = */ true);
|
|
|
|
this.addRevocationInfo = getStringOption(attributes.addRevocationInfo, [
|
|
|
|
"",
|
|
|
|
"required",
|
|
|
|
"optional",
|
|
|
|
"none",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.version = getInteger({
|
|
|
|
data: this.version,
|
|
|
|
defaultValue: 5,
|
|
|
|
validate: x => x >= 1 && x <= 5,
|
|
|
|
});
|
|
|
|
this.appearanceFilter = null;
|
|
|
|
this.certificates = null;
|
|
|
|
this.digestMethods = null;
|
|
|
|
this.encodings = null;
|
|
|
|
this.encryptionMethods = null;
|
|
|
|
this.handler = null;
|
|
|
|
this.lockDocument = null;
|
|
|
|
this.mdp = null;
|
|
|
|
this.reasons = null;
|
|
|
|
this.timeStamp = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Float extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "float");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
|
|
|
const number = parseFloat(this[$content].trim());
|
|
|
|
this[$content] = isNaN(number) ? null : number;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$content] !== null ? this[$content].toString() : ""
|
|
|
|
);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Font extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "font", /* hasChildren = */ true);
|
|
|
|
this.baselineShift = getMeasurement(attributes.baselineShift);
|
|
|
|
this.fontHorizontalScale = getFloat({
|
|
|
|
data: attributes.fontHorizontalScale,
|
|
|
|
defaultValue: 100,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.fontVerticalScale = getFloat({
|
|
|
|
data: attributes.fontVerticalScale,
|
|
|
|
defaultValue: 100,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.kerningMode = getStringOption(attributes.kerningMode, [
|
|
|
|
"none",
|
|
|
|
"pair",
|
|
|
|
]);
|
|
|
|
this.letterSpacing = getMeasurement(attributes.letterSpacing, "0");
|
|
|
|
this.lineThrough = getInteger({
|
|
|
|
data: attributes.lineThrough,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1 || x === 2,
|
|
|
|
});
|
|
|
|
this.lineThroughPeriod = getStringOption(attributes.lineThroughPeriod, [
|
|
|
|
"all",
|
|
|
|
"word",
|
|
|
|
]);
|
|
|
|
this.overline = getInteger({
|
|
|
|
data: attributes.overline,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1 || x === 2,
|
|
|
|
});
|
|
|
|
this.overlinePeriod = getStringOption(attributes.overlinePeriod, [
|
|
|
|
"all",
|
|
|
|
"word",
|
|
|
|
]);
|
|
|
|
this.posture = getStringOption(attributes.posture, ["normal", "italic"]);
|
|
|
|
this.size = getMeasurement(attributes.size, "10pt");
|
2021-06-15 02:16:42 +09:00
|
|
|
this.typeface = attributes.typeface || "Courier";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.underline = getInteger({
|
|
|
|
data: attributes.underline,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1 || x === 2,
|
|
|
|
});
|
|
|
|
this.underlinePeriod = getStringOption(attributes.underlinePeriod, [
|
|
|
|
"all",
|
|
|
|
"word",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.weight = getStringOption(attributes.weight, ["normal", "bold"]);
|
|
|
|
this.extras = null;
|
|
|
|
this.fill = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle]() {
|
|
|
|
const style = toStyle(this, "fill");
|
2021-05-19 18:09:21 +09:00
|
|
|
const color = style.color;
|
2021-03-26 00:54:36 +09:00
|
|
|
if (color) {
|
|
|
|
if (color === "#000000") {
|
2021-05-19 18:09:21 +09:00
|
|
|
// Default font color.
|
|
|
|
delete style.color;
|
2021-03-26 00:54:36 +09:00
|
|
|
} else if (!color.startsWith("#")) {
|
2021-03-25 21:02:39 +09:00
|
|
|
// We've a gradient which is not possible for a font color
|
|
|
|
// so use a workaround.
|
2021-05-19 18:09:21 +09:00
|
|
|
style.background = color;
|
2021-03-25 21:02:39 +09:00
|
|
|
style.backgroundClip = "text";
|
|
|
|
style.color = "transparent";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.baselineShift) {
|
|
|
|
style.verticalAlign = measureToString(this.baselineShift);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: fontHorizontalScale
|
|
|
|
// TODO: fontVerticalScale
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
|
|
|
|
style.letterSpacing = measureToString(this.letterSpacing);
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
if (this.lineThrough !== 0) {
|
|
|
|
style.textDecoration = "line-through";
|
|
|
|
if (this.lineThrough === 2) {
|
|
|
|
style.textDecorationStyle = "double";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: lineThroughPeriod
|
|
|
|
|
|
|
|
if (this.overline !== 0) {
|
|
|
|
style.textDecoration = "overline";
|
|
|
|
if (this.overline === 2) {
|
|
|
|
style.textDecorationStyle = "double";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: overlinePeriod
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
style.fontStyle = this.posture;
|
2021-03-25 21:02:39 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const fontSize = measureToString(0.99 * this.size);
|
2021-03-25 21:02:39 +09:00
|
|
|
if (fontSize !== "10px") {
|
|
|
|
style.fontSize = fontSize;
|
|
|
|
}
|
|
|
|
|
2021-06-23 18:10:20 +09:00
|
|
|
setFontFamily(this, this[$globalData].fontFinder, style);
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
if (this.underline !== 0) {
|
|
|
|
style.textDecoration = "underline";
|
|
|
|
if (this.underline === 2) {
|
|
|
|
style.textDecorationStyle = "double";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: underlinePeriod
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
style.fontWeight = this.weight;
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
return style;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Format extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "format", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.picture = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Handler extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "handler");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Hyphenation extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "hyphenation");
|
|
|
|
this.excludeAllCaps = getInteger({
|
|
|
|
data: attributes.excludeAllCaps,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.excludeInitialCap = getInteger({
|
|
|
|
data: attributes.excludeInitialCap,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.hyphenate = getInteger({
|
|
|
|
data: attributes.hyphenate,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.pushCharacterCount = getInteger({
|
|
|
|
data: attributes.pushCharacterCount,
|
|
|
|
defaultValue: 3,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.remainCharacterCount = getInteger({
|
|
|
|
data: attributes.remainCharacterCount,
|
|
|
|
defaultValue: 3,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.wordCharacterCount = getInteger({
|
|
|
|
data: attributes.wordCharacterCount,
|
|
|
|
defaultValue: 7,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Image extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "image");
|
|
|
|
this.aspect = getStringOption(attributes.aspect, [
|
|
|
|
"fit",
|
|
|
|
"actual",
|
|
|
|
"height",
|
|
|
|
"none",
|
|
|
|
"width",
|
|
|
|
]);
|
|
|
|
this.contentType = attributes.contentType || "";
|
|
|
|
this.href = attributes.href || "";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.transferEncoding = getStringOption(attributes.transferEncoding, [
|
|
|
|
"base64",
|
|
|
|
"none",
|
|
|
|
"package",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
|
|
|
[$toHTML]() {
|
2021-05-22 22:09:43 +09:00
|
|
|
if (this.href || !this[$content]) {
|
2021-05-31 01:02:07 +09:00
|
|
|
// TODO: href can be a Name referring to an internal stream
|
2021-05-22 22:09:43 +09:00
|
|
|
// containing a picture.
|
|
|
|
// In general, we don't get remote data and use what we have
|
|
|
|
// in the pdf itself, so no picture for non null href.
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
// TODO: Firefox doesn't support natively tiff (and tif) format.
|
2021-03-31 22:42:21 +09:00
|
|
|
if (this.transferEncoding === "base64") {
|
2021-05-22 19:23:09 +09:00
|
|
|
const buffer = stringToBytes(atob(this[$content]));
|
2021-03-31 22:42:21 +09:00
|
|
|
const blob = new Blob([buffer], { type: this.contentType });
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-05-22 22:09:43 +09:00
|
|
|
name: "img",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaImage"],
|
2021-05-22 22:09:43 +09:00
|
|
|
style: {},
|
|
|
|
src: URL.createObjectURL(blob),
|
|
|
|
},
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class ImageEdit extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "imageEdit", /* hasChildren = */ true);
|
|
|
|
this.data = getStringOption(attributes.data, ["link", "embed"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
[$toHTML](availableSpace) {
|
|
|
|
if (this.data === "embed") {
|
|
|
|
return HTMLResult.success({
|
|
|
|
name: "div",
|
|
|
|
children: [],
|
|
|
|
attributes: {},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLResult.EMPTY;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Integer extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "integer");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
|
|
|
const number = parseInt(this[$content].trim(), 10);
|
|
|
|
this[$content] = isNaN(number) ? null : number;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$content] !== null ? this[$content].toString() : ""
|
|
|
|
);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Issuers extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "issuers", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.certificate = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Items extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "items", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.save = getInteger({
|
|
|
|
data: attributes.save,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.boolean = new XFAObjectArray();
|
|
|
|
this.date = new XFAObjectArray();
|
|
|
|
this.dateTime = new XFAObjectArray();
|
|
|
|
this.decimal = new XFAObjectArray();
|
|
|
|
this.exData = new XFAObjectArray();
|
|
|
|
this.float = new XFAObjectArray();
|
|
|
|
this.image = new XFAObjectArray();
|
|
|
|
this.integer = new XFAObjectArray();
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
this.time = new XFAObjectArray();
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$hasItem](value) {
|
|
|
|
return (
|
|
|
|
this.hasOwnProperty(value[$nodeName]) &&
|
|
|
|
this[value[$nodeName]].children.some(
|
|
|
|
node => node[$content] === value[$content]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
[$toHTML]() {
|
|
|
|
const output = [];
|
|
|
|
for (const child of this[$getChildren]()) {
|
|
|
|
output.push(child[$text]());
|
|
|
|
}
|
|
|
|
return HTMLResult.success(output);
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Keep extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "keep", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
const options = ["none", "contentArea", "pageArea"];
|
|
|
|
this.intact = getStringOption(attributes.intact, options);
|
|
|
|
this.next = getStringOption(attributes.next, options);
|
|
|
|
this.previous = getStringOption(attributes.previous, options);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class KeyUsage extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "keyUsage");
|
|
|
|
const options = ["", "yes", "no"];
|
|
|
|
this.crlSign = getStringOption(attributes.crlSign, options);
|
|
|
|
this.dataEncipherment = getStringOption(
|
|
|
|
attributes.dataEncipherment,
|
|
|
|
options
|
|
|
|
);
|
|
|
|
this.decipherOnly = getStringOption(attributes.decipherOnly, options);
|
|
|
|
this.digitalSignature = getStringOption(
|
|
|
|
attributes.digitalSignature,
|
|
|
|
options
|
|
|
|
);
|
|
|
|
this.encipherOnly = getStringOption(attributes.encipherOnly, options);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.keyAgreement = getStringOption(attributes.keyAgreement, options);
|
|
|
|
this.keyCertSign = getStringOption(attributes.keyCertSign, options);
|
|
|
|
this.keyEncipherment = getStringOption(attributes.keyEncipherment, options);
|
|
|
|
this.nonRepudiation = getStringOption(attributes.nonRepudiation, options);
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Line extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "line", /* hasChildren = */ true);
|
|
|
|
this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.slope = getStringOption(attributes.slope, ["\\", "/"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.edge = null;
|
|
|
|
}
|
2021-06-05 03:10:35 +09:00
|
|
|
|
|
|
|
[$toHTML]() {
|
|
|
|
const parent = this[$getParent]()[$getParent]();
|
|
|
|
const edge = this.edge ? this.edge : new Edge({});
|
|
|
|
const edgeStyle = edge[$toStyle]();
|
|
|
|
const style = Object.create(null);
|
2021-06-20 22:45:54 +09:00
|
|
|
const thickness =
|
|
|
|
edge.presence === "visible" ? Math.round(edge.thickness) : 0;
|
|
|
|
style.strokeWidth = measureToString(thickness);
|
2021-06-05 03:10:35 +09:00
|
|
|
style.stroke = edgeStyle.color;
|
|
|
|
let x1, y1, x2, y2;
|
|
|
|
let width = "100%";
|
|
|
|
let height = "100%";
|
|
|
|
|
2021-06-20 22:45:54 +09:00
|
|
|
if (parent.w <= thickness) {
|
2021-06-05 03:10:35 +09:00
|
|
|
[x1, y1, x2, y2] = ["50%", 0, "50%", "100%"];
|
|
|
|
width = style.strokeWidth;
|
2021-06-20 22:45:54 +09:00
|
|
|
} else if (parent.h <= thickness) {
|
2021-06-05 03:10:35 +09:00
|
|
|
[x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
|
|
|
|
height = style.strokeWidth;
|
|
|
|
} else {
|
|
|
|
if (this.slope === "\\") {
|
|
|
|
[x1, y1, x2, y2] = [0, 0, "100%", "100%"];
|
|
|
|
} else {
|
|
|
|
[x1, y1, x2, y2] = [0, "100%", "100%", 0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const line = {
|
|
|
|
name: "line",
|
|
|
|
attributes: {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
x1,
|
|
|
|
y1,
|
|
|
|
x2,
|
|
|
|
y2,
|
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return HTMLResult.success({
|
|
|
|
name: "svg",
|
|
|
|
children: [line],
|
|
|
|
attributes: {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
style: {
|
|
|
|
position: "absolute",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Linear extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "linear", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, [
|
|
|
|
"toRight",
|
|
|
|
"toBottom",
|
|
|
|
"toLeft",
|
|
|
|
"toTop",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle](startColor) {
|
|
|
|
startColor = startColor ? startColor[$toStyle]() : "#FFFFFF";
|
|
|
|
const transf = this.type.replace(/([RBLT])/, " $1").toLowerCase();
|
|
|
|
const endColor = this.color ? this.color[$toStyle]() : "#000000";
|
|
|
|
return `linear-gradient(${transf}, ${startColor}, ${endColor})`;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class LockDocument extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "lockDocument");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
|
|
|
this[$content] = getStringOption(this[$content], ["auto", "0", "1"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Manifest extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "manifest", /* hasChildren = */ true);
|
|
|
|
this.action = getStringOption(attributes.action, [
|
|
|
|
"include",
|
|
|
|
"all",
|
|
|
|
"exclude",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.ref = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Margin extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "margin", /* hasChildren = */ true);
|
|
|
|
this.bottomInset = getMeasurement(attributes.bottomInset, "0");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.leftInset = getMeasurement(attributes.leftInset, "0");
|
|
|
|
this.rightInset = getMeasurement(attributes.rightInset, "0");
|
|
|
|
this.topInset = getMeasurement(attributes.topInset, "0");
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
|
|
|
[$toStyle]() {
|
|
|
|
return {
|
2021-03-26 00:54:36 +09:00
|
|
|
margin:
|
|
|
|
measureToString(this.topInset) +
|
|
|
|
" " +
|
|
|
|
measureToString(this.rightInset) +
|
|
|
|
" " +
|
|
|
|
measureToString(this.bottomInset) +
|
|
|
|
" " +
|
|
|
|
measureToString(this.leftInset),
|
2021-03-31 22:42:21 +09:00
|
|
|
};
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Mdp extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "mdp");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.permissions = getInteger({
|
|
|
|
data: attributes.permissions,
|
|
|
|
defaultValue: 2,
|
|
|
|
validate: x => x === 1 || x === 3,
|
|
|
|
});
|
|
|
|
this.signatureType = getStringOption(attributes.signatureType, [
|
|
|
|
"filler",
|
|
|
|
"author",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Medium extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "medium");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.imagingBBox = getBBox(attributes.imagingBBox);
|
|
|
|
this.long = getMeasurement(attributes.long);
|
|
|
|
this.orientation = getStringOption(attributes.orientation, [
|
|
|
|
"portrait",
|
|
|
|
"landscape",
|
|
|
|
]);
|
|
|
|
this.short = getMeasurement(attributes.short);
|
|
|
|
this.stock = attributes.stock || "";
|
|
|
|
this.trayIn = getStringOption(attributes.trayIn, [
|
|
|
|
"auto",
|
|
|
|
"delegate",
|
|
|
|
"pageFront",
|
|
|
|
]);
|
|
|
|
this.trayOut = getStringOption(attributes.trayOut, ["auto", "delegate"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Message extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "message", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class NumericEdit extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "numericEdit", /* hasChildren = */ true);
|
|
|
|
this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, [
|
|
|
|
"auto",
|
|
|
|
"off",
|
|
|
|
"on",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.comb = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: incomplete.
|
|
|
|
const style = toStyle(this, "border", "font", "margin");
|
|
|
|
const html = {
|
|
|
|
name: "input",
|
|
|
|
attributes: {
|
|
|
|
type: "text",
|
2021-05-24 20:42:42 +09:00
|
|
|
fieldId: this[$getParent]()[$getParent]()[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaTextfield"],
|
2021-03-31 22:42:21 +09:00
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "label",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaLabel"],
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
|
|
|
children: [html],
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Occur extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "occur", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.initial = getInteger({
|
|
|
|
data: attributes.initial,
|
|
|
|
defaultValue: 1,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.max = getInteger({
|
|
|
|
data: attributes.max,
|
|
|
|
defaultValue: 1,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.min = getInteger({
|
|
|
|
data: attributes.min,
|
|
|
|
defaultValue: 1,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Oid extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "oid");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Oids extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "oids", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.oid = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Overflow extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "overflow");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.leader = attributes.leader || "";
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
this.trailer = attributes.trailer || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PageArea extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "pageArea", /* hasChildren = */ true);
|
|
|
|
this.blankOrNotBlank = getStringOption(attributes.blankOrNotBlank, [
|
|
|
|
"any",
|
|
|
|
"blank",
|
|
|
|
"notBlank",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.initialNumber = getInteger({
|
|
|
|
data: attributes.initialNumber,
|
|
|
|
defaultValue: 1,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.numbered = getInteger({
|
|
|
|
data: attributes.numbered,
|
|
|
|
defaultValue: 1,
|
|
|
|
validate: x => true,
|
|
|
|
});
|
|
|
|
this.oddOrEven = getStringOption(attributes.oddOrEven, [
|
|
|
|
"any",
|
|
|
|
"even",
|
|
|
|
"odd",
|
|
|
|
]);
|
|
|
|
this.pagePosition = getStringOption(attributes.pagePosition, [
|
|
|
|
"any",
|
|
|
|
"first",
|
|
|
|
"last",
|
|
|
|
"only",
|
|
|
|
"rest",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.medium = null;
|
|
|
|
this.occur = null;
|
|
|
|
this.area = new XFAObjectArray();
|
|
|
|
this.contentArea = new XFAObjectArray();
|
|
|
|
this.draw = new XFAObjectArray();
|
|
|
|
this.exclGroup = new XFAObjectArray();
|
|
|
|
this.field = new XFAObjectArray();
|
|
|
|
this.subform = new XFAObjectArray();
|
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
[$isUsable]() {
|
|
|
|
if (!this[$extra]) {
|
|
|
|
this[$extra] = {
|
|
|
|
numberOfUse: 0,
|
|
|
|
};
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
!this.occur ||
|
|
|
|
this.occur.max === -1 ||
|
|
|
|
this[$extra].numberOfUse < this.occur.max
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
[$cleanPage]() {
|
|
|
|
delete this[$extra];
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$getNextPage]() {
|
|
|
|
if (!this[$extra]) {
|
|
|
|
this[$extra] = {
|
2021-06-21 23:02:33 +09:00
|
|
|
numberOfUse: 0,
|
2021-05-19 18:09:21 +09:00
|
|
|
};
|
|
|
|
}
|
2021-06-21 23:02:33 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const parent = this[$getParent]();
|
|
|
|
if (parent.relation === "orderedOccurrence") {
|
2021-06-21 23:02:33 +09:00
|
|
|
if (this[$isUsable]()) {
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$extra].numberOfUse += 1;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent[$getNextPage]();
|
|
|
|
}
|
|
|
|
|
|
|
|
[$getAvailableSpace]() {
|
2021-06-16 23:02:41 +09:00
|
|
|
return this[$extra].space || { width: 0, height: 0 };
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-03-19 18:11:40 +09:00
|
|
|
[$toHTML]() {
|
|
|
|
// TODO: incomplete.
|
2021-06-21 22:45:04 +09:00
|
|
|
if (!this[$extra]) {
|
|
|
|
this[$extra] = {
|
|
|
|
numberOfUse: 1,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const children = [];
|
|
|
|
this[$extra].children = children;
|
2021-03-19 18:11:40 +09:00
|
|
|
|
|
|
|
const style = Object.create(null);
|
2021-03-25 21:02:39 +09:00
|
|
|
if (this.medium && this.medium.short && this.medium.long) {
|
2021-03-19 18:11:40 +09:00
|
|
|
style.width = measureToString(this.medium.short);
|
|
|
|
style.height = measureToString(this.medium.long);
|
2021-06-16 23:02:41 +09:00
|
|
|
this[$extra].space = {
|
|
|
|
width: this.medium.short,
|
|
|
|
height: this.medium.long,
|
|
|
|
};
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.medium.orientation === "landscape") {
|
|
|
|
const x = style.width;
|
|
|
|
style.width = style.height;
|
|
|
|
style.height = x;
|
2021-06-16 23:02:41 +09:00
|
|
|
this[$extra].space = {
|
|
|
|
width: this.medium.long,
|
|
|
|
height: this.medium.short,
|
|
|
|
};
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
} else {
|
2021-05-19 18:09:21 +09:00
|
|
|
warn("XFA - No medium specified in pageArea: please file a bug.");
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$childrenToHTML]({
|
2021-06-06 23:37:21 +09:00
|
|
|
filter: new Set(["area", "draw", "field", "subform"]),
|
|
|
|
include: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
// contentarea must be the last container to be sure it is
|
|
|
|
// on top of the others.
|
|
|
|
this[$childrenToHTML]({
|
|
|
|
filter: new Set(["contentArea"]),
|
2021-05-19 18:09:21 +09:00
|
|
|
include: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
return HTMLResult.success({
|
2021-03-19 18:11:40 +09:00
|
|
|
name: "div",
|
|
|
|
children,
|
|
|
|
attributes: {
|
|
|
|
id: this[$uid],
|
|
|
|
style,
|
|
|
|
},
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class PageSet extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "pageSet", /* hasChildren = */ true);
|
|
|
|
this.duplexImposition = getStringOption(attributes.duplexImposition, [
|
|
|
|
"longEdge",
|
|
|
|
"shortEdge",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.relation = getStringOption(attributes.relation, [
|
|
|
|
"orderedOccurrence",
|
|
|
|
"duplexPaginated",
|
|
|
|
"simplexPaginated",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.occur = null;
|
|
|
|
this.pageArea = new XFAObjectArray();
|
|
|
|
this.pageSet = new XFAObjectArray();
|
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
[$cleanPage]() {
|
|
|
|
for (const page of this.pageArea.children) {
|
|
|
|
page[$cleanPage]();
|
|
|
|
}
|
|
|
|
for (const page of this.pageSet.children) {
|
|
|
|
page[$cleanPage]();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[$isUsable]() {
|
|
|
|
return (
|
|
|
|
!this.occur ||
|
|
|
|
this.occur.max === -1 ||
|
|
|
|
this[$extra].numberOfUse < this.occur.max
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$getNextPage]() {
|
|
|
|
if (!this[$extra]) {
|
|
|
|
this[$extra] = {
|
|
|
|
numberOfUse: 1,
|
2021-06-21 23:02:33 +09:00
|
|
|
pageIndex: -1,
|
|
|
|
pageSetIndex: -1,
|
2021-05-19 18:09:21 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.relation === "orderedOccurrence") {
|
2021-06-21 23:02:33 +09:00
|
|
|
if (this[$extra].pageIndex + 1 < this.pageArea.children.length) {
|
|
|
|
this[$extra].pageIndex += 1;
|
|
|
|
const pageArea = this.pageArea.children[this[$extra].pageIndex];
|
|
|
|
return pageArea[$getNextPage]();
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
if (this[$extra].pageSetIndex + 1 < this.pageSet.children.length) {
|
|
|
|
this[$extra].pageSetIndex += 1;
|
|
|
|
return this.pageSet.children[this[$extra].pageSetIndex][$getNextPage]();
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
if (this[$isUsable]()) {
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$extra].numberOfUse += 1;
|
2021-06-21 23:02:33 +09:00
|
|
|
this[$extra].pageIndex = -1;
|
|
|
|
this[$extra].pageSetIndex = -1;
|
|
|
|
return this[$getNextPage]();
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
const parent = this[$getParent]();
|
|
|
|
if (parent instanceof PageSet) {
|
|
|
|
return parent[$getNextPage]();
|
|
|
|
}
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
this[$cleanPage]();
|
2021-05-19 18:09:21 +09:00
|
|
|
return this[$getNextPage]();
|
|
|
|
}
|
2021-06-16 23:02:41 +09:00
|
|
|
const pageNumber = this[$getTemplateRoot]()[$extra].pageNumber;
|
2021-05-19 18:09:21 +09:00
|
|
|
const parity = pageNumber % 2 === 0 ? "even" : "odd";
|
|
|
|
const position = pageNumber === 0 ? "first" : "rest";
|
|
|
|
|
|
|
|
let page = this.pageArea.children.find(
|
|
|
|
p => p.oddOrEven === parity && p.pagePosition === position
|
|
|
|
);
|
|
|
|
if (page) {
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
|
|
|
page = this.pageArea.children.find(
|
|
|
|
p => p.oddOrEven === "any" && p.pagePosition === position
|
|
|
|
);
|
|
|
|
if (page) {
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
|
|
|
page = this.pageArea.children.find(
|
|
|
|
p => p.oddOrEven === "any" && p.pagePosition === "any"
|
|
|
|
);
|
|
|
|
if (page) {
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.pageArea.children[0];
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Para extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "para", /* hasChildren = */ true);
|
|
|
|
this.hAlign = getStringOption(attributes.hAlign, [
|
|
|
|
"left",
|
|
|
|
"center",
|
|
|
|
"justify",
|
|
|
|
"justifyAll",
|
|
|
|
"radix",
|
|
|
|
"right",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
2021-03-26 00:54:36 +09:00
|
|
|
this.lineHeight = attributes.lineHeight
|
|
|
|
? getMeasurement(attributes.lineHeight, "0pt")
|
|
|
|
: "";
|
|
|
|
this.marginLeft = attributes.marginLeft
|
|
|
|
? getMeasurement(attributes.marginLeft, "0pt")
|
|
|
|
: "";
|
|
|
|
this.marginRight = attributes.marginRight
|
|
|
|
? getMeasurement(attributes.marginRight, "0pt")
|
|
|
|
: "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.orphans = getInteger({
|
|
|
|
data: attributes.orphans,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.preserve = attributes.preserve || "";
|
2021-03-26 00:54:36 +09:00
|
|
|
this.radixOffset = attributes.radixOffset
|
|
|
|
? getMeasurement(attributes.radixOffset, "0pt")
|
|
|
|
: "";
|
|
|
|
this.spaceAbove = attributes.spaceAbove
|
|
|
|
? getMeasurement(attributes.spaceAbove, "0pt")
|
|
|
|
: "";
|
|
|
|
this.spaceBelow = attributes.spaceBelow
|
|
|
|
? getMeasurement(attributes.spaceBelow, "0pt")
|
|
|
|
: "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.tabDefault = attributes.tabDefault
|
|
|
|
? getMeasurement(this.tabDefault)
|
2021-03-26 00:54:36 +09:00
|
|
|
: "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.tabStops = (attributes.tabStops || "")
|
|
|
|
.trim()
|
|
|
|
.split(/\s+/)
|
|
|
|
.map((x, i) => (i % 2 === 1 ? getMeasurement(x) : x));
|
2021-03-26 00:54:36 +09:00
|
|
|
this.textIndent = attributes.textIndent
|
|
|
|
? getMeasurement(attributes.textIndent, "0pt")
|
|
|
|
: "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.vAlign = getStringOption(attributes.vAlign, [
|
|
|
|
"top",
|
|
|
|
"bottom",
|
|
|
|
"middle",
|
|
|
|
]);
|
|
|
|
this.widows = getInteger({
|
|
|
|
data: attributes.widows,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.hyphenation = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-03-26 00:54:36 +09:00
|
|
|
[$toStyle]() {
|
|
|
|
const style = toStyle(this, "hAlign");
|
|
|
|
if (this.marginLeft !== "") {
|
|
|
|
style.marginLeft = measureToString(this.marginLeft);
|
|
|
|
}
|
|
|
|
if (this.marginRight !== "") {
|
|
|
|
style.marginRight = measureToString(this.marginRight);
|
|
|
|
}
|
|
|
|
if (this.spaceAbove !== "") {
|
|
|
|
style.marginTop = measureToString(this.spaceAbove);
|
|
|
|
}
|
|
|
|
if (this.spaceBelow !== "") {
|
|
|
|
style.marginBottom = measureToString(this.spaceBelow);
|
|
|
|
}
|
|
|
|
if (this.textIndent !== "") {
|
|
|
|
style.textIndent = measureToString(this.textIndent);
|
2021-05-19 18:09:21 +09:00
|
|
|
fixTextIndent(style);
|
2021-03-26 00:54:36 +09:00
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.lineHeight > 0) {
|
2021-03-31 22:42:21 +09:00
|
|
|
style.lineHeight = measureToString(this.lineHeight);
|
|
|
|
}
|
|
|
|
|
2021-03-26 00:54:36 +09:00
|
|
|
if (this.tabDefault !== "") {
|
2021-03-31 22:42:21 +09:00
|
|
|
style.tabSize = measureToString(this.tabDefault);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.tabStops.length > 0) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.hyphenatation) {
|
2021-03-26 00:54:36 +09:00
|
|
|
Object.assign(style, this.hyphenatation[$toStyle]());
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return style;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class PasswordEdit extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "passwordEdit", /* hasChildren = */ true);
|
|
|
|
this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, [
|
|
|
|
"auto",
|
|
|
|
"off",
|
|
|
|
"on",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.passwordChar = attributes.passwordChar || "*";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Pattern extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "pattern", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, [
|
|
|
|
"crossHatch",
|
|
|
|
"crossDiagonal",
|
|
|
|
"diagonalLeft",
|
|
|
|
"diagonalRight",
|
|
|
|
"horizontal",
|
|
|
|
"vertical",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle](startColor) {
|
|
|
|
startColor = startColor ? startColor[$toStyle]() : "#FFFFFF";
|
|
|
|
const endColor = this.color ? this.color[$toStyle]() : "#000000";
|
|
|
|
const width = 5;
|
|
|
|
const cmd = "repeating-linear-gradient";
|
|
|
|
const colors = `${startColor},${startColor} ${width}px,${endColor} ${width}px,${endColor} ${
|
|
|
|
2 * width
|
|
|
|
}px`;
|
|
|
|
switch (this.type) {
|
|
|
|
case "crossHatch":
|
|
|
|
return `${cmd}(to top,${colors}) ${cmd}(to right,${colors})`;
|
|
|
|
case "crossDiagonal":
|
|
|
|
return `${cmd}(45deg,${colors}) ${cmd}(-45deg,${colors})`;
|
|
|
|
case "diagonalLeft":
|
|
|
|
return `${cmd}(45deg,${colors})`;
|
|
|
|
case "diagonalRight":
|
|
|
|
return `${cmd}(-45deg,${colors})`;
|
|
|
|
case "horizontal":
|
|
|
|
return `${cmd}(to top,${colors})`;
|
|
|
|
case "vertical":
|
|
|
|
return `${cmd}(to right,${colors})`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Picture extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "picture");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Proto extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "proto", /* hasChildren = */ true);
|
|
|
|
this.appearanceFilter = new XFAObjectArray();
|
|
|
|
this.arc = new XFAObjectArray();
|
|
|
|
this.area = new XFAObjectArray();
|
|
|
|
this.assist = new XFAObjectArray();
|
|
|
|
this.barcode = new XFAObjectArray();
|
|
|
|
this.bindItems = new XFAObjectArray();
|
|
|
|
this.bookend = new XFAObjectArray();
|
|
|
|
this.boolean = new XFAObjectArray();
|
|
|
|
this.border = new XFAObjectArray();
|
|
|
|
this.break = new XFAObjectArray();
|
|
|
|
this.breakAfter = new XFAObjectArray();
|
|
|
|
this.breakBefore = new XFAObjectArray();
|
|
|
|
this.button = new XFAObjectArray();
|
|
|
|
this.calculate = new XFAObjectArray();
|
|
|
|
this.caption = new XFAObjectArray();
|
|
|
|
this.certificate = new XFAObjectArray();
|
|
|
|
this.certificates = new XFAObjectArray();
|
|
|
|
this.checkButton = new XFAObjectArray();
|
|
|
|
this.choiceList = new XFAObjectArray();
|
|
|
|
this.color = new XFAObjectArray();
|
|
|
|
this.comb = new XFAObjectArray();
|
|
|
|
this.connect = new XFAObjectArray();
|
|
|
|
this.contentArea = new XFAObjectArray();
|
|
|
|
this.corner = new XFAObjectArray();
|
|
|
|
this.date = new XFAObjectArray();
|
|
|
|
this.dateTime = new XFAObjectArray();
|
|
|
|
this.dateTimeEdit = new XFAObjectArray();
|
|
|
|
this.decimal = new XFAObjectArray();
|
|
|
|
this.defaultUi = new XFAObjectArray();
|
|
|
|
this.desc = new XFAObjectArray();
|
|
|
|
this.digestMethod = new XFAObjectArray();
|
|
|
|
this.digestMethods = new XFAObjectArray();
|
|
|
|
this.draw = new XFAObjectArray();
|
|
|
|
this.edge = new XFAObjectArray();
|
|
|
|
this.encoding = new XFAObjectArray();
|
|
|
|
this.encodings = new XFAObjectArray();
|
|
|
|
this.encrypt = new XFAObjectArray();
|
|
|
|
this.encryptData = new XFAObjectArray();
|
|
|
|
this.encryption = new XFAObjectArray();
|
|
|
|
this.encryptionMethod = new XFAObjectArray();
|
|
|
|
this.encryptionMethods = new XFAObjectArray();
|
|
|
|
this.event = new XFAObjectArray();
|
|
|
|
this.exData = new XFAObjectArray();
|
|
|
|
this.exObject = new XFAObjectArray();
|
|
|
|
this.exclGroup = new XFAObjectArray();
|
|
|
|
this.execute = new XFAObjectArray();
|
|
|
|
this.extras = new XFAObjectArray();
|
|
|
|
this.field = new XFAObjectArray();
|
|
|
|
this.fill = new XFAObjectArray();
|
|
|
|
this.filter = new XFAObjectArray();
|
|
|
|
this.float = new XFAObjectArray();
|
|
|
|
this.font = new XFAObjectArray();
|
|
|
|
this.format = new XFAObjectArray();
|
|
|
|
this.handler = new XFAObjectArray();
|
|
|
|
this.hyphenation = new XFAObjectArray();
|
|
|
|
this.image = new XFAObjectArray();
|
|
|
|
this.imageEdit = new XFAObjectArray();
|
|
|
|
this.integer = new XFAObjectArray();
|
|
|
|
this.issuers = new XFAObjectArray();
|
|
|
|
this.items = new XFAObjectArray();
|
|
|
|
this.keep = new XFAObjectArray();
|
|
|
|
this.keyUsage = new XFAObjectArray();
|
|
|
|
this.line = new XFAObjectArray();
|
|
|
|
this.linear = new XFAObjectArray();
|
|
|
|
this.lockDocument = new XFAObjectArray();
|
|
|
|
this.manifest = new XFAObjectArray();
|
|
|
|
this.margin = new XFAObjectArray();
|
|
|
|
this.mdp = new XFAObjectArray();
|
|
|
|
this.medium = new XFAObjectArray();
|
|
|
|
this.message = new XFAObjectArray();
|
|
|
|
this.numericEdit = new XFAObjectArray();
|
|
|
|
this.occur = new XFAObjectArray();
|
|
|
|
this.oid = new XFAObjectArray();
|
|
|
|
this.oids = new XFAObjectArray();
|
|
|
|
this.overflow = new XFAObjectArray();
|
|
|
|
this.pageArea = new XFAObjectArray();
|
|
|
|
this.pageSet = new XFAObjectArray();
|
|
|
|
this.para = new XFAObjectArray();
|
|
|
|
this.passwordEdit = new XFAObjectArray();
|
|
|
|
this.pattern = new XFAObjectArray();
|
|
|
|
this.picture = new XFAObjectArray();
|
|
|
|
this.radial = new XFAObjectArray();
|
|
|
|
this.reason = new XFAObjectArray();
|
|
|
|
this.reasons = new XFAObjectArray();
|
|
|
|
this.rectangle = new XFAObjectArray();
|
|
|
|
this.ref = new XFAObjectArray();
|
|
|
|
this.script = new XFAObjectArray();
|
|
|
|
this.setProperty = new XFAObjectArray();
|
|
|
|
this.signData = new XFAObjectArray();
|
|
|
|
this.signature = new XFAObjectArray();
|
|
|
|
this.signing = new XFAObjectArray();
|
|
|
|
this.solid = new XFAObjectArray();
|
|
|
|
this.speak = new XFAObjectArray();
|
|
|
|
this.stipple = new XFAObjectArray();
|
|
|
|
this.subform = new XFAObjectArray();
|
|
|
|
this.subformSet = new XFAObjectArray();
|
|
|
|
this.subjectDN = new XFAObjectArray();
|
|
|
|
this.subjectDNs = new XFAObjectArray();
|
|
|
|
this.submit = new XFAObjectArray();
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
this.textEdit = new XFAObjectArray();
|
|
|
|
this.time = new XFAObjectArray();
|
|
|
|
this.timeStamp = new XFAObjectArray();
|
|
|
|
this.toolTip = new XFAObjectArray();
|
|
|
|
this.traversal = new XFAObjectArray();
|
|
|
|
this.traverse = new XFAObjectArray();
|
|
|
|
this.ui = new XFAObjectArray();
|
|
|
|
this.validate = new XFAObjectArray();
|
|
|
|
this.value = new XFAObjectArray();
|
|
|
|
this.variables = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Radial extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "radial", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["toEdge", "toCenter"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle](startColor) {
|
|
|
|
startColor = startColor ? startColor[$toStyle]() : "#FFFFFF";
|
|
|
|
const endColor = this.color ? this.color[$toStyle]() : "#000000";
|
|
|
|
const colors =
|
|
|
|
this.type === "toEdge"
|
|
|
|
? `${startColor},${endColor}`
|
|
|
|
: `${endColor},${startColor}`;
|
|
|
|
return `radial-gradient(circle to center, ${colors})`;
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Reason extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "reason");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Reasons extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "reasons", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.reason = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Rectangle extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "rectangle", /* hasChildren = */ true);
|
|
|
|
this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.corner = new XFAObjectArray(4);
|
|
|
|
this.edge = new XFAObjectArray(4);
|
|
|
|
this.fill = null;
|
|
|
|
}
|
2021-06-05 03:10:35 +09:00
|
|
|
|
|
|
|
[$toHTML]() {
|
|
|
|
const edge = this.edge.children.length
|
|
|
|
? this.edge.children[0]
|
|
|
|
: new Edge({});
|
|
|
|
const edgeStyle = edge[$toStyle]();
|
|
|
|
const style = Object.create(null);
|
|
|
|
if (this.fill) {
|
|
|
|
Object.assign(style, this.fill[$toStyle]());
|
|
|
|
} else {
|
|
|
|
style.fill = "transparent";
|
|
|
|
}
|
2021-06-20 22:45:54 +09:00
|
|
|
style.strokeWidth = measureToString(
|
|
|
|
edge.presence === "visible" ? 2 * edge.thickness : 0
|
|
|
|
);
|
2021-06-05 03:10:35 +09:00
|
|
|
style.stroke = edgeStyle.color;
|
|
|
|
|
|
|
|
const corner = this.corner.children.length
|
|
|
|
? this.corner.children[0]
|
|
|
|
: new Corner({});
|
|
|
|
const cornerStyle = corner[$toStyle]();
|
|
|
|
|
|
|
|
const rect = {
|
|
|
|
name: "rect",
|
|
|
|
attributes: {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
rx: cornerStyle.radius,
|
|
|
|
ry: cornerStyle.radius,
|
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return HTMLResult.success({
|
|
|
|
name: "svg",
|
|
|
|
children: [rect],
|
|
|
|
attributes: {
|
|
|
|
xmlns: SVG_NS,
|
|
|
|
style: {
|
|
|
|
position: "absolute",
|
|
|
|
},
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class RefElement extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "ref");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Script extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "script");
|
|
|
|
this.binding = attributes.binding || "";
|
|
|
|
this.contentType = attributes.contentType || "";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.runAt = getStringOption(attributes.runAt, [
|
|
|
|
"client",
|
|
|
|
"both",
|
|
|
|
"server",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SetProperty extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "setProperty");
|
|
|
|
this.connection = attributes.connection || "";
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SignData extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "signData", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.operation = getStringOption(attributes.operation, [
|
|
|
|
"sign",
|
|
|
|
"clear",
|
|
|
|
"verify",
|
|
|
|
]);
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.filter = null;
|
|
|
|
this.manifest = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Signature extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "signature", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["PDF1.3", "PDF1.6"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.border = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.filter = null;
|
|
|
|
this.manifest = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Signing extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "signing", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.certificate = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Solid extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "solid", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle](startColor) {
|
|
|
|
return startColor ? startColor[$toStyle]() : "#FFFFFF";
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Speak extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "speak");
|
|
|
|
this.disable = getInteger({
|
|
|
|
data: attributes.disable,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.priority = getStringOption(attributes.priority, [
|
|
|
|
"custom",
|
|
|
|
"caption",
|
|
|
|
"name",
|
|
|
|
"toolTip",
|
|
|
|
]);
|
|
|
|
this.rid = attributes.rid || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Stipple extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "stipple", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.rate = getInteger({
|
|
|
|
data: attributes.rate,
|
|
|
|
defaultValue: 50,
|
|
|
|
validate: x => x >= 0 && x <= 100,
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.color = null;
|
|
|
|
this.extras = null;
|
|
|
|
}
|
2021-03-25 21:02:39 +09:00
|
|
|
|
|
|
|
[$toStyle](bgColor) {
|
|
|
|
const alpha = this.rate / 100;
|
|
|
|
return Util.makeHexColor(
|
|
|
|
Math.round(bgColor.value.r * (1 - alpha) + this.value.r * alpha),
|
|
|
|
Math.round(bgColor.value.g * (1 - alpha) + this.value.g * alpha),
|
|
|
|
Math.round(bgColor.value.b * (1 - alpha) + this.value.b * alpha)
|
|
|
|
);
|
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Subform extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "subform", /* hasChildren = */ true);
|
|
|
|
this.access = getStringOption(attributes.access, [
|
|
|
|
"open",
|
|
|
|
"nonInteractive",
|
|
|
|
"protected",
|
|
|
|
"readOnly",
|
|
|
|
]);
|
|
|
|
this.allowMacro = getInteger({
|
|
|
|
data: attributes.allowMacro,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.anchorType = getStringOption(attributes.anchorType, [
|
|
|
|
"topLeft",
|
|
|
|
"bottomCenter",
|
|
|
|
"bottomLeft",
|
|
|
|
"bottomRight",
|
|
|
|
"middleCenter",
|
|
|
|
"middleLeft",
|
|
|
|
"middleRight",
|
|
|
|
"topCenter",
|
|
|
|
"topRight",
|
|
|
|
]);
|
|
|
|
this.colSpan = getInteger({
|
|
|
|
data: attributes.colSpan,
|
|
|
|
defaultValue: 1,
|
2021-05-19 18:09:21 +09:00
|
|
|
validate: n => n >= 1 || n === -1,
|
2021-02-01 23:12:19 +09:00
|
|
|
});
|
|
|
|
this.columnWidths = (attributes.columnWidths || "")
|
|
|
|
.trim()
|
|
|
|
.split(/\s+/)
|
|
|
|
.map(x => (x === "-1" ? -1 : getMeasurement(x)));
|
2021-03-31 22:42:21 +09:00
|
|
|
this.h = attributes.h ? getMeasurement(attributes.h) : "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.hAlign = getStringOption(attributes.hAlign, [
|
|
|
|
"left",
|
|
|
|
"center",
|
|
|
|
"justify",
|
|
|
|
"justifyAll",
|
|
|
|
"radix",
|
|
|
|
"right",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.layout = getStringOption(attributes.layout, [
|
|
|
|
"position",
|
|
|
|
"lr-tb",
|
|
|
|
"rl-row",
|
|
|
|
"rl-tb",
|
|
|
|
"row",
|
|
|
|
"table",
|
|
|
|
"tb",
|
|
|
|
]);
|
|
|
|
this.locale = attributes.locale || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.maxH = getMeasurement(attributes.maxH, "0pt");
|
|
|
|
this.maxW = getMeasurement(attributes.maxW, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.mergeMode = getStringOption(attributes.mergeMode, [
|
|
|
|
"consumeData",
|
|
|
|
"matchTemplate",
|
|
|
|
]);
|
2021-03-31 22:42:21 +09:00
|
|
|
this.minH = getMeasurement(attributes.minH, "0pt");
|
|
|
|
this.minW = getMeasurement(attributes.minW, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.presence = getStringOption(attributes.presence, [
|
|
|
|
"visible",
|
|
|
|
"hidden",
|
|
|
|
"inactive",
|
|
|
|
"invisible",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.restoreState = getStringOption(attributes.restoreState, [
|
|
|
|
"manual",
|
|
|
|
"auto",
|
|
|
|
]);
|
|
|
|
this.scope = getStringOption(attributes.scope, ["name", "none"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
2021-03-31 22:42:21 +09:00
|
|
|
this.w = attributes.w ? getMeasurement(attributes.w) : "";
|
|
|
|
this.x = getMeasurement(attributes.x, "0pt");
|
|
|
|
this.y = getMeasurement(attributes.y, "0pt");
|
2021-02-01 23:12:19 +09:00
|
|
|
this.assist = null;
|
|
|
|
this.bind = null;
|
|
|
|
this.bookend = null;
|
|
|
|
this.border = null;
|
|
|
|
this.break = null;
|
|
|
|
this.calculate = null;
|
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.keep = null;
|
|
|
|
this.margin = null;
|
|
|
|
this.occur = null;
|
|
|
|
this.overflow = null;
|
|
|
|
this.pageSet = null;
|
|
|
|
this.para = null;
|
|
|
|
this.traversal = null;
|
|
|
|
this.validate = null;
|
|
|
|
this.variables = null;
|
|
|
|
this.area = new XFAObjectArray();
|
|
|
|
this.breakAfter = new XFAObjectArray();
|
|
|
|
this.breakBefore = new XFAObjectArray();
|
|
|
|
this.connect = new XFAObjectArray();
|
|
|
|
this.draw = new XFAObjectArray();
|
|
|
|
this.event = new XFAObjectArray();
|
|
|
|
this.exObject = new XFAObjectArray();
|
|
|
|
this.exclGroup = new XFAObjectArray();
|
|
|
|
this.field = new XFAObjectArray();
|
|
|
|
this.proto = new XFAObjectArray();
|
|
|
|
this.setProperty = new XFAObjectArray();
|
|
|
|
this.subform = new XFAObjectArray();
|
|
|
|
this.subformSet = new XFAObjectArray();
|
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
|
2021-06-12 00:49:13 +09:00
|
|
|
*[$getContainedChildren]() {
|
|
|
|
// This function is overriden in order to fake that subforms under
|
|
|
|
// this set are in fact under parent subform.
|
|
|
|
yield* getContainedChildren(this);
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$flushHTML]() {
|
|
|
|
return flushHTML(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
[$addHTML](html, bbox) {
|
|
|
|
addHTML(this, html, bbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
[$getAvailableSpace]() {
|
|
|
|
return getAvailableSpace(this);
|
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
[$isSplittable](x) {
|
|
|
|
// We cannot cache the result here because the contentArea
|
|
|
|
// can change.
|
|
|
|
const root = this[$getTemplateRoot]();
|
|
|
|
const contentArea = root[$extra].currentContentArea;
|
|
|
|
if (contentArea && Math.max(this.minH, this.h || 0) >= contentArea.h) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.layout === "position") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.keep && this.keep.intact !== "none") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const parentLayout = this[$getParent]().layout;
|
|
|
|
if (parentLayout && parentLayout.includes("row")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.overflow && this.overflow.target) {
|
|
|
|
const target = root[$searchNode](this.overflow.target, this);
|
|
|
|
return target && target[0] === contentArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
|
|
|
if (this.presence === "hidden" || this.presence === "inactive") {
|
|
|
|
return HTMLResult.EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
this.breakBefore.children.length > 1 ||
|
|
|
|
this.breakAfter.children.length > 1
|
|
|
|
) {
|
|
|
|
// Specs are always talking about the breakBefore element
|
|
|
|
// and it doesn't really make sense to have several ones.
|
|
|
|
warn(
|
|
|
|
"XFA - Several breakBefore or breakAfter in subforms: please file a bug."
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
if (this.breakBefore.children.length >= 1) {
|
|
|
|
const breakBefore = this.breakBefore.children[0];
|
|
|
|
if (!breakBefore[$extra]) {
|
|
|
|
// Set $extra to true to consume it.
|
|
|
|
breakBefore[$extra] = true;
|
|
|
|
return HTMLResult.breakNode(breakBefore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this[$extra] && this[$extra].afterBreakAfter) {
|
2021-06-16 23:02:41 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-06-14 01:57:51 +09:00
|
|
|
}
|
|
|
|
|
2021-03-19 18:11:40 +09:00
|
|
|
// TODO: incomplete.
|
2021-05-19 18:09:21 +09:00
|
|
|
fixDimensions(this);
|
|
|
|
const children = [];
|
|
|
|
const attributes = {
|
|
|
|
id: this[$uid],
|
2021-06-21 01:56:14 +09:00
|
|
|
class: [],
|
2021-05-19 18:09:21 +09:00
|
|
|
};
|
2021-03-19 18:11:40 +09:00
|
|
|
|
2021-06-21 01:56:14 +09:00
|
|
|
setAccess(this, attributes.class);
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (!this[$extra]) {
|
|
|
|
this[$extra] = Object.create(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.assign(this[$extra], {
|
|
|
|
children,
|
|
|
|
attributes,
|
|
|
|
attempt: 0,
|
|
|
|
availableSpace,
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
prevHeight: 0,
|
|
|
|
currentWidth: 0,
|
|
|
|
});
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
if (!checkDimensions(this, availableSpace)) {
|
|
|
|
return HTMLResult.FAILURE;
|
2021-06-14 01:57:51 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const filter = new Set([
|
|
|
|
"area",
|
|
|
|
"draw",
|
|
|
|
"exclGroup",
|
|
|
|
"field",
|
|
|
|
"subform",
|
|
|
|
"subformSet",
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (this.layout.includes("row")) {
|
2021-06-12 00:49:13 +09:00
|
|
|
const columnWidths = this[$getSubformParent]().columnWidths;
|
2021-03-26 00:54:36 +09:00
|
|
|
if (Array.isArray(columnWidths) && columnWidths.length > 0) {
|
|
|
|
this[$extra].columnWidths = columnWidths;
|
|
|
|
this[$extra].currentColumn = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const style = toStyle(
|
|
|
|
this,
|
|
|
|
"anchorType",
|
|
|
|
"dimensions",
|
|
|
|
"position",
|
|
|
|
"presence",
|
2021-06-03 02:14:41 +09:00
|
|
|
"border",
|
|
|
|
"margin",
|
2021-05-19 18:09:21 +09:00
|
|
|
"hAlign"
|
|
|
|
);
|
2021-05-28 18:17:38 +09:00
|
|
|
const classNames = ["xfaSubform"];
|
2021-03-31 22:42:21 +09:00
|
|
|
const cl = layoutClass(this);
|
|
|
|
if (cl) {
|
2021-05-28 18:17:38 +09:00
|
|
|
classNames.push(cl);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
attributes.style = style;
|
2021-06-03 02:14:41 +09:00
|
|
|
attributes.class = classNames;
|
2021-03-19 18:11:40 +09:00
|
|
|
|
|
|
|
if (this.name) {
|
2021-03-25 21:02:39 +09:00
|
|
|
attributes.xfaName = this.name;
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
const isSplittable = this[$isSplittable]();
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
// If the container overflows into itself we add an extra
|
|
|
|
// layout step to accept finally the element which caused
|
|
|
|
// the overflow.
|
|
|
|
let maxRun =
|
|
|
|
this.layout === "lr-tb" || this.layout === "rl-tb"
|
|
|
|
? MAX_ATTEMPTS_FOR_LRTB_LAYOUT
|
|
|
|
: 1;
|
2021-06-16 23:02:41 +09:00
|
|
|
maxRun += !isSplittable && this.layout !== "position" ? 1 : 0;
|
2021-06-14 01:57:51 +09:00
|
|
|
for (; this[$extra].attempt < maxRun; this[$extra].attempt++) {
|
|
|
|
const result = this[$childrenToHTML]({
|
2021-05-19 18:09:21 +09:00
|
|
|
filter,
|
|
|
|
include: true,
|
|
|
|
});
|
2021-06-14 01:57:51 +09:00
|
|
|
if (result.success) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (result.isBreak()) {
|
|
|
|
return result;
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
if (this[$extra].attempt === maxRun) {
|
|
|
|
if (this.overflow) {
|
2021-06-16 23:02:41 +09:00
|
|
|
this[$getTemplateRoot]()[$extra].overflowNode = this.overflow;
|
2021-06-14 01:57:51 +09:00
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
if (!isSplittable) {
|
|
|
|
// Since a new try will happen in a new container with maybe
|
|
|
|
// new dimensions, we invalidate already layed out components.
|
2021-06-03 02:14:41 +09:00
|
|
|
delete this[$extra];
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
let marginH = 0;
|
|
|
|
let marginV = 0;
|
|
|
|
if (this.margin) {
|
|
|
|
marginH = this.margin.leftInset + this.margin.rightInset;
|
|
|
|
marginV = this.margin.topInset + this.margin.bottomInset;
|
|
|
|
}
|
|
|
|
|
2021-06-16 23:02:41 +09:00
|
|
|
const width = Math.max(this[$extra].width + marginH, this.w || 0);
|
|
|
|
const height = Math.max(this[$extra].height + marginV, this.h || 0);
|
|
|
|
const bbox = [this.x, this.y, width, height];
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.w === "") {
|
2021-06-16 23:02:41 +09:00
|
|
|
style.width = measureToString(width);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
if (this.h === "") {
|
2021-06-16 23:02:41 +09:00
|
|
|
style.height = measureToString(height);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
const html = {
|
2021-03-19 18:11:40 +09:00
|
|
|
name: "div",
|
|
|
|
attributes,
|
|
|
|
children,
|
|
|
|
};
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
const result = HTMLResult.success(createWrapper(this, html), bbox);
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (this.breakAfter.children.length >= 1) {
|
|
|
|
const breakAfter = this.breakAfter.children[0];
|
2021-06-14 01:57:51 +09:00
|
|
|
this[$extra].afterBreakAfter = result;
|
|
|
|
return HTMLResult.breakNode(breakAfter);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
delete this[$extra];
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
return result;
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class SubformSet extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "subformSet", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.relation = getStringOption(attributes.relation, [
|
|
|
|
"ordered",
|
|
|
|
"choice",
|
|
|
|
"unordered",
|
|
|
|
]);
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.bookend = null;
|
|
|
|
this.break = null;
|
|
|
|
this.desc = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.occur = null;
|
|
|
|
this.overflow = null;
|
|
|
|
this.breakAfter = new XFAObjectArray();
|
|
|
|
this.breakBefore = new XFAObjectArray();
|
|
|
|
this.subform = new XFAObjectArray();
|
|
|
|
this.subformSet = new XFAObjectArray();
|
2021-05-19 18:09:21 +09:00
|
|
|
|
2021-06-12 00:49:13 +09:00
|
|
|
// TODO: need to handle break stuff and relation.
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
|
2021-06-12 00:49:13 +09:00
|
|
|
*[$getContainedChildren]() {
|
|
|
|
// This function is overriden in order to fake that subforms under
|
|
|
|
// this set are in fact under parent subform.
|
|
|
|
yield* getContainedChildren(this);
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
|
2021-06-12 00:49:13 +09:00
|
|
|
[$getSubformParent]() {
|
|
|
|
let parent = this[$getParent]();
|
|
|
|
while (!(parent instanceof Subform)) {
|
|
|
|
parent = parent[$getParent]();
|
|
|
|
}
|
|
|
|
return parent;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class SubjectDN extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "subjectDN");
|
|
|
|
this.delimiter = attributes.delimiter || ",";
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
|
|
|
this[$content] = new Map(
|
|
|
|
this[$content].split(this.delimiter).map(kv => {
|
|
|
|
kv = kv.split("=", 2);
|
|
|
|
kv[0] = kv[0].trim();
|
|
|
|
return kv;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SubjectDNs extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "subjectDNs", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.subjectDN = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Submit extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "submit", /* hasChildren = */ true);
|
|
|
|
this.embedPDF = getInteger({
|
|
|
|
data: attributes.embedPDF,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.format = getStringOption(attributes.format, [
|
|
|
|
"xdp",
|
|
|
|
"formdata",
|
|
|
|
"pdf",
|
|
|
|
"urlencoded",
|
|
|
|
"xfd",
|
|
|
|
"xml",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.target = attributes.target || "";
|
|
|
|
this.textEncoding = getKeyword({
|
|
|
|
data: attributes.textEncoding
|
|
|
|
? attributes.textEncoding.toLowerCase()
|
|
|
|
: "",
|
|
|
|
defaultValue: "",
|
|
|
|
validate: k =>
|
|
|
|
[
|
|
|
|
"utf-8",
|
|
|
|
"big-five",
|
|
|
|
"fontspecific",
|
|
|
|
"gbk",
|
|
|
|
"gb-18030",
|
|
|
|
"gb-2312",
|
|
|
|
"ksc-5601",
|
|
|
|
"none",
|
|
|
|
"shift-jis",
|
|
|
|
"ucs-2",
|
|
|
|
"utf-16",
|
|
|
|
].includes(k) || k.match(/iso-8859-[0-9]{2}/),
|
|
|
|
});
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.xdpContent = attributes.xdpContent || "";
|
|
|
|
this.encrypt = null;
|
|
|
|
this.encryptData = new XFAObjectArray();
|
|
|
|
this.signData = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Template extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "template", /* hasChildren = */ true);
|
|
|
|
this.baseProfile = getStringOption(attributes.baseProfile, [
|
|
|
|
"full",
|
|
|
|
"interactiveForms",
|
|
|
|
]);
|
|
|
|
this.extras = null;
|
2021-03-19 18:11:40 +09:00
|
|
|
|
|
|
|
// Spec is unclear:
|
|
|
|
// A container element that describes a single subform capable of
|
|
|
|
// enclosing other containers.
|
|
|
|
// Can we have more than one subform ?
|
2021-02-01 23:12:19 +09:00
|
|
|
this.subform = new XFAObjectArray();
|
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
|
|
|
|
[$finalize]() {
|
|
|
|
if (this.subform.children.length === 0) {
|
|
|
|
warn("XFA - No subforms in template node.");
|
|
|
|
}
|
|
|
|
if (this.subform.children.length >= 2) {
|
|
|
|
warn("XFA - Several subforms in template node: please file a bug.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$searchNode](expr, container) {
|
|
|
|
if (expr.startsWith("#")) {
|
|
|
|
// This is an id.
|
|
|
|
return [this[$ids].get(expr.slice(1))];
|
|
|
|
}
|
|
|
|
return searchNode(this, container, expr, true, true);
|
|
|
|
}
|
|
|
|
|
2021-03-19 18:11:40 +09:00
|
|
|
[$toHTML]() {
|
2021-05-19 18:09:21 +09:00
|
|
|
if (!this.subform.children.length) {
|
|
|
|
return HTMLResult.success({
|
|
|
|
name: "div",
|
|
|
|
children: [],
|
|
|
|
});
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
this[$extra] = {
|
2021-06-14 01:57:51 +09:00
|
|
|
overflowNode: null,
|
2021-05-19 18:09:21 +09:00
|
|
|
pageNumber: 1,
|
|
|
|
pagePosition: "first",
|
|
|
|
oddOrEven: "odd",
|
|
|
|
blankOrNotBlank: "nonBlank",
|
|
|
|
};
|
|
|
|
|
|
|
|
const root = this.subform.children[0];
|
2021-06-21 23:02:33 +09:00
|
|
|
root.pageSet[$cleanPage]();
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const pageAreas = root.pageSet.pageArea.children;
|
|
|
|
const mainHtml = {
|
2021-03-19 18:11:40 +09:00
|
|
|
name: "div",
|
|
|
|
children: [],
|
|
|
|
};
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
let pageArea = null;
|
|
|
|
let breakBefore = null;
|
|
|
|
let breakBeforeTarget = null;
|
|
|
|
if (root.breakBefore.children.length >= 1) {
|
|
|
|
breakBefore = root.breakBefore.children[0];
|
|
|
|
breakBeforeTarget = breakBefore.target;
|
|
|
|
} else if (
|
|
|
|
root.subform.children.length >= 1 &&
|
|
|
|
root.subform.children[0].breakBefore.children.length >= 1
|
|
|
|
) {
|
|
|
|
breakBefore = root.subform.children[0].breakBefore.children[0];
|
|
|
|
breakBeforeTarget = breakBefore.target;
|
|
|
|
} else if (root.break && root.break.beforeTarget) {
|
|
|
|
breakBefore = root.break;
|
|
|
|
breakBeforeTarget = breakBefore.beforeTarget;
|
|
|
|
} else if (
|
|
|
|
root.subform.children.length >= 1 &&
|
|
|
|
root.subform.children[0].break &&
|
|
|
|
root.subform.children[0].break.beforeTarget
|
|
|
|
) {
|
|
|
|
breakBefore = root.subform.children[0].break;
|
|
|
|
breakBeforeTarget = breakBefore.beforeTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (breakBefore) {
|
|
|
|
const target = this[$searchNode](
|
|
|
|
breakBeforeTarget,
|
|
|
|
breakBefore[$getParent]()
|
|
|
|
);
|
|
|
|
if (target instanceof PageArea) {
|
|
|
|
pageArea = target;
|
|
|
|
// Consume breakBefore.
|
|
|
|
breakBefore[$extra] = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pageArea) {
|
|
|
|
pageArea = pageAreas[0];
|
|
|
|
}
|
|
|
|
|
2021-06-21 23:02:33 +09:00
|
|
|
pageArea[$extra] = {
|
|
|
|
numberOfUse: 1,
|
|
|
|
};
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
const pageAreaParent = pageArea[$getParent]();
|
|
|
|
pageAreaParent[$extra] = {
|
|
|
|
numberOfUse: 1,
|
2021-06-21 23:02:33 +09:00
|
|
|
pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
|
|
|
|
pageSetIndex: 0,
|
2021-05-19 18:09:21 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
let targetPageArea;
|
|
|
|
let leader = null;
|
|
|
|
let trailer = null;
|
2021-06-14 01:57:51 +09:00
|
|
|
let hasSomething = true;
|
|
|
|
let hasSomethingCounter = 0;
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
while (true) {
|
2021-06-14 01:57:51 +09:00
|
|
|
if (!hasSomething) {
|
|
|
|
// Nothing has been added in the previous page
|
|
|
|
if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
|
|
|
|
warn("XFA - Something goes wrong: please file a bug.");
|
|
|
|
return mainHtml;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hasSomethingCounter = 0;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
targetPageArea = null;
|
|
|
|
const page = pageArea[$toHTML]().html;
|
|
|
|
mainHtml.children.push(page);
|
|
|
|
|
|
|
|
if (leader) {
|
2021-06-16 23:02:41 +09:00
|
|
|
page.children.push(leader[$toHTML](pageArea[$extra].space).html);
|
2021-05-19 18:09:21 +09:00
|
|
|
leader = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trailer) {
|
2021-06-16 23:02:41 +09:00
|
|
|
page.children.push(trailer[$toHTML](pageArea[$extra].space).html);
|
2021-05-19 18:09:21 +09:00
|
|
|
trailer = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const contentAreas = pageArea.contentArea.children;
|
2021-06-03 02:14:41 +09:00
|
|
|
const htmlContentAreas = page.children.filter(node =>
|
|
|
|
node.attributes.class.includes("xfaContentarea")
|
2021-05-19 18:09:21 +09:00
|
|
|
);
|
2021-06-14 01:57:51 +09:00
|
|
|
|
|
|
|
hasSomething = false;
|
|
|
|
|
|
|
|
const flush = index => {
|
|
|
|
const html = root[$flushHTML]();
|
|
|
|
if (html) {
|
2021-06-24 02:42:36 +09:00
|
|
|
hasSomething =
|
|
|
|
hasSomething || (html.children && html.children.length !== 0);
|
2021-06-14 01:57:51 +09:00
|
|
|
htmlContentAreas[index].children.push(html);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
for (let i = 0, ii = contentAreas.length; i < ii; i++) {
|
|
|
|
const contentArea = (this[$extra].currentContentArea = contentAreas[i]);
|
|
|
|
const space = { width: contentArea.w, height: contentArea.h };
|
|
|
|
|
|
|
|
if (leader) {
|
|
|
|
htmlContentAreas[i].children.push(leader[$toHTML](space).html);
|
|
|
|
leader = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trailer) {
|
|
|
|
htmlContentAreas[i].children.push(trailer[$toHTML](space).html);
|
|
|
|
trailer = null;
|
|
|
|
}
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
const html = root[$toHTML](space);
|
2021-05-19 18:09:21 +09:00
|
|
|
if (html.success) {
|
|
|
|
if (html.html) {
|
2021-06-24 02:42:36 +09:00
|
|
|
hasSomething =
|
|
|
|
hasSomething ||
|
|
|
|
(html.html.children && html.html.children.length !== 0);
|
2021-05-19 18:09:21 +09:00
|
|
|
htmlContentAreas[i].children.push(html.html);
|
2021-06-16 23:02:41 +09:00
|
|
|
} else if (!hasSomething) {
|
|
|
|
mainHtml.children.pop();
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
return mainHtml;
|
|
|
|
}
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
if (html.isBreak()) {
|
|
|
|
const node = html.breakNode;
|
2021-05-19 18:09:21 +09:00
|
|
|
|
|
|
|
if (node.targetType === "auto") {
|
2021-06-14 01:57:51 +09:00
|
|
|
flush(i);
|
2021-05-19 18:09:21 +09:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const startNew = node.startNew === 1;
|
|
|
|
|
|
|
|
if (node.leader) {
|
|
|
|
leader = this[$searchNode](node.leader, node[$getParent]());
|
|
|
|
leader = leader ? leader[0] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node.trailer) {
|
|
|
|
trailer = this[$searchNode](node.trailer, node[$getParent]());
|
|
|
|
trailer = trailer ? trailer[0] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let target = null;
|
|
|
|
if (node.target) {
|
|
|
|
target = this[$searchNode](node.target, node[$getParent]());
|
|
|
|
target = target ? target[0] : target;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node.targetType === "pageArea") {
|
2021-06-21 23:02:33 +09:00
|
|
|
if (!(target instanceof PageArea)) {
|
|
|
|
target = null;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
if (startNew) {
|
2021-06-21 23:02:33 +09:00
|
|
|
targetPageArea = target || pageArea;
|
2021-06-14 01:57:51 +09:00
|
|
|
flush(i);
|
|
|
|
i = Infinity;
|
2021-06-21 23:02:33 +09:00
|
|
|
} else if (target && target !== pageArea) {
|
2021-05-19 18:09:21 +09:00
|
|
|
targetPageArea = target;
|
2021-06-14 01:57:51 +09:00
|
|
|
flush(i);
|
|
|
|
i = Infinity;
|
2021-06-21 23:02:33 +09:00
|
|
|
} else {
|
|
|
|
i--;
|
2021-06-14 01:57:51 +09:00
|
|
|
}
|
|
|
|
} else if (node.targetType === "contentArea") {
|
2021-06-21 23:02:33 +09:00
|
|
|
if (!(target instanceof ContentArea)) {
|
|
|
|
target = null;
|
|
|
|
}
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
const index = contentAreas.findIndex(e => e === target);
|
|
|
|
if (index !== -1) {
|
|
|
|
flush(i);
|
|
|
|
i = index - 1;
|
|
|
|
} else {
|
|
|
|
i--;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
}
|
2021-06-14 01:57:51 +09:00
|
|
|
continue;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
if (this[$extra].overflowNode) {
|
|
|
|
const node = this[$extra].overflowNode;
|
|
|
|
this[$extra].overflowNode = null;
|
2021-05-19 18:09:21 +09:00
|
|
|
|
2021-06-14 01:57:51 +09:00
|
|
|
flush(i);
|
|
|
|
|
|
|
|
if (node.leader) {
|
|
|
|
leader = this[$searchNode](node.leader, node[$getParent]());
|
|
|
|
leader = leader ? leader[0] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node.trailer) {
|
|
|
|
trailer = this[$searchNode](node.trailer, node[$getParent]());
|
|
|
|
trailer = trailer ? trailer[0] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let target = null;
|
|
|
|
if (node.target) {
|
|
|
|
target = this[$searchNode](node.target, node[$getParent]());
|
|
|
|
target = target ? target[0] : target;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target instanceof PageArea) {
|
|
|
|
// We must stop the contentAreas filling and go to the next page.
|
|
|
|
targetPageArea = target;
|
|
|
|
i = Infinity;
|
|
|
|
continue;
|
|
|
|
} else if (target instanceof ContentArea) {
|
|
|
|
const index = contentAreas.findIndex(e => e === target);
|
|
|
|
if (index !== -1) {
|
|
|
|
i = index - 1;
|
|
|
|
} else {
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
2021-06-14 01:57:51 +09:00
|
|
|
|
|
|
|
flush(i);
|
2021-05-19 18:09:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
this[$extra].pageNumber += 1;
|
2021-06-21 23:02:33 +09:00
|
|
|
if (targetPageArea) {
|
|
|
|
if (targetPageArea[$isUsable]()) {
|
|
|
|
targetPageArea[$extra].numberOfUse += 1;
|
|
|
|
} else {
|
|
|
|
targetPageArea = null;
|
|
|
|
}
|
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
pageArea = targetPageArea || pageArea[$getNextPage]();
|
|
|
|
}
|
2021-03-19 18:11:40 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Text extends ContentObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "text");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.maxChars = getInteger({
|
|
|
|
data: attributes.maxChars,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x >= 0,
|
|
|
|
});
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.rid = attributes.rid || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
[$acceptWhitespace]() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-01 23:12:19 +09:00
|
|
|
[$onChild](child) {
|
|
|
|
if (child[$namespaceId] === NamespaceIds.xhtml.id) {
|
|
|
|
this[$content] = child;
|
2021-02-18 18:32:25 +09:00
|
|
|
return true;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-02-18 18:32:25 +09:00
|
|
|
warn(`XFA - Invalid content in Text: ${child[$nodeName]}.`);
|
|
|
|
return false;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-06-03 02:14:41 +09:00
|
|
|
[$onText](str) {
|
|
|
|
if (this[$content] instanceof XFAObject) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
super[$onText](str);
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
if (typeof this[$content] === "string") {
|
2021-03-26 00:54:36 +09:00
|
|
|
// \u2028 is a line separator.
|
|
|
|
// \u2029 is a paragraph separator.
|
2021-06-11 16:58:56 +09:00
|
|
|
const html = valueToHtml(this[$content]).html;
|
2021-03-26 00:54:36 +09:00
|
|
|
|
|
|
|
if (this[$content].includes("\u2029")) {
|
|
|
|
// We've plain text containing a paragraph separator
|
|
|
|
// so convert it into a set of <p>.
|
|
|
|
html.name = "div";
|
|
|
|
html.children = [];
|
|
|
|
this[$content]
|
|
|
|
.split("\u2029")
|
|
|
|
.map(para =>
|
|
|
|
// Convert a paragraph into a set of <span> (for lines)
|
|
|
|
// separated by <br>.
|
|
|
|
para.split(/[\u2028\n]/).reduce((acc, line) => {
|
|
|
|
acc.push(
|
|
|
|
{
|
|
|
|
name: "span",
|
|
|
|
value: line,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "br",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
return acc;
|
|
|
|
}, [])
|
|
|
|
)
|
|
|
|
.forEach(lines => {
|
|
|
|
html.children.push({
|
|
|
|
name: "p",
|
|
|
|
children: lines,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (/[\u2028\n]/.test(this[$content])) {
|
|
|
|
html.name = "div";
|
|
|
|
html.children = [];
|
|
|
|
// Convert plain text into a set of <span> (for lines)
|
|
|
|
// separated by <br>.
|
|
|
|
this[$content].split(/[\u2028\n]/).forEach(line => {
|
|
|
|
html.children.push(
|
|
|
|
{
|
|
|
|
name: "span",
|
|
|
|
value: line,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "br",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success(html);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-03-26 00:54:36 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return this[$content][$toHTML](availableSpace);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class TextEdit extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "textEdit", /* hasChildren = */ true);
|
|
|
|
this.allowRichText = getInteger({
|
|
|
|
data: attributes.allowRichText,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, [
|
|
|
|
"auto",
|
|
|
|
"off",
|
|
|
|
"on",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
2021-06-17 03:15:24 +09:00
|
|
|
this.multiLine = attributes.multiLine || "";
|
2021-02-01 23:12:19 +09:00
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.vScrollPolicy = getStringOption(attributes.vScrollPolicy, [
|
|
|
|
"auto",
|
|
|
|
"off",
|
|
|
|
"on",
|
|
|
|
]);
|
|
|
|
this.border = null;
|
|
|
|
this.comb = null;
|
|
|
|
this.extras = null;
|
|
|
|
this.margin = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-06-17 03:15:24 +09:00
|
|
|
[$clean](builder) {
|
|
|
|
super[$clean](builder);
|
|
|
|
const parent = this[$getParent]();
|
|
|
|
const defaultValue = parent instanceof Draw ? 1 : 0;
|
|
|
|
this.multiLine = getInteger({
|
|
|
|
data: this.multiLine,
|
|
|
|
defaultValue,
|
|
|
|
validate: x => x === 0 || x === 1,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: incomplete.
|
|
|
|
const style = toStyle(this, "border", "font", "margin");
|
|
|
|
let html;
|
2021-03-26 00:54:36 +09:00
|
|
|
if (this.multiLine === 1) {
|
2021-03-31 22:42:21 +09:00
|
|
|
html = {
|
|
|
|
name: "textarea",
|
|
|
|
attributes: {
|
2021-05-24 20:42:42 +09:00
|
|
|
fieldId: this[$getParent]()[$getParent]()[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaTextfield"],
|
2021-03-31 22:42:21 +09:00
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
html = {
|
|
|
|
name: "input",
|
|
|
|
attributes: {
|
|
|
|
type: "text",
|
2021-05-24 20:42:42 +09:00
|
|
|
fieldId: this[$getParent]()[$getParent]()[$uid],
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaTextfield"],
|
2021-03-31 22:42:21 +09:00
|
|
|
style,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.success({
|
2021-03-31 22:42:21 +09:00
|
|
|
name: "label",
|
|
|
|
attributes: {
|
2021-06-03 02:14:41 +09:00
|
|
|
class: ["xfaLabel"],
|
2021-03-31 22:42:21 +09:00
|
|
|
},
|
|
|
|
children: [html],
|
2021-05-19 18:09:21 +09:00
|
|
|
});
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Time extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "time");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.name = attributes.name || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
|
|
|
|
[$finalize]() {
|
2021-06-11 16:58:56 +09:00
|
|
|
// TODO: need to handle the string as a time and not as a date.
|
|
|
|
const date = this[$content].trim();
|
|
|
|
this[$content] = date ? new Date(date) : null;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-06-11 16:58:56 +09:00
|
|
|
return valueToHtml(this[$content] ? this[$content].toString() : "");
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class TimeStamp extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "timeStamp");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.server = attributes.server || "";
|
|
|
|
this.type = getStringOption(attributes.type, ["optional", "required"]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ToolTip extends StringObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "toolTip");
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.rid = attributes.rid || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Traversal extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "traversal", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.traverse = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Traverse extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "traverse", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.operation = getStringOption(attributes.operation, [
|
|
|
|
"next",
|
|
|
|
"back",
|
|
|
|
"down",
|
|
|
|
"first",
|
|
|
|
"left",
|
|
|
|
"right",
|
|
|
|
"up",
|
|
|
|
]);
|
|
|
|
this.ref = attributes.ref || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.script = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
get name() {
|
|
|
|
// SOM expression: see page 94
|
|
|
|
return this.operation;
|
|
|
|
}
|
|
|
|
|
|
|
|
[$isTransparent]() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Ui extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "ui", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.picture = null;
|
|
|
|
|
|
|
|
// One-of properties
|
|
|
|
this.barcode = null;
|
|
|
|
this.button = null;
|
|
|
|
this.checkButton = null;
|
|
|
|
this.choiceList = null;
|
|
|
|
this.dateTimeEdit = null;
|
|
|
|
this.defaultUi = null;
|
|
|
|
this.imageEdit = null;
|
|
|
|
this.numericEdit = null;
|
|
|
|
this.passwordEdit = null;
|
|
|
|
this.signature = null;
|
|
|
|
this.textEdit = null;
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
// TODO: picture.
|
|
|
|
for (const name of Object.getOwnPropertyNames(this)) {
|
|
|
|
if (name === "extras" || name === "picture") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const obj = this[name];
|
|
|
|
if (!(obj instanceof XFAObject)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return obj[$toHTML](availableSpace);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Validate extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "validate", /* hasChildren = */ true);
|
|
|
|
this.formatTest = getStringOption(attributes.formatTest, [
|
|
|
|
"warning",
|
|
|
|
"disabled",
|
|
|
|
"error",
|
|
|
|
]);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.nullTest = getStringOption(attributes.nullTest, [
|
|
|
|
"disabled",
|
|
|
|
"error",
|
|
|
|
"warning",
|
|
|
|
]);
|
|
|
|
this.scriptTest = getStringOption(attributes.scriptTest, [
|
|
|
|
"error",
|
|
|
|
"disabled",
|
|
|
|
"warning",
|
|
|
|
]);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.extras = null;
|
|
|
|
this.message = null;
|
|
|
|
this.picture = null;
|
|
|
|
this.script = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Value extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "value", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.override = getInteger({
|
|
|
|
data: attributes.override,
|
|
|
|
defaultValue: 0,
|
|
|
|
validate: x => x === 1,
|
|
|
|
});
|
|
|
|
this.relevant = getRelevant(attributes.relevant);
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
|
|
|
|
// One-of properties
|
|
|
|
this.arc = null;
|
|
|
|
this.boolean = null;
|
|
|
|
this.date = null;
|
|
|
|
this.dateTime = null;
|
|
|
|
this.decimal = null;
|
|
|
|
this.exData = null;
|
|
|
|
this.float = null;
|
|
|
|
this.image = null;
|
|
|
|
this.integer = null;
|
|
|
|
this.line = null;
|
|
|
|
this.rectangle = null;
|
|
|
|
this.text = null;
|
|
|
|
this.time = null;
|
|
|
|
}
|
2021-02-25 03:05:04 +09:00
|
|
|
|
|
|
|
[$setValue](value) {
|
2021-05-19 18:09:21 +09:00
|
|
|
const parent = this[$getParent]();
|
|
|
|
if (parent instanceof Field) {
|
|
|
|
if (parent.ui && parent.ui.imageEdit) {
|
|
|
|
if (!this.image) {
|
|
|
|
this.image = new Image({});
|
|
|
|
}
|
|
|
|
this.image[$content] = value[$content];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-25 03:05:04 +09:00
|
|
|
const valueName = value[$nodeName];
|
|
|
|
if (this[valueName] !== null) {
|
|
|
|
this[valueName][$content] = value[$content];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset all the properties.
|
|
|
|
for (const name of Object.getOwnPropertyNames(this)) {
|
|
|
|
const obj = this[name];
|
|
|
|
if (obj instanceof XFAObject) {
|
|
|
|
this[name] = null;
|
|
|
|
this[$removeChild](obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this[value[$nodeName]] = value;
|
|
|
|
this[$appendChild](value);
|
|
|
|
}
|
2021-03-31 22:42:21 +09:00
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
[$text]() {
|
|
|
|
if (this.exData) {
|
|
|
|
return this.exData[$content][$text]().trim();
|
|
|
|
}
|
|
|
|
for (const name of Object.getOwnPropertyNames(this)) {
|
|
|
|
if (name === "image") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const obj = this[name];
|
|
|
|
if (obj instanceof XFAObject) {
|
|
|
|
return (obj[$content] || "").toString().trim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
[$toHTML](availableSpace) {
|
2021-03-31 22:42:21 +09:00
|
|
|
for (const name of Object.getOwnPropertyNames(this)) {
|
|
|
|
const obj = this[name];
|
|
|
|
if (!(obj instanceof XFAObject)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return obj[$toHTML](availableSpace);
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
|
|
|
|
2021-05-19 18:09:21 +09:00
|
|
|
return HTMLResult.EMPTY;
|
2021-03-31 22:42:21 +09:00
|
|
|
}
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
class Variables extends XFAObject {
|
|
|
|
constructor(attributes) {
|
|
|
|
super(TEMPLATE_NS_ID, "variables", /* hasChildren = */ true);
|
|
|
|
this.id = attributes.id || "";
|
|
|
|
this.use = attributes.use || "";
|
|
|
|
this.usehref = attributes.usehref || "";
|
|
|
|
this.boolean = new XFAObjectArray();
|
|
|
|
this.date = new XFAObjectArray();
|
|
|
|
this.dateTime = new XFAObjectArray();
|
|
|
|
this.decimal = new XFAObjectArray();
|
|
|
|
this.exData = new XFAObjectArray();
|
|
|
|
this.float = new XFAObjectArray();
|
|
|
|
this.image = new XFAObjectArray();
|
|
|
|
this.integer = new XFAObjectArray();
|
|
|
|
this.manifest = new XFAObjectArray();
|
|
|
|
this.script = new XFAObjectArray();
|
|
|
|
this.text = new XFAObjectArray();
|
|
|
|
this.time = new XFAObjectArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
[$isTransparent]() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TemplateNamespace {
|
|
|
|
static [$buildXFAObject](name, attributes) {
|
|
|
|
if (TemplateNamespace.hasOwnProperty(name)) {
|
2021-02-18 18:32:25 +09:00
|
|
|
const node = TemplateNamespace[name](attributes);
|
|
|
|
node[$setSetAttributes](attributes);
|
|
|
|
return node;
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
static appearanceFilter(attrs) {
|
|
|
|
return new AppearanceFilter(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static arc(attrs) {
|
|
|
|
return new Arc(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static area(attrs) {
|
|
|
|
return new Area(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static assist(attrs) {
|
|
|
|
return new Assist(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static barcode(attrs) {
|
|
|
|
return new Barcode(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bind(attrs) {
|
|
|
|
return new Bind(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bindItems(attrs) {
|
|
|
|
return new BindItems(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bookend(attrs) {
|
|
|
|
return new Bookend(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static boolean(attrs) {
|
|
|
|
return new BooleanElement(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static border(attrs) {
|
|
|
|
return new Border(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static break(attrs) {
|
|
|
|
return new Break(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static breakAfter(attrs) {
|
|
|
|
return new BreakAfter(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static breakBefore(attrs) {
|
|
|
|
return new BreakBefore(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static button(attrs) {
|
|
|
|
return new Button(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static calculate(attrs) {
|
|
|
|
return new Calculate(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static caption(attrs) {
|
|
|
|
return new Caption(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static certificate(attrs) {
|
|
|
|
return new Certificate(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static certificates(attrs) {
|
|
|
|
return new Certificates(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static checkButton(attrs) {
|
|
|
|
return new CheckButton(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static choiceList(attrs) {
|
|
|
|
return new ChoiceList(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static color(attrs) {
|
|
|
|
return new Color(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static comb(attrs) {
|
|
|
|
return new Comb(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static connect(attrs) {
|
|
|
|
return new Connect(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static contentArea(attrs) {
|
|
|
|
return new ContentArea(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static corner(attrs) {
|
|
|
|
return new Corner(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static date(attrs) {
|
2021-03-31 22:42:21 +09:00
|
|
|
return new DateElement(attrs);
|
2021-02-01 23:12:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
static dateTime(attrs) {
|
|
|
|
return new DateTime(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static dateTimeEdit(attrs) {
|
|
|
|
return new DateTimeEdit(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static decimal(attrs) {
|
|
|
|
return new Decimal(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static defaultUi(attrs) {
|
|
|
|
return new DefaultUi(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static desc(attrs) {
|
|
|
|
return new Desc(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static digestMethod(attrs) {
|
|
|
|
return new DigestMethod(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static digestMethods(attrs) {
|
|
|
|
return new DigestMethods(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static draw(attrs) {
|
|
|
|
return new Draw(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static edge(attrs) {
|
|
|
|
return new Edge(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encoding(attrs) {
|
|
|
|
return new Encoding(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encodings(attrs) {
|
|
|
|
return new Encodings(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encrypt(attrs) {
|
|
|
|
return new Encrypt(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encryptData(attrs) {
|
|
|
|
return new EncryptData(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encryption(attrs) {
|
|
|
|
return new Encryption(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encryptionMethod(attrs) {
|
|
|
|
return new EncryptionMethod(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static encryptionMethods(attrs) {
|
|
|
|
return new EncryptionMethods(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static event(attrs) {
|
|
|
|
return new Event(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static exData(attrs) {
|
|
|
|
return new ExData(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static exObject(attrs) {
|
|
|
|
return new ExObject(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static exclGroup(attrs) {
|
|
|
|
return new ExclGroup(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static execute(attrs) {
|
|
|
|
return new Execute(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static extras(attrs) {
|
|
|
|
return new Extras(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static field(attrs) {
|
|
|
|
return new Field(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static fill(attrs) {
|
|
|
|
return new Fill(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static filter(attrs) {
|
|
|
|
return new Filter(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static float(attrs) {
|
|
|
|
return new Float(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static font(attrs) {
|
|
|
|
return new Font(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static format(attrs) {
|
|
|
|
return new Format(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static handler(attrs) {
|
|
|
|
return new Handler(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static hyphenation(attrs) {
|
|
|
|
return new Hyphenation(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static image(attrs) {
|
|
|
|
return new Image(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static imageEdit(attrs) {
|
|
|
|
return new ImageEdit(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static integer(attrs) {
|
|
|
|
return new Integer(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static issuers(attrs) {
|
|
|
|
return new Issuers(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static items(attrs) {
|
|
|
|
return new Items(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static keep(attrs) {
|
|
|
|
return new Keep(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static keyUsage(attrs) {
|
|
|
|
return new KeyUsage(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static line(attrs) {
|
|
|
|
return new Line(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static linear(attrs) {
|
|
|
|
return new Linear(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static lockDocument(attrs) {
|
|
|
|
return new LockDocument(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static manifest(attrs) {
|
|
|
|
return new Manifest(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static margin(attrs) {
|
|
|
|
return new Margin(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static mdp(attrs) {
|
|
|
|
return new Mdp(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static medium(attrs) {
|
|
|
|
return new Medium(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static message(attrs) {
|
|
|
|
return new Message(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static numericEdit(attrs) {
|
|
|
|
return new NumericEdit(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static occur(attrs) {
|
|
|
|
return new Occur(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static oid(attrs) {
|
|
|
|
return new Oid(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static oids(attrs) {
|
|
|
|
return new Oids(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static overflow(attrs) {
|
|
|
|
return new Overflow(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static pageArea(attrs) {
|
|
|
|
return new PageArea(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static pageSet(attrs) {
|
|
|
|
return new PageSet(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static para(attrs) {
|
|
|
|
return new Para(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static passwordEdit(attrs) {
|
|
|
|
return new PasswordEdit(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static pattern(attrs) {
|
|
|
|
return new Pattern(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static picture(attrs) {
|
|
|
|
return new Picture(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static proto(attrs) {
|
|
|
|
return new Proto(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static radial(attrs) {
|
|
|
|
return new Radial(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static reason(attrs) {
|
|
|
|
return new Reason(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static reasons(attrs) {
|
|
|
|
return new Reasons(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static rectangle(attrs) {
|
|
|
|
return new Rectangle(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ref(attrs) {
|
|
|
|
return new RefElement(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static script(attrs) {
|
|
|
|
return new Script(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static setProperty(attrs) {
|
|
|
|
return new SetProperty(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static signData(attrs) {
|
|
|
|
return new SignData(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static signature(attrs) {
|
|
|
|
return new Signature(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static signing(attrs) {
|
|
|
|
return new Signing(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static solid(attrs) {
|
|
|
|
return new Solid(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static speak(attrs) {
|
|
|
|
return new Speak(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static stipple(attrs) {
|
|
|
|
return new Stipple(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static subform(attrs) {
|
|
|
|
return new Subform(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static subformSet(attrs) {
|
|
|
|
return new SubformSet(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static subjectDN(attrs) {
|
|
|
|
return new SubjectDN(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static subjectDNs(attrs) {
|
|
|
|
return new SubjectDNs(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static submit(attrs) {
|
|
|
|
return new Submit(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static template(attrs) {
|
|
|
|
return new Template(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static text(attrs) {
|
|
|
|
return new Text(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static textEdit(attrs) {
|
|
|
|
return new TextEdit(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static time(attrs) {
|
|
|
|
return new Time(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static timeStamp(attrs) {
|
|
|
|
return new TimeStamp(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static toolTip(attrs) {
|
|
|
|
return new ToolTip(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static traversal(attrs) {
|
|
|
|
return new Traversal(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static traverse(attrs) {
|
|
|
|
return new Traverse(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ui(attrs) {
|
|
|
|
return new Ui(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static validate(attrs) {
|
|
|
|
return new Validate(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static value(attrs) {
|
|
|
|
return new Value(attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static variables(attrs) {
|
|
|
|
return new Variables(attrs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-25 03:05:04 +09:00
|
|
|
export {
|
|
|
|
BindItems,
|
|
|
|
Field,
|
|
|
|
Items,
|
|
|
|
SetProperty,
|
|
|
|
Template,
|
|
|
|
TemplateNamespace,
|
|
|
|
Text,
|
|
|
|
Value,
|
|
|
|
};
|