1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

XFA - Layout correctly a subform with row layout (bug 1718740)

- Fix issues with subformSet elements which are not a real container.
This commit is contained in:
Calixte Denizet 2021-07-06 14:11:21 +02:00
parent b3de26f514
commit 5f76b6370c
5 changed files with 52 additions and 60 deletions

View file

@ -1073,7 +1073,7 @@ class CheckButton extends XFAObject {
const value = (field.value && field.value[$text]()) || "off";
const checked = value === exportedValue.on || undefined;
const container = field[$getParent]();
const container = field[$getSubformParent]();
const fieldId = field[$uid];
let dataId;
@ -2113,27 +2113,15 @@ class ExclGroup extends XFAObject {
[$isSplittable]() {
// We cannot cache the result here because the contentArea
// can change.
if (!this[$getParent]()[$isSplittable]()) {
if (!this[$getSubformParent]()[$isSplittable]()) {
return false;
}
const root = this[$getTemplateRoot]();
const contentArea = root[$extra].currentContentArea;
if (contentArea && Math.max(this.minH, this.h || 0) >= contentArea.h) {
return true;
}
if (this[$extra]._isSplittable !== undefined) {
return this[$extra]._isSplittable;
}
if (this.layout === "position") {
this[$extra]._isSplittable = false;
return false;
}
const parentLayout = this[$getParent]().layout;
if (parentLayout && parentLayout.includes("row")) {
if (this.layout === "position" || this.layout.includes("row")) {
this[$extra]._isSplittable = false;
return false;
}
@ -2205,8 +2193,8 @@ class ExclGroup extends XFAObject {
const filter = new Set(["field"]);
if (this.layout === "row") {
const columnWidths = this[$getParent]().columnWidths;
if (this.layout.includes("row")) {
const columnWidths = this[$getSubformParent]().columnWidths;
if (Array.isArray(columnWidths) && columnWidths.length > 0) {
this[$extra].columnWidths = columnWidths;
this[$extra].currentColumn = 0;
@ -4387,6 +4375,14 @@ class Subform extends XFAObject {
this.subformSet = new XFAObjectArray();
}
[$getSubformParent]() {
const parent = this[$getParent]();
if (parent instanceof SubformSet) {
return parent[$getSubformParent]();
}
return parent;
}
[$isBindable]() {
return true;
}
@ -4412,25 +4408,21 @@ class Subform extends XFAObject {
[$isSplittable]() {
// We cannot cache the result here because the contentArea
// can change.
if (!this[$getParent]()[$isSplittable]()) {
if (!this[$getSubformParent]()[$isSplittable]()) {
return false;
}
const root = this[$getTemplateRoot]();
const contentArea = root[$extra].currentContentArea;
if (contentArea && Math.max(this.minH, this.h || 0) >= contentArea.h) {
return true;
}
const contentArea = this[$getTemplateRoot]()[$extra].currentContentArea;
if (this.overflow) {
return this.overflow[$getExtra]().target !== contentArea;
if (this.overflow && this.overflow[$getExtra]().target === contentArea) {
return false;
}
if (this[$extra]._isSplittable !== undefined) {
return this[$extra]._isSplittable;
}
if (this.layout === "position") {
if (this.layout === "position" || this.layout.includes("row")) {
this[$extra]._isSplittable = false;
return false;
}
@ -4440,12 +4432,6 @@ class Subform extends XFAObject {
return false;
}
const parentLayout = this[$getParent]().layout;
if (parentLayout && parentLayout.includes("row")) {
this[$extra]._isSplittable = false;
return false;
}
this[$extra]._isSplittable = true;
return true;