Merge pull request #8110 from timvandermeij/interactive-forms-choice-inherit-options
Interactive forms: make choice widget options inheritable (issue 8094)
This commit is contained in:
commit
9db4240b85
@ -861,9 +861,12 @@ var ChoiceWidgetAnnotation = (function ChoiceWidgetAnnotationClosure() {
|
|||||||
// the display value. If the array consists of strings, then these
|
// the display value. If the array consists of strings, then these
|
||||||
// represent both the export and display value. In this case, we convert
|
// represent both the export and display value. In this case, we convert
|
||||||
// it to an array of arrays as well for convenience in the display layer.
|
// it to an array of arrays as well for convenience in the display layer.
|
||||||
|
// Note that the specification does not state that the `Opt` field is
|
||||||
|
// inheritable, but in practice PDF generators do make annotations
|
||||||
|
// inherit the options from a parent annotation (issue 8094).
|
||||||
this.data.options = [];
|
this.data.options = [];
|
||||||
|
|
||||||
var options = params.dict.get('Opt');
|
var options = Util.getInheritableProperty(params.dict, 'Opt');
|
||||||
if (isArray(options)) {
|
if (isArray(options)) {
|
||||||
var xref = params.xref;
|
var xref = params.xref;
|
||||||
for (var i = 0, ii = options.length; i < ii; i++) {
|
for (var i = 0, ii = options.length; i < ii; i++) {
|
||||||
|
@ -1142,6 +1142,34 @@ describe('annotation', function() {
|
|||||||
expect(data.options).toEqual(expected);
|
expect(data.options).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle inherited option arrays (issue 8094)', function() {
|
||||||
|
var options = [
|
||||||
|
['Value1', 'Description1'],
|
||||||
|
['Value2', 'Description2'],
|
||||||
|
];
|
||||||
|
var expected = [
|
||||||
|
{ exportValue: 'Value1', displayValue: 'Description1' },
|
||||||
|
{ exportValue: 'Value2', displayValue: 'Description2' },
|
||||||
|
];
|
||||||
|
|
||||||
|
var parentDict = new Dict();
|
||||||
|
parentDict.set('Opt', options);
|
||||||
|
|
||||||
|
choiceWidgetDict.set('Parent', parentDict);
|
||||||
|
|
||||||
|
var choiceWidgetRef = new Ref(123, 0);
|
||||||
|
var xref = new XRefMock([
|
||||||
|
{ ref: choiceWidgetRef, data: choiceWidgetDict, },
|
||||||
|
]);
|
||||||
|
|
||||||
|
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||||
|
pdfManagerMock, idFactoryMock);
|
||||||
|
var data = annotation.data;
|
||||||
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||||
|
|
||||||
|
expect(data.options).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle array field values', function() {
|
it('should handle array field values', function() {
|
||||||
var fieldValue = ['Foo', 'Bar'];
|
var fieldValue = ['Foo', 'Bar'];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user