From 257de0e8c53c1d1e4c0e0e0b0c0ecbe62c2e43dd Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 27 Jun 2021 15:02:53 +0200 Subject: [PATCH] XFA - Replace deprecated break element (bug 1718053) - the break element has been deprecated in XFA 2.4 but some old documents can use it, so replace it with one (or more) of its possible substitutions: - breakBefore; - breakAfter; - overflow. --- src/core/xfa/template.js | 40 +++++++++++++++++++++++++++++++ test/pdfs/xfa_bug1718053.pdf.link | 1 + test/test_manifest.json | 8 +++++++ 3 files changed, 49 insertions(+) create mode 100644 test/pdfs/xfa_bug1718053.pdf.link diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index e9ac5ac71..830495d7d 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -4222,6 +4222,46 @@ class Subform extends XFAObject { } [$toHTML](availableSpace) { + if (this.break) { + // break element is deprecated so plug it on one of its replacement + // breakBefore or breakAfter. + if (this.break.after !== "auto" || this.break.afterTarget !== "") { + const node = new BreakAfter({ + targetType: this.break.after, + target: this.break.afterTarget, + startNew: this.break.startNew.toString(), + }); + node[$globalData] = this[$globalData]; + this[$appendChild](node); + this.breakAfter.push(node); + } + + if (this.break.before !== "auto" || this.break.beforeTarget !== "") { + const node = new BreakBefore({ + targetType: this.break.before, + target: this.break.beforeTarget, + startNew: this.break.startNew.toString(), + }); + node[$globalData] = this[$globalData]; + this[$appendChild](node); + this.breakBefore.push(node); + } + + if (this.break.overflowTarget !== "") { + const node = new Overflow({ + target: this.break.overflowTarget, + leader: this.break.overflowLeader, + trailer: this.break.overflowTrailer, + }); + node[$globalData] = this[$globalData]; + this[$appendChild](node); + this.overflow.push(node); + } + + this[$removeChild](this.break); + this.break = null; + } + if (this.presence === "hidden" || this.presence === "inactive") { return HTMLResult.EMPTY; } diff --git a/test/pdfs/xfa_bug1718053.pdf.link b/test/pdfs/xfa_bug1718053.pdf.link new file mode 100644 index 000000000..8b781704a --- /dev/null +++ b/test/pdfs/xfa_bug1718053.pdf.link @@ -0,0 +1 @@ +https://bug1718053.bmoattachments.org/attachment.cgi?id=9228759 diff --git a/test/test_manifest.json b/test/test_manifest.json index 97e6d2ff3..d864d2e3b 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -938,6 +938,14 @@ "lastPage": 2, "type": "eq" }, + { "id": "xfa_bug1718053", + "file": "pdfs/xfa_bug1718053.pdf", + "md5": "252d728d2c456dcb81699342a71c42ea", + "link": true, + "rounds": 1, + "enableXfa": true, + "type": "eq" + }, { "id": "xfa_bug1717681", "file": "pdfs/xfa_bug1717681.pdf", "md5": "435b1eae7e017b1a932fe204d1ba8be5",