This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths/Module6.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
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
<?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="Module6" script:language="StarBasic">&apos;************************************************
&apos;Copyright (C) 2010 Didier Dorange-Pattoret
&apos; avec l&apos;aide de Romain Dorange-Pattoret en juillet août 2010
&apos;38, chemin de l&apos;Abbaye 
&apos;74940 Annecy le Vieux
&apos;France
&apos;ddorange@dmaths.com
&apos;
&apos;
&apos;This library is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public Licence (GPL)
&apos;as published by the Free Software Foundation; either
&apos;version 2.1 of the License, or (at your option) any later version.

&apos;This library 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 GNU
&apos;General Public License for more details.

&apos;You should have received a copy of the GNU General Public Licence (GPL)
&apos;along with this library; if not, write to the Free Software
&apos;Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
&apos;************************************************


Public oFigure,oCreePoint,oCreePointSupp,oCreeDroite,oCreePolygone,oCreeCercle,oCreeGdmath,oPageF,oDocumentF as Object
Public iNbreInitDessin,iNbreDessinFait,iNumCourbe as Integer rem iNbreDessinFait contient le nbre de dessins faits
Rem iNumCourbe désigne le numéro de la courbe tracée 
Public bFigure,bCourbe,bInit,bDraw as Boolean rem bCourbe indique si l&apos;ontrace une courbe ou le repère
rem bInit = True au démarrage, bDraw on dessine dans un doc dessin
Private bPolygone as Boolean
Private Xpos2, Xpos3, Ypos2, Ypos3 as Integer
Private LeCadre as Object

Type Point
X as Single
Y as Single
Nom as String
End type
Public iNbrePoints as Integer
Public Points(1 to 100) as Point

Type Droite 
a as Single
b as Single
c as Single
Nom as String
End Type
Public iNbreDroites as Integer
Public Droites(1 to 100) as Droite

Type Cercle
Centre as String
X as Single
Y as Single
Rayon as Single
Nom as String
End Type
Public iNbreCercles as Integer 
Public Cercles(1 to 100) as Cercle

Private iNbreObjetGdmath as integer

Public XminiF,XmaxiF,YminiF,YmaxiF,NUXF,NUYF as Single
Public XAtemp,YAtemp,XBtemp,YBTemp As Single

Private iZoom as Integer
Private xa,xb,ya,yb as Integer
Global bInitByWriter as Boolean rem True si lancee depuis un doc dessin
Global sFonteName as String, iFonteTaille as Integer rem stocke les parametres correspondants 
Global monDocument1 as Object


Sub FaireFigureInWriter
	Dim sUrl as String
	Call VerifOperationnel	
	Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
	bInitByWriter = True
	monDocument1 = ThisComponent
	sFonteName = ThisComponent.CurrentController.ViewCursor.CharFontName
	iFonteTaille = ThisComponent.CurrentController.ViewCursor.CharHeight
	mFileProperties(0).Name = &quot;Hidden&quot;
	mFileProperties(0).Value = False
	mFileProperties(1).Name=&quot;MacroExecutionMode&quot;
	mFileProperties(1).Value=com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
	oDesktop = createUnoService(&quot;com.sun.star.frame.Desktop&quot;)
	sUrl = &quot;private:factory/sdraw&quot;
	oDocumentF = oDesktop.LoadComponentFromURL(sUrl,&quot;_blank&quot;,0,mFileProperties())
	oDocumentF.CurrentController.Frame.ContainerWindow.ToFront
	If (OOoNumVersion &lt; 330 or getguitype = 1) Then FaireFigure Else Avertir(25)
End Sub


Sub FaireFigureInDraw
	If bInitByWriter = False Then
		sFonteName = &quot;Times New Roman&quot;
		iFonteTaille = 12
	Endif
	FaireFigure
End Sub



Sub FaireFigure &apos;(Optional sFonteName2 as String, Optional iFonteTaille2 as Integer) 
	oDocumentF = ThisComponent
	oPageF= oDocumentF.Drawpages(0)
	iNbreInitDessin = oPageF.GetCount()
	bFigure = True
	iNbreDessinFait = 0
	iNbreObjetGdmath = 0
	iNumCourbe = 0
	bInit = True
	oFigure = LoadDialog(&quot;Dmaths&quot;,&quot;Figure&quot;)
	oOptions = LoadDialog(&quot;Dmaths&quot;,&quot;Options&quot;)
	oFigure.setPosSize(0,0,161,194,com.sun.star.awt.PosSize.POS)
	RecupereOptions(sOptionsTraceCourbe) rem cette macro permet de récuperer les options de tracer sauvegardées
	oFigure.GetControl(&quot;TextField1&quot;).SetFocus()
	oFigure.GetControl(&quot;ScrollBar1&quot;).Value = oDocumentF.currentController.ZoomValue
	oFigure.GetControl(&quot;TextFieldZoom&quot;).Text = oDocumentF.currentController.ZoomValue
	oFigure.GetControl(&quot;ListBox1&quot;).SelectItemPos(0,True)
	MAJoFigure()
	oFigure.Execute()
End Sub

Sub FinFaireFigure
&apos;	on  Error Resume next
	Dim oCollectionFigures,oAJoute as Object
	oFigure.EndExecute()
	oCollectionFigures = createUnoService(&quot;com.sun.star.drawing.ShapeCollection&quot;)
	For I=iNbreInitDessin To oPageF.GetCount()-1
		oAJoute=oPageF.GetByIndex(I)
		oCollectionFigures.Add(oAjoute)
		oCollectionFigures.getByIndex(I-iNbreInitDessin).LayerID = 1
	Next I	
	oGroup = oPageF.Group(oCollectionFigures)
	oPageF.remove(LeCadre)
	&apos;MRI oPageF
	If oPageF.getCount &gt; 0 Then
		oMaFigure =  oPageF.GetByIndex(oPageF.getCount-1)
		oMaFigure.LayerID = 1
	    oDocumentF.CurrentController.Select(oMaFigure)
		ClipboardCopy(oDocumentF)
	Endif
	rem on copie la figure si macro appelee depuis un document writer
	If bInitByWriter = True Then 
		monDocument1.CurrentController.Frame.ContainerWindow.ToFront
		ClipboardPaste(monDocument1)
		ToucheEchap (monDocument1)
		If (OOoNumVersion &gt;= 330 or getguitype = 1) Then oDocumentF.Close(False)
		bInitByWriter = False
	EndIf
	
End Sub

Sub AnnulerFaireFigure
	Dim oEnleve as Object
	on error resume next	
	If iNbreDessinFait&gt;0 Then
	For I=0 To iNbreDessinFait-1
	oEnleve = oPageF.GetByIndex(iNbreInitDessin)
	oPageF.Remove(oEnleve)
	Next I
	End if
	oPageF.remove(LeCadre)
	If (bInitByWriter and getguitype =1) Then	oDocumentF.Close(False)
	bInitByWriter = False
	oFigure.EndExecute()	
End Sub

Sub LanceCreation &apos;macro qui lance la creation
	
	Dim mNoArgs(0) As New com.sun.star.beans.PropertyValue
	Dim dimensionsLeCadre As New com.sun.star.awt.Size
	Dim positionLeCadre As New com.sun.star.awt.Point
	
	If bInit=True Then	
		XminiF=CsngPlus(oFigure.GetControl(&quot;TextField1&quot;).Peer.Text)
		XmaxiF=CsngPlus(oFigure.GetControl(&quot;TextField2&quot;).Peer.Text)
		YminiF=CsngPlus(oFigure.GetControl(&quot;TextField3&quot;).Peer.Text)
		YmaxiF=CsngPlus(oFigure.GetControl(&quot;TextField4&quot;).Peer.Text)
		NUXF=CsngPlus(oFigure.GetControl(&quot;TextField5&quot;).Peer.Text)
		NUYF=CsngPlus(oFigure.GetControl(&quot;TextField6&quot;).Peer.Text)
		LeCadre = oDocumentF.createInstance(&quot;com.sun.star.drawing.RectangleShape&quot;)
		dimensionsLeCadre.Width = (XmaxiF - XminiF)*1000/NUXF
		dimensionsLeCadre.Height = (YmaxiF - YminiF)*1000/NUYF
		positionLeCadre.x = 2000
		positionLeCadre.y = 2000	
		leCadre.Size = dimensionsLeCadre
		leCadre.Position = positionLeCadre
		Dim mesTirets As New com.sun.star.drawing.LineDash
		With mesTirets
		  .Style = com.sun.star.drawing.DashStyle.RECT
		  .Dots = 4       &apos; 4 points
		  .DotLen = 50    &apos; de 0,5 mm
		  .Dashes = 2     &apos; suivis de 2 tirets
		  .DashLen = 200  &apos; de 2 mm
		  .Distance = 150 &apos; espacés de 1,5 mm
		End With
		leCadre.LineDash = mesTirets
		leCadre.LineStyle = com.sun.star.drawing.LineStyle.DASH
		leCadre.FillStyle = 0
	&apos;	MRI LeCadre
		oPageF.add(LeCadre)
		iNbreInitDessin = iNbreInitDessin + 1
	Endif

	bInit=False	
	oFigure.GetControl(&quot;TextField1&quot;).Enable=False
	oFigure.GetControl(&quot;TextField2&quot;).Enable=False
	oFigure.GetControl(&quot;TextField3&quot;).Enable=False
	oFigure.GetControl(&quot;TextField4&quot;).Enable=False
	oFigure.GetControl(&quot;TextField5&quot;).Enable=False
	oFigure.GetControl(&quot;TextField6&quot;).Enable=False
	oFigure.GetControl(&quot;Label3&quot;).Enable=False
	oFigure.GetControl(&quot;Label4&quot;).Enable=False
	oFigure.GetControl(&quot;Label5&quot;).Enable=False
	oFigure.GetControl(&quot;Label6&quot;).Enable=False
	oFigure.GetControl(&quot;Label7&quot;).Enable=False
	oFigure.GetControl(&quot;Label8&quot;).Enable=False
	
	Dim oListBox as Object
	oListBox=oFigure.GetControl(&quot;ListBox1&quot;)
	Select Case oListBox.getSelectedItemPos()
		Case 0
		CreationPoint
		Case 1
		CreationDroite
		Case 2
		CreationCercle
		Case 3
		CreationPolygone
		Case 4
		CreationRepere
		Case 5
		CreationCourbe
		Case 6
		CreationGdmath	
	End Select

End Sub

Sub CreationGdmath
 	oCreeGdmath = LoadDialog(&quot;Dmaths&quot;,&quot;CreeGdmath&quot; )
	oCreeGdmath.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	oCreeGdmath.GetControl(&quot;ScrollBar3&quot;).Value = oDocumentF.currentController.ZoomValue
	oCreeGdmath.GetControl(&quot;TextFieldZoom&quot;).Text = oDocumentF.currentController.ZoomValue
	oCreeGdmath.GetControl(&quot;CommandButton1&quot;).Model.ImageURL = ConvertToURL(sChemindmaths &amp; &quot;icons/addons/Gdmath_26.bmp&quot;) 
	oFigure.SetVisible(False)
 	oCreeGdmath.Execute()
End Sub

Sub LanceCreationGdmath
	BasicLibraries.LoadLibrary(&quot;OOoGdmath&quot;)
	Call Debug.Main 
	oCreeGdmath.GetControl(&quot;ScrollBar1&quot;).Enable = TRUE
	oCreeGdmath.GetControl(&quot;ScrollBar2&quot;).Enable = TRUE
End Sub


Sub ValideCreationGdmath
	oCreeGdmath.EndExecute()
	Dim toto as object
&apos;	Print IsNull(oDocumentF.CurrentSelection)
	If Not IsNull(oDocumentF.CurrentSelection) Then
		iNbreObjetGdmath = iNbreObjetGdmath + 1
		oFigure.GetControl(&quot;ListBox2&quot;).Additem(sVocab(iLang,271) &amp; iNbreObjetGdmath,iNbreDessinFait)
		oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(iNbreDessinFait,True)
		iNbreDessinFait = iNbreDessinFait + 1
	End if
	oDocumentF.currentController.select(toto)
	MAJoFigure ()
	oFigure.GetControl(&quot;ScrollBar1&quot;).Value = oDocumentF.currentController.ZoomValue
	oFigure.GetControl(&quot;TextFieldZoom&quot;).Text = oDocumentF.currentController.ZoomValue
	oFigure.SetVisible(True)
End sub

Sub AnnuleCreationGdmath
	oCreeGdmath.EndExecute()
&apos;	Print IsNull(oDocumentF.CurrentSelection)
	If Not IsNull(oDocumentF.CurrentSelection) Then
		oDocumentF.currentController.selection.getByIndex(0).Dispose()
		oFigure.GetControl(&quot;ListBox2&quot;).RemoveItems(oFigure.GetControl(&quot;ListBox2&quot;).getSelectedItemPos(),1)
		oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(oFigure.GetControl(&quot;ListBox2&quot;).ItemCount-1,True)		
	Endif
	MAJoFigure ()
	oFigure.GetControl(&quot;ScrollBar1&quot;).Value = oDocumentF.currentController.ZoomValue
	oFigure.GetControl(&quot;TextFieldZoom&quot;).Text = oDocumentF.currentController.ZoomValue
	oFigure.SetVisible(True)
End sub


Sub CreationPoint

	oFigure.SetVisible(False)
	oCreePoint = LoadDialog(&quot;Dmaths&quot;,&quot;CreePoint&quot; )
	oCreePoint.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	oCreePoint.GetControl(&quot;OptionButton1&quot;).SetState(True)


	
