This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/CmathOOo/mCmathOOo.xba is in libreoffice-dmaths 3.4+dfsg1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
 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
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="mCmathOOo" script:language="StarBasic">&apos;*****  BASIC  *****
&apos;CmathOOo
&apos;Copyright (C) 2005  Christophe devalland

&apos;This program is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public License
&apos;as published by the Free Software Foundation; either version 2
&apos;of the License, or (at your option) any later version.

&apos;This program is distributed in the hope that it will be useful,
&apos;but WITHOUT ANY WARRANTY; without even the implied warranty of
&apos;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
&apos;GNU General Public License for more details.

&apos;You should have received a copy of the GNU General Public License
&apos;along with this program; if not, write to the Free Software
&apos;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Option Explicit
public bModeTexte as boolean
global sSearch() as string, sReplace() as string
const cNbArgMax=3		&apos; nombre d&apos;arguments maximum pour les fonctions acceptant un nb variable
						&apos; de paramètres (matrices, systèmes...). Cependant, en cas de dépassement, le programme redimensionnera
						&apos; le tableau. Il n&apos;y aura donc pas d&apos;erreurs, juste un léger ralentissement.

sub main
	ThisComponent.unlockControllers
end sub

sub FormuleTexte
	dim oViewCursor as Object, oTextCursor as Object
	dim sPolice as String, sFormule as String
	dim iTaille as Integer
	bModeTexte=True
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	sFormule=SelectionnerFormule(oTextCursor,0)
	sFormule=BugDu2x(sFormule)
	sFormule=SubstitutionVirgule(sFormule)
	sFormule=SubstitutionsAvantTraitement(sFormule)
	sFormule=TraitementFormule(sFormule,False)
	sFormule=SubstitutionsApresTraitement(sFormule)
    InsereFormule(OViewCursor, oTextCursor, sPolice, iTaille, sFormule, bModeTexte)
end sub

sub FormuleCentree
	dim oViewCursor as Object, oTextCursor as Object
	dim sPolice as String, sFormule as String
	dim iTaille as Integer
	bModeTexte=False
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	sFormule=SelectionnerFormule(oTextCursor,0)
	sFormule=BugDu2x(sFormule)
	sFormule=SubstitutionVirgule(sFormule)
	sFormule=SubstitutionsAvantTraitement(sFormule)
	sFormule=TraitementFormule(sFormule,False)
	sFormule=SubstitutionsApresTraitement(sFormule)
    InsereFormule(OViewCursor, oTextCursor, sPolice, iTaille, sFormule, bModeTexte)
end sub



&apos;-------------------------------------------------------------------------------------
Function SubstitutionVirgule(sFormule as String) as String
	&apos; recherche d&apos;une virgule :
	&apos; si elle est entourée de chiffres elle est fait partie d&apos;un nombre
	&apos; sinon, c&apos;est un séparateur (listes, ...)
	dim i as integer, iPosVirg as integer
	i=1
	iPosVirg=Instr(sFormule,&quot;,&quot;)
	Do while iPosVirg&gt;i
		if InStr(&quot;0123456789&quot;,mid(sFormule,iPosVirg-1,1))=0 or InStr(&quot;0123456789&quot;,mid(sFormule,iPosVirg+1,1))=0 then
			sFormule=left(sFormule,iPosVirg-1)+&quot;**{nitalic ,}**&quot;+mid(sFormule,iPosVirg+1)
			iPosVirg=iPosVirg+14
		end if
		i=iPosVirg
		iPosVirg=i+Instr(mid(sFormule,i+1),&quot;,&quot;)
	loop
	SubstitutionVirgule=sFormule
end function

&apos;-------------------------------------------------------------------------------------
Function BugDu2x(sFormule as String) as String
	&apos; recherche d&apos;une multiplication implicite entre un chiffre et une lettre
	&apos; si trouvée, ajouter une espace
	&apos; pourra être effacé après correction du bug http://www.openoffice.org/issues/show_bug.cgi?id=45689
	dim i as integer
	dim iChiffre as integer
	dim iLettre as integer
	i=1
	do while i&lt;len(sFormule)
		iChiffre=asc(mid(sFormule,i,1))
		iLettre=asc(mid(sFormule,i+1,1))
		if ((iChiffre&gt;47 and iChiffre&lt;58) and ((iLettre&gt;96 and iLettre&lt;123) or (iLettre&gt;64 and iLettre&lt;91))) then
			sFormule=left(sFormule,i)&amp;&quot; &quot;&amp;mid(sFormule,i+1)
			i=i+3
		else
			i=i+1
		end if
	loop
	BugDu2x=sFormule
end function



&apos;-------------------------------------------------------------------------------------
Function SubstitutionsAvantTraitement(sFormule as String) as String
	dim i as integer, j as integer, iPosAcc as integer, iPosGuil as integer, iNiveauAcc as integer
	dim iPosVirg as integer
	dim sCaractere as string
	dim n as integer
	dim sSubstitution as string
	
	if sFormule&lt;&gt;&quot;&quot; then
		iPosAcc=Instr(sFormule,&quot;{&quot;)
		iPosGuil=Instr(sFormule,&quot;&quot;&quot;&quot;)
		if iPosAcc+iPosGuil&gt;0 then &apos;ne pas substituer à l&apos;intérieur d&apos;un commentaire ou d&apos;une formule déjà traitée
			if (iPosAcc&gt;0 and iPosGuil&gt;iPosAcc) or iPosGuil=0 then
				iNiveauAcc=1
				i=iPosAcc
				do while iNiveauAcc&gt;0
						i=i+1
						if i&gt;len(sFormule) then
							msgbox(&quot;Erreur d&apos;accolades !&quot;)
							stop
						end if
						sCaractere=Mid(sFormule,i,1)				
						if sCaractere=&quot;{&quot; then
							iNiveauAcc=iNiveauAcc+1
						end if
						if sCaractere=&quot;}&quot; then
							iNiveauAcc=iNiveauAcc-1
						end if
				loop
				SubstitutionsAvantTraitement=SubstitutionsAvantTraitement(left(sFormule,iPosAcc-1))+mid(sFormule,iPosAcc,i-iPosAcc+1)+SubstitutionsAvantTraitement(mid(sFormule,i+1))
				exit function
			else
				i=Instr(mid(sFormule,iPosGuil+1),&quot;&quot;&quot;&quot;)
				if i=0 then
					msgbox(&quot;Erreur de guillemets !&quot;)
					stop
				end if
				SubstitutionsAvantTraitement=SubstitutionsAvantTraitement(left(sFormule,iPosGuil-1))+mid(sFormule,iPosGuil,i+1)+SubstitutionsAvantTraitement(mid(sFormule,i+iPosGuil+1))
				exit function
			end if
		end if
		&apos; substitutions mots-clé touche F8
&apos;		i=0
		i=Instr(sFormule,&quot;$&quot;)

&apos;		do while j&gt;i
			&apos;i=j
		if i&gt;0 then
			sSubstitution=sSubstitutionF8(mid(sFormule,i+1,2))
			if sSubstitution=&quot;&quot; then
				sSubstitution=&quot;{color red{&quot;&quot;??&quot;&quot;}}&quot;
			end if
			sFormule=SubstitutionsAvantTraitement(left(sFormule,i-1))+sSubstitution+SubstitutionsAvantTraitement(mid(sFormule,i+3))
		else
		
			&apos;initialisation si besoin
			&apos;évite de définir n tableaux identiques lors des appels récursifs
			if UBound(sSearch())&lt;0 then
				sSearch() = Array( &quot;arcsin&quot;,&quot;arccos&quot;,&quot;arctan&quot;,&quot;arccot&quot;,&quot;arsinh&quot;,&quot;arcosh&quot;,&quot;artanh&quot;,&quot;arcoth&quot;,_
								&quot;cosh&quot;,&quot;sinh&quot;,&quot;tanh&quot;,&quot;coth&quot;,&quot;cos&quot;,&quot;sin&quot;,&quot;tan&quot;,&quot;cot&quot;,_
								&quot;argch&quot;,&quot;argsh&quot;,&quot;argth&quot;,&quot;ch&quot;,&quot;sh&quot;,&quot;th&quot;,_
								&quot;ln&quot;,&quot;e^&quot;,&quot;--&quot;,&quot;...&quot;,&quot;&lt;=&quot;,&quot;arg&quot;,&quot;!&quot;,_
								&quot;&gt;=&quot;,&quot;&lt;&gt;&quot;,&quot;==&quot;,&quot;|&quot;,&quot;^-&quot;,&quot;^+&quot;,&quot;=&quot;,&quot;&lt;&quot;,&quot;&gt;&quot;)
				sReplace() = Array(&quot; arcsin &quot;,&quot; arccos &quot;,&quot; arctan &quot;,&quot; arccot &quot;,&quot; arsinh &quot;,&quot;  arcosh &quot;,&quot; artanh &quot;,&quot; arcoth &quot;,_
								&quot; cosh &quot;,&quot; sinh &quot;,&quot; tanh &quot;,&quot; coth &quot;,&quot; cos &quot;,&quot; sin &quot;,&quot; tan &quot;,&quot; cot &quot;,_
								&quot; func argch &quot;,&quot; func argsh &quot;,&quot; func argth &quot;,&quot; func ch &quot;,&quot; func sh &quot;,&quot; func th &quot;,_
								&quot; ln &quot;,&quot; func e^&quot;,&quot;*rightarrow*&quot;,&quot; dotslow &quot;,&quot;**leslant**&quot;,&quot;&quot;&quot;arg&quot;&quot;&quot;,&quot;&quot;&quot;!&quot;&quot;&quot;,_
								&quot;**geslant**&quot;,&quot;**neq**&quot;,&quot;**equiv**&quot;,&quot;**divides**&quot;,&quot;^&quot;&quot;&quot;&quot;&quot;,&quot;^&quot;&quot;+&quot;&quot;&quot;,&quot;**=**&quot;,&quot;**&lt;**&quot;,&quot;**&gt;**&quot;)
			end if
			For n = LBound(sSearch()) To UBound(sSearch())
				i=Instr(1,sFormule,sSearch(n),0)
				if i&gt;0 then
					sFormule=SubstitutionsAvantTraitement(left(sFormule,i-1))+sReplace(n)+SubstitutionsAvantTraitement(mid(sFormule,i+len(sSearch(n))))
					exit for
				end if
			Next n
		end if
	end if
	SubstitutionsAvantTraitement=sFormule
end function


&apos;-------------------------------------------------------------------------------------------------------
sub SubstitutionsApresTraitement(sFormule as String) as String
	dim sSearchAfter() as string, sReplaceAfter() as string
	dim n as integer, i as integer
	
	sSearchAfter() = Array(&quot;;&quot;,&quot;  &quot;,&quot;*=*&quot;,&quot;*&lt;*&quot;,&quot;*&gt;*&quot;,&quot;*&lt;&gt;*&quot;)
	sReplaceAfter() = Array(&quot;{nitalic ;}&quot;,&quot; &quot;,&quot;=&quot;,&quot;&lt;&quot;,&quot;&gt;&quot;,&quot;&lt;&gt;&quot;)
	For n = LBound(sSearchAfter()) To UBound(sSearchAfter())
		i=Instr(sFormule,sSearchAfter(n))
		do while i&gt;0
			sFormule=left(sFormule,i-1)+sReplaceAfter(n)+mid(sFormule,i+len(sSearchAfter(n)))
			i=Instr(i+len(sReplaceAfter(n)),sFormule,sSearchAfter(n))
		loop
	Next n
	SubstitutionsApresTraitement=sFormule
end sub

&apos;--------------------------------------------------------------------------------------
sub BasculeModeTexte
	dim oViewCursor as object, oTextCursor as object
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor.getStart())
 	oTextCursor.Text.insertString(oTextCursor, chr(34), FALSE)
