Grammalecte  Check-in [58cdb431b8]

Overview
Comment:[fr][oxt] formateur de texte: table de remplacement séparée
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fr
Files: files | file ages | folders
SHA3-256: 58cdb431b875aa6f69a1de2d216d4db639c74f64cc1fc15932e8da346127181f
User & Date: olr on 2017-06-27 13:38:07
Original Comment: [fr][oxt] formateur de texte: tablede remplacement séparée
Other Links: manifest | tags
Context
2017-06-27
13:57
[fr][oxt] table de remplacement pour le formateur de texte check-in: 36321ba3ed user: olr tags: trunk, fr
13:38
[fr][oxt] formateur de texte: table de remplacement séparée check-in: 58cdb431b8 user: olr tags: trunk, fr
08:49
[fr][bug] formateur de texte: URL check-in: 001f5897d2 user: olr tags: trunk, fr
Changes

Modified gc_lang/fr/config.ini from [c79f625391] to [2a6b6ad1cb].

70
71
72
73
74
75
76

77
78
79
80
81
# ContextMenu
oxt/ContextMenu/ContextMenu.py = ContextMenu.py
oxt/ContextMenu/jobs.xcu = config/jobs.xcu
# TextFormatter
oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py
oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py
oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py

# Conjugueur
oxt/Conjugueur/Conjugueur.py = pythonpath/Conjugueur.py
# Modify author
oxt/ChangeAuthor/Author.py = pythonpath/Author.py
oxt/ChangeAuthor/ca_strings.py = pythonpath/ca_strings.py







>





70
71
72
73
74
75
76
77
78
79
80
81
82
# ContextMenu
oxt/ContextMenu/ContextMenu.py = ContextMenu.py
oxt/ContextMenu/jobs.xcu = config/jobs.xcu
# TextFormatter
oxt/TextFormatter/TextFormatter.py = pythonpath/TextFormatter.py
oxt/TextFormatter/tf_strings.py = pythonpath/tf_strings.py
oxt/TextFormatter/tf_options.py = pythonpath/tf_options.py
oxt/TextFormatter/tf_tabrep.py = pythonpath/tf_tabrep.py
# Conjugueur
oxt/Conjugueur/Conjugueur.py = pythonpath/Conjugueur.py
# Modify author
oxt/ChangeAuthor/Author.py = pythonpath/Author.py
oxt/ChangeAuthor/ca_strings.py = pythonpath/ca_strings.py

Modified gc_lang/fr/oxt/TextFormatter/TextFormatter.py from [63b9caa31e] to [6fb58f6672].

11
12
13
14
15
16
17

18
19
20
21
22
23
24
import time

if sys.version_info.major == 3:
    import imp

import tf_strings
import tf_options

import helpers


from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener









>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import time

if sys.version_info.major == 3:
    import imp

import tf_strings
import tf_options
import tf_tabrep
import helpers