Rem initialise les listeBox	
	for I=0 to iNbrePoints-1
		oCreePoint.GetControl(&quot;ListBox3&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreePoint.GetControl(&quot;ListBox4&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreePoint.GetControl(&quot;ListBox5&quot;).addItem(Points(iNbrePoints-I).Nom,I)				
	next I
	
	for I=0 to iNbreDroites-1		
		oCreePoint.GetControl(&quot;ListBox6&quot;).addItem(Droites(iNbreDroites-I).Nom,I)
		oCreePoint.GetControl(&quot;ListBox7&quot;).addItem(Droites(iNbreDroites-I).Nom,I)
		oCreePoint.GetControl(&quot;ListBox8&quot;).addItem(Droites(iNbreDroites-I).Nom,I)
	next I
	
	If iNbrePoints &gt; 0 Then 
		oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text = IncrementeASCII(Points(iNbrePoints).Nom,1)
		oCreePoint.GetControl(&quot;ListBox5&quot;).selectItem(Points(iNbrePoints).Nom,true)
	Else 
		oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;A&quot;
	EndIf
	
	&apos;Parametres par defaut : derniers points crees
	If iNbrePoints &gt; 0  Then  		
		oCreePoint.GetControl(&quot;ListBox4&quot;).selectItem(Points(iNbrePoints).Nom,true)
		oCreePoint.GetControl(&quot;ListBox5&quot;).selectItem(Points(iNbrePoints).Nom,true)
	EndIf

	If iNbrePoints &gt; 1 Then
		oCreePoint.GetControl(&quot;ListBox3&quot;).selectItem(Points(iNbrePoints-1).Nom,true)  
	EndIf
	
	&apos;Gestion du OptionButton2
	If iNbrePoints &lt; 2  Then
			oCreePoint.GetControl(&quot;OptionButton2&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;ListBox3&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;TextField5&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;ListBox4&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;Label3&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;Label4&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;Label5&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;Label6&quot;).setEnable(false)
	Else 
		If iNbreDroites &gt;= 2 Then oCreePoint.GetControl(&quot;ListBox6&quot;).selectItem(Droites(iNbreDroites-1).Nom,true) 
		If iNbreDroites &gt;= 1 Then oCreePoint.GetControl(&quot;ListBox7&quot;).selectItem(Droites(iNbreDroites).Nom,true) 
	Endif

	&apos;Gestion du OptionButton3
	If  iNbreDroites &lt; 2 Then 
			oCreePoint.GetControl(&quot;OptionButton3&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;ListBox6&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;ListBox7&quot;).setEnable(false)
			oCreePoint.GetControl(&quot;Label7&quot;).setEnable(false)
	Else 
		oCreePoint.GetControl(&quot;ListBox6&quot;).selectItem(Droites(iNbreDroites-1).Nom,true) 
		oCreePoint.GetControl(&quot;ListBox7&quot;).selectItem(Droites(iNbreDroites).Nom,true) 
	Endif

	&apos;Gestion du OptionButton4
	If (iNbreDroites = 0 OR iNbrePoints = 0) Then 
		oCreePoint.GetControl(&quot;OptionButton4&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;Label2&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;ListBox5&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;ListBox8&quot;).setEnable(false)
	Else
		If iNbreDroites &gt;= 1 Then oCreePoint.GetControl(&quot;ListBox8&quot;).selectItem(Droites(iNbreDroites).Nom,true) 
	Endif
	
	&apos;Gestion du OptionButton13 (Intersection de Cercle)
	for I=0 to iNbreCercles-1
		oCreePoint.GetControl(&quot;ListBox1&quot;).addItem(Cercles(iNbreCercles-I).Nom,I)
		oCreePoint.GetControl(&quot;ListBox2&quot;).addItem(Cercles(iNbreCercles-I).Nom,I)
	next I
	
	for I=iNbreCercles to iNbreCercles+iNbreDroites-1
		oCreePoint.GetControl(&quot;ListBox2&quot;).addItem(Droites(iNbreCercles+iNbreDroites-I).Nom,I)
	next I

	
	If (oCreePoint.GetControl(&quot;ListBox1&quot;).ItemCount &gt; 0 AND oCreePoint.GetControl(&quot;ListBox2&quot;).ItemCount &gt; 1) Then 
		oCreePoint.GetControl(&quot;ListBox1&quot;).selectItemPos(0,true)
		oCreePoint.GetControl(&quot;ListBox2&quot;).selectItemPos(1,true)
	Else 
		oCreePoint.GetControl(&quot;Label8&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;OptionButton13&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;ListBox1&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;ListBox2&quot;).setEnable(false)
	Endif

	&apos;Gestion de l&apos;optionButton14
	
	for I=0 to iNbreCercles-1		
		oCreePoint.GetControl(&quot;ListBox9&quot;).addItem(Cercles(iNbreCercles-I).Nom,I)				
	next I
	
	If (iNbreCercles&gt;0) Then 
		oCreePoint.GetControl(&quot;ListBox9&quot;).selectItemPos(0,true)
	Else 
		oCreePoint.GetControl(&quot;Label9&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;OptionButton14&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;TextField4&quot;).setEnable(false)
		oCreePoint.GetControl(&quot;ListBox9&quot;).setEnable(false)
	Endif

	&apos;On force le premier bouton
	oCreePoint.GetControl(&quot;OptionButton1&quot;).setState(true)
	
	oCreePoint.GetControl(&quot;TextField2&quot;).setFocus()
	
	oCreePoint.toFront()
	oCreePoint.Execute()
End Sub


Sub AnnulerCreationPoint
	oCreePoint.EndExecute()
	oFigure.SetVisible(True)
End Sub


Sub FinCreationPoint &apos;(Optional bPolygone as Boolean)
	If DetermineSiObjetExiste(oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text) Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
		Goto Fin:
	End if
	
	If oCreePoint.Model.OptionButton2.State=1 Then rem point dans un repère
		ConstruitPointRepere	
	Elseif oCreePoint.Model.OptionButton3.State=1 Then rem intersection de deux droites
		ConstruitIntersectionDroites
	Elseif oCreePoint.Model.OptionButton4.State=1 Then rem projeté orthogonal
		ConstruitProjeteOrthogonal
	Elseif oCreePoint.Model.OptionButton13.State=1 Then rem intersection cercles
		ConstruitIntersectionCercles
	Elseif oCreePoint.Model.OptionButton14.State=1 Then rem intersection cercles
		ConstruitPointSurCercle
	Else
		FinCreationPoint2(Csng(oCreePoint.GetControl(&quot;TextField2&quot;).Peer.Text),Csng(oCreePoint.GetControl(&quot;TextField3&quot;).Peer.Text))
	Endif
	If bError=True Then Goto Fin

	Fin:
	bError=False
	MAJoFigure
	oCreePoint.EndExecute()
	oFigure.SetVisible(True)		
End Sub


Sub FinCreationPoint2(XA,YA as Single, Optional PositionAffichage as Integer)

	iNbrePoints=iNbrePoints+1
	Points(iNbrePoints).Nom = oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text
	Points(iNbrePoints).X = XA
	Points(iNbrePoints).Y = YA
	
	If Not bPolygone Then Rem Pour le tracé d&apos;un polygone
		If (Points(iNbrePoints).X&lt;XminiF or Points(iNbrePoints).X&gt;XmaxiF or Points(iNbrePoints).Y&lt;YminiF or Points(iNbrePoints).Y&gt;YmaxiF) Then 
			If msgbox(sVocab(iLang,239)+Chr(13)+sVocab(iLang,240),36,&quot;Dmaths&quot;)=7 Then 
				oFigure.GetControl(&quot;ListBox2&quot;).Additem(sVocab(iLang,237) &amp; oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text,oFigure.GetControl(&quot;ListBox2&quot;).GetItemCount())
				oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(oFigure.GetControl(&quot;ListBox2&quot;).GetItemCount()-1,True)
				Goto Finb
			Endif
		Endif
	EndIf
	
	oFigure.GetControl(&quot;ListBox2&quot;).Additem(sVocab(iLang,237) &amp; oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text,iNbreDessinFait)
	oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(iNbreDessinFait,True)
	
	Dim oShapes as Object
	Dim oMarquePoints(1) as Object
	
	iNbreDessinFait=iNbreDessinFait+1
	oShapes = createUnoService(&quot;com.sun.star.drawing.ShapeCollection&quot;)
	
	
	If oCreePoint.Model.CheckBox1.State=1 Then
			xa = 1000*(2+(Points(iNbrePoints).X-XMiniF)/NUXF)-iMarqHorPoints
		ya = 1000*(2+(YmaxiF-Points(iNbrePoints).Y)/NUYF)-iMarqVerPoints
		xb = 1000*(2+(Points(iNbrePoints).X-XMiniF)/NUXF)+iMarqHorPoints
		yb = 1000*(2+(YmaxiF-Points(iNbrePoints).Y)/NUYF)+iMarqVerPoints
		oMarquePoints(0) = CreateMarque(oDocumentF,oPageF,xa,ya,xb,yb,0,False)
		xa = 1000*(2+(Points(iNbrePoints).X-XMiniF)/NUXF)+iMarqVerPoints
		ya = 1000*(2+(YmaxiF-Points(iNbrePoints).Y)/NUYF)-iMarqHorPoints
		xb = 1000*(2+(Points(iNbrePoints).X-XMiniF)/NUXF)-iMarqVerPoints
		yb = 1000*(2+(YmaxiF-Points(iNbrePoints).Y)/NUYF)+iMarqHorPoints
		oMarquePoints(1) = CreateMarque(oDocumentF,oPageF,xa,ya,xb,yb,0,False)
		oShapes.add(oMarquePoints(0))
		oShapes.add(oMarquePoints(1))
	Else 
		xa = 2000
		ya = 2000
		xb = 2000
		yb = 2000
		oMarquePoints(0) = CreateMarque(oDocumentF,oPageF,xa,ya,xb,yb,0,False)
		oShapes.add(oMarquePoints(0))	
	Endif
	
	If oCreePoint.Model.CheckBox2.State=1 Then
		If oCreePoint.Model.CheckBox1.State=0 Then iNbreDessinFait=iNbreDessinFait+1
		Dim oNomPoints as Object
		Dim aPosPoints(iNbrePoints) As New com.sun.star.awt.Point
		Dim iAngle as Integer		
		If IsMissing(PositionAffichage) Then
			iAngle = DetermineiAngle(oCreePoint)
		Else 
			iAngle = PositionAffichage   rem determine l&apos;affichage du point
		Endif	
		oNomPoints = oDocumentF.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
		oNomPoints.TextAutoGrowWidth  = True
		oNomPoints.TextAutoGrowHeight  = True
		aPosPoints(iNbrePoints).x=1000*(2+(Points(iNbrePoints).X-XMiniF)/NUXF)-50+300*cos((3.141592*iAngle)/4)&apos; +1000*oFigure.Model.CheckBox1.State
		aPosPoints(iNbrePoints).y=1000*(2+(YmaxiF-Points(iNbrePoints).Y)/NUYF)-300-300*sin((3.141592*iAngle)/4)&apos; +1000*oFigure.Model.CheckBox1.State
		oNomPoints.Position=aPosPoints(iNbrePoints)
		oPageF.add(oNomPoints)
		oNomPoints.String=oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text
	&apos;	oNomPoints.CharPosture = com.sun.star.awt.FontSlant.ITALIC
		Rem On règle la police et la taille des noms de points
		If Not IsNull(sFonteName) Then oNomPoints.CharFontName = sFonteName
		If Not IsNull(iFonteTaille) Then oNomPoints.CharHeight = iFonteTaille
		regleIndice(oNomPoints)
		oShapes.add(oNomPoints)	
	Endif
	
	
	
	oPageF.Group(oShapes)

	Finb:

End Sub

Sub CreationPolygone

	If (iNbrePoints &lt; 2) Then  
		msgBox(sVocab(iLang,259),64,&quot;Dmaths&quot;)
		Goto Fin
	Endif
	
	oFigure.SetVisible(False)

	bPolygone = True
	oCreePolygone = LoadDialog(&quot;Dmaths&quot;,&quot;CreePolygone&quot; )
	oCreePolygone.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	oCreePolygone.GetControl(&quot;OptionButton1&quot;).SetState(True)
	
	Xpos2 = oCreePolygone.GetControl(&quot;TextField2&quot;).PosSize.X
	Xpos3 = oCreePolygone.GetControl(&quot;TextField3&quot;).PosSize.X
	Ypos2 = oCreePolygone.GetControl(&quot;TextField2&quot;).PosSize.Y
	Ypos3 = oCreePolygone.GetControl(&quot;TextField3&quot;).PosSize.Y
	
	for I=0 to iNbrePoints-1
		oCreePolygone.GetControl(&quot;ListBox1&quot;).addItem(Points(I+1).Nom,I)
		oCreePolygone.GetControl(&quot;ListBox2&quot;).addItem(Points(I+1).Nom,I)
		oCreePolygone.GetControl(&quot;ListBox3&quot;).addItem(Points(I+1).Nom,I)				
	next I

	oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text = incrementeASCII(Points(iNbrePoints).Nom,1)
	oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text = incrementeASCII(Points(iNbrePoints).Nom,2)

	oCreePolygone.GetControl(&quot;ListBox2&quot;).selectItemPos(1,true)
	oCreePolygone.GetControl(&quot;Label2&quot;).Visible = false
	oCreePolygone.GetControl(&quot;Label3&quot;).Visible = false
	oCreePolygone.GetControl(&quot;ListBox1&quot;).selectItemPos(0,true)	
	oCreePolygone.GetControl(&quot;ListBox3&quot;).selectItemPos(2,true)
	if iNbrePoints = 2 Then
			oCreePolygone.GetControl(&quot;OptionButton1&quot;).setEnable(false)
			oCreePolygone.GetControl(&quot;OptionButton2&quot;).State = 1
			oCreePolygone.GetControl(&quot;ListBox3&quot;).Visible = false		
	Else
			oCreePolygone.GetControl(&quot;TextField3&quot;).Visible = false
			oCreePolygone.GetControl(&quot;TextField2&quot;).SetPosSize(Xpos3,Ypos3,36,15,com.sun.star.awt.PosSize.POS)
			oCreePolygone.GetControl(&quot;CheckBox1&quot;).Visible = false
	Endif	
	
	InitialiseListBoxTriangleIsoceleRectangle()
	oFigure.SetVisible(False)
	oCreePolygone.toFront()
	oCreePolygone.Execute()
	
	Fin:
End Sub

Sub AnnulerCreationPolygone
	oCreePolygone.EndExecute()
	oFigure.SetVisible(True)
End Sub

Sub InitialiseListBoxTriangleIsoceleRectangle 
Rem cette macro initialise le contenu de la liste box dans laquelle on choisit l angle droit
	oCreePolygone.GetControl(&quot;ListBox5&quot;).RemoveItems(0,oCreePolygone.GetControl(&quot;ListBox5&quot;).ItemCount)
	oCreePolygone.GetControl(&quot;ListBox5&quot;).addItem(oCreePolygone.GetControl(&quot;ListBox1&quot;).selectedItem,0)
	oCreePolygone.GetControl(&quot;ListBox5&quot;).addItem(oCreePolygone.GetControl(&quot;ListBox2&quot;).selectedItem,1)
	oCreePolygone.GetControl(&quot;ListBox5&quot;).addItem(oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text,2)
	oCreePolygone.GetControl(&quot;ListBox5&quot;).selectItemPos(0,True)
End Sub



Sub TraceSegment(s1,s2 as String)

	oCreeDroite = LoadDialog(&quot;Dmaths&quot;,&quot;CreeDroite&quot; )
	oCreeDroite.Model.CheckBox2.State=1

	for I=0 to iNbrePoints-1		
		oCreeDroite.GetControl(&quot;ListBox5&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeDroite.GetControl(&quot;ListBox6&quot;).addItem(Points(iNbrePoints-I).Nom,I)
	next I
	oCreeDroite.GetControl(&quot;ListBox5&quot;).selectItem(s1,true)
	oCreeDroite.GetControl(&quot;ListBox6&quot;).selectItem(s2,true)
	oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+s1+s2+&quot;]&quot;			
	FinCreationDroite
	
	oCreeDroite.Model.CheckBox2.State=0
End Sub


Sub FinCreationPolygone

	Dim X(1 to 4),Y(1 to 4) as Single
	Dim NC as Integer &apos; nombre de côté
	Dim L1,L2 As Single
	Dim RH, R As Single &apos;rapport de l&apos;homothétie, rayon du polygone 
	Dim LAngle As Single
	
		&apos;On initialise le contenu minimum de oCreeDroite nécessaire à la création des segments
		If oCreePolygone.Model.CheckBox2.State=1 Then
			oCreeDroite = LoadDialog(&quot;Dmaths&quot;,&quot;CreeDroite&quot; )
			oCreeDroite.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	
			for I=0 to iNbrePoints-1		
				oCreeDroite.GetControl(&quot;ListBox5&quot;).addItem(Points(iNbrePoints-I).Nom,I)
				oCreeDroite.GetControl(&quot;ListBox6&quot;).addItem(Points(iNbrePoints-I).Nom,I)
			next I		
		End if
	
			X(1) =  Points(DetermineIndexPoint(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)).X
			Y(1) =  Points(DetermineIndexPoint(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)).Y
			X(2) =  Points(DetermineIndexPoint(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)).X
			Y(2) =  Points(DetermineIndexPoint(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)).Y	
		
	
		If oCreePolygone.Model.OptionButton1.State=1 Then rem parallelogramme
				

			X(3) =  Points(DetermineIndexPoint(oCreePolygone.GetControl(&quot;ListBox3&quot;).SelectedItem)).X
			Y(3) =  Points(DetermineIndexPoint(oCreePolygone.GetControl(&quot;ListBox3&quot;).SelectedItem)).Y
			
			X(4) = X(3) + X(1) - X(2)
			Y(4) = Y(3) + Y(1) - Y(2)
		 
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if
		
			XAtemp = X(4)
			YAtemp = Y(4)
			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text = oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text
		
			iAngle = CalculPositionAffichage(X,Y,4,4)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
		 
		 	If oCreePolygone.Model.CheckBox2.State=1 Then
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem,	oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem,oCreePolygone.GetControl(&quot;ListBox3&quot;).selectedItem)
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox3&quot;).SelectedItem,oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text,oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)
			End if	
		 
		Elseif oCreePolygone.Model.OptionButton2.State=1 Then rem rectangle
					
			L1 = ((X(1)-X(2))^2+(Y(1)-Y(2))^2)^(1/2)
			L2 = CsngPlus(oCreePolygone.GetControl(&quot;TextField1&quot;).Peer.Text)
	
			RH = L2/L1
				
			
			If oCreePolygone.Model.CheckBox1.State=1 Then
				LAngle = - Pi()/2
			Else LAngle = Pi()/2
			End if
			
			X(4) = RH*cos(LAngle)*(X(1)-X(2))-RH*sin(LAngle)*(Y(1)-Y(2))+X(2)
			Y(4) = RH*sin(LAngle)*(X(1)-X(2))+RH*cos(LAngle)*(X(1)-X(2))+Y(2)
			
			X(3) = RH*cos(-LAngle)*(X(2)-X(1))-RH*sin(-LAngle)*(Y(2)-Y(1))+X(1)
			Y(3) = RH*sin(-LAngle)*(X(2)-X(1))+RH*cos(-LAngle)*(X(2)-X(1))+Y(1)
			
			
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if
		
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if
		
			XAtemp = X(4)
			YAtemp = Y(4)
			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text
			iAngle = CalculPositionAffichage(X,Y,4,4)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
			
			XAtemp = X(3)
			YAtemp = Y(3)
			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text
			iAngle = CalculPositionAffichage(X,Y,3,4)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
			
			If oCreePolygone.Model.CheckBox2.State=1 Then
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem,oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem,	oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text,oCreePolygone.GetControl(&quot;TextField3&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField3&quot;).peer.text,oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)
			End if	
		
			
		Elseif oCreePolygone.Model.OptionButton3.State=1 Then rem carré
	
			RH = 1
				
			
			If oCreePolygone.Model.CheckBox1.State=1 Then
				LAngle = - Pi()/2
			Else LAngle = Pi()/2
			End if
			
			X(4) = RH*cos(LAngle)*(X(1)-X(2))-RH*sin(LAngle)*(Y(1)-Y(2))+X(2)
			Y(4) = RH*sin(LAngle)*(X(1)-X(2))+RH*cos(LAngle)*(X(1)-X(2))+Y(2)
			
			X(3) = RH*cos(-LAngle)*(X(2)-X(1))-RH*sin(-LAngle)*(Y(2)-Y(1))+X(1)
			Y(3) = RH*sin(-LAngle)*(X(2)-X(1))+RH*cos(-LAngle)*(X(2)-X(1))+Y(1)
			
			
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if
		
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if
		
			XAtemp = X(4)
			YAtemp = Y(4)
			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text
			iAngle = CalculPositionAffichage(X,Y,4,4)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
			
			XAtemp = X(3)
			YAtemp = Y(3)
			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePolygone.GetControl(&quot;TextField3&quot;).Peer.Text
			iAngle = CalculPositionAffichage(X,Y,3,4)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
			
			If oCreePolygone.Model.CheckBox2.State=1 Then
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem,oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem,	oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text,oCreePolygone.GetControl(&quot;TextField3&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField3&quot;).peer.text,oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)
			End if	
		
		Elseif oCreePolygone.Model.OptionButton4.State=1 Then rem triangle equilateral 
			
			If oCreePolygone.Model.CheckBox1.State=1 Then LAngle = Pi()/3 Else LAngle = -Pi()/3
		
			
			X(3) = cos(LAngle)*(X(2)-X(1))+sin(LAngle)*(Y(1)-Y(2))+X(1)
			Y(3) = cos(LAngle)*(Y(2)-Y(1))+sin(LAngle)*(X(2)-X(1))+Y(1)
			
			
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if
		
			XAtemp = X(3)
			YAtemp = Y(3)
			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text
			iAngle = CalculPositionAffichage(X,Y,3,3)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
			
			If oCreePolygone.Model.CheckBox2.State=1 Then
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem,oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem,oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text,oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)
				oCreeDroite.Model.CheckBox2.State=0
			End if
		
		Elseif oCreePolygone.Model.OptionButton5.State=1 Then rem triangle isocele rectangle
			If DetermineSiObjetExiste(oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text) Then
				msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
				Goto Fin:
			End if

			
			If oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem = oCreePolygone.GetControl(&quot;ListBox5&quot;).SelectedItem Then rem rectangle en A
				If oCreePolygone.Model.CheckBox1.State=1 Then LAngle = Pi()/2 Else LAngle = -Pi()/2
				X(3) = cos(LAngle)*(X(2)-X(1))+sin(LAngle)*(Y(1)-Y(2))+X(1)
				Y(3) = cos(LAngle)*(Y(2)-Y(1))+sin(LAngle)*(X(2)-X(1))+Y(1)			
			
			Elseif oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem = oCreePolygone.GetControl(&quot;ListBox5&quot;).SelectedItem Then rem rectangle en B
				If oCreePolygone.Model.CheckBox1.State=1 Then LAngle = Pi()/4 Else LAngle = -Pi()/4
				X(3) = sqr(2)*(cos(LAngle)*(X(2)-X(1))+sin(LAngle)*(Y(1)-Y(2)))+X(1)
				Y(3) = sqr(2)*(cos(LAngle)*(Y(2)-Y(1))+sin(LAngle)*(X(2)-X(1)))+Y(1)			
			Else
				If oCreePolygone.Model.CheckBox1.State=1 Then LAngle = Pi()/4 Else LAngle = -Pi()/4
				X(3) = sqr(0.5)*(cos(LAngle)*(X(2)-X(1))+sin(LAngle)*(Y(1)-Y(2)))+X(1)
				Y(3) = sqr(0.5)*(cos(LAngle)*(Y(2)-Y(1))+sin(LAngle)*(X(2)-X(1)))+Y(1)
			Endif
				XAtemp = X(3)
				YAtemp = Y(3)			
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePolygone.GetControl(&quot;TextField2&quot;).Peer.Text
			iAngle = CalculPositionAffichage(X,Y,3,3)
			FinCreationPoint2(XAtemp,YAtemp,iAngle)
			
			If oCreePolygone.Model.CheckBox2.State=1 Then
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem,oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem)
				TraceSegment(oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem,oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text)
				TraceSegment(oCreePolygone.GetControl(&quot;TextField2&quot;).peer.text,oCreePolygone.GetControl(&quot;ListBox1&quot;).SelectedItem)
				oCreeDroite.Model.CheckBox2.State=0
			End if	
			
		Elseif oCreePolygone.Model.OptionButton6.State=1 Then rem polygone regulier
			
			NomduPoint = oCreePolygone.GetControl(&quot;ListBox2&quot;).SelectedItem 
	
			NC = Cint(oCreePolygone.GetControl(&quot;TextField4&quot;).Peer.Text)
			If NC &lt; 3 Then
				msgbox(sVocab(iLang,265),64,&quot;Dmaths&quot;)
				Goto Fin:
			Endif
			
			Dim CorrectifAffichage As Single
			CorrectifAffichage = pi/4 + DetermineAnglePolaire(X(1),Y(1),X(2),Y(2))
			
			For I = 1 To NC-1
				LAngle = (2*pi*I)/NC
				If oCreePolygone.Model.CheckBox1.State=0 Then LAngle = -1*LAngle
				XAtemp = X(1) + cos(LAngle)*(X(2)-X(1)) - sin(LAngle)*(Y(2)-Y(1))
				YAtemp = Y(1) + sin(LAngle)*(X(2)-X(1)) + cos(LAngle)*(Y(2)-Y(1))
				NomduPoint = IncrementeASCII(NomduPoint,1)
				Do while DetermineSiPointExiste(NomduPoint)
				 	NomduPoint = IncrementeASCII(NomduPoint,1)
				Loop
				oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text = NomduPoint
				iAngle = Int(DetermineMesurePrincipale(LAngle+CorrectifAffichage))
				FinCreationPoint2(XAtemp,YAtemp,iAngle)
			Next I	
		
			If oCreePolygone.Model.CheckBox2.State=1 Then
				For I = iNbrePoints-NC+1 To iNbrePoints-1
					TraceSegment(Points(I).Nom,Points(I+1).Nom)
				Next I
					TraceSegment(Points(iNbrePoints).Nom,Points(iNbrePoints-NC+1).Nom)
			End if		
		End if
			
			
		bError=False
		MAJoFigure
		oCreePolygone.EndExecute()
		oFigure.SetVisible(True)
		Fin:	