end sub

&apos;--------------------------------------------------------------------------------------
sub InsereSymboleRacine
	dim oViewCursor as object, oTextCursor as object
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor.getStart())
 	oTextCursor.Text.insertString(oTextCursor, &quot;&quot;, FALSE)
end sub

&apos;--------------------------------------------------------------------------------------
sub InsereSymboleMultiplication
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor.getStart())
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;{}times{}&quot;,False)
end sub

&apos;--------------------------------------------------------------------------------------
sub InsereSymboleDivision
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor.getStart())
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;{}div{}&quot;,False)
end sub

&apos;--------------------------------------------------------------------------------------
sub InsereSymboleSoustraction
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor.getStart())
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;{}-{}&quot;,False)
end sub

&apos;--------------------------------------------------------------------------------------
sub Vecteur
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer, sFormule as string
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
   	If oTextCursor.IsCollapsed() then
		sFormule=SelectionnerFormule(oTextCursor,2)
		if left(sFormule,1)&lt;&quot;A&quot; then
			oTextCursor.goRight(2,False)
			sFormule=SelectionnerFormule(oTextCursor,1)
		end if
	else
			sFormule=SelectionnerFormule(oTextCursor,0)			
	end if
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;widevec{&quot;+sFormule+&quot;}&quot;,true)
end sub

&apos;--------------------------------------------------------------------------------------
sub Barre
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer, sFormule as string
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
   	If oTextCursor.IsCollapsed() then
		sFormule=SelectionnerFormule(oTextCursor,1)
	else
		sFormule=SelectionnerFormule(oTextCursor,0)			
	end if
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;overline{&quot;+sFormule+&quot;}&quot;,true)
end sub

&apos;--------------------------------------------------------------------------------------
sub Angle
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer, sFormule as string
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
   	If oTextCursor.IsCollapsed() then
		sFormule=SelectionnerFormule(oTextCursor,2)
		oTextCursor.goRight(2,False)
		if left(sFormule,1)&lt;&quot;A&quot; then
			sFormule=SelectionnerFormule(oTextCursor,1)
		else
			sFormule=SelectionnerFormule(oTextCursor,3)			
		end if
	else
			sFormule=SelectionnerFormule(oTextCursor,0)			
	end if
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;widehat{&quot;+sFormule+&quot;}&quot;,true)
end sub

&apos;--------------------------------------------------------------------------------------
sub Racine
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer, sFormule as string
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	sFormule=SelectionnerFormule(oTextCursor,0)
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;sqrt{&quot;+TraitementFormule(sFormule,False)+&quot;}&quot;,true)
end sub

&apos;--------------------------------------------------------------------------------------
sub Script
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, iTaille as integer, sFormule as string
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
    If oTextCursor.IsCollapsed() then
		sFormule=SelectionnerFormule(oTextCursor,1)
	end if
	InsereFormule(oViewCursor, oTextCursor, sPolice, iTaille, &quot;{font serif nitalic{&quot;+sFormule+&quot;}}&quot;,true)

&apos;	oTextCursor.CharFontName=&quot;Cmathcal&quot;
&apos; 	oTextCursor.goRight(1,False)
&apos;    oTextCursor.CharFontName=sPolice
end sub

&apos;--------------------------------------------------------------------------------------
Function TraitementFormule(sFormule as String, bReduire as boolean) as String
	&apos;si bReduire vaut true, une fraction verra la taille de la police diminuer de 1.

	dim sNiveauSup as string, sCaractere as string, sSizedebut as string, sSizefin as string
	dim sFormuleGauche as string, sFormuleDroite as string, sOperateur as string
	dim iNiveauPar as integer, iPos as integer, iPosSup as integer, iPosSep as integer
	dim iPos2 as integer, n as integer, iPosDebutArg as integer, iPosFinArg as integer, iNbCol as integer
	dim i as integer, j as integer, iNbLig as integer
	

	if sFormule=&quot;&quot; then goto fin
	dim iPosNiveauSup(1 to len(sFormule)) as integer
	Dim sArg as Variant
	sNiveauSup=&quot;&quot;
	iNiveauPar=0
	iPos=0
	iPosSup=0
	iPosSep=0
	Do While iPos&lt;len(sFormule)
		iPos=iPos+1		
		iPosSup=iPosSup+1	
		sCaractere=Mid(sFormule,iPos,1)
		sNiveauSup=sNiveauSup + sCaractere
		iPosNiveauSup(iPosSup)=iPos
		Select Case sCaractere
		Case &quot;(&quot;
			iNiveauPar=iNiveauPar+1
			do while iNiveauPar&gt;0
				iPos=iPos+1
				if iPos&gt;len(sFormule) then
					msgbox(&quot;Erreur de parenthèses !&quot;)
					stop
				end if
				sCaractere=Mid(sFormule,iPos,1)				
				if sCaractere=&quot;(&quot; then
					iNiveauPar=iNiveauPar+1
				end if
				if sCaractere=&quot;)&quot; then
					iNiveauPar=iNiveauPar-1
				end if
			loop
			iPosSup=iPosSup+1	
			sNiveauSup=sNiveauSup+sCaractere
			iPosNiveauSup(iPosSup)=iPos
		Case &quot;{&quot;
			iNiveauPar=iNiveauPar+1
			do while iNiveauPar&gt;0
				iPos=iPos+1
				if iPos&gt;len(sFormule) then
					msgbox(&quot;Erreur d&apos;accolades !&quot;)
					stop
				end if
				sCaractere=Mid(sFormule,iPos,1)				
				if sCaractere=&quot;{&quot; then
					iNiveauPar=iNiveauPar+1
				end if
				if sCaractere=&quot;}&quot; then
					iNiveauPar=iNiveauPar-1
				end if
			loop
			iPosSup=iPosSup+1	
			sNiveauSup=sNiveauSup+sCaractere
			iPosNiveauSup(iPosSup)=iPos
		Case &quot;[&quot;, &quot;]&quot;
			sNiveauSup=left(sNiveauSup,iPosSup-1)+&quot;[&quot;
			iNiveauPar=iNiveauPar+1
			do while iNiveauPar&gt;0
				iPos=iPos+1
				if iPos&gt;len(sFormule) then
					msgbox(&quot;Erreur de crochets !&quot;)
					stop
				end if
				sCaractere=Mid(sFormule,iPos,1)				
				if sCaractere=&quot;[&quot; or sCaractere=&quot;]&quot; then
					iNiveauPar=iNiveauPar-1
				end if
			loop
			iPosSup=iPosSup+1	
			sNiveauSup=sNiveauSup+&quot;]&quot;
			iPosNiveauSup(iPosSup)=iPos
		Case chr(34)
			iNiveauPar=iNiveauPar+1
			do while iNiveauPar&gt;0
				iPos=iPos+1
				if iPos&gt;len(sFormule) then
					msgbox(&quot;Erreur de guillemets !&quot;)
					stop
				end if
				sCaractere=Mid(sFormule,iPos,1)				
				if sCaractere=chr(34) then
					iNiveauPar=iNiveauPar-1
				end if
			loop
			iPosSup=iPosSup+1	
			sNiveauSup=sNiveauSup+sCaractere
			iPosNiveauSup(iPosSup)=iPos
		end select
	loop

	&apos; caractère de séparation
	iPos=Instr(sNiveauSup,&quot;;&quot;)
	if iPos&gt;0 then
		sFormule=TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;;&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)
		goto fin
	end if
	
	&apos;addition
	iPos=Instr(sNiveauSup,&quot;+&quot;)
	if iPos&gt;0 then
		if iPosNiveauSup(iPos)=1 then &apos;rien à gauche
			sFormule=&quot;+&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)
			goto fin
		&apos; si ce n&apos;est pas ^+
		elseif bEstCeSigne(mid(sFormule,iPosNiveauSup(iPos)-1,1))=False then
			sFormule=TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;+&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)
			goto fin
		end if
	end if

	&apos;soustraction
	iPos=Instr(sNiveauSup,&quot;-&quot;)
	if iPos&gt;0 then
		if iPosNiveauSup(iPos)=1 then &apos;rien à gauche
			sFormule=&quot;-&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)
			goto fin
		&apos; si ce n&apos;est pas ^-
		elseif bEstCeSigne(mid(sFormule,iPosNiveauSup(iPos)-1,1))=False then
			sFormule=TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;-&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)
			goto fin
		end if
	end if
	
	&apos; multiplication à usage interne
	&apos; ne traite pas l&apos;opérateur entre les **
	iPos=Instr(sNiveauSup,&quot;**&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPos2=Instr(mid(sNiveauSup,iPos+2),&quot;**&quot;)
		sOperateur=mid(sFormule,iPosNiveauSup(iPos)+2,iPosNiveauSup(iPos2+iPos+1)-iPosNiveauSup(iPos)-2)
		sFormuleDroite=mid(sFormule,iPosNiveauSup(iPos2+iPos+1)+2)
&apos;		if sFormuleGauche=&quot;&quot; then 
&apos;			sFormule=&quot;&quot;
&apos;		else
			sFormule=&quot;{&quot;+TraitementFormule(sFormuleGauche,bReduire)+&quot;}&quot;
&apos;		end if
		sFormule=sFormule+sOperateur
&apos;		if sFormuleDroite&lt;&gt;&quot;&quot; then 
			sFormule=sFormule+&quot;{&quot;+TraitementFormule(sFormuleDroite,bReduire)+&quot;}&quot;
&apos;		end if
		goto fin
	end if

	&apos; multiplication invisible
	iPos=Instr(sNiveauSup,&quot;*&quot;)
	if iPos&gt;0 then
		sFormule=TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot; &quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)
		goto fin
	end if
	
	&apos;point
	iPos=Instr(sNiveauSup,&quot;.&quot;)
	if iPos&gt;0 then
		sFormule=&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;}cdot{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),bReduire)+&quot;}&quot;
		goto fin
	end if
	
	&apos;division
	iPos=Instr(sNiveauSup,&quot;/&quot;)
	if iPos&gt;0 then
		&apos; aller chercher le dernier &quot;/&quot;
		do while Instr(iPos+1,sNiveauSup,&quot;/&quot;)&gt;0
			iPos=Instr(iPos+1,sNiveauSup,&quot;/&quot;)
		loop
		if bModeTexte=False and bReduire=true then