from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener


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
            # NOTE: A LOT OF REGEX COULD BE MERGED IF ICU ENGINE WAS NOT SO BUGGY
            # "([;?!…])(?=[:alnum:])" => "$1 " doesn’t work properly
            # "(?<=[:alnum:])([;?!…])" => " $1 " doesn’t work properly
            self.pbar.ProgressValue = 0
            # Restructuration
            if self.struct.State:
                if self.struct1.State:
                    n = self._replaceText(xElem, "\\n", "\\n", True) # end of line => end of paragraph
                    self.struct1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.struct2.State:
                    n = self._replaceText(xElem, "([:alpha:])- *\n([:alpha:])", "$1$2", True)  # EOL
                    n += self._replaceHyphenAtEndOfParagraphs(xElem) # EOP
                    self.struct2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.struct3.State:
                    n = self._mergeContiguousParagraphs(xElem)
                    self.struct3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.struct.State = False
                self._switchCheckBox(self.struct)
            self.pbar.ProgressValue = 3
            # espaces surnuméraires
            if self.ssp.State:
                if self.ssp3.State:
                    n = self._replaceText(xElem, "[  ]+$", "", True)
                    self.ssp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp2.State:
                    n = self._replaceText(xElem, "  ", " ", False) # espace + espace insécable -> espace
                    n += self._replaceText(xElem, "  ", " ", False) # espace insécable + espace -> espace
                    n += self._replaceText(xElem, "  +", " ", True) # espaces surnuméraires
                    n += self._replaceText(xElem, "  +", " ", True) # espaces insécables surnuméraires
                    self.ssp2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp1.State:
                    n = self._replaceText(xElem, "^[  ]+", "", True)
                    self.ssp1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp4.State:
                    n = self._replaceText(xElem, " +(?=[.,…])", "", True)
                    self.ssp4_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp5.State:
                    n = self._replaceText(xElem, "\\([  ]+", "(", True)
                    n += self._replaceText(xElem, "[  ]+\\)", ")", True)
                    self.ssp5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp6.State:
                    n = self._replaceText(xElem, "\\[[  ]+", "[", True)
                    n += self._replaceText(xElem, "[  ]+\\]", "]", True)
                    self.ssp6_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp7.State:
                    n = self._replaceText(xElem, "“[  ]+", "“", True)
                    n += self._replaceText(xElem, "[  ]”", "”", True)
                    self.ssp7_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.ssp.State = False
                self._switchCheckBox(self.ssp)
            self.pbar.ProgressValue = 10
            # espaces typographiques
            if self.nbsp.State:
                if self.nbsp1.State:
                    if self.nnbsp1.State:
                        # espaces insécables fines
                        n = self._replaceText(xElem, "(?<=[:alnum:]);", " ;", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:])[?][   ]", " ? ", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:])[?]$", " ?", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:])!", " !", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}]);", " ;", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])[?][   ]", " ? ", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])[?]$", " ?", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])!", " !", True)
                        n += self._replaceText(xElem, "[  ]+([;?!])", " $1", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:]):[   ]", " : ", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:]):$", " :", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}]):", " :", True)
                        n += self._replaceText(xElem, "[  ]+:", " :", True)
                    else:
                        # espaces insécables
                        n = self._replaceText(xElem, "(?<=[:alnum:]):[   ]", " : ", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:]):$", " :", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:]);", " ;", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:])[?][   ]", " ? ", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:])[?]$", " ?", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:])!", " !", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}]):", " :", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}]);", " ;", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])[?][   ]", " ? ", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])[?]$", " ?", True)
                        n += self._replaceText(xElem, "(?<=[]…)»}])!", " !", True)
                        n += self._replaceText(xElem, "[  ]+([:;?!])", " $1", True)
                    # réparations
                    n -= self._replaceText(xElem, "([[(])[   ]([!?:;])", "$1$2", True)
                    n -= self._replaceText(xElem, "(?<=http)[   ]://", "://", True)
                    n -= self._replaceText(xElem, "(?<=https)[   ]://", "://", True)
                    n -= self._replaceText(xElem, "(?<=ftp)[   ]://", "://", True)
                    n -= self._replaceText(xElem, "(?<=&)amp[   ];", "amp;", True)          
                    n -= self._replaceText(xElem, "(?<=&)nbsp[   ];", "nbsp;", True)
                    n -= self._replaceText(xElem, "(?<=&)lt[   ];", "lt;", True)
                    n -= self._replaceText(xElem, "(?<=&)gt[   ];", "gt;", True)
                    n -= self._replaceText(xElem, "(?<=&)apos[   ];", "apos;", True)
                    n -= self._replaceText(xElem, "(?<=&)quot[   ];", "quot;", True)
                    n -= self._replaceText(xElem, "(?<=&)thinsp[   ];", "thinsp;", True)
                    self.nbsp1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp2.State:
                    if self.nnbsp2.State:
                        # espaces insécables fines
                        n = self._replaceText(xElem, "«(?=[:alnum:])", "« ", True)
                        n += self._replaceText(xElem, "«[  ]+", "« ", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:]|[.!?])»", " »", True)
                        n += self._replaceText(xElem, "[  ]+»", " »", True)
                    else:
                        # espaces insécables
                        n = self._replaceText(xElem, "«(?=[:alnum:])", "« ", True)
                        n += self._replaceText(xElem, "«[  ]+", "« ", True)
                        n += self._replaceText(xElem, "(?<=[:alnum:]|[.!?])»", " »", True)
                        n += self._replaceText(xElem, "[  ]+»", " »", True)
                    self.nbsp2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp3.State:
                    n = self._replaceText(xElem, "([:digit:])([%‰€$£¥˚℃])", "$1 $2", True)
                    n += self._replaceText(xElem, "([:digit:]) ([%‰€$£¥˚℃])", "$1 $2", True)
                    self.nbsp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp4.State:
                    if self.nnbsp4.State:
                        # espaces insécables fines
                        n = self._replaceText(xElem, "([:digit:])[  ]([:digit:])", "$1 $2", True)
                    else:
                        # espaces insécables
                        n = self._replaceText(xElem, "([:digit:])[  ]([:digit:])", "$1 $2", True)
                    self.nbsp4_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp5.State:
                    n = self._replaceText(xElem, "(?<=[0-9⁰¹²³⁴⁵⁶⁷⁸⁹]) ?([kcmµnd]?(?:[slgJKΩΩℓ]|m[²³]?|Wh?|Hz|dB)|[%‰]|°C)\\b", " $1", True, True)
                    self.nbsp5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if False:
                    n = self._replaceText(xElem, "\\b(MM?\\.|Mlle|Mgr) ", "$1 ", True)
                    self.nbsp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.nbsp.State = False
                self._switchCheckBox(self.nbsp)
            self.pbar.ProgressValue = 15
            # points médians
            if self.typo.State:
                if self.typo6.State:
                    n = self._replaceText(xElem, "\\bN\\.([ms])\\b", "N·$1", True, True) # N·m et N·m-1, N·s
                    n += self._replaceText(xElem, "\\bW\\.h\\b", "W·h", True, True)
                    n += self._replaceText(xElem, "\\bPa\\.s\\b", "Pa·s", True, True)
                    n += self._replaceText(xElem, "\\bA\\.h\\b", "A·h", True, True)
                    n += self._replaceText(xElem, "\\bΩ\\.m\\b", "Ω·m", True, True)
                    n += self._replaceText(xElem, "\\bS\\.m\\b", "S·m", True, True)
                    n += self._replaceText(xElem, "\\bg\\.s(?=-1)\\b", "g·s", True, True)
                    n += self._replaceText(xElem, "\\bm\\.s(?=-[12])\\b", "m·s", True, True)
                    n += self._replaceText(xElem, "\\bg\\.m(?=2|-3)\\b", "g·m", True, True)
                    n += self._replaceText(xElem, "\\bA\\.m(?=-1)\\b", "A·m", True, True)
                    n += self._replaceText(xElem, "\\bJ\\.K(?=-1)\\b", "J·K", True, True)
                    n += self._replaceText(xElem, "\\bW\\.m(?=-2)\\b", "W·m", True, True)
                    n += self._replaceText(xElem, "\\bcd\\.m(?=-2)\\b", "cd·m", True, True)
                    n += self._replaceText(xElem, "\\bC\\.kg(?=-1)\\b", "C·kg", True, True)
                    n += self._replaceText(xElem, "\\bH\\.m(?=-1)\\b", "H·m", True, True)
                    n += self._replaceText(xElem, "\\bJ\\.kg(?=-1)\\b", "J·kg", True, True)
                    n += self._replaceText(xElem, "\\bJ\\.m(?=-3)\\b", "J·m", True, True)
                    n += self._replaceText(xElem, "\\bm[2²]\\.s\\b", "m²·s", True, True)
                    n += self._replaceText(xElem, "\\bm[3³]\\.s(?=-1)\\b", "m³·s", True, True)
                    #n += self._replaceText(xElem, "\\bJ.kg-1.K-1\\b", "J·kg-1·K-1", True, True)
                    #n += self._replaceText(xElem, "\\bW.m-1.K-1\\b", "W·m-1·K-1", True, True)
                    #n += self._replaceText(xElem, "\\bW.m-2.K-1\\b", "W·m-2·K-1", True, True)
                    n += self._replaceText(xElem, "\\b(Y|Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)Ω\\b", "$1Ω", True, True)
                    self.typo6_res.Label = str(n)
                    self.pbar.ProgressValue += 1
            # espaces manquants
            if self.space.State:
                if self.space1.State:
                    n = self._replaceText(xElem, ";(?=[:alnum:])", "; ", True)
                    n += self._replaceText(xElem, "\\?(?=[A-ZÉÈÊÂÀÎ])", "? ", True, True)
                    n += self._replaceText(xElem, "!(?=[:alnum:])", "! ", True)
                    n += self._replaceText(xElem, "…(?=[:alnum:])", "… ", True)
                    n += self._replaceText(xElem, "\\.(?=[A-ZÉÈÎ][:alpha:])", ". ", True, True)
                    n += self._replaceText(xElem, "\\.(?=À)", ". ", True, True)
                    n += self._replaceText(xElem, ",(?=[:alpha:])", ", ", True)
                    n += self._replaceText(xElem, "([:alpha:]),([0-9])", "$1, $2", True)
                    n += self._replaceText(xElem, ":(?=[:alpha:])", ": ", True)
                    # réparations
                    n -= self._replaceText(xElem, "(?<=DnT), w\\b", ",w", True, True)
                    n -= self._replaceText(xElem, "(?<=DnT), A\\b", ",A", True, True)
                    self.space1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.space2.State:
                    n = self._replaceText(xElem, " -(?=[:alpha:]|[\"«“'‘])", " - ", True)
                    n += self._replaceText(xElem, " –(?=[:alpha:]|[\"«“'‘])", " – ", True) # demi-cadratin
                    n += self._replaceText(xElem, " —(?=[:alpha:]|[\"«“'‘])", " — ", True) # cadratin
                    n += self._replaceText(xElem, "(?<=[:alpha:])– ", " – ", True)
                    n += self._replaceText(xElem, "(?<=[:alpha:])— ", " — ", True)
                    n += self._replaceText(xElem, "(?<=[:alpha:])- ", " - ", True)
                    n += self._replaceText(xElem, "(?<=[\"»”'’])– ", " – ", True)
                    n += self._replaceText(xElem, "(?<=[\"»”'’])— ", " — ", True)
                    n += self._replaceText(xElem, "(?<=[\"»”'’])- ", " - ", True)
                    self.space2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.space.State = False
                self._switchCheckBox(self.space)
            self.pbar.ProgressValue = 17
            # Suppression
            if self.delete.State:
                if self.delete1.State:
                    n = self._replaceText(xElem, "­", "", False) # tiret conditionnel / soft hyphen
                    self.delete1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.delete2.State:
                    n = self._replaceBulletsByEmDash(xElem)
                    self.delete2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.delete.State = False
                self._switchCheckBox(self.delete)
            self.pbar.ProgressValue = 20
            # signes typographiques
            if self.typo.State:
                if self.typo1.State:
                    n = self._replaceText(xElem, "\\bl['´‘′`](?=[:alnum:])", "l’", True, True)
                    n += self._replaceText(xElem, "\\bj['´‘′`](?=[:alnum:])", "j’", True, True)
                    n += self._replaceText(xElem, "\\bm['´‘′`](?=[:alnum:])", "m’", True, True)
                    n += self._replaceText(xElem, "\\bt['´‘′`](?=[:alnum:])", "t’", True, True)
                    n += self._replaceText(xElem, "\\bs['´‘′`](?=[:alnum:])", "s’", True, True)
                    n += self._replaceText(xElem, "\\bc['´‘′`](?=[:alnum:])", "c’", True, True)
                    n += self._replaceText(xElem, "\\bd['´‘′`](?=[:alnum:])", "d’", True, True)
                    n += self._replaceText(xElem, "\\bn['´‘′`](?=[:alnum:])", "n’", True, True)
                    n += self._replaceText(xElem, "\\bç['´‘′`](?=[:alnum:])", "ç’", True, True)
                    n += self._replaceText(xElem, "\\bL['´‘′`](?=[:alnum:])", "L’", True, True)
                    n += self._replaceText(xElem, "\\bJ['´‘′`](?=[:alnum:])", "J’", True, True)
                    n += self._replaceText(xElem, "\\bM['´‘′`](?=[:alnum:])", "M’", True, True)
                    n += self._replaceText(xElem, "\\bT['´‘′`](?=[:alnum:])", "T’", True, True)
                    n += self._replaceText(xElem, "\\bS['´‘′`](?=[:alnum:])", "S’", True, True)
                    n += self._replaceText(xElem, "\\bC['´‘′`](?=[:alnum:])", "C’", True, True)
                    n += self._replaceText(xElem, "\\bD['´‘′`](?=[:alnum:])", "D’", True, True)
                    n += self._replaceText(xElem, "\\bN['´‘′`](?=[:alnum:])", "N’", True, True)
                    n += self._replaceText(xElem, "\\bÇ['´‘′`](?=[:alnum:])", "Ç’", True, True)
                    n += self._replaceText(xElem, "(qu|jusqu|lorsqu|puisqu|quoiqu|quelqu|presqu|entr|aujourd|prud)['´‘′`]", "$1’", True)
                    self.typo1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo2.State:
                    n = self._replaceText(xElem, "...", "…", False)
                    n += self._replaceText(xElem, "(?<=…)[.][.]", "…", True)
                    n += self._replaceText(xElem, "…[.](?![.])", "…", True)
                    self.typo2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo3.State:
                    if self.typo3b.State:
                        # demi-cadratin
                        n = self._replaceText(xElem, " - ", " – ", False)
                        n += self._replaceText(xElem, " — ", " – ", False)
                        n += self._replaceText(xElem, " -,", " –,", False)
                        n += self._replaceText(xElem, " —,", " –,", False)
                    else:
                        # cadratin
                        n = self._replaceText(xElem, " - ", " — ", False)
                        n += self._replaceText(xElem, " – ", " — ", False)
                        n += self._replaceText(xElem, " -,", " —,", False)
                        n += self._replaceText(xElem, " –,", " —,", False)
                    self.typo3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo4.State:
                    if self.typo4a.State:
                        # cadratin
                        n = self._replaceText(xElem, "^-[  ]", "— ", True)
                        n += self._replaceText(xElem, "^–[  ]", "— ", True)
                        n += self._replaceText(xElem, "^— ", "— ", True)
                        n += self._replaceText(xElem, "^«[  ][—–-][  ]", "« — ", True)
                        n += self._replaceText(xElem, "^[-–—](?=[:alnum:])", "— ", True)
                    else:
                        # demi-cadratin
                        n = self._replaceText(xElem, "^-[  ]", "– ", True)
                        n += self._replaceText(xElem, "^—[  ]", "– ", True)
                        n += self._replaceText(xElem, "^– ", "– ", True)
                        n += self._replaceText(xElem, "^[-–—](?=[:alnum:])", "– ", True)
                    self.typo4_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo5.State:
                    n = self._replaceText(xElem, '"([:alpha:]+)"', "“$1”", True)
                    n += self._replaceText(xElem, "''([:alpha:]+)''", "“$1”", True)
                    n += self._replaceText(xElem, "'([:alpha:]+)'", "“$1”", True)
                    n += self._replaceText(xElem, '^"(?=[:alnum:])', "« ", True)
                    n += self._replaceText(xElem, "^''(?=[:alnum:])", "« ", True)
                    n += self._replaceText(xElem, ' "(?=[:alnum:])', " « ", True)
                    n += self._replaceText(xElem, " ''(?=[:alnum:])", " « ", True)
                    n += self._replaceText(xElem, '\\("(?=[:alnum:])', "(« ", True)
                    n += self._replaceText(xElem, "\\(''(?=[:alnum:])", "(« ", True)
                    n += self._replaceText(xElem, '(?<=[:alnum:])"$', " »", True)
                    n += self._replaceText(xElem, "(?<=[:alnum:])''$", " »", True)
                    n += self._replaceText(xElem, '(?<=[:alnum:])"(?=[] ,.:;?!…)])', " »", True)
                    n += self._replaceText(xElem, "(?<=[:alnum:])''(?=[] ,.:;?!…)])", " »", True)
                    n += self._replaceText(xElem, '(?<=[.!?…])" ', " » ", True)
                    n += self._replaceText(xElem, '(?<=[.!?…])"$', " »", True)
                    self.typo5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo7.State:
                    # ligatures: no initial cap
                    n = self._replaceText(xElem, "coeur", "cœur", False, True)
                    n += self._replaceText(xElem, "coel([aeio])", "cœl$1", True, True)
                    n += self._replaceText(xElem, "choeur", "chœur", False, True)
                    n += self._replaceText(xElem, "foet", "fœt", False, True)
                    n += self._replaceText(xElem, "oeil", "œil", False, True)
                    n += self._replaceText(xElem, "oeno", "œno", False, True)
                    n += self._replaceText(xElem, "oesoph", "œsoph", False, True)
                    n += self._replaceText(xElem, "oestro", "œstro", False, True)
                    n += self._replaceText(xElem, "oeuf", "œuf", False, True)
                    n += self._replaceText(xElem, "oeuvr", "œuvr", False, True)
                    n += self._replaceText(xElem, "moeur", "mœur", False, True)
                    n += self._replaceText(xElem, "noeu", "nœu", False, True)
                    n += self._replaceText(xElem, "soeur", "sœur", False, True)
                    n += self._replaceText(xElem, "voeu", "vœu", False, True)
                    n += self._replaceText(xElem, "aequo", "æquo", False, True)
                    # ligatures: with initial cap
                    n += self._replaceText(xElem, "Coeur", "Cœur", False, True)
                    n += self._replaceText(xElem, "Coel([aeio])", "Cœl$1", True, True)
                    n += self._replaceText(xElem, "Choeur", "Chœur", False, True)
                    n += self._replaceText(xElem, "Foet", "Fœt", False, True)
                    n += self._replaceText(xElem, "Oeil", "Œil", False, True)
                    n += self._replaceText(xElem, "Oeno", "Œno", False, True)
                    n += self._replaceText(xElem, "Oesoph", "Œsoph", False, True)
                    n += self._replaceText(xElem, "Oestro", "Œstro", False, True)
                    n += self._replaceText(xElem, "Oeuf", "Œuf", False, True)
                    n += self._replaceText(xElem, "Oeuvr", "Œuvr", False, True)
                    n += self._replaceText(xElem, "Moeur", "Mœur", False, True)
                    n += self._replaceText(xElem, "Noeu", "Nœu", False, True)
                    n += self._replaceText(xElem, "Soeur", "Sœur", False, True)
                    n += self._replaceText(xElem, "Voeu", "Vœu", False, True)
                    n += self._replaceText(xElem, "Aequo", "Æquo", False, True)
                    # common words with missing diacritics
                    n += self._replaceText(xElem, "\\bCa\\b", "Ça", True, True)
                    n += self._replaceText(xElem, " ca\\b", " ça", True, True)
                    n += self._replaceText(xElem, "\\bdej[aà]\\b", "déjà", True, True)
                    n += self._replaceText(xElem, "\\bDej[aà]\\b", "Déjà", True, True)
                    n += self._replaceText(xElem, "\\bplutot\\b", "plutôt", True, True)
                    n += self._replaceText(xElem, "\\bPlutot\\b", "Plutôt", True, True)
                    n += self._replaceText(xElem, "\\b([cC]e(?:ux|lles?|lui))-la\\b", "$1-là", True, True)
                    n += self._replaceText(xElem, "\\bmalgre\\b", "malgré", True, True)
                    n += self._replaceText(xElem, "\\bMalgre\\b", "Malgré", True, True)
                    n += self._replaceText(xElem, "\\betre\\b", "être", True, True)
                    n += self._replaceText(xElem, "\\bEtre\\b", "Être", True, True)
                    n += self._replaceText(xElem, "\\btres\\b", "très", True, True)
                    n += self._replaceText(xElem, "\\bTres\\b", "Très", True, True)
                    n += self._replaceText(xElem, "\\bEtai([ts]|ent)\\b", "Étai$1", True, True)
                    n += self._replaceText(xElem, "\\bE(tat|cole|crit|poque|tude|ducation|glise|conomi(?:qu|)e|videmment|lysée|tienne|thiopie|cosse|gypt(?:e|ien)|rythrée|pinal|vreux)", "É$1", True, True)
                    self.typo7_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo8.State:
                    # ligatures typographiques : fi, fl, ff, ffi, ffl, ft, st
                    n = 0
                    if self.typo8a.State:
                        if self.typo_ffi.State:







|



|













|



|
<
<
<



|



|



|
<



|
<



|
<










|
<
<
<
<
<
<
<
<
<
<
<
<


|
<
<
<
<
<
<
<
<
<
<
<

<
<
<
|
<
<
<
<
<
<
<





|
<
<
<


|
<
<
<



|
<





|


|



|



|








<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





|
<
<
<
<
<
<
<
<

|
<



|
<
<
<
<
<
<
<
<








|












|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<



|
<
<





|
<
<
<


|
<
<
<





|
<
<
<
<


|
<
<
<



|
<
<
<
<
<
<
<
<
<
<
<
<
<
<



<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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
            # NOTE: A LOT OF REGEX COULD BE MERGED IF ICU ENGINE WAS NOT SO BUGGY
            # "([;?!…])(?=[:alnum:])" => "$1 " doesn’t work properly
            # "(?<=[:alnum:])([;?!…])" => " $1 " doesn’t work properly
            self.pbar.ProgressValue = 0
            # Restructuration
            if self.struct.State:
                if self.struct1.State:
                    n = self._replaceList(xElem, "struct1")
                    self.struct1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.struct2.State:
                    n = self._replaceList(xElem, "struct2")
                    n += self._replaceHyphenAtEndOfParagraphs(xElem) # EOP
                    self.struct2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.struct3.State:
                    n = self._mergeContiguousParagraphs(xElem)
                    self.struct3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.struct.State = False
                self._switchCheckBox(self.struct)
            self.pbar.ProgressValue = 3
            # espaces surnuméraires
            if self.ssp.State:
                if self.ssp3.State:
                    n = self._replaceList(xElem, "ssp3")
                    self.ssp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp2.State:
                    n = self._replaceList(xElem, "ssp2")



                    self.ssp2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp1.State:
                    n = self._replaceList(xElem, "ssp1")
                    self.ssp1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp4.State:
                    n = self._replaceList(xElem, "ssp4")
                    self.ssp4_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp5.State:
                    n = self._replaceList(xElem, "ssp5")

                    self.ssp5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp6.State:
                    n = self._replaceList(xElem, "ssp6")

                    self.ssp6_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.ssp7.State:
                    n = self._replaceList(xElem, "ssp7")

                    self.ssp7_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.ssp.State = False
                self._switchCheckBox(self.ssp)
            self.pbar.ProgressValue = 10
            # espaces typographiques
            if self.nbsp.State:
                if self.nbsp1.State:
                    if self.nnbsp1.State:
                        # espaces insécables fines
                        n = self._replaceList(xElem, "nnbsp1")












                    else:
                        # espaces insécables
                        n = self._replaceList(xElem, "nbsp1")











                    # réparations



                    n -= self._replaceList(xElem, "nbsp1_fix")







                    self.nbsp1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp2.State:
                    if self.nnbsp2.State:
                        # espaces insécables fines
                        n = self._replaceList(xElem, "nnbsp2")



                    else:
                        # espaces insécables
                        n = self._replaceList(xElem, "nbsp2")



                    self.nbsp2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp3.State:
                    n = self._replaceList(xElem, "nbsp3")

                    self.nbsp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp4.State:
                    if self.nnbsp4.State:
                        # espaces insécables fines
                        n = self._replaceList(xElem, "nnbsp4")
                    else:
                        # espaces insécables
                        n = self._replaceList(xElem, "nbsp4")
                    self.nbsp4_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.nbsp5.State:
                    n = self._replaceList(xElem, "nbsp5")
                    self.nbsp5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if False:
                    n = self._replaceList(xElem, "nbsp6")
                    self.nbsp3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.nbsp.State = False
                self._switchCheckBox(self.nbsp)
            self.pbar.ProgressValue = 15
            # points médians
            if self.typo.State:
                if self.typo6.State:

                    n = self._replaceList(xElem, "typo6")





















                    self.typo6_res.Label = str(n)
                    self.pbar.ProgressValue += 1
            # espaces manquants
            if self.space.State:
                if self.space1.State:
                    n = self._replaceList(xElem, "space1")








                    # réparations
                    n -= self._replaceList(xElem, "space1_fix")

                    self.space1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.space2.State:
                    n = self._replaceList(xElem, "space2")








                    self.space2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.space.State = False
                self._switchCheckBox(self.space)
            self.pbar.ProgressValue = 17
            # Suppression
            if self.delete.State:
                if self.delete1.State:
                    n = self._replaceList(xElem, "delete1")
                    self.delete1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.delete2.State:
                    n = self._replaceBulletsByEmDash(xElem)
                    self.delete2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.delete.State = False
                self._switchCheckBox(self.delete)
            self.pbar.ProgressValue = 20
            # signes typographiques
            if self.typo.State:
                if self.typo1.State:
                    n = self._replaceList(xElem, "typo1")


















                    self.typo1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo2.State:
                    n = self._replaceList(xElem, "typo2")


                    self.typo2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo3.State:
                    if self.typo3b.State:
                        # demi-cadratin
                        n = self._replaceList(xElem, "typo3b")



                    else:
                        # cadratin
                        n = self._replaceList(xElem, "typo3a")



                    self.typo3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo4.State:
                    if self.typo4a.State:
                        # cadratin
                        n = self._replaceList(xElem, "typo4a")




                    else:
                        # demi-cadratin
                        n = self._replaceList(xElem, "typo4b")



                    self.typo4_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo5.State:
                    n = self._replaceList(xElem, "typo5")














                    self.typo5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo7.State:

                    n = self._replaceList(xElem, "typo7")














































                    self.typo7_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.typo8.State:
                    # ligatures typographiques : fi, fl, ff, ffi, ffl, ft, st
                    n = 0
                    if self.typo8a.State:
                        if self.typo_ffi.State:
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
936
937
938
939
940
941