End Sub


Function CalculPositionAffichage(X,Y as Single,Num as Integer,NP) as Integer rem Num numéro du point, NP nombre points
	Dim Xma, Yma, Xmi, Ymi as Single
	Xma = X(1) : Xmi = X(1) : Yma = Y(1) : Ymi = Y(1)
 	For I=2 To NP
	If X(I) &gt; Xma then Xma = X(I) :	If Y(I) &gt; Yma then Yma = Y(I) 
	If X(I) &lt; Xmi then Xmi = X(I) : If Y(I) &lt; Ymi then Ymi = Y(I)	
	Next I  
	If X(Num) &gt;= (Xma+Xmi)/2 and Y(Num) &gt;= (Yma+Ymi)/2 Then CalculPositionAffichage = 1
	If X(Num) &lt;= (Xma+Xmi)/2 and Y(Num) &lt;= (Yma+Ymi)/2 Then CalculPositionAffichage = 5
	If X(Num) &gt;= (Xma+Xmi)/2 and Y(Num) &lt;= (Yma+Ymi)/2 Then CalculPositionAffichage = 7
	If X(Num) &lt;= (Xma+Xmi)/2 and Y(Num) &gt;= (Yma+Ymi)/2 Then CalculPositionAffichage = 3	
End Function



Sub ConstruitPointSurCercle

	Dim angle as Single
	Dim X1,Y1 as Single
	Dim I1 as Integer

	I1 = DetermineIndexCercle(oCreePoint.GetControl(&quot;ListBox9&quot;).SelectedItem)
	angle = Csng(oCreePoint.GetControl(&quot;TextField4&quot;).Peer.Text)
	X1 = Cercles(I1).X + Cercles(I1).Rayon*cos(angle*PI()/180)
	Y1 = Cercles(I1).Y + Cercles(I1).Rayon*sin(angle*PI()/180)
	
	XAtemp = X1
	YAtemp = Y1
	
	FinCreationPoint2(XAtemp,YAtemp)
	
End Sub	

