all files / primitives/ pdf-dictionary.js

90.54% Statements 134/148
85% Branches 17/20
79.55% Functions 35/44
90.54% Lines 134/148
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248   198× 198× 198× 198× 198× 198× 198× 198× 198× 193× 193× 193×     11×         2047×           97×     189×                 394×           328×     184×                       298×     368×           151×                     92×                     33397×                           15×         244× 93×     151× 151×   151×   151×   151×     151×   151× 15×   151× 147×   151× 151×     147× 147× 147× 147× 407× 407× 407× 407× 407× 407× 407×                             15×        
define(["require", "exports", "./../collections/dictionary", "./pdf-name", "./../input-output/pdf-operators", "./../input-output/pdf-dictionary-properties"], function (require, exports, dictionary_1, pdf_name_1, pdf_operators_1, pdf_dictionary_properties_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfDictionary = (function () {
        function PdfDictionary(dictionary) {
            this.position7 = -1;
            this.primitiveItems = new dictionary_1.Dictionary();
            this.prefix = '<<';
            this.suffix = '>>';
            this.resources = [];
            this.object = null;
            this.archive = true;
            this.isResource = false;
            if (typeof dictionary === 'undefined') {
                this.primitiveItems = new dictionary_1.Dictionary();
                this.encrypt = true;
                this.dictionaryProperties = new pdf_dictionary_properties_1.DictionaryProperties();
            }
            else {
                this.primitiveItems = new dictionary_1.Dictionary();
                var keys = dictionary.items.keys();
                var values = dictionary.items.values();
                for (var index = 0; index < dictionary.items.size(); index++) {
                    this.primitiveItems.setValue(keys[index], values[index]);
                }
                this.status = dictionary.status;
                this.freezeChanges(this);
                this.encrypt = true;
                this.dictionaryProperties = new pdf_dictionary_properties_1.DictionaryProperties();
            }
        }
        Object.defineProperty(PdfDictionary.prototype, "items", {
            get: function () {
                return this.primitiveItems;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "status", {
            get: function () {
                return this.status7;
            },
            set: function (value) {
                this.status7 = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "isSaving", {
            get: function () {
                return this.isSaving7;
            },
            set: function (value) {
                this.isSaving7 = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "objectCollectionIndex", {
            get: function () {
                return this.index7;
            },
            set: function (value) {
                this.index7 = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "clonedObject", {
            get: function () {
                return this.object;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "position", {
            get: function () {
                return this.position7;
            },
            set: function (value) {
                this.position7 = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "Count", {
            get: function () {
                return this.primitiveItems.size();
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfDictionary.prototype, "Dictionary", {
            get: function () {
                return this;
            },
            enumerable: true,
            configurable: true
        });
        PdfDictionary.prototype.getArchive = function () {
            return this.archive;
        };
        PdfDictionary.prototype.setArchive = function (value) {
            this.archive = value;
        };
        PdfDictionary.prototype.setEncrypt = function (value) {
            this.encrypt = value;
            this.modify();
        };
        PdfDictionary.prototype.getEncrypt = function () {
            return this.encrypt;
        };
        PdfDictionary.prototype.freezeChanges = function (freezer) {
            this.bChanged = false;
        };
        PdfDictionary.prototype.clone = function (crossTable) {
            var newDict = new PdfDictionary();
            return newDict;
        };
        PdfDictionary.prototype.modify = function () {
            this.bChanged = true;
        };
        PdfDictionary.prototype.remove = function (key) {
            if (typeof key !== 'string') {
                this.primitiveItems.remove(key.value);
                this.modify();
            }
            else {
                this.remove(new pdf_name_1.PdfName(key));
            }
        };
        PdfDictionary.prototype.containsKey = function (key) {
            var returnValue = false;
            returnValue = this.primitiveItems.containsKey(key.toString());
            return returnValue;
        };
        PdfDictionary.prototype.onBeginSave = function () {
            this.beginSave.sender.beginSave();
        };
        PdfDictionary.prototype.onFontDictionaryBeginSave = function () {
            this.fontDictionaryBeginSave.sender.fontDictionaryBeginSave();
        };
        PdfDictionary.prototype.onDescendantFontBeginSave = function () {
            this.descendantFontBeginSave.sender.descendantFontBeginSave();
        };
        PdfDictionary.prototype.onTemplateBeginSave = function () {
            this.pageBeginDrawTemplate.sender.pageBeginSave();
        };
        PdfDictionary.prototype.onBeginAnnotationSave = function () {
            this.annotationBeginSave.sender.beginSave();
        };
        PdfDictionary.prototype.onSectionBeginSave = function (writer) {
            var saveEvent = this.sectionBeginSave;
            saveEvent.sender.beginSave(saveEvent.state, writer);
        };
        PdfDictionary.prototype.save = function (writer, bRaiseEvent) {
            if (typeof bRaiseEvent === 'undefined') {
                this.save(writer, true);
            }
            else {
                writer.write(this.prefix);
                if (typeof this.beginSave !== 'undefined') {
                    this.onBeginSave();
                }
                if (typeof this.descendantFontBeginSave !== 'undefined') {
                    this.onDescendantFontBeginSave();
                }
                if (typeof this.fontDictionaryBeginSave !== 'undefined') {
                    this.onFontDictionaryBeginSave();
                }
                Iif (typeof this.annotationBeginSave !== 'undefined') {
                    this.onBeginAnnotationSave();
                }
                if (typeof this.sectionBeginSave !== 'undefined') {
                    this.onSectionBeginSave(writer);
                }
                if (typeof this.pageBeginDrawTemplate !== 'undefined') {
                    this.onTemplateBeginSave();
                }
                if (this.Count > 0) {
                    this.saveItems(writer);
                }
                writer.write(this.suffix);
                writer.write(pdf_operators_1.Operators.newLine);
            }
        };
        PdfDictionary.prototype.saveItems = function (writer) {
            writer.write(pdf_operators_1.Operators.newLine);
            var keys = this.primitiveItems.keys();
            var values = this.primitiveItems.values();
            for (var index = 0; index < keys.length; index++) {
                var key = keys[index];
                var name_1 = new pdf_name_1.PdfName(key);
                name_1.save(writer);
                writer.write(pdf_operators_1.Operators.whiteSpace);
                var resources = values[index];
                resources.save(writer);
                writer.write(pdf_operators_1.Operators.newLine);
            }
        };
        return PdfDictionary;
    }());
    exports.PdfDictionary = PdfDictionary;
    var SaveSectionCollectionEventHandler = (function () {
        function SaveSectionCollectionEventHandler(sender) {
            this.sender = sender;
        }
        return SaveSectionCollectionEventHandler;
    }());
    exports.SaveSectionCollectionEventHandler = SaveSectionCollectionEventHandler;
    var SaveDescendantFontEventHandler = (function () {
        function SaveDescendantFontEventHandler(sender) {
            this.sender = sender;
        }
        return SaveDescendantFontEventHandler;
    }());
    exports.SaveDescendantFontEventHandler = SaveDescendantFontEventHandler;
    var SaveFontDictionaryEventHandler = (function () {
        function SaveFontDictionaryEventHandler(sender) {
            this.sender = sender;
        }
        return SaveFontDictionaryEventHandler;
    }());
    exports.SaveFontDictionaryEventHandler = SaveFontDictionaryEventHandler;
    var SaveAnnotationEventHandler = (function () {
        function SaveAnnotationEventHandler(sender) {
            this.sender = sender;
        }
        return SaveAnnotationEventHandler;
    }());
    exports.SaveAnnotationEventHandler = SaveAnnotationEventHandler;
    var SaveSectionEventHandler = (function () {
        function SaveSectionEventHandler(sender, state) {
            this.sender = sender;
            this.state = state;
        }
        return SaveSectionEventHandler;
    }());
    exports.SaveSectionEventHandler = SaveSectionEventHandler;
    var SaveTemplateEventHandler = (function () {
        function SaveTemplateEventHandler(sender) {
            this.sender = sender;
        }
        return SaveTemplateEventHandler;
    }());
    exports.SaveTemplateEventHandler = SaveTemplateEventHandler;
});