942
943
944
945
946
947
948
949


950
951
952
953
954
955
956
957
958
959
960
961
962
963
964


965
966
967
968
969
970
971
972
973
974
975
976
977
                self.typo.State = False
                self._switchCheckBox(self.typo)
            self.pbar.ProgressValue = 28
            # divers
            if self.misc.State:
                if self.misc1.State:
                    if self.misc1a.State:
                        n = self._replaceText(xElem, "(?<=\\b[0-9][0-9][0-9][0-9])(i?[èe]me|è|e)\\b", "ᵉ", True)
                        n += self._replaceText(xElem, "(?<=\\b[0-9][0-9][0-9])(i?[èe]me|è|e)\\b", "ᵉ", True)
                        n += self._replaceText(xElem, "(?<=\\b[0-9][0-9])(i?[èe]me|è|e)\\b", "ᵉ", True)
                        n += self._replaceText(xElem, "(?<=\\b[0-9])(i?[èe]me|è|e)\\b", "ᵉ", True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL][XVICL][XVICL][XVICL])(i?[èe]me|è|e)\\b", "ᵉ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL][XVICL][XVICL])(i?[èe]me|è|e)\\b", "ᵉ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL][XVICL])(i?[èe]me|è|e)\\b", "ᵉ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL])(i?[èe]me|è)\\b", "ᵉ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b(au|l[ea]|du) [XVICL])e\\b", "ᵉ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVI])e(?= siècle)", "ᵉ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[1I])er\\b", "ᵉʳ", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[1I])re\\b", "ʳᵉ", True, True)
                    else:
                        n = self._replaceText(xElem, "(?<=\\b[0-9][0-9][0-9][0-9])(i?[èe]me|è|ᵉ)\\b", "e", True)
                        n += self._replaceText(xElem, "(?<=\\b[0-9][0-9][0-9])(i?[èe]me|è|ᵉ)\\b", "e", True)
                        n += self._replaceText(xElem, "(?<=\\b[0-9][0-9])(i?[èe]me|è|ᵉ)\\b", "e", True)
                        n += self._replaceText(xElem, "(?<=\\b[0-9])(i?[èe]me|è|ᵉ)\\b", "e", True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL][XVICL][XVICL][XVICL])(i?[èe]me|è|ᵉ)\\b", "e", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL][XVICL][XVICL])(i?[èe]me|è|ᵉ)\\b", "e", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL][XVICL])(i?[èe]me|è|ᵉ)\\b", "e", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[XVICL])(i?[èe]me|è|ᵉ)\\b", "e", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[1I])ᵉʳ\\b", "er", True, True)
                        n += self._replaceText(xElem, "(?<=\\b[1I])ʳᵉ\\b", "er", True, True)
                    self.misc1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.misc2.State:
                    n = self._replaceText(xElem, "etc(…|[.][.][.]?)", "etc.", True, True)
                    n += self._replaceText(xElem, "(?<!,) etc[.]", ", etc.", True, True)
                    self.misc2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.misc3.State:
                    n = self._replaceText(xElem, "[ -]t[’'](?=il\\b|elle|on\\b)", "-t-", True)
                    n += self._replaceText(xElem, " t-(?=il|elle|on)", "-t-", True)
                    n += self._replaceText(xElem, "[ -]t[’'-](?=ils|elles)", "-", True)
                    n += self._replaceText(xElem, "(?<=[td])-t-(?=il|elle|on)", "-", True)
                    n += self._replaceText(xElem, "(celles?|celui|ceux) (ci|là)\\b", "$1-$2", True)
                    n += self._replaceText(xElem, "\\bdix (sept|huit|neuf)", "dix-$1", True)
                    n += self._replaceText(xElem, "quatre vingt", "quatre-vingt", False)
                    n += self._replaceText(xElem, "(soixante|quatre-vingt) dix", "$1-dix", True)
                    n += self._replaceText(xElem, "(vingt|trente|quarante|cinquante|soixante(?:-dix|)|quatre-vingt(?:-dix|)) (deux|trois|quatre|cinq|six|sept|huit|neuf)", "$1-$2", True)
                    n += self._replaceText(xElem, "(?<!-)\\b(ci) (joint|desso?us|contre|devant|avant|après|incluse|g[îi]t|gisent)", "$1-$2", True)
                    n += self._replaceText(xElem, "\\bvis à vis", "vis-à-vis", False, True)
                    n += self._replaceText(xElem, "\\bVis à vis", "Vis-à-vis", False, True)
                    n += self._replaceText(xElem, "week end", "week-end", False, True)
                    n += self._replaceText(xElem, "Week end", "Week-end", False, True)
                    n += self._replaceText(xElem, "(plus|moins) value", "$1-value", True)
                    self.misc3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.misc5.State:
                    n = self._replaceText(xElem, "(qu|lorsqu|puisqu|quoiqu|presqu|jusqu|aujourd|entr|quelqu) ", "$1’", True, True)
                    if self.misc5b.State:
                        n += self._replaceText(xElem, "\\bj (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "j’", True, True)
                        n += self._replaceText(xElem, "\\bn (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "n’", True, True)
                        n += self._replaceText(xElem, "\\bm (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "m’", True, True)
                        n += self._replaceText(xElem, "\\bt (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "t’", True, True)
                        n += self._replaceText(xElem, "\\bs (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "s’", True, True)
                        n += self._replaceText(xElem, "\\bc (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "c’", True, True)
                        n += self._replaceText(xElem, "\\bç (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "ç’", True, True)
                        n += self._replaceText(xElem, "\\bl (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "l’", True, True)
                        n += self._replaceText(xElem, "\\bd (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "d’", True, True)
                        if self.misc5c.State:
                            n += self._replaceText(xElem, "\\bJ (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "J’", True, True)
                            n += self._replaceText(xElem, "\\bN (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "N’", True, True)
                            n += self._replaceText(xElem, "\\bM (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "M’", True, True)
                            n += self._replaceText(xElem, "\\bT (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "T’", True, True)
                            n += self._replaceText(xElem, "\\bS (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "S’", True, True)
                            n += self._replaceText(xElem, "\\bC (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "C’", True, True)
                            n += self._replaceText(xElem, "\\bÇ (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "Ç’", True, True)
                            n += self._replaceText(xElem, "\\bL (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "L’", True, True)
                            n += self._replaceText(xElem, "\\bD (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])", "D’", True, True)
                    self.misc5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.misc.State = False
                self._switchCheckBox(self.misc)
            self.pbar.ProgressValue = self.pbar.ProgressValueMax
            # end of processing
            xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.ARROW"))
            xWindowPeer.setPointer(xPointer)
            for x in xWindowPeer.Windows:
                x.setPointer(xPointer)
            self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?)
            nEndTime = time.clock()
            self.time_res.Label = getTimeRes(nEndTime-nStartTime)
        except:
            traceback.print_exc()















    def _replaceText (self, xElem, sPattern, sRep, bRegex, bCaseSensitive=False):
        try:
            xRD = xElem.createReplaceDescriptor()
            xRD.SearchString = sPattern
            xRD.ReplaceString = sRep
            xRD.SearchRegularExpression = bRegex
            xRD.SearchCaseSensitive = bCaseSensitive
            return xElem.replaceAll(xRD)
        except:
            traceback.print_exc()
        return 0

    def _replaceHyphenAtEndOfParagraphs (self, xDoc):
        self._replaceText(xDoc, "-[  ]+$", "-", True) # remove spaces at end of paragraphs if - is the last character


        xHunspell = self.xSvMgr.createInstanceWithContext("com.sun.star.linguistic2.SpellChecker", self.ctx)
        xCursor = xDoc.Text.createTextCursor()
        xCursor.gotoStart(False)
        n = 0
        while xCursor.gotoNextParagraph(False):
            xCursor.goLeft(2, True)
            if xCursor.String.startswith("-"):
                xCursor.gotoStartOfWord(False)
                xLocale = xCursor.CharLocale
                xCursor.gotoEndOfWord(True)
                sWord1 = xCursor.String
                xCursor.gotoNextParagraph(False)
                xCursor.gotoEndOfWord(True)
                sWord2 = xCursor.String
                if sWord1 and sWord2 and xHunspell.isValid(sWord1+sWord2, xLocale, ()):
                    xCursor.gotoStartOfParagraph(False)
                    xCursor.goLeft(2, True)
                    xCursor.setString("")
                    n += 1
            else:
                xCursor.goRight(2, False)


        return n

    def _mergeContiguousParagraphs (self, xDoc):
        self._replaceText(xDoc, "^[  ]+$", "", True) # clear empty paragraphs
        xCursor = xDoc.Text.createTextCursor()
        xCursor.gotoStart(False)
        n = 0
        try:


            while xCursor.gotoNextParagraph(False):
                xCursor.gotoEndOfParagraph(True)
                if xCursor.String != "":
                    xCursor.gotoStartOfParagraph(False)
                    xCursor.goLeft(1, True)
                    xCursor.setString(" ")
                    n += 1
        except:
            traceback.print_exc()
        self._replaceText(xDoc, "  +", " ", True)
        return n

    def _replaceBulletsByEmDash (self, xDoc):
        xCursor = xDoc.Text.createTextCursor()
        helpers.xray(xCursor)


        xCursor.gotoStart(False)
        sParaStyleName = ""
        if not self.delete2c.State:
            sParaStyleName = "Standard"  if self.delete2a.State  else "Text body"
        n = 0
        try:
            if xCursor.NumberingStyleName != "":
                xCursor.NumberingStyleName = ""
                if sParaStyleName:
                    xCursor.ParaStyleName = sParaStyleName
                xDoc.Text.insertString(xCursor, "— ", False)
                n += 1
            while xCursor.gotoNextParagraph(False):







<
<
<
<
<
<
<
<
<
<
|
<

<
<
<
<
<
<
<
<
|
<



|
<



|
<
<
<
<
<
<
<
<
<
<
<
<
<
<



|

|
<
<
<
<
<
<
<
<

|
<
<
<
<
<
<
<
<
















>
>
>
>
>
>
>
>
>
>
>
>
>
>
|



|









>
>
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>



|
<
<


>
>














|
>
>
|
|
|
|
<
<







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
                self.typo.State = False
                self._switchCheckBox(self.typo)
            self.pbar.ProgressValue = 28
            # divers
            if self.misc.State:
                if self.misc1.State:
                    if self.misc1a.State:










                        n = self._replaceList(xElem, "misc1a")

                    else:








                        n = self._replaceList(xElem, "misc1b")

                    self.misc1_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.misc2.State:
                    n = self._replaceList(xElem, "misc2")

                    self.misc2_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.misc3.State:
                    n = self._replaceList(xElem, "misc3")














                    self.misc3_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                if self.misc5.State:
                    n = self._replaceList(xElem, "misc5a")
                    if self.misc5b.State:
                        n += self._replaceList(xElem, "misc5b")








                        if self.misc5c.State:
                            n += self._replaceList(xElem, "misc5c")








                    self.misc5_res.Label = str(n)
                    self.pbar.ProgressValue += 1
                self.misc.State = False
                self._switchCheckBox(self.misc)
            self.pbar.ProgressValue = self.pbar.ProgressValueMax
            # end of processing
            xPointer.setType(uno.getConstantByName("com.sun.star.awt.SystemPointer.ARROW"))
            xWindowPeer.setPointer(xPointer)
            for x in xWindowPeer.Windows:
                x.setPointer(xPointer)
            self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?)
            nEndTime = time.clock()
            self.time_res.Label = getTimeRes(nEndTime-nStartTime)
        except:
            traceback.print_exc()

    def _replaceList (self, xElem, sList):
        if sList not in tf_tabrep.dTableRepl:
            print("# Error. List <"+sList+"> not found")
            return 0
        n = 0
        try:
            for sPattern, sRepl, bRegex, bCaseSensitive in tf_tabrep.dTableRepl[sList]:
                n += self._replaceText(xElem, sPattern, sRepl, bRegex, bCaseSensitive)
        except:
            print("# Error with "+sList)
            traceback.print_exc()
        return n


    def _replaceText (self, xElem, sPattern, sRepl, bRegex, bCaseSensitive=False):
        try:
            xRD = xElem.createReplaceDescriptor()
            xRD.SearchString = sPattern
            xRD.ReplaceString = sRepl
            xRD.SearchRegularExpression = bRegex
            xRD.SearchCaseSensitive = bCaseSensitive
            return xElem.replaceAll(xRD)
        except:
            traceback.print_exc()
        return 0

    def _replaceHyphenAtEndOfParagraphs (self, xDoc):
        self._replaceText(xDoc, "-[  ]+$", "-", True) # remove spaces at end of paragraphs if - is the last character
        n = 0
        try:
            xHunspell = self.xSvMgr.createInstanceWithContext("com.sun.star.linguistic2.SpellChecker", self.ctx)
            xCursor = xDoc.Text.createTextCursor()
            xCursor.gotoStart(False)

            while xCursor.gotoNextParagraph(False):
                xCursor.goLeft(2, True)
                if xCursor.String.startswith("-"):
                    xCursor.gotoStartOfWord(False)
                    xLocale = xCursor.CharLocale
                    xCursor.gotoEndOfWord(True)
                    sWord1 = xCursor.String
                    xCursor.gotoNextParagraph(False)
                    xCursor.gotoEndOfWord(True)
                    sWord2 = xCursor.String
                    if sWord1 and sWord2 and xHunspell.isValid(sWord1+sWord2, xLocale, ()):
                        xCursor.gotoStartOfParagraph(False)
                        xCursor.goLeft(2, True)
                        xCursor.setString("")
                        n += 1
                else:
                    xCursor.goRight(2, False)
        except:
            traceback.print_exc()
        return n

    def _mergeContiguousParagraphs (self, xDoc):
        self._replaceText(xDoc, "^[  ]+$", "", True) # clear empty paragraphs    


        n = 0
        try:
            xCursor = xDoc.Text.createTextCursor()
            xCursor.gotoStart(False)
            while xCursor.gotoNextParagraph(False):
                xCursor.gotoEndOfParagraph(True)
                if xCursor.String != "":
                    xCursor.gotoStartOfParagraph(False)
                    xCursor.goLeft(1, True)
                    xCursor.setString(" ")
                    n += 1
        except:
            traceback.print_exc()
        self._replaceText(xDoc, "  +", " ", True)
        return n

    def _replaceBulletsByEmDash (self, xDoc):
        xCursor = xDoc.Text.createTextCursor()
        #helpers.xray(xCursor)
        n = 0
        try:
            xCursor.gotoStart(False)
            sParaStyleName = ""
            if not self.delete2c.State:
                sParaStyleName = "Standard"  if self.delete2a.State  else "Text body"


            if xCursor.NumberingStyleName != "":
                xCursor.NumberingStyleName = ""
                if sParaStyleName:
                    xCursor.ParaStyleName = sParaStyleName
                xDoc.Text.insertString(xCursor, "— ", False)
                n += 1
            while xCursor.gotoNextParagraph(False):

Modified make.py from [78de6b4826] to [14dcb35490].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

def getConfig (sLang):
    xConfig = configparser.SafeConfigParser()
    xConfig.optionxform = str
    try:
        xConfig.read("gc_lang/" + sLang + "/config.ini", encoding="utf-8")
    except:
        print("Config file in project [" + sLang + "] not found")
        exit()
    return xConfig


def createOptionsLabelProperties (dOptLbl):
    sContent = ""
    for sOpt, tLabel in dOptLbl.items():







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

def getConfig (sLang):
    xConfig = configparser.SafeConfigParser()
    xConfig.optionxform = str
    try:
        xConfig.read("gc_lang/" + sLang + "/config.ini", encoding="utf-8")
    except:
        print("# Error. Can’t read config file [" + sLang + "]")
        exit()
    return xConfig


def createOptionsLabelProperties (dOptLbl):
    sContent = ""
    for sOpt, tLabel in dOptLbl.items():

Modified tests/fr/formateur_de_texte.odt from [0fbb935ea9] to [d7d8a124ac].

cannot compute difference between binary files