XFA - By default a text ui has only one line when in a field element
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1716809.
This commit is contained in:
parent
f9a0568f96
commit
793a0156ce
@ -18,6 +18,7 @@ import {
|
|||||||
$addHTML,
|
$addHTML,
|
||||||
$appendChild,
|
$appendChild,
|
||||||
$childrenToHTML,
|
$childrenToHTML,
|
||||||
|
$clean,
|
||||||
$content,
|
$content,
|
||||||
$extra,
|
$extra,
|
||||||
$finalize,
|
$finalize,
|
||||||
@ -4820,11 +4821,7 @@ class TextEdit extends XFAObject {
|
|||||||
"on",
|
"on",
|
||||||
]);
|
]);
|
||||||
this.id = attributes.id || "";
|
this.id = attributes.id || "";
|
||||||
this.multiLine = getInteger({
|
this.multiLine = attributes.multiLine || "";
|
||||||
data: attributes.multiLine,
|
|
||||||
defaultValue: 1,
|
|
||||||
validate: x => x === 0,
|
|
||||||
});
|
|
||||||
this.use = attributes.use || "";
|
this.use = attributes.use || "";
|
||||||
this.usehref = attributes.usehref || "";
|
this.usehref = attributes.usehref || "";
|
||||||
this.vScrollPolicy = getStringOption(attributes.vScrollPolicy, [
|
this.vScrollPolicy = getStringOption(attributes.vScrollPolicy, [
|
||||||
@ -4838,6 +4835,17 @@ class TextEdit extends XFAObject {
|
|||||||
this.margin = null;
|
this.margin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[$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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[$toHTML](availableSpace) {
|
[$toHTML](availableSpace) {
|
||||||
// TODO: incomplete.
|
// TODO: incomplete.
|
||||||
const style = toStyle(this, "border", "font", "margin");
|
const style = toStyle(this, "border", "font", "margin");
|
||||||
|
1
test/pdfs/xfa_bug1716809.pdf.link
Normal file
1
test/pdfs/xfa_bug1716809.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://bugzilla.mozilla.org/attachment.cgi?id=9227437
|
@ -938,6 +938,14 @@
|
|||||||
"enableXfa": true,
|
"enableXfa": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "xfa_bug1716809",
|
||||||
|
"file": "pdfs/xfa_bug1716809.pdf",
|
||||||
|
"md5": "7192f9e27e8b84776d107f57cbe353d5",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"enableXfa": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "xfa_annual_expense_report",
|
{ "id": "xfa_annual_expense_report",
|
||||||
"file": "pdfs/xfa_annual_expense_report.pdf",
|
"file": "pdfs/xfa_annual_expense_report.pdf",
|
||||||
"md5": "06866e7a6bbc0346789208ef5f6e885c",
|
"md5": "06866e7a6bbc0346789208ef5f6e885c",
|
||||||
|
@ -137,7 +137,7 @@ describe("XFAFactory", function () {
|
|||||||
<medium stock="default" short="456pt" long="789pt"/>
|
<medium stock="default" short="456pt" long="789pt"/>
|
||||||
<field y="1pt" w="11pt" h="22pt" x="2pt">
|
<field y="1pt" w="11pt" h="22pt" x="2pt">
|
||||||
<ui>
|
<ui>
|
||||||
<textEdit/>
|
<textEdit multiLine="0"/>
|
||||||
</ui>
|
</ui>
|
||||||
<value>
|
<value>
|
||||||
<text maxChars="123"/>
|
<text maxChars="123"/>
|
||||||
@ -160,9 +160,54 @@ describe("XFAFactory", function () {
|
|||||||
expect(factory.numberPages).toEqual(1);
|
expect(factory.numberPages).toEqual(1);
|
||||||
|
|
||||||
const pages = factory.getPages();
|
const pages = factory.getPages();
|
||||||
const field = searchHtmlNode(pages, "name", "textarea");
|
const field = searchHtmlNode(pages, "name", "input");
|
||||||
|
|
||||||
expect(field.attributes.maxLength).toEqual(123);
|
expect(field.attributes.maxLength).toEqual(123);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should have an input or textarea", function () {
|
||||||
|
const xml = `
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
|
||||||
|
<template xmlns="http://www.xfa.org/schema/xfa-template/3.3">
|
||||||
|
<subform name="root" mergeMode="matchTemplate">
|
||||||
|
<pageSet>
|
||||||
|
<pageArea>
|
||||||
|
<contentArea x="123pt" w="456pt" h="789pt"/>
|
||||||
|
<medium stock="default" short="456pt" long="789pt"/>
|
||||||
|
<field y="1pt" w="11pt" h="22pt" x="2pt">
|
||||||
|
<ui>
|
||||||
|
<textEdit/>
|
||||||
|
</ui>
|
||||||
|
</field>
|
||||||
|
<field y="1pt" w="11pt" h="22pt" x="2pt">
|
||||||
|
<ui>
|
||||||
|
<textEdit multiLine="1"/>
|
||||||
|
</ui>
|
||||||
|
</field>
|
||||||
|
</pageArea>
|
||||||
|
</pageSet>
|
||||||
|
<subform name="first">
|
||||||
|
<draw><value><text>foo</text></value></draw>
|
||||||
|
</subform>
|
||||||
|
</subform>
|
||||||
|
</template>
|
||||||
|
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
|
||||||
|
<xfa:data>
|
||||||
|
</xfa:data>
|
||||||
|
</xfa:datasets>
|
||||||
|
</xdp:xdp>
|
||||||
|
`;
|
||||||
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
|
expect(factory.numberPages).toEqual(1);
|
||||||
|
|
||||||
|
const pages = factory.getPages();
|
||||||
|
const field1 = searchHtmlNode(pages, "name", "input");
|
||||||
|
expect(field1).not.toEqual(null);
|
||||||
|
|
||||||
|
const field2 = searchHtmlNode(pages, "name", "textarea");
|
||||||
|
expect(field2).not.toEqual(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user