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

94.58% Statements 454/480
78.85% Branches 246/312
97.83% Functions 90/92
94.58% Lines 454/480
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 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935   79927× 79927× 79927× 79927× 79927× 79927×     228073×     3668×           228195×     6470×           243607×     14927×           133806×     248×           150168×               224086×     22647×           76465×     1178×           18754×                 164501×               75845×     1065×           188954×     2779×           122962×     1146×           76177×     16741×           456170×     984×           42216×     116×           42011×     141×           41995×     1563×           138012×     351×           39645×     1878×           40224×     759×           38613×     6501×           61420×     7115×           149243×     1273×           23112×               23112×               23112×               23112×               23112×               357789×     89×           41825×     7737×           163250×     19958×           41742×     19939×         3726762× 3395972× 3395972× 982×     3394990× 12682× 12682× 12682× 12682× 12682×   12682× 12661× 12661× 84672× 84672× 63958× 63958× 790× 790× 728×             3394990× 3394990× 134806×         330790× 330790× 330790×     3260184×   3260184× 3260184× 3260184× 814409×     2445775×     3260184× 3260184× 3196033× 2289480×     906553×   482074×       3260184×   3394990× 3394990× 3330839× 2418852×     911987× 487814×     424173× 424173×         3394990× 4054259× 134806×     3919453×     3394990× 134806× 134806×   3260184×   3395972× 3395972× 13664× 14539× 14539× 982× 982×     13557×       3394990×   139291× 75×   139291×       28086×     111205× 111205×   127×   111078×     28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086× 28086×   926838× 926838× 28086×     2445850× 2445850×   125855× 125855×   128504× 128504×   15947× 15947×   48572× 48572×   18754× 18754×   164502× 164502×   47673× 47673×   120362× 120362×   80436× 80436×   55130× 55130×   6564× 6564×         394415× 394415×   134640× 134640×   39356× 39356×   39961× 39961×   18435× 18435×   18313× 18313×             218099× 218099×       71328× 71328×   357779× 357779×       59734× 59734×   131338× 131338×   150153× 150153×   2445850×   12234×                                                     120×     226× 226× 226× 226×       226×   226×   8179124× 3692007× 3692007×   4487117×   11029×     11029× 11029×   42962× 21785×   42962× 42962× 42962×   12837× 12627× 3991×   12627×   12627× 23×     12604×                                   3991× 3991× 20× 20×         3991× 3991× 3971×   3991×   13×   93×   336248×                                                                                         22×   22×   22×   22×   22×   22×   22×   22×     22×   22×   22×   22×   22× 11×   22×   22×   22×     22×     22×     22×     22×     22×   22×   22×   22×                              
define(["require", "exports", "../viewer/page", "../../base/dictionary", "../../base/unique-format", "../../base/unique-formats", "./style", "@syncfusion/ej2-base", "../track-changes/track-changes"], function (require, exports, page_1, dictionary_1, unique_format_1, unique_formats_1, style_1, ej2_base_1, track_changes_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var WCharacterFormat = (function () {
        function WCharacterFormat(node) {
            this.uniqueCharacterFormat = undefined;
            this.ownerBase = undefined;
            this.baseCharStyle = undefined;
            this.removedIds = [];
            this.revisions = [];
            this.ownerBase = node;
        }
        Object.defineProperty(WCharacterFormat.prototype, "bold", {
            get: function () {
                return this.getPropertyValue('bold');
            },
            set: function (value) {
                this.setPropertyValue('bold', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "italic", {
            get: function () {
                return this.getPropertyValue('italic');
            },
            set: function (value) {
                this.setPropertyValue('italic', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontSize", {
            get: function () {
                return this.getPropertyValue('fontSize');
            },
            set: function (value) {
                this.setPropertyValue('fontSize', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "characterSpacing", {
            get: function () {
                return this.getPropertyValue('characterSpacing');
            },
            set: function (value) {
                this.setPropertyValue('characterSpacing', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "scaling", {
            get: function () {
                return this.getPropertyValue('scaling');
            },
            set: function (value) {
                this.setPropertyValue('scaling', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontFamily", {
            get: function () {
                return this.getPropertyValue('fontFamily');
            },
            set: function (value) {
                this.setPropertyValue('fontFamily', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "underline", {
            get: function () {
                return this.getPropertyValue('underline');
            },
            set: function (value) {
                this.setPropertyValue('underline', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "underlineColor", {
            get: function () {
                return this.getPropertyValue('underlineColor');
            },
            set: function (value) {
                this.setPropertyValue('underlineColor', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontHintType", {
            get: function () {
                return this.getPropertyValue('fontHintType');
            },
            set: function (value) {
                this.setPropertyValue('fontHintType', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "strikethrough", {
            get: function () {
                return this.getPropertyValue('strikethrough');
            },
            set: function (value) {
                this.setPropertyValue('strikethrough', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "baselineAlignment", {
            get: function () {
                return this.getPropertyValue('baselineAlignment');
            },
            set: function (value) {
                this.setPropertyValue('baselineAlignment', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "highlightColor", {
            get: function () {
                return this.getPropertyValue('highlightColor');
            },
            set: function (value) {
                this.setPropertyValue('highlightColor', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontColor", {
            get: function () {
                return this.getPropertyValue('fontColor');
            },
            set: function (value) {
                this.setPropertyValue('fontColor', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "bidi", {
            get: function () {
                return this.getPropertyValue('bidi');
            },
            set: function (value) {
                this.setPropertyValue('bidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "localeIdBidi", {
            get: function () {
                return this.getPropertyValue('localeIdBidi');
            },
            set: function (value) {
                this.setPropertyValue('localeIdBidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "localeIdFarEast", {
            get: function () {
                return this.getPropertyValue('localeIdFarEast');
            },
            set: function (value) {
                this.setPropertyValue('localeIdFarEast', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "localeIdAscii", {
            get: function () {
                return this.getPropertyValue('localeIdAscii');
            },
            set: function (value) {
                this.setPropertyValue('localeIdAscii', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "bdo", {
            get: function () {
                return this.getPropertyValue('bdo');
            },
            set: function (value) {
                this.setPropertyValue('bdo', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "boldBidi", {
            get: function () {
                return this.getPropertyValue('boldBidi');
            },
            set: function (value) {
                this.setPropertyValue('boldBidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "italicBidi", {
            get: function () {
                return this.getPropertyValue('italicBidi');
            },
            set: function (value) {
                this.setPropertyValue('italicBidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontSizeBidi", {
            get: function () {
                return this.getPropertyValue('fontSizeBidi');
            },
            set: function (value) {
                this.setPropertyValue('fontSizeBidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontFamilyBidi", {
            get: function () {
                return this.getPropertyValue('fontFamilyBidi');
            },
            set: function (value) {
                this.setPropertyValue('fontFamilyBidi', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "allCaps", {
            get: function () {
                return this.getPropertyValue('allCaps');
            },
            set: function (value) {
                this.setPropertyValue('allCaps', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "Lowercase", {
            get: function () {
                return this.getPropertyValue('Lowercase');
            },
            set: function (value) {
                this.setPropertyValue('Lowercase', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "Uppercase", {
            get: function () {
                return this.getPropertyValue('Uppercase');
            },
            set: function (value) {
                this.setPropertyValue('Uppercase', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "SentenceCase", {
            get: function () {
                return this.getPropertyValue('SentenceCase');
            },
            set: function (value) {
                this.setPropertyValue('SentenceCase', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "ToggleCase", {
            get: function () {
                return this.getPropertyValue('ToggleCase');
            },
            set: function (value) {
                this.setPropertyValue('ToggleCase', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "CapitalizeEachWord", {
            get: function () {
                return this.getPropertyValue('CapitalizeEachWord');
            },
            set: function (value) {
                this.setPropertyValue('CapitalizeEachWord', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "complexScript", {
            get: function () {
                return this.getPropertyValue('complexScript');
            },
            set: function (value) {
                this.setPropertyValue('complexScript', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontFamilyFarEast", {
            get: function () {
                return this.getPropertyValue('fontFamilyFarEast');
            },
            set: function (value) {
                this.setPropertyValue('fontFamilyFarEast', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontFamilyAscii", {
            get: function () {
                return this.getPropertyValue('fontFamilyAscii');
            },
            set: function (value) {
                this.setPropertyValue('fontFamilyAscii', value);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WCharacterFormat.prototype, "fontFamilyNonFarEast", {
            get: function () {
                return this.getPropertyValue('fontFamilyNonFarEast');
            },
            set: function (value) {
                this.setPropertyValue('fontFamilyNonFarEast', value);
            },
            enumerable: true,
            configurable: true
        });
        WCharacterFormat.prototype.getPropertyValue = function (property) {
            if (!this.hasValue(property)) {
                var charStyleValue = this.checkCharacterStyle(property);
                if (!ej2_base_1.isNullOrUndefined(charStyleValue)) {
                    return charStyleValue;
                }
                else {
                    if (!ej2_base_1.isNullOrUndefined(this.baseCharStyle)) {
                        var paragraph = undefined;
                        var line = undefined;
                        Eif (!ej2_base_1.isNullOrUndefined(this.ownerBase)) {
                            paragraph = this.ownerBase.paragraph;
                            line = this.ownerBase.line;
                        }
                        if (!ej2_base_1.isNullOrUndefined(paragraph) && !ej2_base_1.isNullOrUndefined(line)) {
                            var length_1 = line.children.length;
                            for (var i = 0; i < length_1; i++) {
                                var element = this.ownerBase.line.children[i];
                                if (element instanceof page_1.TextElementBox) {
                                    var text = element.text;
                                    if (text.startsWith('HYPERLINK')) {
                                        var index = text.indexOf('_Toc');
                                        if (index !== -1) {
                                            this.baseCharStyle = this.ownerBase.paragraph.paragraphFormat.baseStyle;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    var baseStyleValue = this.checkBaseStyle(property);
                    if (!ej2_base_1.isNullOrUndefined(baseStyleValue)) {
                        return baseStyleValue;
                    }
                }
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WCharacterFormat.uniqueFormatType, property);
                Eif (!ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat) && this.uniqueCharacterFormat.propertiesHash.containsKey(propertyType)) {
                    return this.uniqueCharacterFormat.propertiesHash.get(propertyType);
                }
            }
            return this.getDefaultValue(property);
        };
        WCharacterFormat.prototype.getDefaultValue = function (property) {
            var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WCharacterFormat.uniqueFormatType, property);
            var docCharacterFormat = this.documentCharacterFormat();
            if (!ej2_base_1.isNullOrUndefined(docCharacterFormat) && !ej2_base_1.isNullOrUndefined(docCharacterFormat.uniqueCharacterFormat) && docCharacterFormat.uniqueCharacterFormat.propertiesHash.containsKey(propertyType)) {
                return docCharacterFormat.uniqueCharacterFormat.propertiesHash.get(propertyType);
            }
            else {
                return WCharacterFormat.getPropertyDefaultValue(property);
            }
        };
        WCharacterFormat.prototype.documentCharacterFormat = function () {
            var docCharacterFormat;
            if (!ej2_base_1.isNullOrUndefined(this.ownerBase)) {
                if (!ej2_base_1.isNullOrUndefined(this.ownerBase.paragraph) && !ej2_base_1.isNullOrUndefined(this.ownerBase.paragraph.bodyWidget) && !ej2_base_1.isNullOrUndefined(this.ownerBase.paragraph.bodyWidget.page)) {
                    docCharacterFormat = this.ownerBase.paragraph.bodyWidget.page.documentHelper.characterFormat;
                }
                else {
                    if (!ej2_base_1.isNullOrUndefined(this.ownerBase.bodyWidget) && !ej2_base_1.isNullOrUndefined(this.ownerBase.bodyWidget.page)
                        && !ej2_base_1.isNullOrUndefined(this.ownerBase.bodyWidget.page.documentHelper)) {
                        docCharacterFormat = this.ownerBase.bodyWidget.page.documentHelper.characterFormat;
                    }
                }
            }
            return docCharacterFormat;
        };
        WCharacterFormat.prototype.checkBaseStyle = function (property) {
            var baseStyle;
            if (!ej2_base_1.isNullOrUndefined(this.ownerBase)) {
                if (!ej2_base_1.isNullOrUndefined(this.ownerBase.paragraph)) {
                    baseStyle = this.ownerBase.paragraph.paragraphFormat.baseStyle;
                }
                else {
                    if ((this.ownerBase instanceof page_1.ParagraphWidget) && !ej2_base_1.isNullOrUndefined(this.ownerBase.paragraphFormat)) {
                        baseStyle = this.ownerBase.paragraphFormat.baseStyle;
                    }
                    else {
                        Eif (!ej2_base_1.isNullOrUndefined(this.ownerBase instanceof style_1.WParagraphStyle)) {
                            baseStyle = this.ownerBase.basedOn;
                        }
                    }
                }
            }
            while (!ej2_base_1.isNullOrUndefined(baseStyle)) {
                if (baseStyle.characterFormat.hasValue(property)) {
                    break;
                }
                else {
                    baseStyle = baseStyle.basedOn;
                }
            }
            if (!ej2_base_1.isNullOrUndefined(baseStyle)) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WCharacterFormat.uniqueFormatType, property);
                return baseStyle.characterFormat.uniqueCharacterFormat.propertiesHash.get(propertyType);
            }
            return undefined;
        };
        WCharacterFormat.prototype.checkCharacterStyle = function (property) {
            var baseStyle = this.baseCharStyle;
            if (!ej2_base_1.isNullOrUndefined(baseStyle)) {
                while (!ej2_base_1.isNullOrUndefined(baseStyle) && baseStyle.name !== 'Default Paragraph Font') {
                    var hasKey = baseStyle.characterFormat.hasValue(property);
                    if (hasKey) {
                        var returnPropertyType = unique_format_1.WUniqueFormat.getPropertyType(WCharacterFormat.uniqueFormatType, property);
                        return baseStyle.characterFormat.uniqueCharacterFormat.propertiesHash.get(returnPropertyType);
                    }
                    else {
                        baseStyle = baseStyle.basedOn;
                    }
                }
            }
            return undefined;
        };
        WCharacterFormat.prototype.setPropertyValue = function (property, value) {
            if (ej2_base_1.isNullOrUndefined(value) || value === '') {
                value = WCharacterFormat.getPropertyDefaultValue(property);
            }
            if (ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat)
                || (ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat.propertiesHash)
                    && ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat.uniqueFormatType)
                    && ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat.referenceCount))) {
                this.initializeUniqueCharacterFormat(property, value);
            }
            else {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueCharacterFormat.uniqueFormatType, property);
                if (this.uniqueCharacterFormat.propertiesHash.containsKey(propertyType) &&
                    this.uniqueCharacterFormat.propertiesHash.get(propertyType) === value) {
                    return;
                }
                this.uniqueCharacterFormat = WCharacterFormat.uniqueCharacterFormats.updateUniqueFormat(this.uniqueCharacterFormat, property, value);
            }
        };
        WCharacterFormat.prototype.initializeUniqueCharacterFormat = function (property, propValue) {
            var uniqueCharFormatTemp = new dictionary_1.Dictionary();
            this.addUniqueCharacterFormat('fontColor', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontFamily', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontSize', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('bold', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('italic', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('underline', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('underlineColor', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontHintType', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('strikethrough', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('baselineAlignment', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('highlightColor', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('styleName', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('bidi', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('bdo', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontFamilyBidi', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontSizeBidi', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('boldBidi', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('italicBidi', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('allCaps', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('Uppercase', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('Lowercase', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('SentenceCase', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('ToggleCase', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('CapitalizeEachWord', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('localeIdAscii', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('localeIdFarEast', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('localeIdBidi', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontFamilyFarEast', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontFamilyAscii', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('fontFamilyNonFarEast', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('complexScript', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('characterSpacing', property, propValue, uniqueCharFormatTemp);
            this.addUniqueCharacterFormat('scaling', property, propValue, uniqueCharFormatTemp);
            this.uniqueCharacterFormat = WCharacterFormat.uniqueCharacterFormats.addUniqueFormat(uniqueCharFormatTemp, WCharacterFormat.uniqueFormatType);
        };
        WCharacterFormat.prototype.addUniqueCharacterFormat = function (property, modifiedProperty, propValue, uniqueCharFormatTemp) {
            var propertyType = unique_format_1.WUniqueFormat.getPropertyType(WCharacterFormat.uniqueFormatType, property);
            if (property === modifiedProperty) {
                uniqueCharFormatTemp.add(propertyType, propValue);
            }
        };
        WCharacterFormat.getPropertyDefaultValue = function (property) {
            var value = undefined;
            switch (property) {
                case 'bold':
                    value = false;
                    break;
                case 'italic':
                    value = false;
                    break;
                case 'fontSize':
                    value = 11;
                    break;
                case 'underline':
                    value = 'None';
                    break;
                case 'underlineColor':
                    value = undefined;
                    break;
                case 'fontHintType':
                    value = 'Default';
                    break;
                case 'strikethrough':
                    value = 'None';
                    break;
                case 'baselineAlignment':
                    value = 'Normal';
                    break;
                case 'highlightColor':
                    value = 'NoColor';
                    break;
                case 'fontColor':
                    value = '#00000000';
                    break;
                case 'fontFamily':
                    value = 'Calibri';
                    break;
                case 'styleName':
                    value = 'Default Paragraph Font';
                    break;
                case 'bidi':
                    value = false;
                    break;
                case 'bdo':
                    value = 'None';
                    break;
                case 'boldBidi':
                    value = false;
                    break;
                case 'italicBidi':
                    value = false;
                    break;
                case 'fontSizeBidi':
                    value = 11;
                    break;
                case 'fontFamilyBidi':
                    value = 'Calibri';
                    break;
                case 'allCaps':
                case 'Uppercase':
                case 'Lowercase':
                case 'CapitalizeEachWord':
                case 'SentenceCase':
                case 'ToggleCase':
                    value = false;
                    break;
                case 'localeIdAscii':
                case 'localeIdFarEast':
                case 'localeIdBidi':
                    value = 0;
                    break;
                case 'complexScript':
                    value = false;
                    break;
                case 'fontFamilyFarEast':
                case 'fontFamilyAscii':
                case 'fontFamilyNonFarEast':
                    value = undefined;
                    break;
                case 'characterSpacing':
                    value = 0;
                    break;
                case 'scaling':
                    value = 100;
                    break;
            }
            return value;
        };
        WCharacterFormat.prototype.isEqualFormat = function (format) {
            return (this.fontSize === format.fontSize
                && this.fontFamily === format.fontFamily
                && this.bold === format.bold
                && this.italic === format.italic
                && this.baselineAlignment === format.baselineAlignment
                && this.underline === format.underline
                && this.fontColor === format.fontColor
                && this.strikethrough === format.strikethrough
                && this.highlightColor === format.highlightColor && this.bidi === format.bidi
                && this.bdo === format.bdo
                && this.allCaps === format.allCaps
                && this.Uppercase === format.Uppercase
                && this.Lowercase === format.Lowercase
                && this.ToggleCase === format.ToggleCase
                && this.SentenceCase === format.SentenceCase
                && this.CapitalizeEachWord === format.CapitalizeEachWord
                && this.localeIdBidi === format.localeIdBidi
                && this.localeIdAscii === format.localeIdAscii
                && this.localeIdFarEast === format.localeIdFarEast
                && this.complexScript === format.complexScript
                && this.fontFamilyAscii === format.fontFamilyAscii
                && this.fontFamilyBidi === format.fontFamilyBidi
                && this.fontFamilyFarEast === format.fontFamilyFarEast
                && this.characterSpacing === format.characterSpacing
                && this.scaling === format.scaling
                && this.fontFamilyNonFarEast === format.fontFamilyNonFarEast);
        };
        WCharacterFormat.prototype.isSameFormat = function (format) {
            return this.baseCharStyle === format.baseCharStyle &&
                this.uniqueCharacterFormat === format.uniqueCharacterFormat;
        };
        WCharacterFormat.prototype.cloneFormat = function () {
            var format = new WCharacterFormat(undefined);
            format.uniqueCharacterFormat = this.uniqueCharacterFormat;
            format.baseCharStyle = this.baseCharStyle;
            Iif (this.revisions.length > 0) {
                format.removedIds = track_changes_1.Revision.cloneRevisions(this.revisions);
            }
            else {
                format.removedIds = this.removedIds.slice();
            }
            return format;
        };
        WCharacterFormat.prototype.hasValue = function (property) {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat) && !ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat.propertiesHash)) {
                var propertyType = unique_format_1.WUniqueFormat.getPropertyType(this.uniqueCharacterFormat.uniqueFormatType, property);
                return this.uniqueCharacterFormat.propertiesHash.containsKey(propertyType);
            }
            return false;
        };
        WCharacterFormat.prototype.clearFormat = function () {
            Iif (!ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat) && this.uniqueCharacterFormat.referenceCount === 0) {
                WCharacterFormat.uniqueCharacterFormats.remove(this.uniqueCharacterFormat);
            }
            this.uniqueCharacterFormat = undefined;
            this.baseCharStyle = undefined;
        };
        WCharacterFormat.prototype.destroy = function () {
            if (!ej2_base_1.isNullOrUndefined(this.uniqueCharacterFormat)) {
                WCharacterFormat.uniqueCharacterFormats.remove(this.uniqueCharacterFormat);
            }
            this.uniqueCharacterFormat = undefined;
            this.baseCharStyle = undefined;
            this.ownerBase = undefined;
        };
        WCharacterFormat.prototype.copyFormat = function (format) {
            if (!ej2_base_1.isNullOrUndefined(format)) {
                if (!ej2_base_1.isNullOrUndefined(format.uniqueCharacterFormat) && format.uniqueCharacterFormat.propertiesHash) {
                    this.updateUniqueCharacterFormat(format);
                }
                if (!ej2_base_1.isNullOrUndefined(format.baseCharStyle)) {
                    this.baseCharStyle = format.baseCharStyle;
                }
                if (format.revisions.length > 0) {
                    this.removedIds = track_changes_1.Revision.cloneRevisions(format.revisions);
                }
                else {
                    this.removedIds = format.removedIds.slice();
                }
            }
        };
        WCharacterFormat.prototype.isEqualTocFormat = function (format) {
            return (this.fontFamily === format.fontFamily
                && this.bold === format.bold
                && this.italic === format.italic
                && this.strikethrough === format.strikethrough
                && this.highlightColor === format.highlightColor
                && this.fontFamilyAscii === format.fontFamilyAscii
                && this.fontFamilyFarEast === format.fontFamilyFarEast
                && this.fontFamilyNonFarEast === format.fontFamilyNonFarEast);
        };
        WCharacterFormat.prototype.copyTocFormat = function (format) {
            Eif (!ej2_base_1.isNullOrUndefined(format.bold)) {
                this.bold = format.bold;
            }
            Eif (!ej2_base_1.isNullOrUndefined(format.italic)) {
                this.italic = format.italic;
            }
            Eif (!ej2_base_1.isNullOrUndefined(format.strikethrough)) {
                this.strikethrough = format.strikethrough;
            }
            Eif (!ej2_base_1.isNullOrUndefined(format.highlightColor)) {
                this.highlightColor = format.highlightColor;
            }
            Eif (!ej2_base_1.isNullOrUndefined(format.fontFamily)) {
                this.fontFamily = format.fontFamily;
                this.fontFamilyAscii = format.fontFamily;
                this.fontFamilyFarEast = format.fontFamily;
                this.fontFamilyNonFarEast = format.fontFamily;
            }
        };
        WCharacterFormat.prototype.updateUniqueCharacterFormat = function (format) {
            var hash = undefined;
            if (this.uniqueCharacterFormat) {
                hash = this.uniqueCharacterFormat.mergeProperties(format.uniqueCharacterFormat);
                Iif (this.uniqueCharacterFormat.referenceCount === 0) {
                    WCharacterFormat.uniqueCharacterFormats.remove(this.uniqueCharacterFormat);
                    this.uniqueCharacterFormat = undefined;
                }
            }
            this.uniqueCharacterFormat = new unique_format_1.WUniqueFormat(WCharacterFormat.uniqueFormatType);
            if (ej2_base_1.isNullOrUndefined(hash)) {
                hash = this.uniqueCharacterFormat.mergeProperties(format.uniqueCharacterFormat);
            }
            this.uniqueCharacterFormat = WCharacterFormat.uniqueCharacterFormats.addUniqueFormat(hash, WCharacterFormat.uniqueFormatType);
        };
        WCharacterFormat.clear = function () {
            this.uniqueCharacterFormats.clear();
        };
        WCharacterFormat.prototype.applyStyle = function (baseCharStyle) {
            this.baseCharStyle = baseCharStyle;
        };
        WCharacterFormat.prototype.getValue = function (property) {
            return this.hasValue(property) ? this.getPropertyValue(property) : undefined;
        };
        WCharacterFormat.prototype.mergeFormat = function (format) {
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('bold'))) {
                this.bold = format.getValue('bold');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('italic'))) {
                this.italic = format.getValue('italic');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontSize'))) {
                this.fontSize = format.getValue('fontSize');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('boldBidi'))) {
                this.boldBidi = format.getValue('boldBidi');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('italicBidi'))) {
                this.italicBidi = format.getValue('italicBidi');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontSizeBidi'))) {
                this.fontSizeBidi = format.getValue('fontSizeBidi');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('characterSpacing'))) {
                this.characterSpacing = format.getValue('characterSpacing');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('scaling'))) {
                this.scaling = format.getValue('scaling');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontFamily'))) {
                this.fontFamily = format.getValue('fontFamily');
            }
            else {
                if (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyAscii'))) {
                    this.fontFamilyAscii = format.getValue('fontFamily');
                }
                if (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyFarEast'))) {
                    this.fontFamilyFarEast = format.getValue('fontFamily');
                }
                if (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyNonFarEast'))) {
                    this.fontFamilyNonFarEast = format.getValue('fontFamily');
                }
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('underline'))) {
                this.underline = format.getValue('underline');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontHintType'))) {
                this.fontHintType = format.getValue('fontHintType');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('strikethrough'))) {
                this.strikethrough = format.getValue('strikethrough');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('baselineAlignment'))) {
                this.baselineAlignment = format.getValue('baselineAlignment');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('highlightColor'))) {
                this.highlightColor = format.getValue('highlightColor');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontColor'))) {
                this.fontColor = format.getValue('fontColor');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('bidi'))) {
                this.bidi = format.getValue('bidi');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('bdo'))) {
                this.bdo = format.getValue('bdo');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('allCaps'))) {
                this.allCaps = format.getValue('allCaps');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('Lowercase'))) {
                this.Lowercase = format.getValue('Lowercase');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('SentenceCase'))) {
                this.SentenceCase = format.getValue('SentenceCase');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('ToggleCase'))) {
                this.ToggleCase = format.getValue('ToggleCase');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('CapitalizeEachWord'))) {
                this.CapitalizeEachWord = format.getValue('CapitalizeEachWord');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('Uppercase'))) {
                this.Uppercase = format.getValue('Uppercase');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('localeIdBidi'))) {
                this.localeIdBidi = format.getValue('localeIdBidi');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('localeIdAscii'))) {
                this.localeIdAscii = format.getValue('localeIdAscii');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('localeIdFarEast'))) {
                this.localeIdFarEast = format.getValue('localeIdFarEast');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('complexScript'))) {
                this.complexScript = format.getValue('complexScript');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyAscii'))) {
                this.fontFamilyAscii = format.getValue('fontFamilyAscii');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyBidi'))) {
                this.fontFamilyBidi = format.getValue('fontFamilyBidi');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyFarEast'))) {
                this.fontFamilyFarEast = format.getValue('fontFamilyFarEast');
            }
            Eif (ej2_base_1.isNullOrUndefined(this.getValue('fontFamilyNonFarEast'))) {
                this.fontFamilyNonFarEast = format.getValue('fontFamilyNonFarEast');
            }
        };
        WCharacterFormat.prototype.assignFormat = function (format) {
            if (format.hasValue('bold')) {
                this.bold = format.getValue('bold');
            }
            if (format.hasValue('italic')) {
                this.italic = format.getValue('italic');
            }
            if (format.hasValue('fontSize')) {
                this.fontSize = format.getValue('fontSize');
            }
            if (format.hasValue('characterSpacing')) {
                this.characterSpacing = format.getValue('characterSpacing');
            }
            if (format.hasValue('scaling')) {
                this.scaling = format.getValue('scaling');
            }
            if (format.hasValue('fontFamily')) {
                this.fontFamily = format.getValue('fontFamily');
                this.fontFamilyFarEast = format.getValue('fontFamily');
                this.fontFamilyAscii = format.getValue('fontFamily');
                this.fontFamilyNonFarEast = format.getValue('fontFamily');
                this.fontFamilyBidi = format.getValue('fontFamily');
            }
            if (format.hasValue('underline')) {
                this.underline = format.getValue('underline');
            }
            Iif (format.hasValue('fontHintType')) {
                this.fontHintType = format.getValue('fontHintType');
            }
            if (format.hasValue('strikethrough')) {
                this.strikethrough = format.getValue('strikethrough');
            }
            if (format.hasValue('baselineAlignment')) {
                this.baselineAlignment = format.getValue('baselineAlignment');
            }
            if (format.hasValue('highlightColor')) {
                this.highlightColor = format.getValue('highlightColor');
            }
            if (format.hasValue('fontColor')) {
                this.fontColor = format.getValue('fontColor');
            }
            if (format.hasValue('bidi')) {
                this.bidi = format.getValue('bidi');
            }
            if (format.hasValue('bdo')) {
                this.bdo = format.getValue('bdo');
            }
            if (format.hasValue('allCaps')) {
                this.allCaps = format.getValue('allCaps');
            }
            Iif (format.hasValue('Lowercase')) {
                this.Lowercase = format.getValue('Lowercase');
            }
            Iif (format.hasValue('SentenceCase')) {
                this.SentenceCase = format.getValue('SentenceCase');
            }
            Iif (format.hasValue('ToggleCase')) {
                this.ToggleCase = format.getValue('ToggleCase');
            }
            Iif (format.hasValue('CapitalizeEachWord')) {
                this.CapitalizeEachWord = format.getValue('CapitalizeEachWord');
            }
            Iif (format.hasValue('Uppercase')) {
                this.Uppercase = format.getValue('Uppercase');
            }
            if (format.hasValue('localeIdBidi')) {
                this.localeIdBidi = format.getValue('localeIdBidi');
            }
            if (format.hasValue('localeIdAscii')) {
                this.localeIdAscii = format.getValue('localeIdAscii');
            }
            if (format.hasValue('localeIdFarEast')) {
                this.localeIdFarEast = format.getValue('localeIdFarEast');
            }
            if (format.hasValue('complexScript')) {
                this.complexScript = format.getValue('complexScript');
            }
        };
        WCharacterFormat.prototype.hasValueWithParent = function (property) {
            var hasValue = this.hasValue(property);
            if (!hasValue && !ej2_base_1.isNullOrUndefined(this.baseCharStyle) && this.baseCharStyle instanceof style_1.WCharacterStyle) {
                hasValue = this.baseCharStyle.characterFormat.hasValue(property);
            }
            var defFormat = this.documentCharacterFormat();
            if (!hasValue && !ej2_base_1.isNullOrUndefined(defFormat)) {
                hasValue = defFormat.hasValue(property);
            }
            return hasValue;
        };
        WCharacterFormat.uniqueCharacterFormats = new unique_formats_1.WUniqueFormats();
        WCharacterFormat.uniqueFormatType = 2;
        return WCharacterFormat;
    }());
    exports.WCharacterFormat = WCharacterFormat;
});