[Annotations] charLimit === 0 means unlimited (bug 1782564)

Changing the charLimit in JS had no impact, so this patch aims to fix
that and add an integration test for it.
This commit is contained in:
Calixte Denizet 2022-08-18 19:27:53 +02:00
parent b05010c3eb
commit c06c5f7cbd
8 changed files with 122 additions and 12 deletions

View file

@ -29,7 +29,6 @@ class Field extends PDFObject {
this.buttonScaleHow = data.buttonScaleHow;
this.ButtonScaleWhen = data.buttonScaleWhen;
this.calcOrderIndex = data.calcOrderIndex;
this.charLimit = data.charLimit;
this.comb = data.comb;
this.commitOnSelChange = data.commitOnSelChange;
this.currentValueIndices = data.currentValueIndices;
@ -69,6 +68,7 @@ class Field extends PDFObject {
this._browseForFileToSubmit = data.browseForFileToSubmit || null;
this._buttonCaption = null;
this._buttonIcon = null;
this._charLimit = data.charLimit;
this._children = null;
this._currentValueIndices = data.currentValueIndices || 0;
this._document = data.doc;
@ -151,6 +151,17 @@ class Field extends PDFObject {
this.fillColor = color;
}
get charLimit() {
return this._charLimit;
}
set charLimit(limit) {
if (typeof limit !== "number") {
throw new Error("Invalid argument value");
}
this._charLimit = Math.max(0, Math.floor(limit));
}
get numItems() {
if (!this._isChoice) {
throw new Error("Not a choice widget");