&apos;			sSizedebut=&quot;&quot;
&apos;			sSizefin=&quot;&quot;
&apos;			les fractions peuvent s&apos;écrire 1 pt plus petit, dans ce cas, enlever les commentaires.
			sSizedebut=&quot;size -1{alignc &quot;
			sSizefin=&quot;}&quot;
		else
			sSizedebut=&quot;{alignc &quot;
			sSizefin=&quot;}&quot;
		end if
		&apos;enlever les parentheses inutiles
		if left(sNiveauSup,iPos-1)=&quot;()&quot; then
			if mid(sNiveauSup,iPos+1)=&quot;()&quot; then
				&apos;parenthèses gauche et droites inutiles
				sFormule=sSizedebut+&quot;{&quot;+TraitementFormule(mid(sFormule,2,iPosNiveauSup(iPos)-3),True)+&quot;}over{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+2,len(sFormule)-iPosNiveauSup(iPos)-2),True)+&quot;}&quot;+sSizefin
			else
				&apos;parenthèses gauche inutiles			
				sFormule=sSizedebut+&quot;{&quot;+TraitementFormule(mid(sFormule,2,iPosNiveauSup(iPos)-3),True)+&quot;}over{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),True)+&quot;}&quot;+sSizefin
			end if
		else
			if mid(sNiveauSup,iPos+1)=&quot;()&quot; then
				&apos;parenthèses droite inutiles			
				sFormule=sSizedebut+&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),True)+&quot;}over{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+2,len(sFormule)-iPosNiveauSup(iPos)-2),True)+&quot;}&quot;+sSizefin
			else
				&apos;pas de parenthèses inutiles
				sFormule=sSizedebut+&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),True)+&quot;}over{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),True)+&quot;}&quot;+sSizefin
			end if
		end if
		goto fin
	end if

	
	&apos;indice
	iPos=Instr(sNiveauSup,&quot;_&quot;)
	if iPos&gt;0 then
		&apos;enlever les parentheses inutiles
		if mid(sNiveauSup,iPos+1)=&quot;()&quot; then
			&apos;parenthèses droite inutiles			
			sFormule=&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;}_{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+2,len(sFormule)-iPosNiveauSup(iPos)-2),false)+&quot;}&quot;
		else
			&apos;pas de parenthèses inutiles
			&apos;tester s&apos;il y a un exposant
			if InStr(mid(sFormule,iPosNiveauSup(iPos)+1),&quot;^&quot;) then
				&apos;voir si () droites inutiles
				sFormule=&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;}_&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),false)
			else
				sFormule=&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;}_{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),false)+&quot;}&quot;
			end if
		end if
	goto fin
	end if
	
	&apos;puissance
	iPos=Instr(sNiveauSup,&quot;^&quot;)
	if iPos&gt;0 then
		&apos;enlever les parentheses inutiles
		if mid(sNiveauSup,iPos+1)=&quot;()&quot; then
			&apos;parenthèses droite inutiles			
			sFormule=&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;}^{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+2,len(sFormule)-iPosNiveauSup(iPos)-2),false)+&quot;}&quot;
		else
			&apos;pas de parenthèses inutiles
			sFormule=&quot;{&quot;+TraitementFormule(left(sFormule,iPosNiveauSup(iPos)-1),bReduire)+&quot;}^{&quot;+TraitementFormule(mid(sFormule,iPosNiveauSup(iPos)+1),false)+&quot;}&quot;
		end if
	goto fin
	end if	

	&apos;racine carrée
	iPos=Instr(sNiveauSup,&quot;&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		if mid(sNiveauSup,iPos+1)=&quot;()&quot; then
		&apos;parenthèses inutiles
			iPosDebutArg=iPosNiveauSup(iPos)+2
			iPosFinArg=iPosNiveauSup(iPos+2)-1
			sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)

			&apos;sArg()=Arguments(mid(sFormule,iPosNiveauSup(iPos)+2,len(sFormule)-iPosNiveauSup(iPos)-2),2)
		else
			sArg()=Arguments(mid(sFormule,iPosNiveauSup(iPos)+1),2)
		end if
		if sArg(2)=&quot;&quot; then 
		&apos; racine carrée
			sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{sqrt{&quot;+TraitementFormule(sArg(1),bReduire)+&quot;}}&quot;
		else
			&apos; racine nième
			sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{nroot{&quot;+TraitementFormule(sArg(1),False)+&quot;}{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}}&quot;
		end if
		goto fin
	end if

	&apos;fonctions *********************************************************************************
	iPos=Instr(sNiveauSup,&quot;bar(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{overline{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;sou(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{underline{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;vec(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{widevec{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;ang(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{widehat{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;nor(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left ldline{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}right rdline}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;abs(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{abs{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;int(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),3)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{int from{&quot;+TraitementFormule(sArg(1),false)+&quot;}to{&quot;+TraitementFormule(sArg(2),false)+&quot;}{&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;uni(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),3)
		if sArg(2)&lt;&gt;&quot;&quot; then
			sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{{{size +9{{}union{}}} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}} csup {&quot;+TraitementFormule(sArg(2),false)+&quot;}{&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		else
			sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{{{size +9{{}union{}}} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		end if
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;ite(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),3)
		if sArg(2)&lt;&gt;&quot;&quot; then
			sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{{{size +9{{}intersection{}}} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}} csup {&quot;+TraitementFormule(sArg(2),false)+&quot;}{&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		else
			sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{{{size +9{{}intersection{}}} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		end if
		goto fin
	end if


	iPos=Instr(sNiveauSup,&quot;som(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),3)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{sum from{&quot;+TraitementFormule(sArg(1),false)+&quot;}to{&quot;+TraitementFormule(sArg(2),false)+&quot;}{&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if
	
	iPos=Instr(sNiveauSup,&quot;pro(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),3)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{prod from{&quot;+TraitementFormule(sArg(1),false)+&quot;}to{&quot;+TraitementFormule(sArg(2),false)+&quot;}{&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if
	
	iPos=Instr(sNiveauSup,&quot;acs(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{&quot;+TraitementFormule(sArg(1),bReduire)+&quot;}overbrace{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;aci(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{&quot;+TraitementFormule(sArg(1),bReduire)+&quot;}underbrace{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	&apos;accolades
	iPos=Instr(sNiveauSup,&quot;acc(&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left lbrace{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}right rbrace}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;til(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{widetilde{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;sys(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))

		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		&apos;sArg()=Arguments(mid(sFormule,iPosNiveauSup(iPos)+4,len(sFormule)-iPosNiveauSup(iPos)-4),10)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{alignl left lbrace stack{&quot;
		sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg(1),true)+&quot;}&quot;
		for n=2 to UBound(sArg())
			sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg(n),bReduire)+&quot;}&quot;
		next n
		sFormule=sFormule+&quot;} right none}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;cov(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{size -1{left( stack{&quot;
		sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg(1),true)+&quot;}&quot;
		for n=2 to UBound(sArg())
			sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg(n),bReduire)+&quot;}&quot;
		next n
		sFormule=sFormule+&quot;} right)}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;cnp(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left( stack{&quot;
		sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg(1),true)+&quot;}&quot;
		for n=2 to UBound(sArg())
			sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg(n),bReduire)+&quot;}&quot;
		next n
		sFormule=sFormule+&quot;} right)}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if
	
	iPos=Instr(sNiveauSup,&quot;emp(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{stack{&quot;
		sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg(1),true)+&quot;}&quot;
		for n=2 to UBound(sArg())
			sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg(n),bReduire)+&quot;}&quot;
		next n
		sFormule=sFormule+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;mat(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		iNbCol=val(sArg(1))
		if iNbCol=0 then
			MsgBox(&quot;Le premier argument doit être le nombre de colonnes !&quot;)
			stop
		end if
		if ((Ubound(sArg())-1) mod iNbCol)&lt;&gt;0 then
			MsgBox(&quot;Il manque des données.&quot;)
			stop
		end if
		iNbLig=(Ubound(sArg())-1)/iNbCol
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left( matrix{&quot;
		for i=1 to iNbLig
			sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg((i-1)*iNbCol+2),true)+&quot;}&quot;
			for j=2 to iNbCol
				sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg((i-1)*iNbCol+j+1),true)+&quot;}&quot;
			next j
			if i&lt;iNbLig then sFormule=sFormule+&quot;##&quot;
		next i
		sFormule=sFormule+&quot;} right)}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;tab(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		iNbCol=val(sArg(1))
		if iNbCol=0 then
			MsgBox(&quot;Le premier argument doit être le nombre de colonnes !&quot;)
			stop
		end if
		if ((Ubound(sArg())-1) mod iNbCol)&lt;&gt;0 then
			MsgBox(&quot;Il manque des données.&quot;)
			stop
		end if
		iNbLig=(Ubound(sArg())-1)/iNbCol
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{matrix{&quot;
		for i=1 to iNbLig
			sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg((i-1)*iNbCol+2),true)+&quot;}&quot;
			for j=2 to iNbCol
				sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg((i-1)*iNbCol+j+1),true)+&quot;}&quot;
			next j
			if i&lt;iNbLig then sFormule=sFormule+&quot;##&quot;
		next i
		sFormule=sFormule+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;tor(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		iNbCol=val(sArg(1))
		if iNbCol=0 then
			MsgBox(&quot;Le premier argument doit être le nombre de colonnes !&quot;)
			stop
		end if
		if ((Ubound(sArg())-1) mod iNbCol)&lt;&gt;0 then
			MsgBox(&quot;Il manque des données.&quot;)
			stop
		end if
		iNbLig=(Ubound(sArg())-1)/iNbCol
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left lbrace matrix{&quot;
		for i=1 to iNbLig
			sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg((i-1)*iNbCol+2),true)+&quot;}&quot;
			for j=2 to iNbCol
				sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg((i-1)*iNbCol+j+1),true)+&quot;}&quot;
			next j
			if i&lt;iNbLig then sFormule=sFormule+&quot;##&quot;
		next i
		sFormule=sFormule+&quot;} right rbrace}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if


	iPos=Instr(sNiveauSup,&quot;det(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		iNbCol=val(sArg(1))
		if iNbCol=0 then
			MsgBox(&quot;Le premier argument doit être le nombre de colonnes !&quot;)
			stop
		end if
		if ((Ubound(sArg())-1) mod iNbCol)&lt;&gt;0 then
			MsgBox(&quot;Il manque des données.&quot;)
			stop
		end if
		iNbLig=(Ubound(sArg())-1)/iNbCol
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{abs{matrix{&quot;
		for i=1 to iNbLig
			sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg((i-1)*iNbCol+2),true)+&quot;}&quot;
			for j=2 to iNbCol
				sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg((i-1)*iNbCol+j+1),true)+&quot;}&quot;
			next j
			if i&lt;iNbLig then sFormule=sFormule+&quot;##&quot;
		next i		
		sFormule=sFormule+&quot;}}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;equ(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		iNbCol=3
		if ((Ubound(sArg())) mod iNbCol)&lt;&gt;0 then
			MsgBox(&quot;Il manque des données.&quot;)
			stop
		end if
		iNbLig=(Ubound(sArg())-1)/iNbCol
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{matrix{&quot;
		for i=1 to iNbLig
			sFormule=sFormule+&quot;alignr{&quot;+TraitementFormule(sArg((i-1)*iNbCol+1),true)+&quot;}&quot;
			sFormule=sFormule+&quot; # alignc{&quot;+TraitementFormule(sArg((i-1)*iNbCol+2),true)+&quot;}&quot;
			sFormule=sFormule+&quot; # alignl{&quot;+TraitementFormule(sArg((i-1)*iNbCol+3),true)+&quot;}&quot;
			if i&lt;iNbLig then 
				sFormule=sFormule+&quot; ## &quot;
			end if
		next i		
		sFormule=sFormule+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if


	iPos=Instr(sNiveauSup,&quot;cro(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		iNbCol=val(sArg(1))
		if iNbCol=0 then
			MsgBox(&quot;Le premier argument doit être le nombre de colonnes !&quot;)
			stop
		end if
		if ((Ubound(sArg())-1) mod iNbCol)&lt;&gt;0 then
			MsgBox(&quot;Il manque des données.&quot;)
			stop
		end if
		iNbLig=(Ubound(sArg())-1)/iNbCol
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left[ matrix{&quot;
		for i=1 to iNbLig
			sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg((i-1)*iNbCol+2),true)+&quot;}&quot;
			for j=2 to iNbCol
				sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg((i-1)*iNbCol+j+1),true)+&quot;}&quot;
			next j
			if i&lt;iNbLig then sFormule=sFormule+&quot;##&quot;
		next i
		sFormule=sFormule+&quot;} right]}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if



	iPos=Instr(sNiveauSup,&quot;acd(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),0)
		
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{alignr left none stack{&quot;
		sFormule=sFormule+&quot;{&quot;+TraitementFormule(sArg(1),bReduire)+&quot;}&quot;
		for n=2 to UBound(sArg())
			sFormule=sFormule+&quot;#{&quot;+TraitementFormule(sArg(n),bReduire)+&quot;}&quot;
		next n
		sFormule=sFormule+&quot;} right rbrace}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;lim(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),3)
		
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{lim from{&quot;
		if sArg(3)=&quot;&quot; then
			sFormule=sFormule+TraitementFormule(sArg(1),false)+&quot;}{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		else
			sFormule=sFormule+&quot;binom{&quot;+TraitementFormule(sArg(1),false)+&quot;}{&quot;+TraitementFormule(sArg(2),false)+&quot;}}{&quot;+TraitementFormule(sArg(3),bReduire)+&quot;}}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		end if
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;inf(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{&quot;&quot;inf&quot;&quot;} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;sup(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{&quot;&quot;sup&quot;&quot;} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;max(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{&quot;&quot;max&quot;&quot;} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	iPos=Instr(sNiveauSup,&quot;min(&quot;)
	if iPos&gt;0 then
		iPosDebutArg=iPosNiveauSup(iPos)+4
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		iPosFinArg=iPosNiveauSup(iPos+4)-1
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+4))
		sArg()=Arguments(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),2)
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{&quot;&quot;min&quot;&quot;} csub {&quot;+TraitementFormule(sArg(1),false)+&quot;}{&quot;+TraitementFormule(sArg(2),bReduire)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if
	
	
	&apos;crochets
	iPos=Instr(sNiveauSup,&quot;[]&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+1))
		iPosDebutArg=iPosNiveauSup(iPos)+1
		iPosFinArg=iPosNiveauSup(iPos+1)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{left&quot;+mid(sFormule,iPosNiveauSup(iPos),1)+&quot;{&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;}right&quot;+mid(sFormule,iPosNiveauSup(iPos+1),1)+&quot;}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if

	
	&apos;parenthèses
	iPos=Instr(sNiveauSup,&quot;()&quot;)
	if iPos&gt;0 then
		sFormuleGauche=left(sFormule,iPosNiveauSup(iPos)-1)
		sFormuleDroite=right(sFormule,len(sFormule)-iPosNiveauSup(iPos+1))
		iPosDebutArg=iPosNiveauSup(iPos)+1
		iPosFinArg=iPosNiveauSup(iPos+1)-1
		sFormule=TraitementFormule(sFormuleGauche,bReduire)+&quot;{(&quot;+TraitementFormule(mid(sFormule,iPosDebutArg,iPosFinArg-iPosDebutArg+1),bReduire)+&quot;)}&quot;+TraitementFormule(sFormuleDroite,bReduire)
		goto fin
	end if
	
	fin:
	TraitementFormule=sFormule
end Function

&apos;--------------------------------------------------------------------------------------
Function SelectionnerFormule(oTextCursor as Object,iNbCarac as integer) as String
&apos; si iNbCarac=0, sélectionner jusqu&apos;à un espace ou équivalent
&apos; sinon, sélectionner iNbCarac caractères
	dim sTexteFormule as string,sFormuleExtraite as string
	dim i as integer
	dim oTempCursor as object, oObjets as object, oFormule as object
	dim sEnum() as string
	
	sTexteFormule=&quot;&quot;
	If oTextCursor.IsCollapsed() then
		if iNbCarac=0 then
			oTextCursor.goLeft(1,True)
			do while not DebutFormule(oTextCursor)
				oTextCursor.goLeft(1,True)
			loop
		else
			oTextCursor.goLeft(iNbCarac,True)
		end if
	end if
	&apos; parcours du texte sélectionné à la recherche de formules
	oTempCursor=oTextCursor.Text.CreateTextCursorByRange(oTextCursor.getEnd())
	do while oTextCursor.Text.compareRegionStarts(oTempCursor,oTextCursor)&lt;0
		oTempCursor.goLeft(0,False)
		oTempCursor.goLeft(1,True)
		if oTempCursor.getString()&lt;&gt;&quot;&quot; then
			&apos; c&apos;est du texte
			sTexteFormule=oTempCursor.getString()+sTexteFormule
		else
			sEnum=oTempCursor.getAvailableServiceNames
			oObjets=oTempCursor.createContentEnumeration(sEnum(0))
			if oObjets.HasMoreElements then
				oFormule=oObjets.NextElement
				if oFormule.getImplementationName=&quot;SwXTextEmbeddedObject&quot; then
					if oFormule.embeddedObject.getImplementationName=&quot;com.sun.star.comp.math.FormulaDocument&quot; then
	  		       		&apos;c&apos;est une formule
	   	    	   		sFormuleExtraite=oFormule.embeddedobject.Formula
	   	       			if right(sFormuleExtraite,2)=&quot;{}&quot; then
	   	       				&apos; c&apos;est une insertion telle que {}times{} etc...
							sTexteFormule=&quot;**&quot;+mid(sFormuleExtraite,3,len(sFormuleExtraite)-4)+&quot;**&quot;+sTexteFormule
						else
							&apos; c&apos;est une formule
							sTexteFormule=&quot;{&quot;+sFormuleExtraite+&quot;}&quot;+sTexteFormule
						end if
					endif
				endif
			endif
	
		end if
	loop
	SelectionnerFormule=sTexteFormule
end Function

&apos;--------------------------------------------------------------------------------------
Function DebutFormule(oTextCursor as Object) as boolean
&apos;repère le début de la formule

	dim sCarac as string
	dim iAsc as integer
	
	sCarac=left(oTextCursor.getstring(),1)
	iAsc=asc(sCarac+&quot; &quot;)
	&apos; si espace ou tabulation ou début de phrase alors le début est trouvé
	if (sCarac=&quot; &quot;) or (iAsc=9) or (iAsc=10) then
		oTextCursor.goRight(1,True)
		DebutFormule=True
	else if (oTextCursor.isStartOfSentence()=True) then
			DebutFormule=True
		else
			DebutFormule=False
		end if
	end if
end function
	
&apos;--------------------------------------------------------------------------------------
Sub InsereFormule(oViewCursor as Object, oTextCursor as Object, sPolice as String, iTaille as Integer, sFormule as String, bModeTexte as boolean)
&apos;ancien OOo115
	dim obj as object
	obj=ThisComponent.CreateInstance(&quot;com.sun.star.text.TextEmbeddedObject&quot;)
	obj.CLSID=&quot;078B7ABA-54FC-457F-8551-6147e776a997&quot;
    obj.AnchorType=com.sun.star.text.TextContentAnchorType.AS_CHARACTER
	ThisComponent.getCurrentController().select(oTextCursor)
    oTextCursor.Text.insertTextContent(oTextCursor, obj, true)        
  	obj.EmbeddedObject.BaseFontHeight=iTaille
  	obj.EmbeddedObject.FontNameVariables=sPolice
  	obj.EmbeddedObject.FontVariablesIsItalic=true
   	obj.EmbeddedObject.FontNameNumbers=sPolice
   	obj.EmbeddedObject.CustomFontNameSerif=&quot;Cmathcal&quot;
  	obj.EmbeddedObject.FontNameText=sPolice
  	obj.EmbeddedObject.FontNameFunctions=sPolice
  	obj.EmbeddedObject.IsScaleAllBrackets=True
  	obj.EmbeddedObject.RelativeIndexSubscript=0
  	obj.EmbeddedObject.RelativeIndexSuperscript=0  	
&apos;   	obj.EmbeddedObject.LeftMargin=20
&apos; 	obj.EmbeddedObject.RightMargin=20
  	obj.EmbeddedObject.IsTextMode=bModeTexte
  	obj.EmbeddedObject.formula=sFormule
  	obj.EmbeddedObject.setmodified(TRUE)
   	obj.LeftMargin=0
  	obj.RightMargin=0
  	oViewCursor.goLeft(1,False)
  	oViewCursor.goRight(1,False)

&apos;--------------------------------
&apos;    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
&apos;    oViewCursor.Charheight=12
&apos;    oViewCursor.Text.insertString(oViewCursor, sFormule, FALSE)

&apos;avec dispatcher :
&apos;	dim dispatcher as object, obj as object, document as object
&apos;	ThisComponent.lockControllers

&apos;	oTextCursor.Text.insertString(oTextCursor, sFormule, true)
&apos;	oViewCursor.gotoRange(oTextCursor,true)

&apos;    document   = ThisComponent.CurrentController.Frame
&apos;    dim Array(0) as new com.sun.star.beans.PropertyValue
&apos;    dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
&apos;    dispatcher.executeDispatch(document, &quot;.uno:InsertObjectStarMath&quot;, &quot;&quot;, 0,Array())
&apos;  	ThisComponent.unlockControllers
&apos;  	obj=ThisComponent.getCurrentSelection()
&apos;  	obj.EmbeddedObject.FontNameVariables=sPolice
&apos;  	obj.EmbeddedObject.FontVariablesIsItalic=true
&apos;   	obj.EmbeddedObject.FontNameNumbers=sPolice
&apos;  	obj.EmbeddedObject.FontNameText=sPolice
&apos;  	obj.EmbeddedObject.FontNameFunctions=sPolice
 &apos; 	obj.EmbeddedObject.BaseFontHeight=iTaille
&apos;  	obj.EmbeddedObject.IsScaleAllBrackets=True
&apos;  	obj.EmbeddedObject.RelativeIndexSubscript=0
&apos;  	obj.EmbeddedObject.RelativeIndexSuperscript=0  	
&apos;  	obj.EmbeddedObject.IsTextMode=bModeTexte
&apos;  	obj.EmbeddedObject.setmodified(TRUE)
&apos;   	obj.LeftMargin=0
&apos;  	obj.RightMargin=0
&apos;    dispatcher.executeDispatch(document, &quot;.uno:Escape&quot;, &quot;&quot;, 0, Array())
&apos;    dispatcher.executeDispatch(document, &quot;.uno:ResetAttributes&quot;, &quot;&quot;, 0, Array())

&apos;	oViewCursor.gotoRange(oTextCursor,false)

&apos;  	oViewCursor.goLeft(1,False)
 &apos;	oViewCursor.goRight(1,False)

end sub


&apos;--------------------------------------------------------------------------------------
function Arguments(sFormule as String, iNbArg as Integer) as Variant
&apos; renvoie un tableau contenant les arguments de la fonction
&apos; si iNbArg=0, on ne sait pas à l&apos;avance le nb d&apos;arguments (ex : matrice, ...)
&apos; sinon, on lit iNbArg arguments

	dim iPos as integer, iCompteurArg as integer, iNiveauPar as integer
	dim sCaractere as string
	dim sArguments(iNbArg) as String
	
	iCompteurArg=1
	iPos=1
	iNiveauPar=0
	Do While iPos&lt;=len(sFormule)
		Do While iPos&lt;=len(sFormule) AND Mid(sFormule,iPos,1)&lt;&gt;&quot;;&quot;	
			&apos;si on dépasse cNbArgMax, redimensionner
			if UBound(sArguments())&lt;iCompteurArg then
				&apos;j&apos;en remets 10 de plus
				redim preserve sArguments(iCompteurArg+10) as String
			end if
			sCaractere=Mid(sFormule,iPos,1)
			sArguments(iCompteurArg)=sArguments(iCompteurArg) + sCaractere
			Select Case sCaractere
			Case &quot;(&quot;
				iNiveauPar=iNiveauPar+1
				do while iNiveauPar&gt;0
					iPos=iPos+1
					if iPos&gt;len(sFormule) then
						msgbox(&quot;Erreur de parenthèses !&quot;)
						stop
					end if
					sCaractere=Mid(sFormule,iPos,1)				
					sArguments(iCompteurArg)=sArguments(iCompteurArg) + sCaractere
					if sCaractere=&quot;(&quot; then
						iNiveauPar=iNiveauPar+1
					end if
					if sCaractere=&quot;)&quot; then
						iNiveauPar=iNiveauPar-1
					end if
				loop
			Case &quot;{&quot;	&apos;prévoir {}
				iNiveauPar=iNiveauPar+1
				do while iNiveauPar&gt;0
					iPos=iPos+1
					if iPos&gt;len(sFormule) then
						msgbox(&quot;Erreur d&apos;accolades !&quot;)
						stop
					end if
					sCaractere=Mid(sFormule,iPos,1)				
					sArguments(iCompteurArg)=sArguments(iCompteurArg) + sCaractere
					if sCaractere=&quot;{&quot; then
						iNiveauPar=iNiveauPar+1
					end if
					if sCaractere=&quot;}&quot; then
						iNiveauPar=iNiveauPar-1
					end if
				loop
			Case &quot;[&quot;,&quot;]&quot;
				iNiveauPar=iNiveauPar+1
				do while iNiveauPar&gt;0
					iPos=iPos+1
					if iPos&gt;len(sFormule) then
						msgbox(&quot;Erreur de crochets !&quot;)
						stop
					end if
					sCaractere=Mid(sFormule,iPos,1)				
					sArguments(iCompteurArg)=sArguments(iCompteurArg) + sCaractere
					if sCaractere=&quot;[&quot; or sCaractere=&quot;]&quot; then
						iNiveauPar=iNiveauPar-1
					end if
				loop
			Case chr(34)
				iNiveauPar=iNiveauPar+1
				do while iNiveauPar&gt;0
					iPos=iPos+1
					if iPos&gt;len(sFormule) then
						msgbox(&quot;Erreur de guillemets !&quot;)
						stop
					end if
					sCaractere=Mid(sFormule,iPos,1)				
					sArguments(iCompteurArg)=sArguments(iCompteurArg) + sCaractere
					if sCaractere=chr(34) then
						iNiveauPar=iNiveauPar-1
					end if
				loop
			end select
			iPos=iPos+1
		loop
		if iPos&lt;=len(sFormule) then
			iPos=iPos+1
		end if
		iCompteurArg=iCompteurArg+1
	loop
	if iNbArg=0 then
		&apos; la tableau sArguments aura une taille égale au nombre de d&apos;arguments
		redim preserve sArguments(iCompteurArg-1) as String
	end if
	Arguments=sArguments()
end function

&apos;--------------------------------------------------------------------------------------
sub InsereExpressionCmathOOo
&apos; 	parcours les 3 caractères précédents le curseur à la recherche d&apos;une insertion
&apos; 	convention : 
&apos; 	les formules sont encadrées de {}
&apos;	les insertions &quot;autotextes&quot; (F3) sont encadrées de $$
&apos;	les autres caractères sont insérés dans le texte sans formatage

	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, sSymbole as string, sSymbolePrecedent as string
	dim iTaille as integer, i as integer, j as integer, k as integer, iNiveauAcc as integer
	dim sExpression(1 to 3) as string, iNbCarac(1 to 3) as integer
	
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
    sSymbolePrecedent=&quot;&quot;
    j=1

    For i =1 to 3
		oViewCursor.goLeft(1,True)
		oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
		sSymbole=oTextCursor.getString()
		if sSymbole=sSymbolePrecedent or sSymbole=&quot; &quot;&amp;sSymbolePrecedent then
			exit for
		end if
		sExpression(j)=sSubstitutionF8(sSymbole)
		if sExpression(j)&lt;&gt;&quot;&quot; then 
			iNbCarac(j)=i
			j=j+1
		end if
		sSymbolePrecedent=sSymbole
	Next i
	oTextCursor.collapseToEnd
&apos;	j-1 donne le nb de cas.
	Select Case j
	Case 2
		&apos; pas d&apos;ambiguïté
		oTextCursor.goLeft(iNbCarac(1),True)
		j=1
	Case 1
		&apos; rien trouvé
		oViewCursor.collapseToEnd
		Msgbox(&quot;Aucune insertion trouvée !&quot;)
		exit sub
	Case Else
		&apos; choix par boîte de dialogue
		dim oDlg as Object, oList as Object
		DialogLibraries.LoadLibrary(&quot;CmathOOo&quot;)
		oDlg = CreateUnoDialog( DialogLibraries.CmathOOo.DialogChoixInsertionF8)
		oList=oDlg.GetControl(&quot;ListBox1&quot;)
		for i=1 to j-1
			&apos;oList.Model.StringItemList()=Array(sExpression(1),sExpression(2))
			oList.addItem(right(sSymbole,iNbcarac(i))&amp;&quot; : &quot;&amp;sExpression(i),i)
		next i
		oList.selectItemPos(0,true)
		oDlg.Execute
		j=oList.SelectedItemPos+1
		oDlg.Dispose
		oTextCursor.goLeft(iNbCarac(j),True)
	End Select
	&apos;effacer la selection
	oTextCursor.String=&quot;&quot;
	oViewCursor.collapseToEnd
	&apos; arrivé ici, sExpression(j) contient l&apos;expression à insérer
	for i=1 to len(sExpression(j))
		sSymbole=mid(sExpression(j),i,1)
		Select Case sSymbole
		Case &quot;{&quot;
			&apos; formule
			k=i
			&apos; rechercher la formule
			iNiveauAcc=1
			do while iNiveauAcc&gt;0
					k=k+1
					if k&gt;len(sExpression(j)) then
						msgbox(&quot;Erreur d&apos;accolades !&quot;)
						stop
					end if
					sSymbole=Mid(sExpression(j),k,1)				
					if sSymbole=&quot;{&quot; then
						iNiveauAcc=iNiveauAcc+1
					end if
					if sSymbole=&quot;}&quot; then
						iNiveauAcc=iNiveauAcc-1
					end if
			loop
			InsereFormule(oViewCursor,oTextCursor, sPolice, iTaille, mid(sExpression(j),i+1,k-i-1),False)
			i=k
		Case &quot;$&quot;
			&apos; rechercher l&apos;autotexte
			k=instr(mid(sExpression(j),i+1),&quot;$&quot;)						
			if k&gt;0 then
				dim oAutoTextContainer as object, oGroup as object, oEntry as object
				oAutoTextContainer = createUnoService(&quot;com.sun.star.text.AutoTextContainer&quot;)
				on Error GoTo AutoTextErreur
				oGroup = oAutoTextContainer.getByName(&quot;CmathOOo&quot;)
				oEntry = oGroup.getByName(mid(sExpression(j),i+1,k-1))
				oEntry.applyTo(oTextCursor)
&apos;				oTextCursor.goRight(1,True)
				AutoTextErreur:
				i=i+k+1
			end if	
			&apos;dim Array(0) as new com.sun.star.beans.PropertyValue 
			&apos;dispatcher.executeDispatch(oFrame, &quot;.uno:ExpandGlossary&quot;, &quot;&quot;, 0, Array())
			rem dispatcher.executeDispatch(oFrame, &amp;quot;.uno:ResetAttributes&amp;quot;, &amp;quot;&amp;quot;, 0, Array())
			rem    ligne précédente en commentaire pour éviter le formattage du paragraphe
			rem    dans le style par défaut, dont l&amp;apos;alignement...
			
		Case Else
			&apos; texte
			oTextCursor.Text.insertString(oTextCursor, sSymbole, FALSE)
		end select 
	next i
&apos;	oViewCursor.gotoRange(oTextCursor.end)
end sub

sub End_DialogChoixInsertionF8(Evenement as Object)
	dim code as integer
	code=Evenement.KeyCode
	if code=com.sun.star.awt.Key.RETURN or code=com.sun.star.awt.Key.SPACE then
		Evenement.Source.Context.EndExecute
	end if
end sub

function sSubstitutionF8(sSymbole as string) as string
	Select Case len(sSymbole)
	Case 1
		Select Case sSymbole
		Case &quot;N&quot;
			sSubstitutionF8=&quot;{SetN}&quot;
		Case &quot;R&quot;
			sSubstitutionF8=&quot;{SetR}&quot;
		Case &quot;Z&quot;
			sSubstitutionF8=&quot;{SetZ}&quot;
		Case &quot;C&quot;
			sSubstitutionF8=&quot;{SetC}&quot;
		Case &quot;Q&quot;
			sSubstitutionF8=&quot;{SetQ}&quot;
		Case &quot;l&quot;
			sSubstitutionF8=&quot;{font serif nitalic size +2{l}}&quot;
		Case &quot;d&quot;
			sSubstitutionF8=&quot;{nitalic d}&quot;
		Case &quot;D&quot;
			sSubstitutionF8=&quot;{nitalic bold D}&quot;

		Case Else
			sSubstitutionF8=&quot;&quot;
		End Select

	Case 2
		Select Case sSymbole
		Case &quot;AL&quot;
			sSubstitutionF8=&quot;{%ALPHA}}&quot;
		Case &quot;al&quot;
			sSubstitutionF8=&quot;{%alpha}&quot;
		Case &quot;BE&quot;
			sSubstitutionF8=&quot;{%BÊTA}&quot;
		Case &quot;be&quot;
			sSubstitutionF8=&quot;{%bêta}&quot;
		Case &quot;KH&quot;
			sSubstitutionF8=&quot;{%KHI}&quot;
		Case &quot;kh&quot;
			sSubstitutionF8=&quot;{%khi}&quot;
		Case &quot;DE&quot;
			sSubstitutionF8=&quot;{%DELTA}&quot;
		Case &quot;de&quot;
			sSubstitutionF8=&quot;{%delta}&quot;
		Case &quot;EP&quot;
			sSubstitutionF8=&quot;{%EPSILON}&quot;
		Case &quot;ep&quot;
			sSubstitutionF8=&quot;{%varepsilon}&quot;
		Case &quot;ET&quot;
			sSubstitutionF8=&quot;{%ÊTA}&quot;
		Case &quot;et&quot;
			sSubstitutionF8=&quot;{%êta}&quot;
		Case &quot;GA&quot;
			sSubstitutionF8=&quot;{%GAMMA}&quot;
		Case &quot;ga&quot;
			sSubstitutionF8=&quot;{%gamma}&quot;
		Case &quot;IO&quot;
			sSubstitutionF8=&quot;{%IOTA}&quot;
		Case &quot;io&quot;
			sSubstitutionF8=&quot;{%iota}&quot;
		Case &quot;KA&quot;
			sSubstitutionF8=&quot;{%KAPPA}&quot;
		Case &quot;ka&quot;
			sSubstitutionF8=&quot;{%kappa}&quot;
		Case &quot;LA&quot;
			sSubstitutionF8=&quot;{%LAMBDA}&quot;
		Case &quot;la&quot;
			sSubstitutionF8=&quot;{%lambda}&quot;
		Case &quot;MU&quot;
			sSubstitutionF8=&quot;{%MU}&quot;
		Case &quot;mu&quot;
			sSubstitutionF8=&quot;{%mu}&quot;
		Case &quot;NU&quot;
			sSubstitutionF8=&quot;{%NU}&quot;
		Case &quot;nu&quot;
			sSubstitutionF8=&quot;{%nu}&quot;
		Case &quot;OM&quot;
			sSubstitutionF8=&quot;{%OMÉGA}&quot;
		Case &quot;om&quot;
			sSubstitutionF8=&quot;{%oméga}&quot;
		Case &quot;PH&quot;
			sSubstitutionF8=&quot;{%PHI}&quot;
		Case &quot;ph&quot;
			sSubstitutionF8=&quot;{%varphi}&quot;
		Case &quot;PI&quot;
			sSubstitutionF8=&quot;{%PI}&quot;
		Case &quot;pi&quot;
			sSubstitutionF8=&quot;{%pi}&quot;
		Case &quot;PS&quot;
			sSubstitutionF8=&quot;{%PSI}&quot;
		Case &quot;ps&quot;
			sSubstitutionF8=&quot;{%psi}&quot;
		Case &quot;RH&quot;
			sSubstitutionF8=&quot;{%RHÔ}&quot;
		Case &quot;rh&quot;
			sSubstitutionF8=&quot;{%rhô}&quot;
		Case &quot;SI&quot;
			sSubstitutionF8=&quot;{%SIGMA}&quot;
		Case &quot;si&quot;
			sSubstitutionF8=&quot;{%sigma}&quot;
		Case &quot;TA&quot;
			sSubstitutionF8=&quot;{%TAU}&quot;
		Case &quot;ta&quot;
			sSubstitutionF8=&quot;{%tau}&quot;
		Case &quot;TH&quot;
			sSubstitutionF8=&quot;{%THÊTA}&quot;
		Case &quot;th&quot;
			sSubstitutionF8=&quot;{%thêta}&quot;
		Case &quot;UP&quot;
			sSubstitutionF8=&quot;{%UPSILON}&quot;
		Case &quot;up&quot;
			sSubstitutionF8=&quot;{%upsilon}&quot;
		Case &quot;XI&quot;
			sSubstitutionF8=&quot;{%XI}&quot;
		Case &quot;xi&quot;
			sSubstitutionF8=&quot;{%xi}&quot;
		Case &quot;ZE&quot;
			sSubstitutionF8=&quot;{%ZÊTA}&quot;
		Case &quot;ze&quot;
			sSubstitutionF8=&quot;{%zêta}&quot;
		Case &quot;ap&quot;
			sSubstitutionF8=&quot;{{}in{}}&quot;
		Case &quot;ex&quot;
			sSubstitutionF8=&quot;{ exists }&quot;
		Case &quot;qs&quot;
			sSubstitutionF8=&quot;{ forall }&quot;
		Case &quot;un&quot;
			sSubstitutionF8=&quot;{{}union{}}&quot;
		Case &quot;it&quot;
			sSubstitutionF8=&quot;{{}intersection{}}&quot;
		Case &quot;ro&quot;
			sSubstitutionF8=&quot;{{}circ{}}&quot;
		Case &quot;di&quot;
			sSubstitutionF8=&quot;{{}div{}}&quot;
		Case &quot;en&quot;
			sSubstitutionF8=&quot;{{}approx{}}&quot;
		Case &quot;eq&quot;
			sSubstitutionF8=&quot;{{}sim{}}&quot;
		Case &quot;co&quot;
			sSubstitutionF8=&quot;{{}equiv{}}&quot;
		Case &quot;fo&quot;
			sSubstitutionF8=&quot;{{}times{}}&quot;
		Case &quot;pp&quot;
			sSubstitutionF8=&quot;{{}or{}}&quot;
		Case &quot;pg&quot;,&quot;ve&quot;
			sSubstitutionF8=&quot;{{}and{}}&quot;
		Case &quot;pe&quot;
			sSubstitutionF8=&quot;{{}ortho{}}&quot;
		Case &quot;sd&quot;
			sSubstitutionF8=&quot;{{}oplus{}}&quot;
		Case &quot;np&quot;
			sSubstitutionF8=&quot;{{}notin{}}&quot;
		Case &quot;im&quot;
			sSubstitutionF8=&quot;{{}drarrow{}}&quot;
		Case &quot;ev&quot;
			sSubstitutionF8=&quot;{{}dlrarrow{}}&quot;
		Case &quot;rc&quot;
			sSubstitutionF8=&quot;{{}dlarrow{}}&quot;
		Case &quot;ic&quot;
			sSubstitutionF8=&quot;{{}subset{}}&quot;
		Case &quot;ni&quot;
			sSubstitutionF8=&quot;{{}nsubset{}}&quot;
		Case &quot;vi&quot;
			sSubstitutionF8=&quot;{emptyset}&quot;
		Case &quot;in&quot;
			sSubstitutionF8=&quot;{infinity}&quot;
		Case &quot;na&quot;
			sSubstitutionF8=&quot;{nabla}&quot;
		Case &quot;dr&quot;
			sSubstitutionF8=&quot;{partial}&quot;
		Case &quot;dx&quot;
			sSubstitutionF8=&quot;{nitalic d}x&quot;
		Case &quot;dy&quot;
			sSubstitutionF8=&quot;{nitalic d}y&quot;
		Case &quot;dz&quot;
			sSubstitutionF8=&quot;{nitalic d}z&quot;
		Case &quot;dt&quot;
			sSubstitutionF8=&quot;{nitalic d}t&quot;
		Case &quot;Rm&quot;
			sSubstitutionF8=&quot;{setR^{{}-{}}}&quot;
		Case &quot;Rp&quot;
			sSubstitutionF8=&quot;{setR^&quot;&quot;+&quot;&quot;}&quot;
		Case &quot;Re&quot;
			sSubstitutionF8=&quot;{setR^&quot;&quot;*&quot;&quot;}&quot;
		Case &quot;Ne&quot;
			sSubstitutionF8=&quot;{SetN^&quot;&quot;*&quot;&quot;}&quot;
		Case &quot;cf&quot;
			sSubstitutionF8=&quot;$cf$&quot;
		Case &quot;cg&quot;
			sSubstitutionF8=&quot;$cg$&quot;
		Case &quot;df&quot;
			sSubstitutionF8=&quot;$df$&quot;
		Case &quot;dg&quot;
			sSubstitutionF8=&quot;$dg$&quot;
		Case &quot;mq&quot;
			sSubstitutionF8=&quot;Montrer que&quot;
		Case Else
			sSubstitutionF8=&quot;&quot;
		End Select
	Case 3
		Select Case sSymbole
		Case &quot;Rpe&quot;
			sSubstitutionF8=&quot;{setR_&quot;&quot;+&quot;&quot;^&quot;&quot;*&quot;&quot;}&quot;
		Case &quot;Rme&quot;
			sSubstitutionF8=&quot;{setR_{{}-{}}^&quot;&quot;*&quot;&quot;}&quot;
		Case &quot;oij&quot;
			sSubstitutionF8=&quot;{(O&quot;&quot;;&quot;&quot;{vec{i}}&quot;&quot;;&quot;&quot;{vec{j}})}&quot;
		Case &quot;ijk&quot;
			sSubstitutionF8=&quot;{(O&quot;&quot;;&quot;&quot;{vec{i}}&quot;&quot;;&quot;&quot;{vec{j}}&quot;&quot;;&quot;&quot;{vec{k}})}&quot;
		Case &quot;ouv&quot;
			sSubstitutionF8=&quot;{(O&quot;&quot;;&quot;&quot;{vec{u}}&quot;&quot;;&quot;&quot;{vec{v}})}&quot;
		Case &quot;dth&quot;
			sSubstitutionF8=&quot;{nitalic d %thêta}&quot;
		Case &quot;xar&quot;
			sSubstitutionF8=&quot;{x in Setr}&quot;
		Case &quot;nan&quot;
			sSubstitutionF8=&quot;{n in Setn}&quot;
		Case &quot;zac&quot;
			sSubstitutionF8=&quot;{z in Setc}&quot;
		Case &quot;ron&quot;
			sSubstitutionF8=&quot;repère orthonormé {(O&quot;&quot;;&quot;&quot;{vec{i}}&quot;&quot;;&quot;&quot;{vec{j}})}&quot;
		Case &quot;cal&quot;
			sSubstitutionF8=&quot;calculatrice&quot;
		Case &quot;gra&quot;
			sSubstitutionF8=&quot;représentation graphique&quot;
		Case &quot;cou&quot;
			sSubstitutionF8=&quot;courbe représentative de la fonction {f}&quot;
		Case &quot;pol&quot;
			sSubstitutionF8=&quot;polynôme&quot;
		Case &quot;bar&quot;
			sSubstitutionF8=&quot;barycentre&quot;
		Case &quot;ba2&quot;
			sSubstitutionF8=&quot;barycentre de acc((,);(,))&quot;
		Case &quot;ba3&quot;
			sSubstitutionF8=&quot;barycentre de acc((,);(,);(,))&quot;
		Case &quot;coo&quot;
			sSubstitutionF8=&quot;coordonnées&quot;
		Case &quot;ord&quot;
			sSubstitutionF8=&quot;ordonnées&quot;
		Case &quot;abs&quot;
			sSubstitutionF8=&quot;abscisses&quot;
		Case &quot;soi&quot;
			sSubstitutionF8=&quot;Soit {f} la fonction définie sur&quot;
		Case &quot;mat&quot;
			sSubstitutionF8=&quot;mathématiques&quot;
		Case &quot;par&quot;
			sSubstitutionF8=&quot;parallélogramme&quot;
		Case &quot;col&quot;
			sSubstitutionF8=&quot;colinéaires&quot;
		Case &quot;asy&quot;
			sSubstitutionF8=&quot;asymptote&quot;
		Case &quot;sun&quot;
			sSubstitutionF8=&quot;{(u_n)_{n in setn}}&quot;
		Case &quot;svn&quot;
			sSubstitutionF8=&quot;{(v_n)_{n in setn}}&quot;
		Case &quot;tv1&quot;
			sSubstitutionF8=&quot;$tabvar1$&quot;
		Case &quot;tv2&quot;
			sSubstitutionF8=&quot;$tabvar2$&quot;
		Case &quot;tv3&quot;
			sSubstitutionF8=&quot;$tabvar3$&quot;
		Case &quot;tv4&quot;
			sSubstitutionF8=&quot;$tabvar4$&quot;
		Case &quot;ts1&quot;
			sSubstitutionF8=&quot;$tabsig1$&quot;
		Case &quot;ts2&quot;
			sSubstitutionF8=&quot;$tabsig2$&quot;
		Case &quot;ts3&quot;
			sSubstitutionF8=&quot;$tabsig3$&quot;
		Case &quot;ts4&quot;
			sSubstitutionF8=&quot;$tabsig4$&quot;
		Case Else
			sSubstitutionF8=&quot;&quot;
		End Select
	End Select
end function


&apos;--------------------------------------------------------------------------------------
sub InsereFormuleF3
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, sSymbole as string, sFormule as string
	dim iTaille as integer
    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
	oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
    sPolice=oViewCursor.CharFontName
    iTaille=oViewCursor.Charheight
	&apos;aller chercher le caractère $
	oTextCursor.goLeft(1,True)
	&apos; effacer le saut de ligne
	if asc(oTextCursor.getstring())=13 then oTextCursor.SetString(&quot;&quot;)
	do while left(oTextCursor.getstring(),1)&lt;&gt;&quot;$&quot;
		oTextCursor.goLeft(1,True)
	loop
	sFormule=mid(oTextCursor.getString(),2)
	InsereFormule(oViewCursor,oTextCursor, sPolice, iTaille, sFormule,False)
end sub


&apos;--------------------------------------------------------------------------------------
Sub AffecteFormule
	dim oLaFormule as object, oDialogPoliceFormules as object, oPgb as object, oLesObjets as object
	dim oViewCursor as object, oTextCursor as object
	dim sPolice as string, sSymbole as string, sMonEnum() as string, sTexteFormule as string
	dim iTaille as integer, iNombreMax as integer, iCas as integer, i as integer, compte as integer
	
	oLaFormule=ThisComponent.getCurrentSelection()
	if oLaFormule.getImplementationName = &quot;SwXTextEmbeddedObject&quot; then
		sPolice=oLaFormule.embeddedobject.FontNameVariables
		iTaille=oLaFormule.EmbeddedObject.BaseFontHeight
	else
	    oViewCursor = ThisComponent.getCurrentController().getViewCursor()
		oTextCursor=oViewCursor.Text.createTextCursorByRange(oViewCursor)
		sPolice=oTextCursor.CharFontName
		iTaille=oTextCursor.CharHeight
	end if
	DialogLibraries.LoadLibrary(&quot;CmathOOo&quot;)
	oDialogPoliceFormules = CreateUnoDialog( DialogLibraries.CmathOOo.DialogPoliceFormules)
	oDialogPoliceFormules.Model.TextFieldPolice.Text=sPolice
	oDialogPoliceFormules.Model.TextFieldTaille.Text=iTaille
	oDialogPoliceFormules.Execute()
	iTaille=val(oDialogPoliceFormules.Model.TextFieldTaille.Text)
	sPolice=oDialogPoliceFormules.Model.TextFieldPolice.Text
	oDialogPoliceFormules.Dispose
	if IsNumeric(iTaille) then
		if IsNull(oLaFormule) then
			Message=&quot;Le redimensionnement ne fonctionne pas sur un nouveau document&quot;+chr(10)
			message=message+&quot;Veuillez enregistrer, quitter et réouvrir votre document&quot;+chr(10)
			message=message+chr(10)+&quot;Désolé&quot;
			msgbox message,64,&quot;problème ...&quot;
			exit sub
		endif
		if oLaFormule.getImplementationName = &quot;SwXTextEmbeddedObject&quot; then
		&apos;	un objet seul est selectionné
			iCas=1
		else
			if thiscomponent.getcurrentcontroller.viewcursor.iscollapsed then
				iCas=2 &apos;rien selectionné --&amp;gt; on applique àtout
				oLaFormule=Thiscomponent
			else
				iCas=3 &apos;portion sélectionnée
				oLaFormule=oLaFormule.getbyIndex(0)
				sMonEnum=oLaFormule.getAvailableServiceNames
				oLesObjets=oLaFormule.createContentEnumeration(sMonEnum(0))
			endif
			&apos;mise en place barre de progression
			iNombreMax=Thiscomponent.drawpage.count
			oPgb=Thiscomponent.currentcontroller.statusIndicator
			oPgb.Start (&quot;Redimensionement en cours ...&quot;,iNombreMax)
			oPgb.value=0
		endif
		
		select case iCas
		
			case 1:
				if oLaFormule.embeddedObject.getImplementationName=&quot;com.sun.star.comp.math.FormulaDocument&quot; then 
					sTexteFormule=oLaFormule.embeddedobject.formula
					oLaFormule.embeddedobject.formula=&quot;&quot;
					oLaFormule.embeddedobject.BaseFontHeight=iTaille
				  	oLaFormule.EmbeddedObject.FontNameVariables=sPolice
				  	oLaFormule.EmbeddedObject.FontVariablesIsItalic=true
				   	oLaFormule.EmbeddedObject.FontNameNumbers=sPolice
				  	oLaFormule.EmbeddedObject.FontNameText=sPolice
				  	oLaFormule.EmbeddedObject.FontNameFunctions=sPolice
				  	oLaFormule.embeddedobject.formula=sTexteFormule
					oLaFormule.embeddedObject.setmodified(true)
				endif	
			case 2:
				oLesObjets=oLaFormule.getEmbeddedObjects
				for i=0 to oLesObjets.count-1
					oPgb.value=i
					oLaFormule=oLesObjets(i)
					if oLaFormule.getImplementationName=&quot;SwXTextEmbeddedObject&quot; then
						if oLaFormule.embeddedObject.getImplementationName=&quot;com.sun.star.comp.math.FormulaDocument&quot; then
							sTexteFormule=oLaFormule.embeddedobject.formula
							oLaFormule.embeddedobject.formula=&quot;&quot;
							oLaFormule.embeddedobject.BaseFontHeight=iTaille
						  	oLaFormule.EmbeddedObject.FontNameVariables=sPolice
						  	oLaFormule.EmbeddedObject.FontVariablesIsItalic=true
						   	oLaFormule.EmbeddedObject.FontNameNumbers=sPolice
						  	oLaFormule.EmbeddedObject.FontNameText=sPolice
						  	oLaFormule.EmbeddedObject.FontNameFunctions=sPolice
						  	oLaFormule.embeddedobject.formula=sTexteFormule
							oLaFormule.embeddedObject.setmodified(true)
						endif
					endif
				next i	
				oPgb.end
			case 3:
				compte=0
				while oLesObjets.HasMoreElements
					oPgb.value=clng(compte+1)
					oLaFormule=oLesObjets.NextElement
					if oLaFormule.getImplementationName=&quot;SwXTextEmbeddedObject&quot; then
						if oLaFormule.embeddedObject.getImplementationName=&quot;com.sun.star.comp.math.FormulaDocument&quot; then
							sTexteFormule=oLaFormule.embeddedobject.formula
							oLaFormule.embeddedobject.formula=&quot;&quot;
							oLaFormule.embeddedobject.BaseFontHeight=iTaille
						  	oLaFormule.EmbeddedObject.FontNameVariables=sPolice
						  	oLaFormule.EmbeddedObject.FontVariablesIsItalic=true
						   	oLaFormule.EmbeddedObject.FontNameNumbers=sPolice
						  	oLaFormule.EmbeddedObject.FontNameText=sPolice
						  	oLaFormule.EmbeddedObject.FontNameFunctions=sPolice
						  	oLaFormule.embeddedobject.formula=sTexteFormule
							oLaFormule.embeddedObject.setmodified(true)
						endif
					endif
				wend
				oPgb.end
		end select
	endif
End Sub

&apos;--------------------------------------------------------------------------------------
function bEstCeSigne(char as String) as boolean
	&apos; si char est une de ces opérations, alors ne pas traiter la somme ou la différence
	bEstCeSigne=(InStr(&quot;+-*/=&quot;&amp;&quot;&quot;&quot;&quot;&amp;&quot;&gt;&quot;&amp;&quot;&lt;&quot;&amp;&quot;&amp;&quot;&amp;&quot;|&quot;&amp;&quot;~&quot;&amp;&quot;^&quot;&amp;&quot;_&quot;&amp;&quot;\&quot;,char)&gt;0)
end function

&apos;---------------------------------------------------------------------------------------
&apos;extrait du projet Dmaths, modifié par C.Devalland
Sub EncadrerFormule
&apos;bascule la formule en mode encadré/non encadré
dim oFormule as object
	oFormule=ThisComponent.getCurrentSelection()
	if oFormule.getImplementationName = &quot;SwXTextEmbeddedObject&quot; then
		oFormule.SetPropertyValue(&quot;LeftBorder&quot;,Array(0,0,2-oFormule.GetPropertyValue(&quot;LeftBorder&quot;).OuterLineWidth,0))
		oFormule.SetPropertyValue(&quot;LeftBorderDistance&quot;,0)
		oFormule.SetPropertyValue(&quot;RightBorder&quot;,Array(0,0,2-oFormule.GetPropertyValue(&quot;RightBorder&quot;).OuterLineWidth,0))
		oFormule.SetPropertyValue(&quot;RightBorderDistance&quot;,0)
		oFormule.SetPropertyValue(&quot;TopBorder&quot;,Array(0,0,2-oFormule.GetPropertyValue(&quot;TopBorder&quot;).OuterLineWidth,0))
		oFormule.SetPropertyValue(&quot;TopBorderDistance&quot;,0)
		oFormule.SetPropertyValue(&quot;BottomBorder&quot;,Array(0,0,2-oFormule.GetPropertyValue(&quot;BottomBorder&quot;).OuterLineWidth,0))
		oFormule.SetPropertyValue(&quot;BottomBorderDistance&quot;,0)
	end if
End Sub
</script:module>