all files / document/automatic-fields/ single-value-field.js

60.98% Statements 25/41
80% Branches 12/15
90% Functions 9/10
57.89% Lines 22/38
11 statements, 6 functions, 9 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                                         
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "./automatic-field", "./../../collections/object-object-pair/dictionary", "./pdf-template-value-pair", "./../../drawing/pdf-drawing", "./../../graphics/figures/pdf-template"], function (require, exports, automatic_field_1, dictionary_1, pdf_template_value_pair_1, pdf_drawing_1, pdf_template_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfSingleValueField = (function (_super) {
        __extends(PdfSingleValueField, _super);
        function PdfSingleValueField() {
            var _this = _super.call(this) || this;
            _this.list = new dictionary_1.TemporaryDictionary();
            _this.painterGraphics = [];
            return _this;
        }
        PdfSingleValueField.prototype.performDraw = function (graphics, location, scalingX, scalingY) {
            _super.prototype.performDrawHelper.call(this, graphics, location, scalingX, scalingY);
            var page = this.getPageFromGraphics(graphics);
            var document = page.document;
            var textValue = this.getValue(graphics);
            if (this.list.containsKey(document)) {
                var pair = this.list.getValue(document);
                var drawLocation = new pdf_drawing_1.PointF(location.x + this.location.x, location.y + this.location.y);
                graphics.drawPdfTemplate(pair.template, drawLocation, new pdf_drawing_1.SizeF(pair.template.width * scalingX, pair.template.height * scalingY));
                this.painterGraphics.push(graphics);
            }
            else {
                var size = this.getSize();
                var template = new pdf_template_1.PdfTemplate(size);
                this.list.setValue(document, new pdf_template_value_pair_1.PdfTemplateValuePair(template, textValue));
                template.graphics.drawString(textValue, this.getFont(), this.pen, this.getBrush(), 0, 0, size.width, size.height, this.stringFormat);
                var drawLocation = new pdf_drawing_1.PointF(location.x + this.location.x, location.y + this.location.y);
                graphics.drawPdfTemplate(template, drawLocation, new pdf_drawing_1.SizeF(template.width * scalingX, template.height * scalingY));
                this.painterGraphics.push(graphics);
            }
        };
        return PdfSingleValueField;
    }(automatic_field_1.PdfAutomaticField));
    exports.PdfSingleValueField = PdfSingleValueField;
});