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

99.09% Statements 218/220
95.24% Branches 60/63
100% Functions 47/47
99.09% Lines 218/220
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 373 374 375 376 377 378 379 380 381 382 383 384   857× 857× 857× 857× 857× 857× 857× 857× 857×     3092×     134×           3091×     133×           16518×     637×           202450×     613×     613×           21501×     1512×           10463×     1510×           20974×     1511×           10102×     1510×           6205×     685×           11131×     850×     850×           9286×     619×           17854×     860×           7803×     670×           557×     596×           557×     596×           723×     580×         335635× 335635× 117972× 117972× 117972×     217663×   12169× 509×   12169× 860×     11309× 11309×   4240×   7069×     860× 860× 860× 860× 860× 860× 860× 860× 860× 860× 860× 860× 860× 860× 860×   11180× 11180× 11180× 860×     218172× 218172×   13907× 13907×   183112× 183112×           85× 85×   5116× 5116×   7876× 7876×   101× 101×   6478× 6478×   997× 997×   492× 492×   218172×   857× 857× 857× 857×   172× 172× 172× 172× 172× 172× 172× 172× 172× 172× 172× 172×   409× 396×   409× 396×   409× 399×   409× 409× 409× 409×   13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13×   359600× 359582× 359582×   18×   547× 545× 544× 544× 544× 544× 544× 544× 544× 544× 544× 544× 544× 544× 544× 544×   545× 544× 544×   545× 544× 544×   545× 10×   545×              
define(["require", "exports", "../../base/dictionary", "../../base/unique-format", "../../base/unique-formats", "./borders", "./shading", "@syncfusion/ej2-base"], function (require, exports, dictionary_1, unique_format_1, unique_formats_1, borders_1, shading_1, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WTableFormat = (function () {
        function WTableFormat(owner) {
            this.uniqueTableFormat = undefined;
            this.borders = new borders_1.WBorders(this);
            this.shading = new shading_1.WShading(this);
            this._title = undefined;
            this._description = undefined;
            this.ownerBase = undefined;
            this._styleName = undefined;
            this.ownerBase = owner;
            this.assignTableMarginValue(5.4, 0, 5.4, 0);
        }
        Object.defineProperty(WTableFormat.prototype, "title", {
            get: function () {
                return this._title;
            },
            set: function (value) {
                this._title = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "description", {
            get: function () {
                return this._description;
            },
            set: function (value) {
                this._description = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "allowAutoFit", {
            get: function () {
                return this.getPropertyValue('allowAutoFit');
            },
            set: function (value) {
                this.setPropertyValue('allowAutoFit', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "cellSpacing", {
            get: function () {
                return this.getPropertyValue('cellSpacing');
            },
            set: function (value) {
                Iif (value < 0 || value > 264.6) {
                    throw new RangeError('The measurement must be between 0 px and 264.6 px.');
                }
                this.setPropertyValue('cellSpacing', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "leftMargin", {
            get: function () {
                return this.getPropertyValue('leftMargin');
            },
            set: function (value) {
                this.setPropertyValue('leftMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "topMargin", {
            get: function () {
                return this.getPropertyValue('topMargin');
            },
            set: function (value) {
                this.setPropertyValue('topMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "rightMargin", {
            get: function () {
                return this.getPropertyValue('rightMargin');
            },
            set: function (value) {
                this.setPropertyValue('rightMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "bottomMargin", {
            get: function () {
                return this.getPropertyValue('bottomMargin');
            },
            set: function (value) {
                this.setPropertyValue('bottomMargin', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "tableAlignment", {
            get: function () {
                return this.getPropertyValue('tableAlignment');
            },
            set: function (value) {
                this.setPropertyValue('tableAlignment', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "leftIndent", {
            get: function () {
                return this.getPropertyValue('leftIndent');
            },
            set: function (value) {
                Iif (value < -1440 || value > 1440) {
                    throw new RangeError('The measurement must be between -1440 px and 1440 px.');
                }
                this.setPropertyValue('leftIndent', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "preferredWidth", {
            get: function () {
                return this.getPropertyValue('preferredWidth');
            },
            set: function (value) {
                this.setPropertyValue('preferredWidth', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "preferredWidthType", {
            get: function () {
                return this.getPropertyValue('preferredWidthType');
            },
            set: function (value) {
                this.setPropertyValue('preferredWidthType', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "bidi", {
            get: function () {
                return this.getPropertyValue('bidi');
            },
            set: function (value) {
                this.setPropertyValue('bidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "horizontalPositionAbs", {
            get: function () {
                return this.getPropertyValue('horizontalPositionAbs');
            },
            set: function (value) {
                this.setPropertyValue('horizontalPositionAbs', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "horizontalPosition", {
            get: function () {
                return this.getPropertyValue('horizontalPosition');
            },
            set: function (value) {
                this.setPropertyValue('horizontalPosition', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WTableFormat.prototype, "styleName", {
            get: function () {
                return this._styleName;
            },
            set: function (value) {
                this._styleName = value;
            },
            enumerable: true,
            configurable: true
        });
        WTableFormat.prototype.getPropertyValue = function (property) {
            var hasValue = this.hasValue(property);
            if (hasValue) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WTableFormat.uniqueFormatType, property);
                Eif (!ej2_base_1.isNullOrUndefined(this.uniqueTableFormat) && this.uniqueTableFormat.propertiesHash.containsKey(propertyType)) {
                    return this.uniqueTableFormat.propertiesHash.get(propertyType);
                }
            }
            return WTableFormat.getPropertyDefaultValue(property);
        };
        WTableFormat.prototype.setPropertyValue = function (property, value) {
            if (ej2_base_1.isNullOrUndefined(value) || value === '') {
                value = WTableFormat.getPropertyDefaultValue(property);
            }
            if (ej2_base_1.isNullOrUndefined(this.uniqueTableFormat)) {
                this.initializeUniqueTableFormat(property, value);
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueTableFormat.uniqueFormatType, property);
                if (this.uniqueTableFormat.propertiesHash.containsKey(propertyType) &&
                    this.uniqueTableFormat.propertiesHash.get(propertyType) === value) {
                    return;
                }
                this.uniqueTableFormat = WTableFormat.uniqueTableFormats.updateUniqueFormat(this.uniqueTableFormat, property, value);
            }
        };
        WTableFormat.prototype.initializeUniqueTableFormat = function (property, propValue) {
            var uniqueTableFormatTemp = new dictionary_1.Dictionary();
            this.addUniqueTableFormat('allowAutoFit', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('cellSpacing', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('leftMargin', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('topMargin', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('bottomMargin', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('rightMargin', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('leftIndent', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('tableAlignment', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('preferredWidth', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('preferredWidthType', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('bidi', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('horizontalPositionAbs', property, propValue, uniqueTableFormatTemp);
            this.addUniqueTableFormat('horizontalPosition', property, propValue, uniqueTableFormatTemp);
            this.uniqueTableFormat = WTableFormat.uniqueTableFormats.addUniqueFormat(uniqueTableFormatTemp, WTableFormat.uniqueFormatType);
        };
        WTableFormat.prototype.addUniqueTableFormat = function (property, modifiedProperty, propValue, uniqueTableFormatTemp) {
            var propertyType;
            propertyType = unique_format_1.WUniqueFormat.getPropertyType(WTableFormat.uniqueFormatType, property);
            if (property === modifiedProperty) {
                uniqueTableFormatTemp.add(propertyType, propValue);
            }
        };
        WTableFormat.getPropertyDefaultValue = function (property) {
            var value = undefined;
            switch (property) {
                case 'allowAutoFit':
                    value = false;
                    break;
                case 'cellSpacing':
                    value = 0;
                    break;
                case 'leftMargin':
                    value = 5.4;
                    break;
                case 'topMargin':
                    value = 0;
                    break;
                case 'bottomMargin':
                    value = 0;
                    break;
                case 'rightMargin':
                    value = 5.4;
                    break;
                case 'leftIndent':
                    value = 0;
                    break;
                case 'tableAlignment':
                    value = 'Left';
                    break;
                case 'preferredWidth':
                    value = 0;
                    break;
                case 'preferredWidthType':
                    value = 'Point';
                    break;
                case 'bidi':
                    value = false;
                    break;
                case 'horizontalPositionAbs':
                    value = null;
                    break;
                case 'horizontalPosition':
                    value = 0;
                    break;
            }
            return value;
        };
        WTableFormat.prototype.assignTableMarginValue = function (left, top, right, bottom) {
            this.leftMargin = left;
            this.topMargin = top;
            this.rightMargin = right;
            this.bottomMargin = bottom;
        };
        WTableFormat.prototype.initializeTableBorders = function () {
            this.borders.left.lineStyle = 'Single';
            this.borders.left.lineWidth = 0.5;
            this.borders.right.lineStyle = 'Single';
            this.borders.right.lineWidth = 0.5;
            this.borders.top.lineStyle = 'Single';
            this.borders.top.lineWidth = 0.5;
            this.borders.bottom.lineStyle = 'Single';
            this.borders.bottom.lineWidth = 0.5;
            this.borders.horizontal.lineStyle = 'Single';
            this.borders.horizontal.lineWidth = 0.5;
            this.borders.vertical.lineStyle = 'Single';
            this.borders.vertical.lineWidth = 0.5;
        };
        WTableFormat.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.borders)) {
                this.borders.destroy();
            }
            if (!ej2_base_1.isNullOrUndefined(this.shading)) {
                this.shading.destroy();
            }
            if (!ej2_base_1.isNullOrUndefined(this.uniqueTableFormat)) {
                WTableFormat.uniqueTableFormats.remove(this.uniqueTableFormat);
            }
            this.uniqueTableFormat = undefined;
            this.ownerBase = undefined;
            this.borders = undefined;
            this.shading = undefined;
        };
        WTableFormat.prototype.cloneFormat = function () {
            var tableFormat = new WTableFormat(undefined);
            tableFormat.leftIndent = this.leftIndent;
            tableFormat.tableAlignment = this.tableAlignment;
            tableFormat.cellSpacing = this.cellSpacing;
            tableFormat.leftMargin = this.leftMargin;
            tableFormat.rightMargin = this.rightMargin;
            tableFormat.topMargin = this.topMargin;
            tableFormat.bottomMargin = this.bottomMargin;
            tableFormat.preferredWidth = this.preferredWidth;
            tableFormat.preferredWidthType = this.preferredWidthType;
            tableFormat.horizontalPositionAbs = this.horizontalPositionAbs;
            tableFormat.horizontalPosition = this.horizontalPosition;
            tableFormat.borders = ej2_base_1.isNullOrUndefined(this.borders) ? undefined : this.borders.cloneFormat();
            tableFormat.shading = ej2_base_1.isNullOrUndefined(this.shading) ? undefined : this.shading.cloneFormat();
            tableFormat.bidi = this.bidi;
            tableFormat.allowAutoFit = this.allowAutoFit;
            tableFormat.styleName = this.styleName;
            tableFormat.title = this.title;
            tableFormat.description = this.description;
            return tableFormat;
        };
        WTableFormat.prototype.hasValue = function (property) {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueTableFormat)) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueTableFormat.uniqueFormatType, property);
                return this.uniqueTableFormat.propertiesHash.containsKey(propertyType);
            }
            return false;
        };
        WTableFormat.prototype.copyFormat = function (format) {
            if (!ej2_base_1.isNullOrUndefined(format)) {
                if (!ej2_base_1.isNullOrUndefined(format.uniqueTableFormat)) {
                    this.cellSpacing = format.cellSpacing;
                    this.leftMargin = format.leftMargin;
                    this.topMargin = format.topMargin;
                    this.rightMargin = format.rightMargin;
                    this.bottomMargin = format.bottomMargin;
                    this.leftIndent = format.leftIndent;
                    this.tableAlignment = format.tableAlignment;
                    this.preferredWidth = format.preferredWidth;
                    this.preferredWidthType = format.preferredWidthType;
                    this.bidi = format.bidi;
                    this.allowAutoFit = format.allowAutoFit;
                    this.horizontalPosition = format.horizontalPosition;
                    this.horizontalPositionAbs = format.horizontalPositionAbs;
                    this.styleName = format.styleName;
                }
                if (!ej2_base_1.isNullOrUndefined(format.borders)) {
                    this.borders = new borders_1.WBorders(this);
                    this.borders.copyFormat(format.borders);
                }
                if (!ej2_base_1.isNullOrUndefined(format.shading)) {
                    this.shading = new shading_1.WShading(this);
                    this.shading.copyFormat(format.shading);
                }
                if (!ej2_base_1.isNullOrUndefined(format.title)) {
                    this.title = format.title;
                }
                if (!ej2_base_1.isNullOrUndefined(format.description)) {
                    this.description = format.description;
                }
            }
        };
        WTableFormat.clear = function () {
            this.uniqueTableFormats.clear();
        };
        WTableFormat.uniqueTableFormats = new unique_formats_1.WUniqueFormats();
        WTableFormat.uniqueFormatType = 8;
        return WTableFormat;
    }());
    exports.WTableFormat = WTableFormat;
});