Merge pull request #8828 from timvandermeij/es6-annotations
Improve the annotation code by converting to ES6 syntax and removing duplicate code
This commit is contained in:
commit
a4cc85fc5f
@ -31,8 +31,8 @@
|
||||
"typogr": "^0.6.6",
|
||||
"uglify-es": "^3.0.28",
|
||||
"vinyl-fs": "^2.4.4",
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-stream": "^3.2.0",
|
||||
"webpack": "^3.5.5",
|
||||
"webpack-stream": "^4.0.0",
|
||||
"wintersmith": "^2.0.0",
|
||||
"yargs": "^3.14.0"
|
||||
},
|
||||
|
@ -24,12 +24,7 @@ import { ColorSpace } from './colorspace';
|
||||
import { OperatorList } from './evaluator';
|
||||
import { Stream } from './stream';
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @alias AnnotationFactory
|
||||
*/
|
||||
function AnnotationFactory() {}
|
||||
AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
||||
class AnnotationFactory {
|
||||
/**
|
||||
* @param {XRef} xref
|
||||
* @param {Object} ref
|
||||
@ -37,19 +32,19 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
||||
* @param {Object} idFactory
|
||||
* @returns {Annotation}
|
||||
*/
|
||||
create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
|
||||
var dict = xref.fetchIfRef(ref);
|
||||
static create(xref, ref, pdfManager, idFactory) {
|
||||
let dict = xref.fetchIfRef(ref);
|
||||
if (!isDict(dict)) {
|
||||
return;
|
||||
}
|
||||
var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
|
||||
let id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
|
||||
|
||||
// Determine the annotation's subtype.
|
||||
var subtype = dict.get('Subtype');
|
||||
let subtype = dict.get('Subtype');
|
||||
subtype = isName(subtype) ? subtype.name : null;
|
||||
|
||||
// Return the right annotation object based on the subtype and field type.
|
||||
var parameters = {
|
||||
let parameters = {
|
||||
xref,
|
||||
dict,
|
||||
ref: isRef(ref) ? ref : null,
|
||||
@ -66,7 +61,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
||||
return new TextAnnotation(parameters);
|
||||
|
||||
case 'Widget':
|
||||
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
let fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
fieldType = isName(fieldType) ? fieldType.name : null;
|
||||
|
||||
switch (fieldType) {
|
||||
@ -111,17 +106,16 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
||||
}
|
||||
return new Annotation(parameters);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var Annotation = (function AnnotationClosure() {
|
||||
// 12.5.5: Algorithm: Appearance streams
|
||||
function getTransformMatrix(rect, bbox, matrix) {
|
||||
var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
|
||||
var minX = bounds[0];
|
||||
var minY = bounds[1];
|
||||
var maxX = bounds[2];
|
||||
var maxY = bounds[3];
|
||||
// 12.5.5: Algorithm: Appearance streams
|
||||
let bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
|
||||
let minX = bounds[0];
|
||||
let minY = bounds[1];
|
||||
let maxX = bounds[2];
|
||||
let maxY = bounds[3];
|
||||
|
||||
if (minX === maxX || minY === maxY) {
|
||||
// From real-life file, bbox was [0, 0, 0, 0]. In this case,
|
||||
@ -129,8 +123,8 @@ var Annotation = (function AnnotationClosure() {
|
||||
return [1, 0, 0, 1, rect[0], rect[1]];
|
||||
}
|
||||
|
||||
var xRatio = (rect[2] - rect[0]) / (maxX - minX);
|
||||
var yRatio = (rect[3] - rect[1]) / (maxY - minY);
|
||||
let xRatio = (rect[2] - rect[0]) / (maxX - minX);
|
||||
let yRatio = (rect[3] - rect[1]) / (maxY - minY);
|
||||
return [
|
||||
xRatio,
|
||||
0,
|
||||
@ -141,8 +135,9 @@ var Annotation = (function AnnotationClosure() {
|
||||
];
|
||||
}
|
||||
|
||||
function Annotation(params) {
|
||||
var dict = params.dict;
|
||||
class Annotation {
|
||||
constructor(params) {
|
||||
let dict = params.dict;
|
||||
|
||||
this.setFlags(dict.get('F'));
|
||||
this.setRectangle(dict.getArray('Rect'));
|
||||
@ -151,41 +146,41 @@ var Annotation = (function AnnotationClosure() {
|
||||
this.setAppearance(dict);
|
||||
|
||||
// Expose public properties using a data object.
|
||||
this.data = {};
|
||||
this.data.id = params.id;
|
||||
this.data.subtype = params.subtype;
|
||||
this.data.annotationFlags = this.flags;
|
||||
this.data.rect = this.rectangle;
|
||||
this.data.color = this.color;
|
||||
this.data.borderStyle = this.borderStyle;
|
||||
this.data.hasAppearance = !!this.appearance;
|
||||
this.data = {
|
||||
annotationFlags: this.flags,
|
||||
borderStyle: this.borderStyle,
|
||||
color: this.color,
|
||||
hasAppearance: !!this.appearance,
|
||||
id: params.id,
|
||||
rect: this.rectangle,
|
||||
subtype: params.subtype,
|
||||
};
|
||||
}
|
||||
|
||||
Annotation.prototype = {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_hasFlag: function Annotation_hasFlag(flags, flag) {
|
||||
_hasFlag(flags, flag) {
|
||||
return !!(flags & flag);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_isViewable: function Annotation_isViewable(flags) {
|
||||
_isViewable(flags) {
|
||||
return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) &&
|
||||
!this._hasFlag(flags, AnnotationFlag.HIDDEN) &&
|
||||
!this._hasFlag(flags, AnnotationFlag.NOVIEW);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_isPrintable: function AnnotationFlag_isPrintable(flags) {
|
||||
_isPrintable(flags) {
|
||||
return this._hasFlag(flags, AnnotationFlag.PRINT) &&
|
||||
!this._hasFlag(flags, AnnotationFlag.INVISIBLE) &&
|
||||
!this._hasFlag(flags, AnnotationFlag.HIDDEN);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
@ -195,7 +190,7 @@ var Annotation = (function AnnotationClosure() {
|
||||
return true;
|
||||
}
|
||||
return this._isViewable(this.flags);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
@ -205,7 +200,7 @@ var Annotation = (function AnnotationClosure() {
|
||||
return false;
|
||||
}
|
||||
return this._isPrintable(this.flags);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the flags.
|
||||
@ -216,9 +211,9 @@ var Annotation = (function AnnotationClosure() {
|
||||
* characteristics
|
||||
* @see {@link shared/util.js}
|
||||
*/
|
||||
setFlags: function Annotation_setFlags(flags) {
|
||||
setFlags(flags) {
|
||||
this.flags = (isInt(flags) && flags > 0) ? flags : 0;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a provided flag is set.
|
||||
@ -230,9 +225,9 @@ var Annotation = (function AnnotationClosure() {
|
||||
* @return {boolean}
|
||||
* @see {@link shared/util.js}
|
||||
*/
|
||||
hasFlag: function Annotation_hasFlag(flag) {
|
||||
hasFlag(flag) {
|
||||
return this._hasFlag(this.flags, flag);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rectangle.
|
||||
@ -241,13 +236,13 @@ var Annotation = (function AnnotationClosure() {
|
||||
* @memberof Annotation
|
||||
* @param {Array} rectangle - The rectangle array with exactly four entries
|
||||
*/
|
||||
setRectangle: function Annotation_setRectangle(rectangle) {
|
||||
setRectangle(rectangle) {
|
||||
if (isArray(rectangle) && rectangle.length === 4) {
|
||||
this.rectangle = Util.normalizeRect(rectangle);
|
||||
} else {
|
||||
this.rectangle = [0, 0, 0, 0];
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color and take care of color space conversion.
|
||||
@ -258,8 +253,8 @@ var Annotation = (function AnnotationClosure() {
|
||||
* (transparent), 1 (grayscale), 3 (RGB) or
|
||||
* 4 (CMYK) elements
|
||||
*/
|
||||
setColor: function Annotation_setColor(color) {
|
||||
var rgbColor = new Uint8Array(3); // Black in RGB color space (default)
|
||||
setColor(color) {
|
||||
let rgbColor = new Uint8Array(3); // Black in RGB color space (default)
|
||||
if (!isArray(color)) {
|
||||
this.color = rgbColor;
|
||||
return;
|
||||
@ -289,7 +284,7 @@ var Annotation = (function AnnotationClosure() {
|
||||
this.color = rgbColor;
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the border style (as AnnotationBorderStyle object).
|
||||
@ -298,14 +293,14 @@ var Annotation = (function AnnotationClosure() {
|
||||
* @memberof Annotation
|
||||
* @param {Dict} borderStyle - The border style dictionary
|
||||
*/
|
||||
setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
|
||||
setBorderStyle(borderStyle) {
|
||||
this.borderStyle = new AnnotationBorderStyle();
|
||||
if (!isDict(borderStyle)) {
|
||||
return;
|
||||
}
|
||||
if (borderStyle.has('BS')) {
|
||||
var dict = borderStyle.get('BS');
|
||||
var dictType = dict.get('Type');
|
||||
let dict = borderStyle.get('BS');
|
||||
let dictType = dict.get('Type');
|
||||
|
||||
if (!dictType || isName(dictType, 'Border')) {
|
||||
this.borderStyle.setWidth(dict.get('W'));
|
||||
@ -313,7 +308,7 @@ var Annotation = (function AnnotationClosure() {
|
||||
this.borderStyle.setDashArray(dict.getArray('D'));
|
||||
}
|
||||
} else if (borderStyle.has('Border')) {
|
||||
var array = borderStyle.getArray('Border');
|
||||
let array = borderStyle.getArray('Border');
|
||||
if (isArray(array) && array.length >= 3) {
|
||||
this.borderStyle.setHorizontalCornerRadius(array[0]);
|
||||
this.borderStyle.setVerticalCornerRadius(array[1]);
|
||||
@ -331,7 +326,7 @@ var Annotation = (function AnnotationClosure() {
|
||||
// See also https://github.com/mozilla/pdf.js/issues/6179.
|
||||
this.borderStyle.setWidth(0);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the (normal) appearance.
|
||||
@ -340,16 +335,16 @@ var Annotation = (function AnnotationClosure() {
|
||||
* @memberof Annotation
|
||||
* @param {Dict} dict - The annotation's data dictionary
|
||||
*/
|
||||
setAppearance: function Annotation_setAppearance(dict) {
|
||||
setAppearance(dict) {
|
||||
this.appearance = null;
|
||||
|
||||
var appearanceStates = dict.get('AP');
|
||||
let appearanceStates = dict.get('AP');
|
||||
if (!isDict(appearanceStates)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// In case the normal appearance is a stream, then it is used directly.
|
||||
var normalAppearanceState = appearanceStates.get('N');
|
||||
let normalAppearanceState = appearanceStates.get('N');
|
||||
if (isStream(normalAppearanceState)) {
|
||||
this.appearance = normalAppearanceState;
|
||||
return;
|
||||
@ -360,12 +355,12 @@ var Annotation = (function AnnotationClosure() {
|
||||
|
||||
// In case the normal appearance is a dictionary, the `AS` entry provides
|
||||
// the key of the stream in this dictionary.
|
||||
var as = dict.get('AS');
|
||||
let as = dict.get('AS');
|
||||
if (!isName(as) || !normalAppearanceState.has(as.name)) {
|
||||
return;
|
||||
}
|
||||
this.appearance = normalAppearanceState.get(as.name);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the annotation for working with a popup in the display layer.
|
||||
@ -374,7 +369,7 @@ var Annotation = (function AnnotationClosure() {
|
||||
* @memberof Annotation
|
||||
* @param {Dict} dict - The annotation's data dictionary
|
||||
*/
|
||||
_preparePopup: function Annotation_preparePopup(dict) {
|
||||
_preparePopup(dict) {
|
||||
if (!dict.has('C')) {
|
||||
// Fall back to the default background color.
|
||||
this.data.color = null;
|
||||
@ -383,9 +378,9 @@ var Annotation = (function AnnotationClosure() {
|
||||
this.data.hasPopup = dict.has('Popup');
|
||||
this.data.title = stringToPDFString(dict.get('T') || '');
|
||||
this.data.contents = stringToPDFString(dict.get('Contents') || '');
|
||||
},
|
||||
}
|
||||
|
||||
loadResources: function Annotation_loadResources(keys) {
|
||||
loadResources(keys) {
|
||||
return this.appearance.dict.getAsync('Resources').then((resources) => {
|
||||
if (!resources) {
|
||||
return;
|
||||
@ -396,32 +391,31 @@ var Annotation = (function AnnotationClosure() {
|
||||
return resources;
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getOperatorList: function Annotation_getOperatorList(evaluator, task,
|
||||
renderForms) {
|
||||
getOperatorList(evaluator, task, renderForms) {
|
||||
if (!this.appearance) {
|
||||
return Promise.resolve(new OperatorList());
|
||||
}
|
||||
|
||||
var data = this.data;
|
||||
var appearanceDict = this.appearance.dict;
|
||||
var resourcesPromise = this.loadResources([
|
||||
let data = this.data;
|
||||
let appearanceDict = this.appearance.dict;
|
||||
let resourcesPromise = this.loadResources([
|
||||
'ExtGState',
|
||||
'ColorSpace',
|
||||
'Pattern',
|
||||
'Shading',
|
||||
'XObject',
|
||||
'Font'
|
||||
'Font',
|
||||
// ProcSet
|
||||
// Properties
|
||||
]);
|
||||
var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
|
||||
var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
|
||||
var transform = getTransformMatrix(data.rect, bbox, matrix);
|
||||
let bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
|
||||
let matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
|
||||
let transform = getTransformMatrix(data.rect, bbox, matrix);
|
||||
|
||||
return resourcesPromise.then((resources) => {
|
||||
var opList = new OperatorList();
|
||||
let opList = new OperatorList();
|
||||
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
|
||||
return evaluator.getOperatorList({
|
||||
stream: this.appearance,
|
||||
@ -434,23 +428,14 @@ var Annotation = (function AnnotationClosure() {
|
||||
return opList;
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
return Annotation;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains all data regarding an annotation's border style.
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
/**
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
function AnnotationBorderStyle() {
|
||||
class AnnotationBorderStyle {
|
||||
constructor() {
|
||||
this.width = 1;
|
||||
this.style = AnnotationBorderStyleType.SOLID;
|
||||
this.dashArray = [3];
|
||||
@ -458,7 +443,6 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
this.verticalCornerRadius = 0;
|
||||
}
|
||||
|
||||
AnnotationBorderStyle.prototype = {
|
||||
/**
|
||||
* Set the width.
|
||||
*
|
||||
@ -466,11 +450,11 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
* @memberof AnnotationBorderStyle
|
||||
* @param {integer} width - The width
|
||||
*/
|
||||
setWidth: function AnnotationBorderStyle_setWidth(width) {
|
||||
setWidth(width) {
|
||||
if (width === (width | 0)) {
|
||||
this.width = width;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style.
|
||||
@ -480,7 +464,7 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
* @param {Object} style - The style object
|
||||
* @see {@link shared/util.js}
|
||||
*/
|
||||
setStyle: function AnnotationBorderStyle_setStyle(style) {
|
||||
setStyle(style) {
|
||||
if (!style) {
|
||||
return;
|
||||
}
|
||||
@ -508,7 +492,7 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dash array.
|
||||
@ -517,18 +501,18 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
* @memberof AnnotationBorderStyle
|
||||
* @param {Array} dashArray - The dash array with at least one element
|
||||
*/
|
||||
setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
|
||||
setDashArray(dashArray) {
|
||||
// We validate the dash array, but we do not use it because CSS does not
|
||||
// allow us to change spacing of dashes. For more information, visit
|
||||
// http://www.w3.org/TR/css3-background/#the-border-style.
|
||||
if (isArray(dashArray) && dashArray.length > 0) {
|
||||
// According to the PDF specification: the elements in a dashArray
|
||||
// According to the PDF specification: the elements in `dashArray`
|
||||
// shall be numbers that are nonnegative and not all equal to zero.
|
||||
var isValid = true;
|
||||
var allZeros = true;
|
||||
for (var i = 0, len = dashArray.length; i < len; i++) {
|
||||
var element = dashArray[i];
|
||||
var validNumber = (+element >= 0);
|
||||
let isValid = true;
|
||||
let allZeros = true;
|
||||
for (let i = 0, len = dashArray.length; i < len; i++) {
|
||||
let element = dashArray[i];
|
||||
let validNumber = (+element >= 0);
|
||||
if (!validNumber) {
|
||||
isValid = false;
|
||||
break;
|
||||
@ -544,7 +528,7 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
} else if (dashArray) {
|
||||
this.width = 0; // Adobe behavior when the array is invalid.
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the horizontal corner radius (from a Border dictionary).
|
||||
@ -553,12 +537,11 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
* @memberof AnnotationBorderStyle
|
||||
* @param {integer} radius - The horizontal corner radius
|
||||
*/
|
||||
setHorizontalCornerRadius:
|
||||
function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
|
||||
setHorizontalCornerRadius(radius) {
|
||||
if (radius === (radius | 0)) {
|
||||
this.horizontalCornerRadius = radius;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the vertical corner radius (from a Border dictionary).
|
||||
@ -567,23 +550,19 @@ var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
|
||||
* @memberof AnnotationBorderStyle
|
||||
* @param {integer} radius - The vertical corner radius
|
||||
*/
|
||||
setVerticalCornerRadius:
|
||||
function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
|
||||
setVerticalCornerRadius(radius) {
|
||||
if (radius === (radius | 0)) {
|
||||
this.verticalCornerRadius = radius;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return AnnotationBorderStyle;
|
||||
})();
|
||||
class WidgetAnnotation extends Annotation {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
function WidgetAnnotation(params) {
|
||||
Annotation.call(this, params);
|
||||
|
||||
var dict = params.dict;
|
||||
var data = this.data;
|
||||
let dict = params.dict;
|
||||
let data = this.data;
|
||||
|
||||
data.annotationType = AnnotationType.WIDGET;
|
||||
data.fieldName = this._constructFieldName(dict);
|
||||
@ -591,7 +570,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
/* getArray = */ true);
|
||||
data.alternativeText = stringToPDFString(dict.get('TU') || '');
|
||||
data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
|
||||
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
let fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
data.fieldType = isName(fieldType) ? fieldType.name : null;
|
||||
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
|
||||
|
||||
@ -608,7 +587,6 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(WidgetAnnotation, Annotation, {
|
||||
/**
|
||||
* Construct the (fully qualified) field name from the (partial) field
|
||||
* names of the field and its ancestors.
|
||||
@ -618,7 +596,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
* @param {Dict} dict - Complete widget annotation dictionary
|
||||
* @return {string}
|
||||
*/
|
||||
_constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
|
||||
_constructFieldName(dict) {
|
||||
// Both the `Parent` and `T` fields are optional. While at least one of
|
||||
// them should be provided, bad PDF generators may fail to do so.
|
||||
if (!dict.has('T') && !dict.has('Parent')) {
|
||||
@ -633,12 +611,12 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
|
||||
// Form the fully qualified field name by appending the partial name to
|
||||
// the parent's fully qualified name, separated by a period.
|
||||
var fieldName = [];
|
||||
let fieldName = [];
|
||||
if (dict.has('T')) {
|
||||
fieldName.unshift(stringToPDFString(dict.get('T')));
|
||||
}
|
||||
|
||||
var loopDict = dict;
|
||||
let loopDict = dict;
|
||||
while (loopDict.has('Parent')) {
|
||||
loopDict = loopDict.get('Parent');
|
||||
if (!isDict(loopDict)) {
|
||||
@ -653,7 +631,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
}
|
||||
}
|
||||
return fieldName.join('.');
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a provided field flag is set.
|
||||
@ -665,30 +643,36 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
* @return {boolean}
|
||||
* @see {@link shared/util.js}
|
||||
*/
|
||||
hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
|
||||
hasFieldFlag(flag) {
|
||||
return !!(this.data.fieldFlags & flag);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return WidgetAnnotation;
|
||||
})();
|
||||
getOperatorList(evaluator, task, renderForms) {
|
||||
// Do not render form elements on the canvas when interactive forms are
|
||||
// enabled. The display layer is responsible for rendering them instead.
|
||||
if (renderForms) {
|
||||
return Promise.resolve(new OperatorList());
|
||||
}
|
||||
return super.getOperatorList(evaluator, task, renderForms);
|
||||
}
|
||||
}
|
||||
|
||||
var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
||||
function TextWidgetAnnotation(params) {
|
||||
WidgetAnnotation.call(this, params);
|
||||
class TextWidgetAnnotation extends WidgetAnnotation {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
// The field value is always a string.
|
||||
this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
|
||||
|
||||
// Determine the alignment of text in the field.
|
||||
var alignment = Util.getInheritableProperty(params.dict, 'Q');
|
||||
let alignment = Util.getInheritableProperty(params.dict, 'Q');
|
||||
if (!isInt(alignment) || alignment < 0 || alignment > 2) {
|
||||
alignment = null;
|
||||
}
|
||||
this.data.textAlignment = alignment;
|
||||
|
||||
// Determine the maximum length of text in the field.
|
||||
var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
|
||||
let maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
|
||||
if (!isInt(maximumLength) || maximumLength < 0) {
|
||||
maximumLength = null;
|
||||
}
|
||||
@ -703,22 +687,12 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
||||
this.data.maxLen !== null;
|
||||
}
|
||||
|
||||
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
|
||||
getOperatorList:
|
||||
function TextWidgetAnnotation_getOperatorList(evaluator, task,
|
||||
renderForms) {
|
||||
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 (renderForms) {
|
||||
return Promise.resolve(operatorList);
|
||||
getOperatorList(evaluator, task, renderForms) {
|
||||
if (renderForms || this.appearance) {
|
||||
return super.getOperatorList(evaluator, task, renderForms);
|
||||
}
|
||||
|
||||
if (this.appearance) {
|
||||
return Annotation.prototype.getOperatorList.call(this, evaluator, task,
|
||||
renderForms);
|
||||
}
|
||||
let operatorList = new OperatorList();
|
||||
|
||||
// Even if there is an appearance stream, ignore it. This is the
|
||||
// behaviour used by Adobe Reader.
|
||||
@ -726,7 +700,7 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
||||
return Promise.resolve(operatorList);
|
||||
}
|
||||
|
||||
var stream = new Stream(stringToBytes(this.data.defaultAppearance));
|
||||
let stream = new Stream(stringToBytes(this.data.defaultAppearance));
|
||||
return evaluator.getOperatorList({
|
||||
stream,
|
||||
task,
|
||||
@ -735,15 +709,12 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
||||
}).then(function () {
|
||||
return operatorList;
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return TextWidgetAnnotation;
|
||||
})();
|
||||
|
||||
var ButtonWidgetAnnotation = (function ButtonWidgetAnnotationClosure() {
|
||||
function ButtonWidgetAnnotation(params) {
|
||||
WidgetAnnotation.call(this, params);
|
||||
class ButtonWidgetAnnotation extends WidgetAnnotation {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) &&
|
||||
!this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
|
||||
@ -761,25 +732,25 @@ var ButtonWidgetAnnotation = (function ButtonWidgetAnnotationClosure() {
|
||||
|
||||
// The parent field's `V` entry holds a `Name` object with the appearance
|
||||
// state of whichever child field is currently in the "on" state.
|
||||
var fieldParent = params.dict.get('Parent');
|
||||
let fieldParent = params.dict.get('Parent');
|
||||
if (isDict(fieldParent) && fieldParent.has('V')) {
|
||||
var fieldParentValue = fieldParent.get('V');
|
||||
let fieldParentValue = fieldParent.get('V');
|
||||
if (isName(fieldParentValue)) {
|
||||
this.data.fieldValue = fieldParentValue.name;
|
||||
}
|
||||
}
|
||||
|
||||
// The button's value corresponds to its appearance state.
|
||||
var appearanceStates = params.dict.get('AP');
|
||||
let appearanceStates = params.dict.get('AP');
|
||||
if (!isDict(appearanceStates)) {
|
||||
return;
|
||||
}
|
||||
var normalAppearanceState = appearanceStates.get('N');
|
||||
let normalAppearanceState = appearanceStates.get('N');
|
||||
if (!isDict(normalAppearanceState)) {
|
||||
return;
|
||||
}
|
||||
var keys = normalAppearanceState.getKeys();
|
||||
for (var i = 0, ii = keys.length; i < ii; i++) {
|
||||
let keys = normalAppearanceState.getKeys();
|
||||
for (let i = 0, ii = keys.length; i < ii; i++) {
|
||||
if (keys[i] !== 'Off') {
|
||||
this.data.buttonValue = keys[i];
|
||||
break;
|
||||
@ -787,33 +758,11 @@ var ButtonWidgetAnnotation = (function ButtonWidgetAnnotationClosure() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
|
||||
getOperatorList:
|
||||
function ButtonWidgetAnnotation_getOperatorList(evaluator, task,
|
||||
renderForms) {
|
||||
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 (renderForms) {
|
||||
return Promise.resolve(operatorList);
|
||||
}
|
||||
|
||||
if (this.appearance) {
|
||||
return Annotation.prototype.getOperatorList.call(this, evaluator, task,
|
||||
renderForms);
|
||||
}
|
||||
return Promise.resolve(operatorList);
|
||||
},
|
||||
});
|
||||
|
||||
return ButtonWidgetAnnotation;
|
||||
})();
|
||||
|
||||
var ChoiceWidgetAnnotation = (function ChoiceWidgetAnnotationClosure() {
|
||||
function ChoiceWidgetAnnotation(params) {
|
||||
WidgetAnnotation.call(this, params);
|
||||
class ChoiceWidgetAnnotation extends WidgetAnnotation {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
// Determine the options. The options array may consist of strings or
|
||||
// arrays. If the array consists of arrays, then the first element of
|
||||
@ -826,12 +775,12 @@ var ChoiceWidgetAnnotation = (function ChoiceWidgetAnnotationClosure() {
|
||||
// inherit the options from a parent annotation (issue 8094).
|
||||
this.data.options = [];
|
||||
|
||||
var options = Util.getInheritableProperty(params.dict, 'Opt');
|
||||
let options = Util.getInheritableProperty(params.dict, 'Opt');
|
||||
if (isArray(options)) {
|
||||
var xref = params.xref;
|
||||
for (var i = 0, ii = options.length; i < ii; i++) {
|
||||
var option = xref.fetchIfRef(options[i]);
|
||||
var isOptionArray = isArray(option);
|
||||
let xref = params.xref;
|
||||
for (let i = 0, ii = options.length; i < ii; i++) {
|
||||
let option = xref.fetchIfRef(options[i]);
|
||||
let isOptionArray = isArray(option);
|
||||
|
||||
this.data.options[i] = {
|
||||
exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
|
||||
@ -851,32 +800,13 @@ var ChoiceWidgetAnnotation = (function ChoiceWidgetAnnotationClosure() {
|
||||
this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
|
||||
this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
|
||||
}
|
||||
|
||||
Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
|
||||
getOperatorList:
|
||||
function ChoiceWidgetAnnotation_getOperatorList(evaluator, task,
|
||||
renderForms) {
|
||||
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 (renderForms) {
|
||||
return Promise.resolve(operatorList);
|
||||
}
|
||||
|
||||
return Annotation.prototype.getOperatorList.call(this, evaluator, task,
|
||||
renderForms);
|
||||
},
|
||||
});
|
||||
class TextAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
const DEFAULT_ICON_SIZE = 22; // px
|
||||
|
||||
return ChoiceWidgetAnnotation;
|
||||
})();
|
||||
|
||||
var TextAnnotation = (function TextAnnotationClosure() {
|
||||
var DEFAULT_ICON_SIZE = 22; // px
|
||||
|
||||
function TextAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.TEXT;
|
||||
|
||||
@ -890,45 +820,36 @@ var TextAnnotation = (function TextAnnotationClosure() {
|
||||
}
|
||||
this._preparePopup(parameters.dict);
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(TextAnnotation, Annotation, {});
|
||||
class LinkAnnotation extends Annotation {
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
return TextAnnotation;
|
||||
})();
|
||||
|
||||
var LinkAnnotation = (function LinkAnnotationClosure() {
|
||||
function LinkAnnotation(params) {
|
||||
Annotation.call(this, params);
|
||||
|
||||
var data = this.data;
|
||||
data.annotationType = AnnotationType.LINK;
|
||||
this.data.annotationType = AnnotationType.LINK;
|
||||
|
||||
Catalog.parseDestDictionary({
|
||||
destDict: params.dict,
|
||||
resultObj: data,
|
||||
resultObj: this.data,
|
||||
docBaseUrl: params.pdfManager.docBaseUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(LinkAnnotation, Annotation, {});
|
||||
|
||||
return LinkAnnotation;
|
||||
})();
|
||||
|
||||
var PopupAnnotation = (function PopupAnnotationClosure() {
|
||||
function PopupAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
class PopupAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.POPUP;
|
||||
|
||||
var dict = parameters.dict;
|
||||
var parentItem = dict.get('Parent');
|
||||
let dict = parameters.dict;
|
||||
let parentItem = dict.get('Parent');
|
||||
if (!parentItem) {
|
||||
warn('Popup annotation has a missing or invalid parent annotation.');
|
||||
return;
|
||||
}
|
||||
|
||||
var parentSubtype = parentItem.get('Subtype');
|
||||
let parentSubtype = parentItem.get('Subtype');
|
||||
this.data.parentType = isName(parentSubtype) ? parentSubtype.name : null;
|
||||
this.data.parentId = dict.getRaw('Parent').toString();
|
||||
this.data.title = stringToPDFString(parentItem.get('T') || '');
|
||||
@ -946,101 +867,73 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
|
||||
// that is most likely a bug. Fallback to inherit the flags from the parent
|
||||
// annotation (this is consistent with the behaviour in Adobe Reader).
|
||||
if (!this.viewable) {
|
||||
var parentFlags = parentItem.get('F');
|
||||
let parentFlags = parentItem.get('F');
|
||||
if (this._isViewable(parentFlags)) {
|
||||
this.setFlags(parentFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(PopupAnnotation, Annotation, {});
|
||||
|
||||
return PopupAnnotation;
|
||||
})();
|
||||
|
||||
var LineAnnotation = (function LineAnnotationClosure() {
|
||||
function LineAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
class LineAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.LINE;
|
||||
|
||||
var dict = parameters.dict;
|
||||
let dict = parameters.dict;
|
||||
this.data.lineCoordinates = Util.normalizeRect(dict.getArray('L'));
|
||||
this._preparePopup(dict);
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(LineAnnotation, Annotation, {});
|
||||
|
||||
return LineAnnotation;
|
||||
})();
|
||||
|
||||
var HighlightAnnotation = (function HighlightAnnotationClosure() {
|
||||
function HighlightAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
class HighlightAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.HIGHLIGHT;
|
||||
this._preparePopup(parameters.dict);
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(HighlightAnnotation, Annotation, {});
|
||||
|
||||
return HighlightAnnotation;
|
||||
})();
|
||||
|
||||
var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
|
||||
function UnderlineAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
class UnderlineAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.UNDERLINE;
|
||||
this._preparePopup(parameters.dict);
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(UnderlineAnnotation, Annotation, {});
|
||||
|
||||
return UnderlineAnnotation;
|
||||
})();
|
||||
|
||||
var SquigglyAnnotation = (function SquigglyAnnotationClosure() {
|
||||
function SquigglyAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
class SquigglyAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.SQUIGGLY;
|
||||
this._preparePopup(parameters.dict);
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(SquigglyAnnotation, Annotation, {});
|
||||
|
||||
return SquigglyAnnotation;
|
||||
})();
|
||||
|
||||
var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() {
|
||||
function StrikeOutAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
class StrikeOutAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
this.data.annotationType = AnnotationType.STRIKEOUT;
|
||||
this._preparePopup(parameters.dict);
|
||||
}
|
||||
}
|
||||
|
||||
Util.inherit(StrikeOutAnnotation, Annotation, {});
|
||||
class FileAttachmentAnnotation extends Annotation {
|
||||
constructor(parameters) {
|
||||
super(parameters);
|
||||
|
||||
return StrikeOutAnnotation;
|
||||
})();
|
||||
|
||||
var FileAttachmentAnnotation = (function FileAttachmentAnnotationClosure() {
|
||||
function FileAttachmentAnnotation(parameters) {
|
||||
Annotation.call(this, parameters);
|
||||
|
||||
var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
|
||||
let file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
|
||||
|
||||
this.data.annotationType = AnnotationType.FILEATTACHMENT;
|
||||
this.data.file = file.serializable;
|
||||
this._preparePopup(parameters.dict);
|
||||
}
|
||||
|
||||
Util.inherit(FileAttachmentAnnotation, Annotation, {});
|
||||
|
||||
return FileAttachmentAnnotation;
|
||||
})();
|
||||
}
|
||||
|
||||
export {
|
||||
Annotation,
|
||||
|
@ -316,10 +316,9 @@ var Page = (function PageClosure() {
|
||||
get annotations() {
|
||||
var annotations = [];
|
||||
var annotationRefs = this.getInheritedPageProp('Annots') || [];
|
||||
var annotationFactory = new AnnotationFactory();
|
||||
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
||||
var annotationRef = annotationRefs[i];
|
||||
var annotation = annotationFactory.create(this.xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(this.xref, annotationRef,
|
||||
this.pdfManager,
|
||||
this.idFactory);
|
||||
if (annotation) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -44,10 +44,9 @@ describe('annotation', function() {
|
||||
}
|
||||
IdFactoryMock.prototype = {};
|
||||
|
||||
var annotationFactory, pdfManagerMock, idFactoryMock;
|
||||
var pdfManagerMock, idFactoryMock;
|
||||
|
||||
beforeAll(function (done) {
|
||||
annotationFactory = new AnnotationFactory();
|
||||
pdfManagerMock = new PDFManagerMock({
|
||||
docBaseUrl: null,
|
||||
});
|
||||
@ -56,7 +55,6 @@ describe('annotation', function() {
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
annotationFactory = null;
|
||||
pdfManagerMock = null;
|
||||
idFactoryMock = null;
|
||||
});
|
||||
@ -72,7 +70,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -92,9 +90,9 @@ describe('annotation', function() {
|
||||
startObjId: 0,
|
||||
});
|
||||
|
||||
var annotation1 = annotationFactory.create(xref, annotationDict,
|
||||
var annotation1 = AnnotationFactory.create(xref, annotationDict,
|
||||
pdfManagerMock, idFactory);
|
||||
var annotation2 = annotationFactory.create(xref, annotationDict,
|
||||
var annotation2 = AnnotationFactory.create(xref, annotationDict,
|
||||
pdfManagerMock, idFactory);
|
||||
var data1 = annotation1.data, data2 = annotation2.data;
|
||||
expect(data1.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -113,7 +111,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toBeUndefined();
|
||||
@ -298,7 +296,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -326,7 +324,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -359,7 +357,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -389,7 +387,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -418,7 +416,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -450,7 +448,7 @@ describe('annotation', function() {
|
||||
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf',
|
||||
});
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManager, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -479,7 +477,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -508,7 +506,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -548,7 +546,7 @@ describe('annotation', function() {
|
||||
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf',
|
||||
});
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManager, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -583,7 +581,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock,
|
||||
idFactoryMock);
|
||||
var data = annotation.data;
|
||||
@ -635,7 +633,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -656,7 +654,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -679,7 +677,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, annotationRef,
|
||||
var annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -709,7 +707,7 @@ describe('annotation', function() {
|
||||
{ ref: annotationRef, data: annotationDict, }
|
||||
]);
|
||||
|
||||
let annotation = annotationFactory.create(xref, annotationRef,
|
||||
let annotation = AnnotationFactory.create(xref, annotationRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
let data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINK);
|
||||
@ -742,7 +740,7 @@ describe('annotation', function() {
|
||||
{ ref: widgetRef, data: widgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, widgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, widgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -759,7 +757,7 @@ describe('annotation', function() {
|
||||
{ ref: widgetRef, data: widgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, widgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, widgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -783,7 +781,7 @@ describe('annotation', function() {
|
||||
{ ref: widgetRef, data: widgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, widgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, widgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -805,7 +803,7 @@ describe('annotation', function() {
|
||||
{ ref: widgetRef, data: widgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, widgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, widgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -837,7 +835,7 @@ describe('annotation', function() {
|
||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, textWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, textWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -860,7 +858,7 @@ describe('annotation', function() {
|
||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, textWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, textWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -884,7 +882,7 @@ describe('annotation', function() {
|
||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, textWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, textWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -903,7 +901,7 @@ describe('annotation', function() {
|
||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, textWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, textWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -920,7 +918,7 @@ describe('annotation', function() {
|
||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, textWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, textWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -948,7 +946,7 @@ describe('annotation', function() {
|
||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, textWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, textWidgetRef,
|
||||
pdfManagerMock,
|
||||
idFactoryMock);
|
||||
var data = annotation.data;
|
||||
@ -989,7 +987,7 @@ describe('annotation', function() {
|
||||
{ ref: buttonWidgetRef, data: buttonWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, buttonWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, buttonWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1018,7 +1016,7 @@ describe('annotation', function() {
|
||||
{ ref: buttonWidgetRef, data: buttonWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, buttonWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, buttonWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1044,7 +1042,7 @@ describe('annotation', function() {
|
||||
{ ref: buttonWidgetRef, data: buttonWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, buttonWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, buttonWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1078,7 +1076,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1113,7 +1111,7 @@ describe('annotation', function() {
|
||||
{ ref: optionOneRef, data: optionOneArr, },
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1145,7 +1143,7 @@ describe('annotation', function() {
|
||||
{ ref: optionBarRef, data: optionBarStr, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1173,7 +1171,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, },
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1191,7 +1189,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1209,7 +1207,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1223,7 +1221,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1241,7 +1239,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1261,7 +1259,7 @@ describe('annotation', function() {
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
var annotation = AnnotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
@ -1284,7 +1282,7 @@ describe('annotation', function() {
|
||||
{ ref: lineRef, data: lineDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, lineRef, pdfManagerMock,
|
||||
var annotation = AnnotationFactory.create(xref, lineRef, pdfManagerMock,
|
||||
idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.LINE);
|
||||
@ -1337,7 +1335,7 @@ describe('annotation', function() {
|
||||
fileSpecDict.assignXref(xref);
|
||||
fileAttachmentDict.assignXref(xref);
|
||||
|
||||
var annotation = annotationFactory.create(xref, fileAttachmentRef,
|
||||
var annotation = AnnotationFactory.create(xref, fileAttachmentRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.FILEATTACHMENT);
|
||||
@ -1366,7 +1364,7 @@ describe('annotation', function() {
|
||||
{ ref: popupRef, data: popupDict, }
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, popupRef,
|
||||
var annotation = AnnotationFactory.create(xref, popupRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.POPUP);
|
||||
|
Loading…
x
Reference in New Issue
Block a user