Sub ConstruitIntersectionCercles

	Dim isCercle as Boolean
	Dim R,S,D As Single  &apos;rayon du premier et second cercle, D distance
	Dim XR,YR As Single &apos;Coordonnée du cercle de référence
	Dim X1,Y1,X2,Y2 As Single
	Dim I1,I2 As Integer &apos;I1 identifiant du cercle, I2 identifiant droite ou cercle
	isCercle = false
	
	For I=1 To iNbreCercles
		if Cercles(I).Nom = oCreePoint.GetControl(&quot;ListBox2&quot;).SelectedItem Then isCercle=True
	Next I
	
	If isCercle= true Then

		Dim XS,YS As Single
		
		I1 = DetermineIndexCercle(oCreePoint.GetControl(&quot;ListBox1&quot;).SelectedItem)
		I2 = DetermineIndexCercle(oCreePoint.GetControl(&quot;ListBox2&quot;).SelectedItem)
		
		R = Cercles(I1).Rayon
		S = Cercles(I2).Rayon
		
		XR =  Cercles(I1).X
		YR =  Cercles(I1).Y
		XS =  Cercles(I2).X
		YS =  Cercles(I2).Y
		
		
		&apos;Calcul de la distance entre les centres
		D = ((XR-XS)^2+(YR-YS)^2)^(1/2)
		
		X1 = abs(R-S)
		X2 = S+R
		
		&apos;Test vérifiant l&apos;existence de points d&apos;intersections
		If ((D&lt;X1) OR (D&gt;X2) OR (XR=XS AND YR=YS)) Then
			Avertir(263)
			bError = true
			goto finb:
		Endif

		&apos;Calcul des coordonnées dans l&apos;ancien repère (celui du cercle)
		X1 = (R^2+D^2-S^2)/(2*D)
		X2 = X1
		
		Y1 = (R^2-X1^2)^(0.5)
		Y2 = - Y1
		
		
		XAtemp = X1*(XS-XR)/D + Y1*(YR-YS)/D + XR
		YAtemp = X1*(YS-YR)/D + Y1*(XS-XR)/D + YR
		
		XBtemp = X2*(XS-XR)/D + Y2*(YR-YS)/D + XR
		YBtemp = X2*(YS-YR)/D + Y2*(XS-XR)/D + YR
		
		 
		
	Else
	
		Dim a,b,c As Single &apos;Coef droite équation cartesienne
		Dim l As Single
		
		I1 = DetermineIndexCercle(oCreePoint.GetControl(&quot;ListBox1&quot;).SelectedItem)
		
		For I=1 To iNbreDroites
			if Droites(I).Nom= oCreePoint.GetControl(&quot;ListBox2&quot;).SelectedItem Then I2=I
		Next I
		
		R = Cercles(I1).Rayon
		XR =  Cercles(I1).X
		YR =  Cercles(I1).Y
		
		a = Droites(I2).a
		b = Droites(I2).b
		c = Droites(I2).c
		
		l = (-a*XR-b*YR+c)/(a^2+b^2)
		
		D = ((l*a)^2+(l*b)^2)^(0.5) rem D mesure la distance du centre du cercle à la droite
		
		&apos;Test vérifiant l&apos;existence de points d&apos;intersections
		If R &lt; D Then
			Avertir(263)
			bError = true
			goto finb:
		Endif
		
		if D = 0 Then
			X1 = 0
			X2 = 0
			Y1 = R
			Y2 = -R
			D = (a^2+b^2)^(0.5)
			XAtemp = XR - (R*b)/D
			YAtemp = YR + (R*a)/D
			XBtemp = XR + (R*b)/D
			YBtemp = YR - (R*a)/D
		
		Else
			X1 = D
			X2 = D
			Y1 = (R^2-D^2)^(0.5)
			Y2 = -Y1
			
			XAtemp = XR + l*a*X1/D - l*b*Y1/D
			YAtemp = YR + (l*b*X1+l*a*Y1)/D
			XBtemp = XR + l*a*X2/D - l*b*Y2/D
			YBtemp = YR + (l*b*X2+l*a*Y2)/D
		End if
	
	Endif
	
	CreationPointSupp
			
		
	finb:
End Sub

Sub ConstruitPointRepere rem fait les calculs pour placer un point dans un repere
	Dim bVerifPoint,Indice1,Indice2 as Integer
	bVerifPoint=0
	For I=1 To iNbrePoints
	If oCreePoint.GetControl(&quot;ListBox3&quot;).SelectedItem = Points(I).Nom Then
	bVerifPoint=bVerifPoint+1
	Indice1=I
	End If
	If oCreePoint.GetControl(&quot;ListBox4&quot;).SelectedItem = Points(I).Nom Then
	bVerifPoint=bVerifPoint+1
	Indice2=I
	EndIf
	Next I
	If bVerifPoint&lt;&gt;2 Then
		msgbox(sVocab(iLang,247),64,&quot;Dmaths&quot;)
		bError=True
	Else
		XAtemp=Points(Indice1).X+CsngPlus(oCreePoint.GetControl(&quot;TextField5&quot;).Peer.Text)*(Points(Indice2).X-Points(Indice1).X)
		YAtemp=Points(Indice1).Y+CsngPlus(oCreePoint.GetControl(&quot;TextField5&quot;).Peer.Text)*(Points(Indice2).Y-Points(Indice1).Y)
		oCreePoint.GetControl(&quot;ListBox3&quot;).Enable=0
		oCreePoint.GetControl(&quot;TextField5&quot;).Enable=0
		oCreePoint.GetControl(&quot;ListBox4&quot;).Enable=0
		oCreePoint.GetControl(&quot;OptionButton1&quot;).State=0
		FinCreationPoint2(XAtemp,YAtemp)
	EndIf
End Sub

Sub ConstruitIntersectionDroites
	Dim LePoint as Point
	If Not(DetermineSiDroiteExiste(oCreePoint.GetControl(&quot;ListBox6&quot;).SelectedItem)) or Not(DetermineSiDroiteExiste(oCreePoint.GetControl(&quot;ListBox7&quot;).SelectedItem)) or oCreePoint.GetControl(&quot;ListBox6&quot;).SelectedItem = oCreePoint.GetControl(&quot;ListBox7&quot;).SelectedItem Then
	msgbox(sVocab(iLang,241),64,&quot;Dmaths&quot;)
	bError=True
	Goto Fin:
	End if
	
	Dim NumDroite1,NumDroite2 as Integer
	NumDroite1 = DetermineIndexDroite(oCreePoint.GetControl(&quot;ListBox6&quot;).SelectedItem)
	NumDroite2 = DetermineIndexDroite(oCreePoint.GetControl(&quot;ListBox7&quot;).SelectedItem)

	LePoint = CalculIntersectionDroites(Droites(NumDroite1),Droites(NumDroite2))

	If  bError = False Then	FinCreationPoint2(LePoint.X,LePoint.Y)
	Fin:
End Sub

Sub CalculIntersectionDroites(D1 as Droite, D2 as Droite) As Point
	Dim LeBonPoint as Point
	Dim Det, DetX, DetY As Single
	&apos;Print D1.a
	Det = D1.a*D2.b-D1.b*D2.a
	If Det = 0 Then
		msgbox(sVocab(iLang,242),64,&quot;Dmaths&quot;)
		bError=True
		Goto Fin:
	Else 
		DetX = D1.c*D2.b - D1.b*D2.c
		DetY = D1.a*D2.c - D1.c*D2.a
		LeBonPoint.X = DetX/Det
		LeBonPoint.Y = DetY/Det
		CalculIntersectionDroites = LeBonPoint
	Endif
	Fin:
End Sub


Sub ConstruitProjeteOrthogonal
	If Not(DetermineSiPointExiste(oCreePoint.GetControl(&quot;ListBox5&quot;).SelectedItem)) Then
	msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePoint.GetControl(&quot;ListBox5&quot;).SelectedItem+&quot; &quot;+sVocab(iLang,243),64,&quot;Dmaths&quot;)
	bError=True
	Goto Fin:
	End if
	If Not(DetermineSiDroiteExiste(oCreePoint.GetControl(&quot;ListBox8&quot;).SelectedItem)) Then
	msgbox(sVocab(iLang,244)+&quot; &quot;+oCreePoint.GetControl(&quot;ListBox8&quot;).SelectedItem+&quot; &quot;+sVocab(iLang,245),64,&quot;Dmaths&quot;)
	bError=True
	Goto Fin:
	End if
	
	Dim PerPendiculaire As Droite
	Dim LePoint as Point
	Dim NumDroite,NumPoint as Integer
	NumPoint = DetermineIndexPoint(oCreePoint.GetControl(&quot;ListBox5&quot;).SelectedItem)
	NumDroite = DetermineIndexDroite(oCreePoint.GetControl(&quot;ListBox8&quot;).SelectedItem)
	PerPendiculaire.a = (-1)*Droites(NumDroite).b
	PerPendiculaire.b = Droites(NumDroite).a
	PerPendiculaire.c = PerPendiculaire.a*Points(NumPoint).X + PerPendiculaire.b*Points(NumPoint).Y

	LePoint = CalculIntersectionDroites(Droites(NumDroite),PerPendiculaire)

	If  bError = False Then	FinCreationPoint2(LePoint.X,LePoint.Y)
	Fin:
End Sub


Sub PointRepere rem place un point dans un repere
	oCreePoint.GetControl(&quot;TextField4&quot;).Enable=1
	oCreePoint.GetControl(&quot;TextField5&quot;).Enable=1
	oCreePoint.GetControl(&quot;TextField6&quot;).Enable=1
	oCreePoint.GetControl(&quot;TextField2&quot;).Enable=0
	oCreePoint.GetControl(&quot;TextField3&quot;).Enable=0
End Sub

Sub CreationPointSupp

	oCreePointSupp = LoadDialog(&quot;Dmaths&quot;,&quot;CreePointSupp&quot; )
	oCreePointSupp.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	

	If iNbrePoints &gt; 0 Then 
		oCreePointSupp.GetControl(&quot;TextField1&quot;).Peer.Text = oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text
		oCreePointSupp.GetControl(&quot;TextField2&quot;).Peer.Text = IncrementeASCII(oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text,1)		
	Else 
		oCreePointSupp.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;&quot;
		oCreePointSupp.GetControl(&quot;TextField2&quot;).Peer.Text=&quot;&quot;
	End If
	
	oCreePointSupp.GetControl(&quot;Label1&quot;).Peer.Text=XAtemp
	oCreePointSupp.GetControl(&quot;Label2&quot;).Peer.Text=YAtemp
	oCreePointSupp.GetControl(&quot;Label5&quot;).Peer.Text=XBtemp
	oCreePointSupp.GetControl(&quot;Label6&quot;).Peer.Text=YBtemp	
		
	oCreePointSupp.toFront()
	oCreePointSupp.Execute()
End Sub


