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

99.22% Statements 127/128
95.24% Branches 60/63
100% Functions 23/23
99.22% Lines 127/128
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   44096× 44096× 44096× 44096× 44096×     212×     429×           230629×     506× 327× 287× 287× 52×       179×   506×           279777×     502×           116347× 116347× 113450×     2897× 2897× 4002× 2755× 2755×     1247×       116347× 116205×     142×           511651× 173000× 138763× 138763× 159522× 23555×     135967×     138763× 23555× 23555×         338651× 338651× 338651×     149445×   1437×   1437× 496×     941× 941×   23×   918×     496× 496× 496× 496× 496×   1488× 1488× 496×     149446× 149446×   104790× 104790×   44493× 44493×   163× 163×   149446×   6692× 6692× 61× 61× 61×   6692× 6072×   6692× 18×       11932913× 603178× 603178×   11329735×   5904×     5904× 5904×   14882× 258×   14882× 14882× 14882× 14882×   13×   3721×   16713×   151× 151× 151× 151× 151× 151× 151× 151×        
define(["require", "exports", "@syncfusion/ej2-base", "../../base/dictionary", "../../base/unique-format", "../../base/unique-formats", "./style"], function (require, exports, ej2_base_1, dictionary_1, unique_format_1, unique_formats_1, style_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WListFormat = (function () {
        function WListFormat(node) {
            this.uniqueListFormat = undefined;
            this.ownerBase = undefined;
            this.baseStyle = undefined;
            this.list = undefined;
            this.ownerBase = node;
        }
        Object.defineProperty(WListFormat.prototype, "nsid", {
            get: function () {
                return this.getPropertyValue('nsid');
            },
            set: function (id) {
                this.setPropertyValue('nsid', id);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListFormat.prototype, "listId", {
            get: function () {
                return this.getPropertyValue('listId');
            },
            set: function (listId) {
                if (listId >= 0) {
                    if (!ej2_base_1.isNullOrUndefined(this.ownerBase)) {
                        var helper = this.ownerBase.getDocumentHelperObject();
                        if (!ej2_base_1.isNullOrUndefined(helper)) {
                            this.list = helper.getListById(listId);
                        }
                    }
                }
                else if (!ej2_base_1.isNullOrUndefined(this.list) && listId < 0) {
                    this.list = undefined;
                }
                this.setPropertyValue('listId', listId);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListFormat.prototype, "listLevelNumber", {
            get: function () {
                return this.getPropertyValue('listLevelNumber');
            },
            set: function (value) {
                this.setPropertyValue('listLevelNumber', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WListFormat.prototype, "listLevel", {
            get: function () {
                var list = undefined;
                if (!ej2_base_1.isNullOrUndefined(this.list)) {
                    list = this.list;
                }
                else {
                    var baseListStyle = this.baseStyle;
                    while (!ej2_base_1.isNullOrUndefined(baseListStyle) && baseListStyle instanceof style_1.WParagraphStyle) {
                        if (baseListStyle.paragraphFormat.listFormat.list) {
                            list = baseListStyle.paragraphFormat.listFormat.list;
                            break;
                        }
                        else {
                            baseListStyle = baseListStyle.basedOn;
                        }
                    }
                }
                if (!ej2_base_1.isNullOrUndefined(list)) {
                    return list.getListLevel(this.listLevelNumber);
                }
                else {
                    return undefined;
                }
            },
            enumerable: true,
            configurable: true
        });
        WListFormat.prototype.getPropertyValue = function (property) {
            if (!this.hasValue(property)) {
                if (this.baseStyle instanceof style_1.WParagraphStyle) {
                    var baseStyle = this.baseStyle;
                    while (!ej2_base_1.isNullOrUndefined(baseStyle)) {
                        if (baseStyle.paragraphFormat.listFormat.hasValue(property)) {
                            break;
                        }
                        else {
                            baseStyle = baseStyle.basedOn;
                        }
                    }
                    if (!ej2_base_1.isNullOrUndefined(baseStyle)) {
                        var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WListFormat.uniqueFormatType, property);
                        return baseStyle.paragraphFormat.listFormat.uniqueListFormat.propertiesHash.get(propertyType);
                    }
                }
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WListFormat.uniqueFormatType, property);
                Eif (!ej2_base_1.isNullOrUndefined(this.uniqueListFormat) && this.uniqueListFormat.propertiesHash.containsKey(propertyType)) {
                    return this.uniqueListFormat.propertiesHash.get(propertyType);
                }
            }
            return WListFormat.getPropertyDefaultValue(property);
        };
        WListFormat.prototype.setPropertyValue = function (property, value) {
            if (ej2_base_1.isNullOrUndefined(value) || value === '') {
                value = WListFormat.getPropertyDefaultValue(property);
            }
            if (ej2_base_1.isNullOrUndefined(this.uniqueListFormat)) {
                this.initializeUniqueListFormat(property, value);
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueListFormat.uniqueFormatType, property);
                if (this.uniqueListFormat.propertiesHash.containsKey(propertyType) &&
                    this.uniqueListFormat.propertiesHash.get(propertyType) === value) {
                    return;
                }
                this.uniqueListFormat = WListFormat.uniqueListFormats.updateUniqueFormat(this.uniqueListFormat, property, value);
            }
        };
        WListFormat.prototype.initializeUniqueListFormat = function (property, propValue) {
            var uniqueListFormatTemp = new dictionary_1.Dictionary();
            this.addUniqueListFormat('listId', property, propValue, uniqueListFormatTemp);
            this.addUniqueListFormat('listLevelNumber', property, propValue, uniqueListFormatTemp);
            this.addUniqueListFormat('nsid', property, propValue, uniqueListFormatTemp);
            this.uniqueListFormat = WListFormat.uniqueListFormats.addUniqueFormat(uniqueListFormatTemp, WListFormat.uniqueFormatType);
        };
        WListFormat.prototype.addUniqueListFormat = function (property, modifiedProperty, propValue, uniqueListFormatTemp) {
            var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WListFormat.uniqueFormatType, property);
            if (property === modifiedProperty) {
                uniqueListFormatTemp.add(propertyType, propValue);
            }
        };
        WListFormat.getPropertyDefaultValue = function (property) {
            var value = undefined;
            switch (property) {
                case 'listId':
                    value = -1;
                    break;
                case 'listLevelNumber':
                    value = 0;
                    break;
                case 'nsid':
                    value = -1;
                    break;
            }
            return value;
        };
        WListFormat.prototype.copyFormat = function (format) {
            Eif (!ej2_base_1.isNullOrUndefined(format)) {
                if (!ej2_base_1.isNullOrUndefined(format.uniqueListFormat)) {
                    this.listId = format.listId;
                    this.listLevelNumber = format.listLevelNumber;
                    this.nsid = format.nsid;
                }
                if (!ej2_base_1.isNullOrUndefined(format.baseStyle)) {
                    this.baseStyle = format.baseStyle;
                }
                if (!ej2_base_1.isNullOrUndefined(format.list)) {
                    this.list = format.list;
                }
            }
        };
        WListFormat.prototype.hasValue = function (property) {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueListFormat)) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueListFormat.uniqueFormatType, property);
                return this.uniqueListFormat.propertiesHash.containsKey(propertyType);
            }
            return false;
        };
        WListFormat.prototype.clearFormat = function () {
            Iif (!ej2_base_1.isNullOrUndefined(this.uniqueListFormat) && this.uniqueListFormat.referenceCount === 0) {
                WListFormat.uniqueListFormats.remove(this.uniqueListFormat);
            }
            this.uniqueListFormat = undefined;
            this.list = undefined;
        };
        WListFormat.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueListFormat)) {
                WListFormat.uniqueListFormats.remove(this.uniqueListFormat);
            }
            this.uniqueListFormat = undefined;
            this.list = undefined;
            this.ownerBase = undefined;
            this.baseStyle = undefined;
        };
        WListFormat.clear = function () {
            this.uniqueListFormats.clear();
        };
        WListFormat.prototype.applyStyle = function (baseStyle) {
            this.baseStyle = baseStyle;
        };
        WListFormat.prototype.getValue = function (property) {
            return this.hasValue(property) ? this.getPropertyValue(property) : undefined;
        };
        WListFormat.prototype.cloneListFormat = function () {
            var format = new WListFormat(undefined);
            format.list = this.list;
            format.listId = this.listId;
            format.nsid = this.nsid;
            format.baseStyle = this.baseStyle;
            format.listLevelNumber = this.listLevelNumber;
            format.uniqueListFormat = this.uniqueListFormat;
            return format;
        };
        WListFormat.uniqueListFormats = new unique_formats_1.WUniqueFormats();
        WListFormat.uniqueFormatType = 7;
        return WListFormat;
    }());
    exports.WListFormat = WListFormat;
});