From 9bbc19484605028838a4c6112dae981c67cffd5c Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 11 Jul 2021 21:01:18 +0200 Subject: [PATCH] XFA - Support assist element --- src/core/xfa/template.js | 26 ++++++++++++++++++++++++++ test/unit/xfa_tohtml_spec.js | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 6188fb509..f9e89565d 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -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 { @@ -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; @@ -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); @@ -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); @@ -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) { diff --git a/test/unit/xfa_tohtml_spec.js b/test/unit/xfa_tohtml_spec.js index 68cbbfcb9..2693eeaf5 100644 --- a/test/unit/xfa_tohtml_spec.js +++ b/test/unit/xfa_tohtml_spec.js @@ -44,6 +44,7 @@ describe("XFAFactory", function () { + A tooltip !! @@ -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"',