Sub FinCreationPointSupp
	Dim AngleAtemp, AngleBtemp as Integer
	Dim LaPente as Single
	If DetermineSiObjetExiste(oCreePointSupp.GetControl(&quot;TextField1&quot;).Peer.Text) Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePointSupp.GetControl(&quot;TextField1&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
		Goto Fin:
	End if
	
	If DetermineSiObjetExiste(oCreePointSupp.GetControl(&quot;TextField2&quot;).Peer.Text) Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreePointSupp.GetControl(&quot;TextField2&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
		Goto Fin:
	End if
	
	Rem determine automatiquement la position daffichage des points
	If XAtemp = XBtemp Then
		If YAtemp &gt; YBtemp Then
			AngleAtemp = 2 : AngleBtemp = 6
		Else
			AngleAtemp = 6 : AngleBtemp = 2
		EndIf
	Else
		LaPente = (YBtemp-YAtemp)/(XBtemp-XAtemp)
		LaPente = Atn(LaPente)
		If (LaPente &lt;= pi/8 and LaPente &gt;= -pi/8) Then
			If XAtemp &gt; XBtemp Then 
				AngleAtemp = 0 : AngleBtemp = 4 
			Else
				AngleAtemp = 4 : AngleBtemp = 0
			Endif
		ElseIf (LaPente &gt;= pi/8 and LaPente &lt;= 3*pi/8) Then
			If YAtemp &gt; YBtemp Then 
				AngleAtemp = 1 : AngleBtemp = 5
			Else
				AngleAtemp = 5 : AngleBtemp = 0
			Endif		
		ElseIf (LaPente &gt;= -3*pi/8 and LaPente &lt;= -pi/8) Then
			If YAtemp &gt; YBtemp Then
				AngleAtemp = 3 : AngleBtemp = 7
			Else
				AngleAtemp = 7 : AngleBtemp = 3
			Endif
		Else 
			If YAtemp &gt; YBtemp Then
				AngleAtemp = 2 : AngleBtemp = 6
			Else
				AngleAtemp = 6 : AngleBtemp = 2
			Endif
		Endif
	Endif
		
	
	If oCreePointSupp.Model.CheckBox1.State=1 Then
		oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePointSupp.GetControl(&quot;TextField1&quot;).Peer.Text
		FinCreationPoint2(XAtemp,YAtemp,AngleAtemp)
	Endif
	
	If oCreePointSupp.Model.CheckBox2.State=1 Then
		oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text=oCreePointSupp.GetControl(&quot;TextField2&quot;).Peer.Text
		FinCreationPoint2(XBtemp,YBtemp,AngleBtemp)
	Endif
	
	oCreePointSupp.EndExecute()
	
	Fin:

End Sub

Sub CreationDroite
	oFigure.SetVisible(False)
	oCreeDroite = LoadDialog(&quot;Dmaths&quot;,&quot;CreeDroite&quot; )
	oCreeDroite.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	
		Rem Initialise les listBox Points
	for I=0 to iNbrePoints-1
		oCreeDroite.GetControl(&quot;ListBox1&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeDroite.GetControl(&quot;ListBox2&quot;).addItem(Points(iNbrePoints-I).Nom,I)		
		oCreeDroite.GetControl(&quot;ListBox5&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeDroite.GetControl(&quot;ListBox6&quot;).addItem(Points(iNbrePoints-I).Nom,I)
	next I
	
			Rem Initialise les listBox Droites
	for I=0 to iNbreDroites-1
		oCreeDroite.GetControl(&quot;ListBox3&quot;).addItem(Droites(iNbreDroites-I).Nom,I)
		oCreeDroite.GetControl(&quot;ListBox4&quot;).addItem(Droites(iNbreDroites-I).Nom,I)	
	next I
		
		
			Rem Prenommage de la droite en fonction de ce qui existe
		If iNbreDroites &gt;=1 Then
			If Len(Droites(iNbreDroites).Nom) = 2 Then
			oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=IncrementeASCII(Droites(iNbreDroites).Nom,1)    &apos;Mid(DerniereDroiteCreee,1,1)&amp;temp
			ElseIf (iNbrePoints &gt;= 2 ) Then
			oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;(&quot;&amp; Points(iNbrePoints-1).Nom &amp; Points(iNbrePoints).Nom &amp; &quot;)&quot;
			Endif
		Else
			oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;D1&quot;
		Endif

	
	Rem Disable si il n&apos;y a pas au moins deux points existants (OptionButton1)
	If iNbrePoints &lt; 2 Then
			oCreeDroite.GetControl(&quot;OptionButton1&quot;).setEnable(false)
			oCreeDroite.GetControl(&quot;ListBox5&quot;).setEnable(false)
			oCreeDroite.GetControl(&quot;ListBox6&quot;).setEnable(false)
			oCreeDroite.GetControl(&quot;OptionButton2&quot;).setState(true)
			oCreeDroite.GetControl(&quot;CheckBox2&quot;).setEnable(false)
			oCreeDroite.GetControl(&quot;CheckBox3&quot;).setEnable(false)
	Else 
			oCreeDroite.GetControl(&quot;ListBox5&quot;).selectItemPos(1,true)
			oCreeDroite.GetControl(&quot;ListBox6&quot;).selectItemPos(0,true)
			&apos;Prenommage
		    oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;(&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;)&quot;
	EndIf
	
	Rem Disable en cas d&apos;absence de point et/ou de droite (OptionButton3, OptionButton4) 
	If (iNbreDroites = 0 OR iNbrePoints = 0) Then
		oCreeDroite.GetControl(&quot;ListBox1&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;ListBox2&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;ListBox3&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;ListBox4&quot;).setEnable(false)
	&apos;	oCreeDroite.GetControl(&quot;Label6&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;Label7&quot;).setEnable(false)
	&apos;	oCreeDroite.GetControl(&quot;Label8&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;Label9&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;OptionButton3&quot;).setEnable(false)
		oCreeDroite.GetControl(&quot;OptionButton4&quot;).setEnable(false)
	Else
		oCreeDroite.GetControl(&quot;ListBox1&quot;).selectItemPos(0,true)
		oCreeDroite.GetControl(&quot;ListBox2&quot;).selectItemPos(0,true)
		oCreeDroite.GetControl(&quot;ListBox3&quot;).selectItem(Droites(iNbreDroites).Nom,true)
		oCreeDroite.GetControl(&quot;ListBox4&quot;).selectItem(Droites(iNbreDroites).Nom,true)		
	Endif
	
	
	oCreeDroite.toFront()
	oCreeDroite.Execute()
End Sub

Sub AnnulerCreationDroite
	oCreeDroite.EndExecute()
	oFigure.SetVisible(True)
End Sub

Sub FinCreationDroite &apos;(byVal Optional bPolygone as Boolean) rem bPolygone = True si on trace un polygone
	Dim DX(1),DY(1) as Single rem les points à tracer
	Dim bTracable as Boolean rem True si tracable
	Dim Indice as Integer
	Dim NumPoint,NumDroite as integer
	Dim oShapes,oDroite as Object
	Dim XA,XB,YA,YB as single
	Dim sNature as String
	bTracable = bPolygone
	If DetermineSiObjetExiste(oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text) Then
		If not bPolygone Then msgbox(sVocab(iLang,246),64,&quot;Dmaths&quot;)
		Goto Fin:
	End if
	rem cas ou la droite est définie par deux points
	If oCreeDroite.Model.OptionButton1.State=1 Then
		If Not(DetermineSiPointExiste(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem) and DetermineSiPointExiste(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem))  Then
		msgbox(sVocab(iLang,247),64,&quot;Dmaths&quot;)
		Goto Fin:
		End if
		Indice = DetermineIndexPoint(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)
		XA = Points(Indice).X
		YA = Points(Indice).Y
		Indice = DetermineIndexPoint(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)
		XB = Points(Indice).X
		YB = Points(Indice).Y		
	rem fin cas ou la droite est définie par deux points
	
	rem cas ou la droite est définie par une parallèle 
	ElseIf oCreeDroite.Model.OptionButton3.State=1 Then
		If Not(DetermineSiPointExiste(oCreeDroite.GetControl(&quot;ListBox1&quot;).SelectedItem))  Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox1&quot;).SelectedItem+&quot; &quot;+sVocab(iLang,243),64,&quot;Dmaths&quot;)
		Goto Fin:
		End if
		If Not(DetermineSiDroiteExiste(oCreeDroite.GetControl(&quot;ListBox3&quot;).SelectedItem))  Then
		msgbox(sVocab(iLang,244)+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox3&quot;).SelectedItem+&quot; &quot;+sVocab(iLang,245),64,&quot;Dmaths&quot;)
		Goto Fin:
		End if
		For I=1 To iNbrePoints
		IF oCreeDroite.GetControl(&quot;ListBox1&quot;).SelectedItem = Points(I).Nom Then NumPoint = I
		Next I
		For I=1 To iNbreDroites
		IF oCreeDroite.GetControl(&quot;ListBox3&quot;).SelectedItem = Droites(I).Nom Then NumDroite = I
		Next I	
	rem fin cas ou la droite est définie par une parallèle
	
	rem cas ou la droite est définie par une perpendiculaire 
	ElseIf oCreeDroite.Model.OptionButton4.State=1 Then
		If Not(DetermineSiPointExiste(oCreeDroite.GetControl(&quot;ListBox2&quot;).SelectedItem))  Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox2&quot;).SelectedItem+&quot; &quot;+sVocab(iLang,243),64,&quot;Dmaths&quot;)
		Goto Fin:
		End if
		If Not(DetermineSiDroiteExiste(oCreeDroite.GetControl(&quot;ListBox4&quot;).SelectedItem))  Then
		msgbox(sVocab(iLang,244)+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox4&quot;).SelectedItem+&quot; &quot;+sVocab(iLang,245),64,&quot;Dmaths&quot;)
		Goto Fin:
		End if
		For I=1 To iNbrePoints
		IF oCreeDroite.GetControl(&quot;ListBox2&quot;).SelectedItem = Points(I).Nom Then NumPoint = I
		Next I
		For I=1 To iNbreDroites
		IF oCreeDroite.GetControl(&quot;ListBox4&quot;).SelectedItem = Droites(I).Nom Then NumDroite = I
		Next I
	EndIf
	rem fin cas ou la droite est définie par une perpendiculaire
	
	Indice = 0
	iNbreDroites = iNbreDroites+1	
		
	If oCreeDroite.Model.OptionButton2.State=1 Then	 rem droite définie par son équation
		If oCreeDroite.GetControl(&quot;TextField4&quot;).Peer.Text&lt;&gt;&quot;&quot; Then
		Droites(iNbreDroites).a = 1
		Droites(iNbreDroites).b = 0
		Droites(iNbreDroites).c = Csng(oCreeDroite.GetControl(&quot;TextField4&quot;).Peer.Text)
		Else
		Droites(iNbreDroites).a = (-1)*Csng(oCreeDroite.GetControl(&quot;TextField5&quot;).Peer.Text)
		Droites(iNbreDroites).b = 1
		Droites(iNbreDroites).c = Csng(oCreeDroite.GetControl(&quot;TextField6&quot;).Peer.Text)
		EndIf
	ElseIf oCreeDroite.Model.OptionButton3.State=1 Then rem droite définie par une parallèle
		Droites(iNbreDroites).a = Droites(NumDroite).a
		Droites(iNbreDroites).b = Droites(NumDroite).b
		Droites(iNbreDroites).c = Droites(NumDroite).a*Points(NumPoint).X + Droites(NumDroite).b*Points(NumPoint).Y
	ElseIf oCreeDroite.Model.OptionButton4.State=1 Then rem droite définie par une perpendiculaire
		Droites(iNbreDroites).a = Droites(NumDroite).b
		Droites(iNbreDroites).b = (-1)*Droites(NumDroite).a
		Droites(iNbreDroites).c = Droites(NumDroite).b*Points(NumPoint).X - Droites(NumDroite).a*Points(NumPoint).Y
	Else rem droite définie par 2 points
		If XA=XB Then
		Droites(iNbreDroites).a = 1
		Droites(iNbreDroites).b = 0
		Droites(iNbreDroites).c = XA
		Else
		Droites(iNbreDroites).a = (YA-YB)/(XB-XA)
		Droites(iNbreDroites).b = 1
		Droites(iNbreDroites).c = YA-((YB-YA)/(XB-XA))*XA
		EndIf
	Endif

	If Droites(iNbreDroites).b &lt;&gt; 0 Then rem droite non parallèle à l&apos;axe des ordonnées
		If Indice&lt;=1 and ((Droites(iNbreDroites).a*XminiF+Droites(iNbreDroites).b*YminiF-Droites(iNbreDroites).c)*(Droites(iNbreDroites).a*XminiF+Droites(iNbreDroites).b*YmaxiF-Droites(iNbreDroites).c) &lt;=0) Then
			bTracable=True
			DX(Indice)=XminiF
			DY(Indice)=((-1)*Droites(iNbreDroites).a*XminiF+Droites(iNbreDroites).c)/Droites(iNbreDroites).b
			Indice=Indice+1
		&apos;	Print 1
		EndIf	
		If Indice&lt;=1 and ((Droites(iNbreDroites).a*XmaxiF+Droites(iNbreDroites).b*YminiF-Droites(iNbreDroites).c)*(Droites(iNbreDroites).a*XmaxiF+Droites(iNbreDroites).b*YmaxiF-Droites(iNbreDroites).c) &lt;=0) Then
			bTracable=True
			DX(Indice)=XmaxiF
			DY(Indice)=((-1)*Droites(iNbreDroites).a*XmaxiF+Droites(iNbreDroites).c)/Droites(iNbreDroites).b
			Indice=Indice+1	
		&apos;	Print 2		
		EndIf
		If Droites(iNbreDroites).a &lt;&gt; 0 Then
		If Indice&lt;=1 and ((Droites(iNbreDroites).a*XminiF+Droites(iNbreDroites).b*YminiF-Droites(iNbreDroites).c)*(Droites(iNbreDroites).a*XmaxiF+Droites(iNbreDroites).b*YminiF-Droites(iNbreDroites).c) &lt;0) Then
			bTracable=True
			DX(Indice) = (Droites(iNbreDroites).c-YMiniF)/Droites(iNbreDroites).a
			DY(Indice) = YminiF
			Indice=Indice+1
		&apos;	Print 3
		EndIf
		If Indice&lt;=1 and ((Droites(iNbreDroites).a*XminiF+Droites(iNbreDroites).b*YmaxiF-Droites(iNbreDroites).c)*(Droites(iNbreDroites).a*XmaxiF+Droites(iNbreDroites).b*YmaxiF-Droites(iNbreDroites).c) &lt;=0) Then
			bTracable=True
			DX(Indice) = (Droites(iNbreDroites).c-YMaxiF)/Droites(iNbreDroites).a
			DY(Indice) = YmaxiF
			Indice=Indice+1	
		&apos;	Print 4		
		EndIf
		EndIf
	Elseif  (Droites(iNbreDroites).c &gt;= XminiF and Droites(iNbreDroites).c &lt;= XmaxiF) Then
		bTracable=True
		DX(0)=Droites(iNbreDroites).c
		DY(0)=YminiF
		DX(1)=Droites(iNbreDroites).c
		DY(1)=YMaxiF	
	End If
	
	If bTracable=True Then
		If oCreeDroite.Model.CheckBox2.State=1 Then
			DX(0)=XA
			DY(0)=YA
			DX(1)=XB
			DY(1)=YB
			sNature=sVocab(iLang,248)+&quot; &quot;
		Elseif oCreeDroite.Model.CheckBox3.State=1 Then
			If (XB-XA)*(DX(0)-XA)&gt;0 or (XA=XB and (YB-YA)*(DY(0)-YA)&gt;0) Then
		 	DX(1)=XA
		 	DY(1)=YA
		 	Else
		 	DX(0)=XA
		 	DY(0)=YA
		 	Endif
		 	sNature=sVocab(iLang,249)+&quot; &quot;
		Else
			sNature=sVocab(iLang,244)+&quot; &quot;
		End If
		oShapes = createUnoService(&quot;com.sun.star.drawing.ShapeCollection&quot;)
		oDroite = CreateMarque(oDocumentF,oPageF,1000*(2+(DX(0)-XMiniF)/NUXF),1000*(2+(YmaxiF-DY(0))/NUYF),1000*(2+(DX(1)-XMiniF)/NUXF),1000*(2+(YmaxiF-DY(1))/NUYF),0,False)
		oShapes.Add(oDroite)
		&apos;CorrigeLeBugPosition(oDroite)
		oFigure.GetControl(&quot;ListBox2&quot;).Additem(sNature+oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text,iNbreDessinFait)
		oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(iNbreDessinFait,True)
		iNbreDessinFait=iNbreDessinFait+1
	Else
		msgbox(sVocab(iLang,250),64,&quot;Dmaths&quot;)
		sNature=sVocab(iLang,244)+&quot; &quot;
		oFigure.GetControl(&quot;ListBox2&quot;).Additem(sNature+oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text,oFigure.GetControl(&quot;ListBox2&quot;).GetItemCount())
		oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(oFigure.GetControl(&quot;ListBox2&quot;).GetItemCount()-1,True)
		oCreeDroite.Model.CheckBox1.State=0
	Endif
	
	Droites(iNbreDroites).Nom = oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text
	
	rem marquage de la droite
	If oCreeDroite.Model.CheckBox1.State=1 Then
		Dim oNomDroite as Object
		Dim aPosDroites(iNbreDroites) As New com.sun.star.awt.Point
		Dim Xmarque,Ymarque as Single
		Xmarque=DX(0)+CsngPlus(oCreeDroite.GetControl(&quot;TextField11&quot;).Peer.Text)*(DX(1)-DX(0))
		Ymarque=DY(0)+CsngPlus(oCreeDroite.GetControl(&quot;TextField11&quot;).Peer.Text)*(DY(1)-DY(0))
		oNomDroite = oDocumentF.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
		oNomDroite.TextAutoGrowWidth  = True
		oNomDroite.TextAutoGrowHeight  = True
		aPosDroites(iNbreDroites).x=1000*(2+(Xmarque-XMiniF)/NUXF)-oCreeDroite.Model.OptionButton5.State*1600
		&apos; marquage droite
		If Droites(iNbreDroites).b &lt;&gt; 0 Then
		aPosDroites(iNbreDroites).y=1000*(2+(YmaxiF-Ymarque)/NUYF)+200*Cos(Atn(-Droites(iNbreDroites).a/Droites(iNbreDroites).b)*(oCreeDroite.Model.OptionButton6.State-oCreeDroite.Model.OptionButton5.State)
		Else
		aPosDroites(iNbreDroites).y=1000*(2+(YmaxiF-Ymarque)/NUYF)
		Endif
		oNomDroite.Position=aPosDroites(iNbreDroites)
		oPageF.add(oNomDroite)
		oNomDroite.String = oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text
		If Len(oNomDroite.String) &lt;= 3 Then oNomDroite.CharPosture = com.sun.star.awt.FontSlant.ITALIC
		Rem On règle la police et la taille des noms de points
		If Not IsNull(sFonteName) Then oNomDroite.CharFontName = sFonteName
		If Not IsNull(iFonteTaille) Then oNomDroite.CharHeight = iFonteTaille
		regleIndice(oNomDroite)
		If oCreeDroite.Model.OptionButton5.State=1 Then oNomDroite.ParaAdjust=com.sun.star.style.ParagraphAdjust.RIGHT
		oShapes.add(oNomDroite)
		oPageF.Group(oShapes)
	Endif
	rem fin du marquage
	
	oCreeDroite.EndExecute()
	oFigure.SetVisible(True)
	Fin:
	MAJoFigure
End Sub


Sub CreationRepere
	oFigure.SetVisible(False)
	oRepfonctions = LoadDialog(&quot;Dmaths&quot;,&quot;Repfonctions&quot; )
	oRepfonctions.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	oOptions = LoadDialog(&quot;Dmaths&quot;,&quot;Options&quot;)
	Nbrecourbes=0
	bDiagbox=False
	oRepfonctions.SetTitle(&quot;Dmaths: &quot;+sVocab(iLang,251))
	oRepfonctions.GetControl(&quot;TextField4&quot;).Peer.Text=oFigure.GetControl(&quot;TextField5&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField5&quot;).Peer.Text=oFigure.GetControl(&quot;TextField6&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField13&quot;).Peer.Text=oFigure.GetControl(&quot;TextField1&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField14&quot;).Peer.Text=oFigure.GetControl(&quot;TextField2&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField7&quot;).Peer.Text=oFigure.GetControl(&quot;TextField3&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField8&quot;).Peer.Text=oFigure.GetControl(&quot;TextField4&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField1&quot;).Peer.Text = &quot;0&quot;
	oRepfonctions.getControl(&quot;CheckBox5&quot;).visible = False
	oRepfonctions.getControl(&quot;CheckBox1&quot;).visible = False
	oRepfonctions.getControl(&quot;FrameControl3&quot;).visible = False
	oRepfonctions.getControl(&quot;FrameControl4&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField17&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField1&quot;).visible = False
	oRepfonctions.getControl(&quot;CheckBox9&quot;).visible = False
	oRepfonctions.getControl(&quot;Label6&quot;).visible = False
	oRepfonctions.getControl(&quot;Label7&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField4&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField5&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField2&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField3&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField2&quot;).Text = Cstr(NUXF)
	oRepfonctions.getControl(&quot;TextField3&quot;).Text = CSTR(NUYF)
	oRepfonctions.getControl(&quot;Label12&quot;).visible = False
	oRepfonctions.getControl(&quot;Label13&quot;).visible = False
	oRepfonctions.getControl(&quot;Label14&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField10&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField11&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField12&quot;).visible = False
	oRepfonctions.getControl(&quot;CommandButton4&quot;).visible = False
	oRepfonctions.getControl(&quot;CommandButton5&quot;).visible = False
	oRepfonctions.getControl(&quot;CommandButton6&quot;).visible = False
	oRepfonctions.getControl(&quot;CommandButton7&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField7&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField8&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField13&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField14&quot;).enable = False
	oRepfonctions.getControl(&quot;CheckBox8&quot;).State = 0
	oRepfonctions.getControl(&quot;CheckBox8&quot;).visible = False
	oRepfonctions.Execute()
End Sub

Sub CreationCourbe
	bCourbe=True
	oFigure.SetVisible(False)
	oRepfonctions = LoadDialog(&quot;Dmaths&quot;,&quot;Repfonctions&quot; )
	oRepfonctions.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
	oOptions = LoadDialog(&quot;Dmaths&quot;,&quot;Options&quot;)
	Nbrecourbes=0
	bDiagbox=False
	oRepfonctions.GetControl(&quot;TextField4&quot;).Peer.Text=oFigure.GetControl(&quot;TextField5&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField5&quot;).Peer.Text=oFigure.GetControl(&quot;TextField6&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField13&quot;).Peer.Text=oFigure.GetControl(&quot;TextField1&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField14&quot;).Peer.Text=oFigure.GetControl(&quot;TextField2&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField7&quot;).Peer.Text=oFigure.GetControl(&quot;TextField3&quot;).Peer.Text
	oRepfonctions.GetControl(&quot;TextField8&quot;).Peer.Text=oFigure.GetControl(&quot;TextField4&quot;).Peer.Text
	oRepfonctions.getControl(&quot;CheckBox5&quot;).visible = False
	oRepfonctions.getControl(&quot;CheckBox1&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField2&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField3&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField2&quot;).Text = Cstr(NUXF)
	oRepfonctions.getControl(&quot;TextField3&quot;).Text = CSTR(NUYF)
	oRepfonctions.getControl(&quot;TextField7&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField8&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField13&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField14&quot;).enable = False
	oRepfonctions.getControl(&quot;TextField15&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField16&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField6&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField9&quot;).visible = False
	oRepfonctions.getControl(&quot;Label1&quot;).visible = False
	oRepfonctions.getControl(&quot;Label17&quot;).visible = False
	oRepfonctions.getControl(&quot;Label8&quot;).visible = False
	oRepfonctions.getControl(&quot;Label11&quot;).visible = False
	oRepfonctions.getControl(&quot;Label13&quot;).visible = False
	oRepfonctions.getControl(&quot;Label14&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField11&quot;).visible = False
	oRepfonctions.getControl(&quot;TextField12&quot;).visible = False
	oRepfonctions.getControl(&quot;CheckBox2&quot;).Visible = False
	oRepfonctions.getControl(&quot;CheckBox4&quot;).Visible = False
	oRepfonctions.getControl(&quot;CheckBox6&quot;).Visible = False
	oRepfonctions.getControl(&quot;CheckBox7&quot;).Visible = False
	oRepfonctions.getControl(&quot;CheckBox3&quot;).Visible = False
	oRepfonctions.getControl(&quot;CheckBox10&quot;).Visible = False
	oRepfonctions.getControl(&quot;CheckBox2&quot;).State = 0
	oRepfonctions.getControl(&quot;CheckBox4&quot;).State = 0
	oRepfonctions.getControl(&quot;CheckBox6&quot;).State = 0
	oRepfonctions.getControl(&quot;CheckBox7&quot;).State = 0
	oRepfonctions.getControl(&quot;OptionButton1&quot;).Visible = False
	oRepfonctions.getControl(&quot;OptionButton2&quot;).Visible = False
	oRepfonctions.getControl(&quot;OptionButton3&quot;).Visible = False
	oRepfonctions.getControl(&quot;OptionButton4&quot;).Visible = False
	oRepfonctions.getControl(&quot;OptionButton5&quot;).Visible = False
	oRepfonctions.getControl(&quot;OptionButton6&quot;).Visible = False
	oRepfonctions.GetControl(&quot;TextField4&quot;).Peer.Text=&quot;0&quot;
	oRepfonctions.GetControl(&quot;TextField5&quot;).Peer.Text=&quot;2&quot;
	oRepfonctions.Execute()
End Sub

Sub CreationCercle

	
	
	If iNbrePoints = 0 Then
		msgBox(sVocab(iLang,261),64,&quot;Dmaths&quot;)
		Goto fin
	Endif
	
	oFigure.SetVisible(False)
	
	oCreeCercle = LoadDialog(&quot;Dmaths&quot;,&quot;CreeCercle&quot; )
	oCreeCercle.setPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)

	If iNbreCercles &gt;= 1 Then
		If Len(Cercles(iNbreCercles).Nom) = 2 Then
			oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text = IncrementeASCII(Cercles(iNbreCercles).Nom,1)
		Else 
			oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;C1&quot;
		EndIf
	Endif

	for I=0 to iNbrePoints-1
		oCreeCercle.GetControl(&quot;ListBox1&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeCercle.GetControl(&quot;ListBox2&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeCercle.GetControl(&quot;ListBox3&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeCercle.GetControl(&quot;ListBox4&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeCercle.GetControl(&quot;ListBox5&quot;).addItem(Points(iNbrePoints-I).Nom,I)
		oCreeCercle.GetControl(&quot;ListBox6&quot;).addItem(Points(iNbrePoints-I).Nom,I)
	next I
	
	oCreeCercle.GetControl(&quot;ListBox1&quot;).selectItemPos(0,true)
	oCreeCercle.GetControl(&quot;ListBox2&quot;).selectItemPos(0,true)

	&apos;OptionButton2
	If oCreeCercle.GetControl(&quot;ListBox2&quot;).ItemCount &gt; 1 Then 
		oCreeCercle.GetControl(&quot;ListBox2&quot;).selectItemPos(0,true)
		oCreeCercle.GetControl(&quot;ListBox3&quot;).selectItemPos(1,true)
	Else 
		oCreeCercle.GetControl(&quot;OptionButton2&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;ListBox2&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;ListBox3&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;Label2&quot;).setEnable(false)
	Endif
	
	&apos;OptionButton3
	If OCreeCercle.GetControl(&quot;ListBox4&quot;).ItemCount &gt; 2 Then
		oCreeCercle.GetControl(&quot;ListBox2&quot;).selectItemPos(0,true)
		oCreeCercle.GetControl(&quot;ListBox2&quot;).selectItemPos(1,true)
		oCreeCercle.GetControl(&quot;ListBox2&quot;).selectItemPos(2,true)	
	Else
		oCreeCercle.GetControl(&quot;ListBox4&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;OptionButton3&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;TextField2&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;CheckBox3&quot;).setEnable(false)
	Endif
	
		&apos;OptionButton12
	If iNbrePoints &lt;= 1 Then
		oCreeCercle.GetControl(&quot;ListBox5&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;ListBox6&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;OptionButton12&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;CheckBox4&quot;).setEnable(false)
		oCreeCercle.GetControl(&quot;TextField4&quot;).setEnable(false)
	Else
		oCreeCercle.GetControl(&quot;ListBox5&quot;).selectItemPos(0,true)
		oCreeCercle.GetControl(&quot;ListBox6&quot;).selectItemPos(1,true)
	Endif
	
	oCreeCercle.toFront()
	oCreeCercle.Execute()	
		
	fin:
	
End Sub


Sub AnnulerCreationCercle
	oCreeCercle.EndExecute()
	oFigure.SetVisible(True)
End Sub


Sub FinCreationCercle

	Dim XA, YA, XB, YB, XC, YC, ALPHA, BETA, DET, DETX, DETY As Single

	If DetermineSiObjetExiste(oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text) Then
		msgbox(sVocab(iLang,260)+&quot; &quot;+oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
		Goto Fin:
	Endif
	
	
	If oCreeCercle.Model.OptionButton3.State=1 Then
	
		Dim selectedPoints(100) AS String
		selectedPoints = oCreeCercle.GetControl(&quot;ListBox4&quot;).getSelectedItems()
	
		If Ubound(selectedPoints) &lt;&gt; 2 Then
			Avertir(264)
			goto Fin:
		End if
		
	End if
	
	If oCreeCercle.Model.OptionButton3.State=1 AND oCreeCercle.GetControl(&quot;CheckBox3&quot;).getState()=1 AND DetermineSiObjetExiste(oCreeCercle.GetControl(&quot;TextField2&quot;).Peer.Text) Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreeCercle.GetControl(&quot;TextField2&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
		Goto Fin:
	Endif
	
	If oCreeCercle.Model.OptionButton12.State=1 AND oCreeCercle.GetControl(&quot;CheckBox4&quot;).getState()=1 AND DetermineSiObjetExiste(oCreeCercle.GetControl(&quot;TextField4&quot;).Peer.Text) Then
		msgbox(sVocab(iLang,237)+&quot; &quot;+oCreeCercle.GetControl(&quot;TextField4&quot;).Peer.Text+&quot; &quot;+sVocab(iLang,238),64,&quot;Dmaths&quot;)
		Goto Fin:
	Endif
	

	iNbreCercles = iNbreCercles+1
	Cercles(iNbreCercles).Nom = oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text
	iNbreDessinFait = iNbreDessinFait+1
	
	
	If oCreeCercle.Model.OptionButton1.State=1 Then rem à partir de 2 points
		rem	CalculRayon

		Cercles(iNbreCercles).Centre = oCreeCercle.GetControl(&quot;ListBox1&quot;).SelectedItem
		Cercles(iNbreCercles).Rayon = csng(oCreeCercle.GetControl(&quot;TextField3&quot;).Peer.Text)
		
		Cercles(iNbreCercles).X = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox1&quot;).SelectedItem)).X
		Cercles(iNbreCercles).Y = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox1&quot;).SelectedItem)).Y
		
	Elseif oCreeCercle.Model.OptionButton2.State=1 Then rem à partir de 2 points

		Cercles(iNbreCercles).Centre = oCreeCercle.GetControl(&quot;ListBox2&quot;).SelectedItem
		Cercles(iNbreCercles).X = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox2&quot;).SelectedItem)).X
		Cercles(iNbreCercles).Y = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox2&quot;).SelectedItem)).Y
		
		XA =  Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox2&quot;).SelectedItem)).X
		YA =  Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox2&quot;).SelectedItem)).Y
		XB =  Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox3&quot;).SelectedItem)).X
		YB =  Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox3&quot;).SelectedItem)).Y
		
		Cercles(iNbreCercles).Rayon = ((XA-XB)^2+(YA-YB)^2)^(1/2)


	Elseif oCreeCercle.Model.OptionButton12.State=1 Then rem de diametre données
		

		XA = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox5&quot;).SelectedItem)).X
		YA = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox5&quot;).SelectedItem)).Y
		XB = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox6&quot;).SelectedItem)).X
		YB = Points(DetermineIndexPoint(oCreeCercle.GetControl(&quot;ListBox6&quot;).SelectedItem)).Y

	
		Cercles(iNbreCercles).X = (XA+XB)/2
		Cercles(iNbreCercles).Y = (YA+YB)/2
		Cercles(iNbreCercles).Rayon = (((XA-XB)^2+(YA-YB)^2)^(1/2))/2
		
		If (oCreeCercle.GetControl(&quot;CheckBox4&quot;).getState()=1  AND Len(oCreeCercle.GetControl(&quot;TextField4&quot;).Peer.Text) &lt;&gt;0 ) Then
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text = oCreeCercle.GetControl(&quot;TextField4&quot;).Peer.Text
			Cercles(iNbreCercles).Centre = oCreeCercle.GetControl(&quot;TextField4&quot;).Peer.Text
			FinCreationPoint2((XA+XB)/2,(YA+YB)/2)
		Else
			Cercles(iNbreCercles).Centre = &quot;&quot;
		Endif
		
	Elseif oCreeCercle.Model.OptionButton3.State = 1 Then rem à partir de 3 points


		XA = Points(DetermineIndexPoint(selectedPoints(0))).X
		YA = Points(DetermineIndexPoint(selectedPoints(0))).Y
		XB = Points(DetermineIndexPoint(selectedPoints(1))).X
		YB = Points(DetermineIndexPoint(selectedPoints(1))).Y
		XC = Points(DetermineIndexPoint(selectedPoints(2))).X
		YC = Points(DetermineIndexPoint(selectedPoints(2))).Y
	
		Rem test d&apos;alignement (produit scalaire)
		If ((XA-XB)*(YB-YC)-(YA-YB)*(XB-XC)) = 0 Then
				msgbox(sVocab(iLang,262))
				Cercles(iNbreCercles).Nom = &quot;&quot;
				iNbreCercles = iNbreCercles-1
				iNbreDessinFait = iNbreDessinFait-1
				goto Fin
		Endif
	
		ALPHA = ((XB^2-XA^2)+(YB^2-YA^2))/2
		BETA = ((XC^2-XA^2)+(YC^2-YA^2))/2
		DET = (XB-XA)*(YC-YA)-(XC-XA)*(YB-YA)
		DETX = ALPHA*(YC-YA)-BETA*(YB-YA) &apos;Coordonnées du centre en X : DETX/DET
		DETY = BETA*(XB-XA)-ALPHA*(XC-XA) &apos;Coordonnées du centre en Y: DETY/DET


		Cercles(iNbreCercles).X = DETX/DET
		Cercles(iNbreCercles).Y = DETY/DET
		Cercles(iNbreCercles).Rayon = ((XA-DETX/DET)^2+(YA-DETY/DET)^2)^(1/2)
		
		If (oCreeCercle.GetControl(&quot;CheckBox3&quot;).getState()=1  AND Len(oCreeCercle.GetControl(&quot;TextField2&quot;).Peer.Text) &lt;&gt;0 ) Then
			oCreePoint.GetControl(&quot;TextField1&quot;).Peer.Text = oCreeCercle.GetControl(&quot;TextField2&quot;).Peer.Text
			Cercles(iNbreCercles).Centre = oCreeCercle.GetControl(&quot;TextField2&quot;).Peer.Text
			FinCreationPoint2(DETX/DET,DETY/DET)
		Else
			Cercles(iNbreCercles).Centre = &quot;&quot;
		Endif
		
		
	Endif
	
	Rem Initialise le centre du cercle
	Cercles(iNbreCercles).Centre = CentreCercle
	
	Dim  R as single
	Dim monCercle, oShapes as Object
	Dim iAngle as Integer
	
	iAngle = DetermineiAngle(oCreeCercle) Rem determine l&apos;angle d&apos;affichage du nom du cercle

	oShapes = createUnoService(&quot;com.sun.star.drawing.ShapeCollection&quot;)	
	xa = Cercles(iNbreCercles).X
	ya = Cercles(iNbreCercles).Y
	R = Cercles(iNbreCercles).Rayon
	oCercles = createUnoService(&quot;com.sun.star.drawing.ShapeCollection&quot;)

	If (xa+R &lt;= XmaxiF and xa-R &gt;= XminiF and ya+R &lt;= YmaxiF and ya-R &gt;= YminiF) Then
		monCercle =	InsereUnCercle(xa,ya,R)
		oShapes.add(monCercle)
	Elseif msgbox(sVocab(iLang,266)+Chr(13)+sVocab(iLang,267),256+36,&quot;Dmaths&quot;) = 6 Then 
		monCercle =	InsereUnCercle(xa,ya,R)
		oShapes.add(monCercle)
	Else 
		iAngle = CorrigeiAngle(Cercles(iNbreCercles),iAngle)
		rem la ligne ci-dessus permet de corriger l&apos;affichage du nom du cercle si elle est en dehors
		rem du rectangle et mal placée
		Dim t as Integer
		t = 0
		Do	 
		If t &lt;= 359 Then monCercle = InsereUnCercle(xa,ya,R,t)
			t = t + 1
		oShapes.add(monCercle)
		Loop while t&lt;=359		
	Endif

	If oCreeCercle.Model.CheckBox1.State=1 Then Rem ecrit le nom du cercle
			Dim oNomPoints as Object
			Dim aPosPoints As New com.sun.star.awt.Point		
			oNomPoints = oDocumentF.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
			oNomPoints.TextAutoGrowWidth  = True
			oNomPoints.TextAutoGrowHeight  = True
	
			aPosPoints.x = 1000*(2+(xa-XMiniF)/NUXF)+50+((R*1000)/NUXF+iAngle*100)*cos((3.141592*iAngle)/4)&apos; 
			aPosPoints.y = 1000*(2+(YmaxiF-ya)/NUYF)-600-((R*1000)/NUYF+iAngle*100)*sin((3.141592*iAngle)/4)&apos;
			oNomPoints.Position = aPosPoints
			oPageF.add(oNomPoints)
			oNomPoints.String = oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text
			oNomPoints.CharPosture = com.sun.star.awt.FontSlant.ITALIC			
			Rem On règle la police et la taille des noms de points
			If Not IsNull(sFonteName) Then oNomPoints.CharFontName = sFonteName
			If Not IsNull(iFonteTaille) Then oNomPoints.CharHeight = iFonteTaille
			regleIndice(oNomPoints)
			oShapes.add(oNomPoints)	
		Endif

	oPageF.Group(oShapes)
		
	oFigure.GetControl(&quot;ListBox2&quot;).Additem(sVocab(iLang,260) &amp; oCreeCercle.GetControl(&quot;TextField1&quot;).Peer.Text,iNbreDessinFait)
	oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(oFigure.GetControl(&quot;ListBox2&quot;).ItemCount-1,True)

	oCreeCercle.EndExecute()
	oFigure.SetVisible(True)
		
		
	Fin:
	bError=False
	MAJoFigure
