|
|
@ -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; |
|
|
@ -65,10 +66,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param {XRef} xref |
|
|
|
* @param {XRef} xref |
|
|
|
* @param {Object} ref |
|
|
|
* @param {Object} ref |
|
|
|
|
|
|
|
* @param {string} uniquePrefix |
|
|
|
|
|
|
|
* @param {Object} idCounters |
|
|
|
|
|
|
|
* @param {boolean} renderInteractiveForms |
|
|
|
* @returns {Annotation} |
|
|
|
* @returns {Annotation} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
create: function AnnotationFactory_create(xref, ref, |
|
|
|
create: function AnnotationFactory_create(xref, ref, |
|
|
|
uniquePrefix, idCounters) { |
|
|
|
uniquePrefix, idCounters, |
|
|
|
|
|
|
|
renderInteractiveForms) { |
|
|
|
var dict = xref.fetchIfRef(ref); |
|
|
|
var dict = xref.fetchIfRef(ref); |
|
|
|
if (!isDict(dict)) { |
|
|
|
if (!isDict(dict)) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -87,6 +92,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { |
|
|
|
ref: isRef(ref) ? ref : null, |
|
|
|
ref: isRef(ref) ? ref : null, |
|
|
|
subtype: subtype, |
|
|
|
subtype: subtype, |
|
|
|
id: id, |
|
|
|
id: id, |
|
|
|
|
|
|
|
renderInteractiveForms: renderInteractiveForms, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
switch (subtype) { |
|
|
|
switch (subtype) { |
|
|
@ -621,9 +627,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 +672,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; |
|
|
|
})(); |
|
|
|
})(); |
|
|
@ -671,6 +696,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { |
|
|
|
function TextWidgetAnnotation(params) { |
|
|
|
function TextWidgetAnnotation(params) { |
|
|
|
WidgetAnnotation.call(this, params); |
|
|
|
WidgetAnnotation.call(this, params); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.renderInteractiveForms = params.renderInteractiveForms; |
|
|
|
|
|
|
|
|
|
|
|
// Determine the alignment of text in the field.
|
|
|
|
// Determine the alignment of text in the field.
|
|
|
|
var alignment = Util.getInheritableProperty(params.dict, 'Q'); |
|
|
|
var alignment = Util.getInheritableProperty(params.dict, 'Q'); |
|
|
|
if (!isInt(alignment) || alignment < 0 || alignment > 2) { |
|
|
|
if (!isInt(alignment) || alignment < 0 || alignment > 2) { |
|
|
@ -684,29 +711,38 @@ 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, { |
|
|
|
getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, |
|
|
|
getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, |
|
|
|
task) { |
|
|
|
task) { |
|
|
|
|
|
|
|
var operatorList = new OperatorList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Do not render form elements on the canvas when interactive forms are
|
|
|
|
|
|
|
|
// enabled. The display layer is responsible for rendering them instead.
|
|
|
|
|
|
|
|
if (this.renderInteractiveForms) { |
|
|
|
|
|
|
|
return Promise.resolve(operatorList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.appearance) { |
|
|
|
if (this.appearance) { |
|
|
|
return Annotation.prototype.getOperatorList.call(this, evaluator, task); |
|
|
|
return Annotation.prototype.getOperatorList.call(this, evaluator, task); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var opList = new OperatorList(); |
|
|
|
|
|
|
|
var data = this.data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Even if there is an appearance stream, ignore it. This is the
|
|
|
|
// Even if there is an appearance stream, ignore it. This is the
|
|
|
|
// behaviour used by Adobe Reader.
|
|
|
|
// behaviour used by Adobe Reader.
|
|
|
|
if (!data.defaultAppearance) { |
|
|
|
if (!this.data.defaultAppearance) { |
|
|
|
return Promise.resolve(opList); |
|
|
|
return Promise.resolve(operatorList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var stream = new Stream(stringToBytes(data.defaultAppearance)); |
|
|
|
var stream = new Stream(stringToBytes(this.data.defaultAppearance)); |
|
|
|
return evaluator.getOperatorList(stream, task, |
|
|
|
return evaluator.getOperatorList(stream, task, this.fieldResources, |
|
|
|
this.fieldResources, opList). |
|
|
|
operatorList). |
|
|
|
then(function () { |
|
|
|
then(function () { |
|
|
|
return opList; |
|
|
|
return operatorList; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|