all files / document-editor/implementation/format/ row-format.js

99.03% Statements 204/206
90.63% Branches 58/64
97.73% Functions 43/44
99.03% Lines 204/206
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 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372   2106× 2106× 2106× 2106× 2106× 2106× 2106× 2106×     36125×     859×           4796×     779×           936×     731×           8350×     860×           5649×     774×           753×     727×           7299×     983×           9626×     988×           1074×     817×           30342×     2427× 181×   2246× 1913×   2427×           78391×     1404× 464×     940×   1404×           857×     802×           755×     736×           857×     802×           1081×     817×         186983× 186983× 120902× 120902× 120902×     66081×   14506× 2705×   14506× 1279×     13227× 13227×   1549×   11678×     1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279× 1279×   20464× 20464× 1279×     68786× 68786×   5954× 5954×   7356× 7356×   55× 55×   3132× 3132×   28412× 28412×   4416× 4416×   843× 843×   6595× 6595×   5215× 5215×   708× 708×   1352× 1352×   1352× 1352×   1352× 1352×   1352× 1352×   692× 692×   68786×             29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29× 29×       29×   29×   239691× 237960× 237960×   1731×   699× 698× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695× 695×   698× 696× 696× 696×   698× 38×     660×       628× 618×   628× 612×   628× 628× 628× 628×          
define(["require", "exports", "@syncfusion/ej2-base", "../../base/dictionary", "../../base/unique-format", "../../base/unique-formats", "./borders", "../track-changes/track-changes"], function (require, exports, ej2_base_1, dictionary_1, unique_format_1, unique_formats_1, borders_1, track_changes_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WRowFormat = (function () {
        function WRowFormat(node) {
            this.uniqueRowFormat = undefined;
            this.borders = new borders_1.WBorders(this);
            this.ownerBase = undefined;
            this.beforeWidth = 0;
            this.afterWidth = 0;
            this.revisions = [];
            this.removedIds = [];
            this.ownerBase = node;
        }
        Object.defineProperty(WRowFormat.prototype, "gridBefore", {
            get: function () {
                return this.getPropertyValue('gridBefore');
            },
            set: function (value) {
                this.setPropertyValue('gridBefore', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "gridBeforeWidth", {
            get: function () {
                return this.getPropertyValue('gridBeforeWidth');
            },
            set: function (value) {
                this.setPropertyValue('gridBeforeWidth', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "gridBeforeWidthType", {
            get: function () {
                return this.getPropertyValue('gridBeforeWidthType');
            },
            set: function (value) {
                this.setPropertyValue('gridBeforeWidthType', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "gridAfter", {
            get: function () {
                return this.getPropertyValue('gridAfter');
            },
            set: function (value) {
                this.setPropertyValue('gridAfter', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "gridAfterWidth", {
            get: function () {
                return this.getPropertyValue('gridAfterWidth');
            },
            set: function (value) {
                this.setPropertyValue('gridAfterWidth', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "gridAfterWidthType", {
            get: function () {
                return this.getPropertyValue('gridAfterWidthType');
            },
            set: function (value) {
                this.setPropertyValue('gridAfterWidthType', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "allowBreakAcrossPages", {
            get: function () {
                return this.getPropertyValue('allowBreakAcrossPages');
            },
            set: function (value) {
                this.setPropertyValue('allowBreakAcrossPages', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "isHeader", {
            get: function () {
                return this.getPropertyValue('isHeader');
            },
            set: function (value) {
                this.setPropertyValue('isHeader', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "rightMargin", {
            get: function () {
                return this.getPropertyValue('rightMargin');
            },
            set: function (value) {
                this.setPropertyValue('rightMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "height", {
            get: function () {
                return this.getPropertyValue('height');
            },
            set: function (value) {
                if (value === 0 && (this.heightType === 'AtLeast' || this.heightType === 'Exactly')) {
                    value = 1;
                }
                else if (this.heightType === 'Auto') {
                    value = 0;
                }
                this.setPropertyValue('height', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "heightType", {
            get: function () {
                return this.getPropertyValue('heightType');
            },
            set: function (value) {
                if (value === 'AtLeast' || value === 'Exactly') {
                    this.height = 1;
                }
                else {
                    this.height = 0;
                }
                this.setPropertyValue('heightType', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "bottomMargin", {
            get: function () {
                return this.getPropertyValue('bottomMargin');
            },
            set: function (value) {
                this.setPropertyValue('bottomMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "leftIndent", {
            get: function () {
                return this.getPropertyValue('leftIndent');
            },
            set: function (value) {
                this.setPropertyValue('leftIndent', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "topMargin", {
            get: function () {
                return this.getPropertyValue('topMargin');
            },
            set: function (value) {
                this.setPropertyValue('topMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WRowFormat.prototype, "leftMargin", {
            get: function () {
                return this.getPropertyValue('leftMargin');
            },
            set: function (value) {
                this.setPropertyValue('leftMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        WRowFormat.prototype.getPropertyValue = function (property) {
            var hasValue = this.hasValue(property);
            if (hasValue) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WRowFormat.uniqueFormatType, property);
                Eif (!ej2_base_1.isNullOrUndefined(this.uniqueRowFormat) && this.uniqueRowFormat.propertiesHash.containsKey(propertyType)) {
                    return this.uniqueRowFormat.propertiesHash.get(propertyType);
                }
            }
            return WRowFormat.getPropertyDefaultValue(property);
        };
        WRowFormat.prototype.setPropertyValue = function (property, value) {
            if (ej2_base_1.isNullOrUndefined(value) || value === '') {
                value = WRowFormat.getPropertyDefaultValue(property);
            }
            if (ej2_base_1.isNullOrUndefined(this.uniqueRowFormat)) {
                this.initializeUniqueRowFormat(property, value);
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueRowFormat.uniqueFormatType, property);
                if (this.uniqueRowFormat.propertiesHash.containsKey(propertyType) &&
                    this.uniqueRowFormat.propertiesHash.get(propertyType) === value) {
                    return;
                }
                this.uniqueRowFormat = WRowFormat.uniqueRowFormats.updateUniqueFormat(this.uniqueRowFormat, property, value);
            }
        };
        WRowFormat.prototype.initializeUniqueRowFormat = function (property, propValue) {
            var uniqueRowFormatTemp = new dictionary_1.Dictionary();
            this.addUniqueRowFormat('allowBreakAcrossPages', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('isHeader', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('height', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('heightType', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridBefore', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridBeforeWidth', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridBeforeWidthType', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridAfter', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridAfterWidth', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridgridAfterWidth', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('gridBeforeWidthType', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('leftMargin', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('rightMargin', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('topMargin', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('bottomMargin', property, propValue, uniqueRowFormatTemp);
            this.addUniqueRowFormat('leftIndent', property, propValue, uniqueRowFormatTemp);
            this.uniqueRowFormat = WRowFormat.uniqueRowFormats.addUniqueFormat(uniqueRowFormatTemp, WRowFormat.uniqueFormatType);
        };
        WRowFormat.prototype.addUniqueRowFormat = function (property, modifiedProperty, propValue, uniqueRowFormatTemp) {
            var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WRowFormat.uniqueFormatType, property);
            if (property === modifiedProperty) {
                uniqueRowFormatTemp.add(propertyType, propValue);
            }
        };
        WRowFormat.getPropertyDefaultValue = function (property) {
            var value = undefined;
            switch (property) {
                case 'allowBreakAcrossPages':
                    value = true;
                    break;
                case 'isHeader':
                    value = false;
                    break;
                case 'height':
                    value = 0;
                    break;
                case 'heightType':
                    value = 'Auto';
                    break;
                case 'gridBefore':
                    value = 0;
                    break;
                case 'gridBeforeWidth':
                    value = 0;
                    break;
                case 'gridBeforeWidthType':
                    value = 'Point';
                    break;
                case 'gridAfter':
                    value = 0;
                    break;
                case 'gridAfterWidth':
                    value = 0;
                    break;
                case 'gridAfterWidthType':
                    value = 'Point';
                    break;
                case 'leftMargin':
                    value = undefined;
                    break;
                case 'topMargin':
                    value = undefined;
                    break;
                case 'bottomMargin':
                    value = undefined;
                    break;
                case 'rightMargin':
                    value = undefined;
                    break;
                case 'leftIndent':
                    value = 0;
                    break;
            }
            return value;
        };
        WRowFormat.prototype.containsMargins = function () {
            return (!ej2_base_1.isNullOrUndefined(this.leftMargin)
                || !ej2_base_1.isNullOrUndefined(this.rightMargin)
                || !ej2_base_1.isNullOrUndefined(this.bottomMargin)
                || !ej2_base_1.isNullOrUndefined(this.topMargin));
        };
        WRowFormat.prototype.cloneFormat = function () {
            var format = new WRowFormat();
            format.allowBreakAcrossPages = this.allowBreakAcrossPages;
            format.heightType = this.heightType;
            format.height = this.height;
            format.isHeader = this.isHeader;
            format.gridBefore = this.gridBefore;
            format.gridBeforeWidth = this.gridBeforeWidth;
            format.gridBeforeWidthType = this.gridBeforeWidthType;
            format.gridAfter = this.gridAfter;
            format.gridAfterWidth = this.gridAfterWidth;
            format.gridAfterWidthType = this.gridAfterWidthType;
            format.leftMargin = this.leftMargin;
            format.rightMargin = this.rightMargin;
            format.topMargin = this.topMargin;
            format.bottomMargin = this.bottomMargin;
            format.leftIndent = this.leftIndent;
            Iif (this.revisions.length > 0) {
                format.removedIds = track_changes_1.Revision.cloneRevisions(this.revisions);
            }
            else {
                format.removedIds = this.removedIds.slice();
            }
            return format;
        };
        WRowFormat.prototype.hasValue = function (property) {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueRowFormat)) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueRowFormat.uniqueFormatType, property);
                return this.uniqueRowFormat.propertiesHash.containsKey(propertyType);
            }
            return false;
        };
        WRowFormat.prototype.copyFormat = function (format) {
            if (!ej2_base_1.isNullOrUndefined(format)) {
                if (!ej2_base_1.isNullOrUndefined(format.uniqueRowFormat)) {
                    this.allowBreakAcrossPages = format.allowBreakAcrossPages;
                    this.isHeader = format.isHeader;
                    this.heightType = format.heightType;
                    this.height = format.height;
                    this.gridBefore = format.gridBefore;
                    this.gridBeforeWidth = format.gridBeforeWidth;
                    this.gridBeforeWidthType = format.gridBeforeWidthType;
                    this.gridAfter = format.gridAfter;
                    this.gridAfterWidth = format.gridAfterWidth;
                    this.gridAfterWidthType = format.gridAfterWidthType;
                    this.leftMargin = format.leftMargin;
                    this.topMargin = format.topMargin;
                    this.rightMargin = format.rightMargin;
                    this.bottomMargin = format.bottomMargin;
                    this.leftIndent = format.leftIndent;
                    this.revisions = format.revisions;
                }
                if (!ej2_base_1.isNullOrUndefined(format.borders)) {
                    this.borders = new borders_1.WBorders(this);
                    this.borders.ownerBase = format;
                    this.borders.copyFormat(format.borders);
                }
                if (format.revisions.length > 0) {
                    this.removedIds = track_changes_1.Revision.cloneRevisions(format.revisions);
                }
                else {
                    this.removedIds = format.removedIds.slice();
                }
            }
        };
        WRowFormat.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.borders)) {
                this.borders.destroy();
            }
            if (!ej2_base_1.isNullOrUndefined(this.uniqueRowFormat)) {
                WRowFormat.uniqueRowFormats.remove(this.uniqueRowFormat);
            }
            this.beforeWidth = undefined;
            this.afterWidth = undefined;
            this.borders = undefined;
            this.uniqueRowFormat = undefined;
        };
        WRowFormat.clear = function () {
            this.uniqueRowFormats.clear();
        };
        WRowFormat.uniqueRowFormats = new unique_formats_1.WUniqueFormats();
        WRowFormat.uniqueFormatType = 6;
        return WRowFormat;
    }());
    exports.WRowFormat = WRowFormat;
});