End Sub


Function InsereUnCercle (X,Y,R as Single,Optional ap as Integer) as Object
	Dim leCercle as Object
	Dim dimensionsForme As New com.sun.star.awt.Size
	Dim positionForme As New com.sun.star.awt.Point
	leCercle = oDocumentF.createInstance(&quot;com.sun.star.drawing.EllipseShape&quot;)
	dimensionsForme.Width = (R *1000 * 2) / NUXF
	dimensionsForme.Height = (R *1000 * 2) / NUYF
	positionForme.x = 1000*(2+(X-R-XMiniF)/NUXF)
	positionForme.y = 1000*(2+(YmaxiF-R-Y)/NUYF)	
	leCercle.Size = dimensionsForme
	leCercle.Position = positionForme
	leCercle.CircleStartAngle = 0
	leCercle.CircleEndAngle = 36000
	If oCreeCercle.Model.CheckBox2.State=0 Then
			leCercle.FillStyle = 0
	Else
			leCercle.FillStyle = 1
	Endif
	leCercle.CircleKind = com.sun.star.drawing.CircleKind.FULL
	If Not IsMissing(ap) Then
			leCercle.CircleKind = com.sun.star.drawing.CircleKind.ARC
			Do until PointInterieurRectangle(X+R*cos(ap*pi/180),Y+R*sin(ap*pi/180))
			if ap = 360 then Exit Function
			ap = ap + 1
			Loop 
		&apos;	Print &quot;1&quot;,ap
			leCercle.CircleStartAngle = ap*100
			Do while (PointInterieurRectangle(X+R*cos(ap*pi/180),Y+R*sin(ap*pi/180)) and ap&lt;=360)
			ap = ap + 1
			Loop 
		&apos;	Print &quot;2&quot;,ap
			leCercle.CircleEndAngle = (ap-1)*100	
	Endif
	rem donne epaisseur du trait
	leCercle.LineWidth = Csng(oOptions.getControl(&quot;TextField1&quot;).Peer.Text)
	oPageF.add(leCercle)
	InsereUnCercle = leCercle
