Text widget annotations: support multiline and read-only fields
Moreover, this patch provides us with a framework for handling field flags in general for all types of widget annotations.
This commit is contained in:
parent
a7c35025fe
commit
f6965fadc0
@ -33,6 +33,7 @@
|
|||||||
coreColorSpace, coreObj, coreEvaluator) {
|
coreColorSpace, coreObj, coreEvaluator) {
|
||||||
|
|
||||||
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
|
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
|
||||||
|
var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
|
||||||
var AnnotationFlag = sharedUtil.AnnotationFlag;
|
var AnnotationFlag = sharedUtil.AnnotationFlag;
|
||||||
var AnnotationType = sharedUtil.AnnotationType;
|
var AnnotationType = sharedUtil.AnnotationType;
|
||||||
var OPS = sharedUtil.OPS;
|
var OPS = sharedUtil.OPS;
|
||||||
@ -621,9 +622,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
|||||||
data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
|
data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
|
||||||
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||||
data.fieldType = isName(fieldType) ? fieldType.name : null;
|
data.fieldType = isName(fieldType) ? fieldType.name : null;
|
||||||
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff') || 0;
|
|
||||||
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
|
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
|
||||||
|
|
||||||
|
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
|
||||||
|
if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
|
||||||
|
data.fieldFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Hide signatures because we cannot validate them.
|
// Hide signatures because we cannot validate them.
|
||||||
if (data.fieldType === 'Sig') {
|
if (data.fieldType === 'Sig') {
|
||||||
this.setFlags(AnnotationFlag.HIDDEN);
|
this.setFlags(AnnotationFlag.HIDDEN);
|
||||||
@ -662,7 +667,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
|||||||
data.fullName = fieldName.join('.');
|
data.fullName = fieldName.join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.inherit(WidgetAnnotation, Annotation, {});
|
Util.inherit(WidgetAnnotation, Annotation, {
|
||||||
|
/**
|
||||||
|
* Check if a provided field flag is set.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
* @memberof WidgetAnnotation
|
||||||
|
* @param {number} flag - Bit position, numbered from one instead of
|
||||||
|
* zero, to check
|
||||||
|
* @return {boolean}
|
||||||
|
* @see {@link shared/util.js}
|
||||||
|
*/
|
||||||
|
hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
|
||||||
|
var mask = 1 << (flag - 1);
|
||||||
|
return !!(this.data.fieldFlags & mask);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return WidgetAnnotation;
|
return WidgetAnnotation;
|
||||||
})();
|
})();
|
||||||
@ -684,6 +704,10 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
|||||||
maximumLength = null;
|
maximumLength = null;
|
||||||
}
|
}
|
||||||
this.data.maxLen = maximumLength;
|
this.data.maxLen = maximumLength;
|
||||||
|
|
||||||
|
// Process field flags for the display layer.
|
||||||
|
this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
|
||||||
|
this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
|
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
|
||||||
|
@ -446,9 +446,15 @@ var TextWidgetAnnotationElement = (
|
|||||||
|
|
||||||
var element = null;
|
var element = null;
|
||||||
if (this.renderInteractiveForms) {
|
if (this.renderInteractiveForms) {
|
||||||
element = document.createElement('input');
|
if (this.data.multiLine) {
|
||||||
element.type = 'text';
|
element = document.createElement('textarea');
|
||||||
|
} else {
|
||||||
|
element = document.createElement('input');
|
||||||
|
element.type = 'text';
|
||||||
|
}
|
||||||
|
|
||||||
element.value = this.data.fieldValue;
|
element.value = this.data.fieldValue;
|
||||||
|
element.disabled = this.data.readOnly;
|
||||||
|
|
||||||
if (this.data.maxLen !== null) {
|
if (this.data.maxLen !== null) {
|
||||||
element.maxLength = this.data.maxLen;
|
element.maxLength = this.data.maxLen;
|
||||||
|
@ -93,6 +93,28 @@ var AnnotationFlag = {
|
|||||||
LOCKEDCONTENTS: 0x200
|
LOCKEDCONTENTS: 0x200
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var AnnotationFieldFlag = {
|
||||||
|
READONLY: 1,
|
||||||
|
REQUIRED: 2,
|
||||||
|
NOEXPORT: 3,
|
||||||
|
MULTILINE: 13,
|
||||||
|
PASSWORD: 14,
|
||||||
|
NOTOGGLETOOFF: 15,
|
||||||
|
RADIO: 16,
|
||||||
|
PUSHBUTTON: 17,
|
||||||
|
COMBO: 18,
|
||||||
|
EDIT: 19,
|
||||||
|
SORT: 20,
|
||||||
|
FILESELECT: 21,
|
||||||
|
MULTISELECT: 22,
|
||||||
|
DONOTSPELLCHECK: 23,
|
||||||
|
DONOTSCROLL: 24,
|
||||||
|
COMB: 25,
|
||||||
|
RICHTEXT: 26,
|
||||||
|
RADIOSINUNISON: 26,
|
||||||
|
COMMITONSELCHANGE: 27,
|
||||||
|
};
|
||||||
|
|
||||||
var AnnotationBorderStyleType = {
|
var AnnotationBorderStyleType = {
|
||||||
SOLID: 1,
|
SOLID: 1,
|
||||||
DASHED: 2,
|
DASHED: 2,
|
||||||
@ -2364,6 +2386,7 @@ exports.OPS = OPS;
|
|||||||
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
|
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
|
||||||
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
|
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
|
||||||
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
|
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
|
||||||
|
exports.AnnotationFieldFlag = AnnotationFieldFlag;
|
||||||
exports.AnnotationFlag = AnnotationFlag;
|
exports.AnnotationFlag = AnnotationFlag;
|
||||||
exports.AnnotationType = AnnotationType;
|
exports.AnnotationType = AnnotationType;
|
||||||
exports.FontType = FontType;
|
exports.FontType = FontType;
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.annotationLayer .textWidgetAnnotation input {
|
.annotationLayer .textWidgetAnnotation input,
|
||||||
|
.annotationLayer .textWidgetAnnotation textarea {
|
||||||
background-color: rgba(0, 54, 255, 0.13);
|
background-color: rgba(0, 54, 255, 0.13);
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -52,11 +53,26 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.annotationLayer .textWidgetAnnotation input:hover {
|
.annotationLayer .textWidgetAnnotation textarea {
|
||||||
|
font: message-box;
|
||||||
|
font-size: 9px;
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.annotationLayer .textWidgetAnnotation input[disabled],
|
||||||
|
.annotationLayer .textWidgetAnnotation textarea[disabled] {
|
||||||
|
background: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.annotationLayer .textWidgetAnnotation input:hover,
|
||||||
|
.annotationLayer .textWidgetAnnotation textarea:hover {
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.annotationLayer .textWidgetAnnotation input:focus {
|
.annotationLayer .textWidgetAnnotation input:focus,
|
||||||
|
.annotationLayer .textWidgetAnnotation textarea:focus {
|
||||||
background: none;
|
background: none;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user