Merge pull request #7900 from Snuffleupagus/choiceWidget-Opt-indirect-objects
Ensure that we handle indirect objects in all types of `Opt` entries in `ChoiceWidget` annotation dictionaries
This commit is contained in:
commit
d0893b0c48
@ -779,14 +779,16 @@ var ChoiceWidgetAnnotation = (function ChoiceWidgetAnnotationClosure() {
|
|||||||
// 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.
|
||||||
this.data.options = [];
|
this.data.options = [];
|
||||||
|
|
||||||
var options = params.dict.getArray('Opt');
|
var options = params.dict.get('Opt');
|
||||||
if (isArray(options)) {
|
if (isArray(options)) {
|
||||||
|
var xref = params.xref;
|
||||||
for (var i = 0, ii = options.length; i < ii; i++) {
|
for (var i = 0, ii = options.length; i < ii; i++) {
|
||||||
var option = options[i];
|
var option = xref.fetchIfRef(options[i]);
|
||||||
|
var isOptionArray = isArray(option);
|
||||||
|
|
||||||
this.data.options[i] = {
|
this.data.options[i] = {
|
||||||
exportValue: isArray(option) ? option[0] : option,
|
exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
|
||||||
displayValue: isArray(option) ? option[1] : option,
|
displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,12 @@ describe('Annotation layer', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle option arrays with array elements', function() {
|
it('should handle option arrays with array elements', function() {
|
||||||
var options = [['foo_export', 'Foo'], ['bar_export', 'Bar']];
|
var optionBarRef = new Ref(20, 0);
|
||||||
|
var optionBarStr = 'Bar';
|
||||||
|
var optionOneRef = new Ref(10, 0);
|
||||||
|
var optionOneArr = ['bar_export', optionBarRef];
|
||||||
|
|
||||||
|
var options = [['foo_export', 'Foo'], optionOneRef];
|
||||||
var expected = [
|
var expected = [
|
||||||
{
|
{
|
||||||
exportValue: 'foo_export',
|
exportValue: 'foo_export',
|
||||||
@ -916,7 +921,9 @@ describe('Annotation layer', function() {
|
|||||||
|
|
||||||
var choiceWidgetRef = new Ref(123, 0);
|
var choiceWidgetRef = new Ref(123, 0);
|
||||||
var xref = new XRefMock([
|
var xref = new XRefMock([
|
||||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
{ ref: choiceWidgetRef, data: choiceWidgetDict, },
|
||||||
|
{ ref: optionBarRef, data: optionBarStr, },
|
||||||
|
{ ref: optionOneRef, data: optionOneArr, },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var choiceWidgetAnnotation = annotationFactory.create(xref,
|
var choiceWidgetAnnotation = annotationFactory.create(xref,
|
||||||
@ -928,7 +935,10 @@ describe('Annotation layer', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle option arrays with string elements', function() {
|
it('should handle option arrays with string elements', function() {
|
||||||
var options = ['Foo', 'Bar'];
|
var optionBarRef = new Ref(10, 0);
|
||||||
|
var optionBarStr = 'Bar';
|
||||||
|
|
||||||
|
var options = ['Foo', optionBarRef];
|
||||||
var expected = [
|
var expected = [
|
||||||
{
|
{
|
||||||
exportValue: 'Foo',
|
exportValue: 'Foo',
|
||||||
@ -944,7 +954,8 @@ describe('Annotation layer', function() {
|
|||||||
|
|
||||||
var choiceWidgetRef = new Ref(981, 0);
|
var choiceWidgetRef = new Ref(981, 0);
|
||||||
var xref = new XRefMock([
|
var xref = new XRefMock([
|
||||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
{ ref: choiceWidgetRef, data: choiceWidgetDict, },
|
||||||
|
{ ref: optionBarRef, data: optionBarStr, }
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var choiceWidgetAnnotation = annotationFactory.create(xref,
|
var choiceWidgetAnnotation = annotationFactory.create(xref,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user