End Function


Function DetermineSiObjetExiste(sNom as String)
	Dim bExiste as Boolean
	For I=1 To iNbreDroites
		If sNom = Droites(I).Nom Then bExiste=True
	Next I
	For I=1 To iNbrePoints
		If sNom = Points(I).Nom Then bExiste=True
	Next I
	For I=1 To iNbreCercles
		If sNom = Cercles(I).Nom Then bExiste=True
	Next I
	DetermineSiObjetExiste=bExiste
End Function	

Function DetermineSiPointExiste(sNom as String)
	Dim bExiste as Boolean
	For I=1 To iNbrePoints
		If sNom = Points(I).Nom Then bExiste=True
	Next I
	DetermineSiPointExiste=bExiste
End Function

Function DetermineSiDroiteExiste(sNom as String)
	Dim bExiste as Boolean
	For I=1 To iNbreDroites
		If sNom = Droites(I).Nom Then bExiste=True
	Next I
	DetermineSiDroiteExiste=bExiste
End Function

Function DetermineSiCercleExiste(sNom as String)
	Dim bExiste as Boolean
	For I=1 To iNbreCercles
		If sNom = Cercles(I).Nom Then bExiste=True
	Next I
	DetermineSiCercleExiste=bExiste
End Function

Function DetermineIndexPoint(sNom as String) as Integer
	Dim pIndex as Integer
	For I=1 To iNbrePoints
		If sNom = Points(I).Nom Then pIndex = I
	Next I
	DetermineIndexPoint = pIndex
End Function

Function DetermineIndexDroite(sNom as String) as Integer
	Dim pIndex as Integer
	For I=1 To iNbreDroites
		If sNom = Droites(I).Nom Then pIndex = I
	Next I
	DetermineIndexDroite = pIndex
End Function



Function DetermineIndexCercle(sNom as String) as Integer
	Dim pIndex as Integer
	For I=1 To iNbreCercles
		If sNom = Cercles(I).Nom Then pIndex = I
	Next I
	DetermineIndexCercle = pIndex
End Function

Sub regleIndice(MonTexte as object)
			carNum = &quot;0123456789&quot;
			carPar = &quot;([])&quot;			
			monCurseur = MonTexte.Text.CreateTextCursor
			monCurseur.collapsetostart()
			For I=1 to Len(MonTexte.String) 			
			monCurseur.goright(1,True)
			If InsTr(carNum,monCurseur.String) &gt; 0 Then			
				monCurseur.CharEscapement = -20
				monCurseur.CharEscapementHeight = 70
				monCurseur.CharPosture = com.sun.star.awt.FontSlant.NONE
			Endif
			If InsTr(carPar,monCurseur.String) &gt; 0 Then			
				monCurseur.CharPosture = com.sun.star.awt.FontSlant.NONE
			Endif
			monCurseur.goright(0,false)		
			Next I
End Sub



Sub Enleve
Dim oEnleve as Object
Dim I as Integer
If oFigure.GetControl(&quot;ListBox2&quot;).ItemCount&gt;0 Then

	Dim selectedObjects(100) AS String
		selectedObjects = oFigure.GetControl(&quot;ListBox2&quot;).getSelectedItems()
	
		If Ubound(selectedObjects) &lt;&gt; 0 Then
			Avertir(377)
			goto Fin
		End if
	
	REM Gestion de la suppression des points
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,237)))=sVocab(iLang,237) Then
		I=1
		Do Until Points(I).Nom = Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,7,Len(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem)-6)  
		I = I+1
		Loop
		For J=I To iNbrePoints-1
			Points(J).Nom = Points(J+1).Nom
			Points(J).X = Points(J+1).X
			Points(J).Y = Points(J+1).Y					
		Next J
	iNbrePoints=iNbrePoints-1
	Endif
	
	REM gestion de la suppression des lignes
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,244)))=sVocab(iLang,244)  Then
		I=1
		Do Until Droites(I).Nom = Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,9,Len(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem)-7) 
		I = I+1
		Loop
		For J=I To iNbreDroites-1
			Droites(J).Nom = Droites(J+1).Nom
			Droites(J).a = Droites(J+1).a
			Droites(J).b = Droites(J+1).b
			Droites(J).c = Droites(J+1).c	
    	Next J
		iNbreDroites=iNbreDroites-1
	Endif

	REM Gestion de la suppression des demi-lignes
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,249)))=sVocab(iLang,249)  Then
		I=1
		Do Until Droites(I).Nom=Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,13,Len(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem)-12) 
		I = I+1
		Loop
		For J=I To iNbreDroites-1
			Droites(J).Nom = Droites(J+1).Nom
			Droites(J).a = Droites(J+1).a
			Droites(J).b = Droites(J+1).b
			Droites(J).c = Droites(J+1).c
    		Next J
		iNbreDroites=iNbreDroites-1
	
	Endif
	
	REM Gestion de la suppression des segments
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,248)))=sVocab(iLang,248)  Then
		I=1
		Do Until Droites(I).Nom=Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,9,Len(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem)-8) 
		I = I+1
		Loop
		For J=I To iNbreDroites-1
			Droites(J).Nom = Droites(J+1).Nom
			Droites(J).a = Droites(J+1).a
			Droites(J).b = Droites(J+1).b
			Droites(J).c = Droites(J+1).c
    	Next J
	iNbreDroites=iNbreDroites-1
	
	Endif
	
		REM Gestion de la suppression des cercles
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,260)))=sVocab(iLang,260)  Then
		I=1
		Do Until Cercles(I).Nom = Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,8,Len(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem)-7) 
		I = I+1
		Loop
		For J=I To iNbreCercles-1
			Cercles(J).Nom = Cercles(J+1).Nom
			Cercles(J).Centre = Cercles(J+1).Centre
			Cercles(J).Rayon = Cercles(J+1).Rayon
			Cercles(J).X = Cercles(J+1).X
			Cercles(J).Y = Cercles(J+1).Y
    	Next J
	iNbreCercles=iNbreCercles-1
	Endif
	
		Rem gestion de la suppression des objets Gdmath 
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,271)))=sVocab(iLang,271)  Then
		iNbreObjetGdmath = iNbreObjetGdmath - 1
	Endif
	
		Rem gestion de la suppression des courbes ou du repère
	If Mid(oFigure.GetControl(&quot;ListBox2&quot;).SelectedItem,1,Len(sVocab(iLang,270)))=sVocab(iLang,270)  Then
		iNumCourbe = iNumCourbe -1	
	Endif
		
	oEnleve = oPageF.GetByIndex(iNbreInitDessin+oFigure.GetControl(&quot;ListBox2&quot;).getSelectedItemPos())
	oPageF.Remove(oEnleve)
	iNbreDessinFait=iNbreDessinFait-1
	
	oFigure.GetControl(&quot;ListBox2&quot;).RemoveItems(oFigure.GetControl(&quot;ListBox2&quot;).getSelectedItemPos(),1)
	oFigure.GetControl(&quot;ListBox2&quot;).SelectItemPos(oFigure.GetControl(&quot;ListBox2&quot;).ItemCount-1,True)
	Fin:
	MAJoFigure
	
