Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XFA -- Add other objects #12949

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions src/core/xfa/connection_set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/* 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 { $buildXFAObject, NamespaceIds } from "./namespaces.js";
import { StringObject, XFAObject, XFAObjectArray } from "./xfa_object.js";

const CONNECTION_SET_NS_ID = NamespaceIds.connectionSet.id;

class ConnectionSet extends XFAObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "connectionSet", /* hasChildren = */ true);
this.wsdlConnection = new XFAObjectArray();
this.xmlConnection = new XFAObjectArray();
this.xsdConnection = new XFAObjectArray();
}
}

class EffectiveInputPolicy extends XFAObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "effectiveInputPolicy");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class EffectiveOutputPolicy extends XFAObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "effectiveOutputPolicy");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class Operation extends StringObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "operation");
this.id = attributes.id || "";
this.input = attributes.input || "";
this.name = attributes.name || "";
this.output = attributes.output || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class RootElement extends StringObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "rootElement");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class SoapAction extends StringObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "soapAction");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class SoapAddress extends StringObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "soapAddress");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class Uri extends StringObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "uri");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class WsdlAddress extends StringObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "wsdlAddress");
this.id = attributes.id || "";
this.name = attributes.name || "";
this.use = attributes.use || "";
this.usehref = attributes.usehref || "";
}
}

class WsdlConnection extends XFAObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "wsdlConnection", /* hasChildren = */ true);
this.dataDescription = attributes.dataDescription || "";
this.name = attributes.name || "";
this.effectiveInputPolicy = null;
this.effectiveOutputPolicy = null;
this.operation = null;
this.soapAction = null;
this.soapAddress = null;
this.wsdlAddress = null;
}
}

class XmlConnection extends XFAObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "xmlConnection", /* hasChildren = */ true);
this.dataDescription = attributes.dataDescription || "";
this.name = attributes.name || "";
this.uri = null;
}
}

class XsdConnection extends XFAObject {
constructor(attributes) {
super(CONNECTION_SET_NS_ID, "xsdConnection", /* hasChildren = */ true);
this.dataDescription = attributes.dataDescription || "";
this.name = attributes.name || "";
this.rootElement = null;
this.uri = null;
}
}

class ConnectionSetNamespace {
static [$buildXFAObject](name, attributes) {
if (ConnectionSetNamespace.hasOwnProperty(name)) {
return ConnectionSetNamespace[name](attributes);
}
return undefined;
}

static connectionSet(attrs) {
return new ConnectionSet(attrs);
}

static effectiveInputPolicy(attrs) {
return new EffectiveInputPolicy(attrs);
}

static effectiveOutputPolicy(attrs) {
return new EffectiveOutputPolicy(attrs);
}

static operation(attrs) {
return new Operation(attrs);
}

static rootElement(attrs) {
return new RootElement(attrs);
}

static soapAction(attrs) {
return new SoapAction(attrs);
}

static soapAddress(attrs) {
return new SoapAddress(attrs);
}

static uri(attrs) {
return new Uri(attrs);
}

static wsdlAddress(attrs) {
return new WsdlAddress(attrs);
}

static wsdlConnection(attrs) {
return new WsdlConnection(attrs);
}

static xmlConnection(attrs) {
return new XmlConnection(attrs);
}

static xsdConnection(attrs) {
return new XsdConnection(attrs);
}
}

export { ConnectionSetNamespace };
69 changes: 69 additions & 0 deletions src/core/xfa/datasets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* 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 { $buildXFAObject, NamespaceIds } from "./namespaces.js";
import {
$namespaceId,
$nodeName,
$onChildCheck,
XFAObject,
XmlObject,
} from "./xfa_object.js";

const DATASETS_NS_ID = NamespaceIds.datasets.id;

class Data extends XmlObject {
constructor(attributes) {
super(DATASETS_NS_ID, "data", attributes);
}
}

class Datasets extends XFAObject {
constructor(attributes) {
super(DATASETS_NS_ID, "datasets", /* hasChildren = */ true);
this.data = null;
this.Signature = null;
}

[$onChildCheck](child) {
const name = child[$nodeName];
if (name === "data") {
return child[$namespaceId] === DATASETS_NS_ID;
}
if (name === "Signature") {
return child[$namespaceId] === NamespaceIds.signature.id;
}
return false;
}
}

class DatasetsNamespace {
static [$buildXFAObject](name, attributes) {
if (DatasetsNamespace.hasOwnProperty(name)) {
return DatasetsNamespace[name](attributes);
}
return undefined;
}

static datasets(attributes) {
return new Datasets(attributes);
}

static data(attributes) {
return new Data(attributes);
}
}

export { DatasetsNamespace };
2 changes: 1 addition & 1 deletion src/core/xfa/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class XFAParser extends XMLParserBase {
if (this._whiteRegex.test(text)) {
return;
}
this._current[$onText](text);
this._current[$onText](text.trim());
}

onCdata(text) {
Expand Down
10 changes: 10 additions & 0 deletions src/core/xfa/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,25 @@
*/

import { ConfigNamespace } from "./config.js";
import { ConnectionSetNamespace } from "./connection_set.js";
import { DatasetsNamespace } from "./datasets.js";
import { LocaleSetNamespace } from "./locale_set.js";
import { SignatureNamespace } from "./signature.js";
import { StylesheetNamespace } from "./stylesheet.js";
import { TemplateNamespace } from "./template.js";
import { XdpNamespace } from "./xdp.js";
import { XhtmlNamespace } from "./xhtml.js";

const NamespaceSetUp = {
config: ConfigNamespace,
connection: ConnectionSetNamespace,
datasets: DatasetsNamespace,
localeSet: LocaleSetNamespace,
signature: SignatureNamespace,
stylesheet: StylesheetNamespace,
template: TemplateNamespace,
xdp: XdpNamespace,
xhtml: XhtmlNamespace,
};

export { NamespaceSetUp };
40 changes: 40 additions & 0 deletions src/core/xfa/signature.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* 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 { $buildXFAObject, NamespaceIds } from "./namespaces.js";
import { XFAObject } from "./xfa_object.js";

const SIGNATURE_NS_ID = NamespaceIds.signature.id;

class Signature extends XFAObject {
constructor(attributes) {
super(SIGNATURE_NS_ID, "signature", /* hasChildren = */ true);
}
}

class SignatureNamespace {
static [$buildXFAObject](name, attributes) {
if (SignatureNamespace.hasOwnProperty(name)) {
return SignatureNamespace[name](attributes);
}
return undefined;
}

static signature(attributes) {
return new Signature(attributes);
}
}

export { SignatureNamespace };
40 changes: 40 additions & 0 deletions src/core/xfa/stylesheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* 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 { $buildXFAObject, NamespaceIds } from "./namespaces.js";
import { XFAObject } from "./xfa_object.js";

const STYLESHEET_NS_ID = NamespaceIds.stylesheet.id;

class Stylesheet extends XFAObject {
constructor(attributes) {
super(STYLESHEET_NS_ID, "stylesheet", /* hasChildren = */ true);
}
}

class StylesheetNamespace {
static [$buildXFAObject](name, attributes) {
if (StylesheetNamespace.hasOwnProperty(name)) {
return StylesheetNamespace[name](attributes);
}
return undefined;
}

static stylesheet(attributes) {
return new Stylesheet(attributes);
}
}

export { StylesheetNamespace };
Loading