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 - Support assist element #13718

Merged
merged 1 commit into from
Jul 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
26 changes: 26 additions & 0 deletions src/core/xfa/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ class Assist extends XFAObject {
this.speak = null;
this.toolTip = null;
}

[$toHTML]() {
return this.toolTip && this.toolTip[$content]
? this.toolTip[$content]
: null;
}
}

class Barcode extends XFAObject {
Expand Down Expand Up @@ -1734,6 +1740,11 @@ class Draw extends XFAObject {
children: [],
};

const assist = this.assist ? this.assist[$toHTML]() : null;
if (assist) {
html.attributes.title = assist;
}

const bbox = computeBbox(this, html, availableSpace);

const value = this.value ? this.value[$toHTML](availableSpace).html : null;
Expand Down Expand Up @@ -2345,6 +2356,11 @@ class ExclGroup extends XFAObject {
children,
};

const assist = this.assist ? this.assist[$toHTML]() : null;
if (assist) {
html.attributes.title = assist;
}

delete this[$extra];

return HTMLResult.success(createWrapper(this, html), bbox);
Expand Down Expand Up @@ -2621,6 +2637,11 @@ class Field extends XFAObject {
children,
};

const assist = this.assist ? this.assist[$toHTML]() : null;
if (assist) {
html.attributes.title = assist;
}

const borderStyle = this.border ? this.border[$toStyle]() : null;

const bbox = computeBbox(this, html, availableSpace);
Expand Down Expand Up @@ -4781,6 +4802,11 @@ class Subform extends XFAObject {
children,
};

const assist = this.assist ? this.assist[$toHTML]() : null;
if (assist) {
html.attributes.title = assist;
}

const result = HTMLResult.success(createWrapper(this, html), bbox);

if (this.breakAfter.children.length >= 1) {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/xfa_tohtml_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe("XFAFactory", function () {
<contentArea x="123pt" w="456pt" h="789pt"/>
<medium stock="default" short="456pt" long="789pt"/>
<draw y="1pt" w="11pt" h="22pt" rotate="90" x="2pt">
<assist><toolTip>A tooltip !!</toolTip></assist>
<font size="7pt" typeface="FooBar" baselineShift="2pt">
<fill>
<color value="12,23,34"/>
Expand Down Expand Up @@ -118,6 +119,7 @@ describe("XFAFactory", function () {
"xfaFont",
"xfaWrapped",
]);
expect(draw.attributes.title).toEqual("A tooltip !!");
expect(draw.attributes.style).toEqual({
color: "#0c1722",
fontFamily: '"FooBar"',
Expand Down