End If
End Sub


Sub CorrigeLeBugPosition (oObj as Object)
	If (OOoNumVersion() &gt;= 300) Then 
	&apos;	oObj.HoriOrientPosition = oObj.HoriOrientPosition + (oObj.AnchorPosition.X - 1002)
	Endif
End Sub

Rem Cette fonction gère l&apos;enable ou non de Enleve
Sub MAJoFigure
If oFigure.GetControl(&quot;ListBox2&quot;).ItemCount = 0 Then
	oFigure.GetControl(&quot;ListBox2&quot;).setEnable(false)
	oFigure.GetControl(&quot;Label2&quot;).setEnable(false)
	oFigure.GetControl(&quot;CommandButton3&quot;).setEnable(false)
Else	
	oFigure.GetControl(&quot;ListBox2&quot;).setEnable(true)
	oFigure.GetControl(&quot;Label2&quot;).setEnable(true)
	oFigure.GetControl(&quot;CommandButton3&quot;).setEnable(true)
Endif
End Sub

Rem cette macro active le bouton correspondant
Sub GetFocusOptionButton(oEvt as Object)
	Dim MonBouton as String
	MonBouton = &quot;OptionButton&quot; &amp; oEvt.Source.Model.Tag	
	oEvt.Source.Context.GetControl(MonBouton).setState(true)	
	
	If oEvt.Source.Context.Model.Name = &quot;CreeDroite&quot; Then
	Rem Place des crochets ou des parentheses si besoin
		If  (oCreeDroite.GetControl(&quot;CheckBox2&quot;).getState()=1 AND oCreeDroite.GetControl(&quot;CheckBox3&quot;).getState()=0 AND (oCreeDroite.GetControl(&quot;ListBox5&quot;).hasFocus() OR oCreeDroite.GetControl(&quot;ListBox6&quot;).hasFocus() OR oCreeDroite.GetControl(&quot;OptionButton1&quot;).getState()=true)) Then
					If (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)=0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)=0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+&quot;&quot;+&quot;]&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)=0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)&lt;&gt;0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;]&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)&lt;&gt;0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)=0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+&quot; &quot;+&quot;]&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)&lt;&gt;0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)&lt;&gt;0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;]&quot;
					Endif
					
		Elseif (oCreeDroite.GetControl(&quot;CheckBox2&quot;).getState()=0 AND oCreeDroite.GetControl(&quot;CheckBox3&quot;).getState()=0 AND (oCreeDroite.GetControl(&quot;ListBox5&quot;).hasFocus() OR oCreeDroite.GetControl(&quot;ListBox6&quot;).hasFocus() OR oCreeDroite.GetControl(&quot;OptionButton1&quot;).getState()=true)) Then
			
					If (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)=0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)=0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;(&quot;+&quot;&quot;+&quot;)&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)=0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)&lt;&gt;0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;(&quot;+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;)&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)&lt;&gt;0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)=0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;(&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+&quot; &quot;+&quot;)&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)&lt;&gt;0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)&lt;&gt;0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;(&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;)&quot;
					Endif
					
		Elseif (oCreeDroite.GetControl(&quot;CheckBox2&quot;).getState()=0 AND oCreeDroite.GetControl(&quot;CheckBox3&quot;).getState()=1 AND (oCreeDroite.GetControl(&quot;ListBox5&quot;).hasFocus() OR oCreeDroite.GetControl(&quot;ListBox6&quot;).hasFocus() OR oCreeDroite.GetControl(&quot;OptionButton1&quot;).getState()=true)) Then
					If (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)=0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)=0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+&quot;&quot;+&quot;)&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)=0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)&lt;&gt;0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+&quot; &quot;+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;)&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)&lt;&gt;0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)=0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+&quot; &quot;+&quot;)&quot;
					Elseif (Len(oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem)&lt;&gt;0 AND Len(oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem)&lt;&gt;0) Then
						oCreeDroite.GetControl(&quot;TextField1&quot;).Peer.Text=&quot;[&quot;+oCreeDroite.GetControl(&quot;ListBox5&quot;).SelectedItem+oCreeDroite.GetControl(&quot;ListBox6&quot;).SelectedItem+&quot;)&quot;
					Endif
		Endif
	
		Rem Gere le conflit 1/2 droite segment
		If oEvt.Source.Model.Name = &quot;CheckBox2&quot; Then
			oEvt.Source.Context.GetControl(&quot;CheckBox3&quot;).SetState(0)
		Elseif oEvt.Source.Model.Name = &quot;CheckBox3&quot; Then
			oEvt.Source.Context.GetControl(&quot;CheckBox2&quot;).SetState(0)
		EndIf	
	
	Endif	
End Sub

Sub GereAffichageBoitePolygone(oEvt as Object)
	Dim MonBouton as String
	MonBouton = &quot;OptionButton&quot; &amp; oEvt.Source.Model.Tag
	oEvt.Source.Context.GetControl(MonBouton).setState(true)
	If oEvt.Source.Model.Tag &lt;= 5 Then
		oEvt.Source.Context.GetControl(&quot;TextField2&quot;).Visible = True
		oEvt.Source.Context.GetControl(&quot;Label2&quot;).Visible = false
		oEvt.Source.Context.GetControl(&quot;Label3&quot;).Visible = false
		oEvt.Source.Context.GetControl(&quot;ListBox3&quot;).Visible = false	
	Else
		oEvt.Source.Context.GetControl(&quot;TextField2&quot;).Visible = false
		oEvt.Source.Context.GetControl(&quot;Label2&quot;).Visible = true
		oEvt.Source.Context.GetControl(&quot;Label3&quot;).Visible = true
		oEvt.Source.Context.GetControl(&quot;ListBox3&quot;).Visible = true
	Endif
	If oEvt.Source.Model.Tag = 1 Then
		oEvt.Source.Context.GetControl(&quot;CheckBox1&quot;).Visible = False
		oEvt.Source.Context.GetControl(&quot;ListBox3&quot;).Visible = True	
		oEvt.Source.Context.GetControl(&quot;TextField2&quot;).SetPosSize(Xpos3,Ypos3,36,15,com.sun.star.awt.PosSize.POS)
	Else
		oEvt.Source.Context.GetControl(&quot;CheckBox1&quot;).Visible = True
		oEvt.Source.Context.GetControl(&quot;ListBox3&quot;).Visible = False
		oEvt.Source.Context.GetControl(&quot;TextField2&quot;).SetPosSize(Xpos2,Ypos2,36,15,com.sun.star.awt.PosSize.POS)
	Endif
	If (oEvt.Source.Model.Tag = 2 or oEvt.Source.Model.Tag = 3) Then
		oEvt.Source.Context.GetControl(&quot;TextField3&quot;).Visible = true
	Else
		oEvt.Source.Context.GetControl(&quot;TextField3&quot;).Visible = false
	Endif
End Sub

Function IncrementeASCII(initial As String,rang as Integer)
	Dim ascii as Integer
	If rang &lt;&gt; 0 Then	
		If Len(initial) = 1 Then
			ascii = Asc(initial) : ascii = ascii + rang
			IncrementeASCII = chr(ascii)		
		Elseif Len(initial) = 2 Then
		&apos;Cas ou Len(DernierPoint) = 2, on increment de 1 en ASCII, seulement le deuxieme char. ex D1 -&gt; D2  
			ascii = Asc(Mid(initial,2,1)) :	ascii = ascii + rang
			IncrementeASCII = Mid(initial,1,1) &amp; chr(ascii)
		Endif
	Else
		If Len(initial) = 1 Then
			ascii = Asc(initial) : ascii = ascii + 1
			IncrementeASCII = chr(ascii) &amp; &quot;1&quot;		
		Elseif Len(initial) = 2 Then
		&apos;Cas ou Len(DernierPoint) = 2,  seulement le premier char. ex D1 -&gt; E1  
			ascii = Asc(Mid(initial,1,1)) :	ascii = ascii + 1
			IncrementeASCII = chr(ascii) &amp; &quot;1&quot;
		Endif
	Endif
End Function

Function DetermineiAngle(oMaboite as Object) as Integer
			If oMaboite.Model.Angle2.State=1 Then DetermineiAngle = 2
			If oMaboite.Model.Angle1.State=1 Then DetermineiAngle = 1
			If oMaboite.Model.Angle0.State=1 Then DetermineiAngle = 0
			If oMaboite.Model.Angle7.State=1 Then DetermineiAngle = 7
			If oMaboite.Model.Angle6.State=1 Then DetermineiAngle = 6
			If oMaboite.Model.Angle5.State=1 Then DetermineiAngle = 5
			If oMaboite.Model.Angle4.State=1 Then DetermineiAngle = 4
			If oMaboite.Model.Angle3.State=1 Then DetermineiAngle = 3
End Function

Function CorrigeiAngle(TheCercle as Cercle, iAngle as Integer) as Integer
rem cette macro corrige un affichage hors du rectangle
rem ecrite le 4 septembre 2010
	Dim XP, YP as Single
	Dim iAnglePro,iCompteur as Integer rem iCompteur Compte le nombre de tests faits.
	iAngleePro = iAngle : iCompteur = 0
	XP = TheCercle.X + TheCercle.Rayon*cos((3.141592*iAngleePro)/4)
	YP = TheCercle.Y + TheCercle.Rayon*sin((3.141592*iAngleePro)/4)
	Do until (PointInterieurRectangle(XP,YP) or iCompteur = 8 )
		iAngleePro = (iAngleePro+1) Mod 8
		XP = TheCercle.X + TheCercle.Rayon*cos((3.141592*iAngleePro)/4)
		YP = TheCercle.Y + TheCercle.Rayon*sin((3.141592*iAngleePro)/4)	
		iCompteur = iCompteur + 1
	Loop
	CorrigeiAngle = iAngleePro
End Function



Function DetermineAnglePolaire(X1,Y1,X2,Y2 as Single) as Single rem renvoit entre 0 et 2 pi
	Dim pente,anglepro as Single
	If (X1 = X2 and Y2 &gt; Y1) Then 
		DetermineAnglePolaire = pi/2
	Elseif (X1 = X2 and Y2 &lt; Y1) Then
		DetermineAnglePolaire = 3*pi/2
	Else
		pente = (Y2-Y1)/(X2-X1)
		anglepro = Atn(pente)
		If (X2 &gt; X1 and anglepro &gt;= 0) Then
			DetermineAnglePolaire = anglepro
		Elseif (X2 &gt; X1 and anglepro &lt;0) Then
			DetermineAnglePolaire = anglepro + 2*pi
		Else
			DetermineAnglePolaire = anglepro + pi
		Endif
	Endif
End Function

Function DetermineMesurePrincipale(X as Single) as Single rem renvoit entre 0 et 2 pi
	Dim NbreTours as Integer
	NbreTours = X/(2*pi)
	If X - Int(NbreTours)*2*pi &gt;= 0 Then 
		DetermineMesurePrincipale = X - Int(NbreTours)*2*pi
	Else
	DetermineMesurePrincipale = X - Int(NbreTours)*2*pi + 2*pi
	Endif
End Function

Function PointInterieurRectangle(X,Y as Single) as Boolean
	If (X&gt;=XMiniF and X&lt;=XmaxiF and Y&gt;=YminiF and Y&lt;=YmaxiF) Then PointInterieurRectangle = True Else PointInterieurRectangle = False
End Function

Sub reglePosYGdmath
		Dim maScrolBar as Object
		Dim LaPos As New com.sun.star.awt.Point
		maScrollBar = oCreeGdmath.GetControl(&quot;ScrollBar1&quot;)
		LaPos.X = oDocumentF.currentController.selection.getByIndex(0).Position.X
		LaPos.Y = maScrollBar.Value			
		oDocumentF.currentController.selection.getByIndex(0).Setposition(LaPos)		
End Sub

Sub reglePosXGdmath
		Dim maScrolBar as Object
		Dim LaPos As New com.sun.star.awt.Point
		maScrollBar = oCreeGdmath.GetControl(&quot;ScrollBar2&quot;)
		LaPos.X = maScrollBar.Value
		LaPos.Y = oDocumentF.currentController.selection.getByIndex(0).Position.Y
	&apos;	MRI oDocumentF.currentController.selection.getByIndex(0)
		oDocumentF.currentController.selection.getByIndex(0).Setposition(LaPos)		
End Sub


Sub regleZoom(oEvt as Object)
    oDocumentF.currentController.ZoomValue = oEvt.Source.Value
    oEvt.Source.Context.GetControl(&quot;TextFieldZoom&quot;).Text = oDocumentF.currentController.ZoomValue    
End sub


Sub ChoixDesOptionsTracer
	oOptions.Execute()
End Sub
</script:module>