/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoGdmath/Gdmath.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 | <?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="Gdmath" script:language="StarBasic">'OOoGdmath
'Copyright (C) 2005-2009 Gilles Daurat
'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or (at your option) any later version.
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
option explicit
Global Const VERSION_GDMATH= "2009.12.06"
Global Const Pi = 3.14159265358979
Global Const FG_RIEN = 0
Global Const FG_CROIX = 1
Global Const FG_TRAIT = 2
Global Const rText = 0
Global Const rLabel = 1
Global Const rHelpText = 2
Global Const rTitle = 3
Global Const iLang = -1
Global oPageDessin as Object
Global oDocumentDessin as Object
Global oPageTexte as Object
Global oDocumentTexte as Object
Global oPageDessin1 as Object
Global oDocumentDessin1 as Object
Global oPremierDocument as Object
Sub Main
End Sub
function fCheminImages() as String rem écrite par Jérôme Ortais
Dim newSplit()
ReDim NewSplit(0)
Dim thePath as string
Dim splitted
' If GetGuiType=4 and FileExists("/Users") Then
' thePath ="file://" & GetRepertoirePath("user") & "/basic/Gdmath/script.xlb"
' Else
thePath = basiclibraries.getLibraryLinkURL("OOoGdmath") rem à adapter.
' Endif
splitted = split(thePath,"/")
newSplit() = splitted()
ReDim Preserve newSplit(0 to ubound(splitted)-2)
fCheminImages = join(NewSplit(),"/") & "/" & "OOoGdmath/Bitmaps/"
End Function
Function GetRepertoirePath(sInstPath as String) as String 'donne le répertoire correspondant
Dim oPathSubstSrv as Object
Dim sPath as String
sInstPath = "$(" & sInstPath & ")"
oPathSubstSrv =createUnoService("com.sun.star.comp.framework.PathSubstitution")
sPath =ConvertFromUrl(oPathSubstSrv.getSubstituteVariableValue(sInstPath))
GetRepertoirePath = sPath
End Function
Sub ChangeTitreDialog(uneDialogue as Object)
InitialiseGdmath()
if instr(1,uneDialogue.Title,VERSION_GDMATH)=0 then
uneDialogue.Title=Ressource(uneDialogue,rTitle) & " - " & VERSION_GDMATH
End if
End Sub
Sub AACExtraitNDF(Fraction as string, num as string, den as string)
Dim a
a = InStr(1, Fraction, "/")
If a <> 0 Then
num = Trim(Left(Fraction, a - 1))
den = Trim(Right(Fraction, Len(Fraction) - a))
Else
num = Trim(Fraction)
den = "1"
End If
If Left(num, 1) = "-" Then num = Mid(num, 2)
End Sub
Function CestUneFigureGeometrique() as Boolean
on error resume next
CestUneFigureGeometrique=False
CestUneFigureGeometrique = (oRectangleForm.Model.CheckBox12.State Or oTriangleForm.Model.CheckBox38.State Or oCercleForm.Model.CheckBox8.State Or oCarreForm.Model.CheckBox12.State)
End Function
Function MarqueMilieu(x0, y0, x1, y1, ts As Object, Optional UneImage As Image) as Object
Dim xm, ym, r
xm = (x0 + x1) / 2
ym = (y0 + y1) / 2
r = Sqr((x0 - xm) * (x0 - xm) + (y0 - ym) * (y0 - ym))
InsereLigne xm - 100 * (y0 - ym) / r, ym + 100 * (x0 - xm) / r, xm + 100 * (y0 - ym) / r, ym - 100 * (x0 - xm) / r, ts, UneImage
End Function
Sub CopierColler()
Dim oDispatcher as Object
Dim oEmptyShapeCollection as Object
Dim oDrawDocView as Object,oTextDocView as Object
' Get a dispatcher, because we'll need it later.
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
' Get an empty collection of shapes. We'll need it lager.
oEmptyShapeCollection = createUnoService( "com.sun.star.drawing.ShapeCollection" )
' Get the document's controller
oDrawDocView = oDocumentDessin.getCurrentController()
oTextDocView = oPremierDocument.getCurrentController()
' Copy whatever is selected.
oDispatcher.executeDispatch( oDrawDocView.Frame, ".uno:Copy", "", 0, Array() )
' Select nothing -- i.e. an empty collection of shapes.
' If you stopped the macro right now and looked at the drawing -- nothing is selected.
oTextDocView.select( oEmptyShapeCollection )
' Now paste whatever is in the clipboard (the shape parameter) onto current page.
oDispatcher.executeDispatch( oTextDocView.Frame, ".uno:Paste", "", 0, Array() )
' After a Paste, the current selection is whatever we just pasted.
End Sub
Sub CopierColler1()
Dim oDispatcher as Object
Dim oEmptyShapeCollection as Object
Dim oDrawDocView as Object,oTextDocView as Object
' Get a dispatcher, because we'll need it later.
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
' Get an empty collection of shapes. We'll need it lager.
oEmptyShapeCollection = createUnoService( "com.sun.star.drawing.ShapeCollection" )
' Get the document's controller
oDrawDocView = oDocumentDessin.getCurrentController()
oTextDocView = oDocumentTexte.getCurrentController()
' Copy whatever is selected.
oDispatcher.executeDispatch( oTextDocView.Frame, ".uno:Copy", "", 0, Array() )
' Select nothing -- i.e. an empty collection of shapes.
' If you stopped the macro right now and looked at the drawing -- nothing is selected.
oDrawDocView.select( oEmptyShapeCollection )
' Now paste whatever is in the clipboard (the shape parameter) onto current page.
oDispatcher.executeDispatch( oDrawDocView.Frame, ".uno:Paste", "", 0, Array() )
' After a Paste, the current selection is whatever we just pasted.
End Sub
Sub Copier1()
dim dsp as Object
dsp=CreateUnoService("com.sun.star.frame.DispatchHelper")
dsp.executeDispatch(oDocumentTexte.CurrentController.Frame, ".uno:Cut", "", 0, Array())
End Sub
Sub Coller1()
dim dsp as object
dsp=CreateUnoService("com.sun.star.frame.DispatchHelper")
dsp.executeDispatch(oDocumentDessin.GetCurrentController().Frame, ".uno:Paste", "", 0, Array())
oDocumentDessin.CurrentController.Select(oPageDessin(0))
End Sub
Sub InitialiseDessin(Optional visible as Boolean)
'Didier Dorange-Pattoret
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
Dim Array()
if IsMissing(visible) then visible = True
mFileProperties(0).Name="Hidden"
mFileProperties(0).Value=True
oPremierDocument=thisComponent
if visible then
oDocumentTexte=StarDesktop.LoadComponentFromURL("private:factory/swriter","_blank", 0, Array())
oPageTexte=oDocumentTexte.drawPage()
oDocumentDessin=StarDesktop.LoadComponentFromURL("private:factory/sdraw","_blank", 0, Array())
else
oDocumentTexte=StarDesktop.LoadComponentFromURL("private:factory/swriter","_blank", 0, mFileProperties())
oPageTexte=oDocumentTexte.drawPage()
oDocumentDessin=StarDesktop.LoadComponentFromURL("private:factory/sdraw","_blank", 0, mFileProperties())
oDocumentDessin.lockControllers
oDocumentTexte.lockControllers
oPremierDocument.lockControllers
End if
oPageDessin=oDocumentDessin.DrawPages(0)
end sub
sub TermineDessin()
' on groupe tous les objets de la feuille
dim i
dim unGroupe as Object
on error resume next
' unGroupe=InitialiseGroupe()
for i=0 to oPageDessin.Count()
SelectionneForme(oDocumentDessin, oPageDessin(i))
' unGroupe.add(oPageDessin(i))
next i
' unGroupe=GroupeObjet(unGroupe)
' SelectionneForme(oDocumentDessin, unGroupe)
CopierColler()
' Copier()
' Coller()
on error resume next
oDocumentDessin.close(True)
oDocumentTexte.close(true)
oPremierDocument.unlockControllers
on error goto 0
end sub
function CentimetersToPoints(a) as double
CentimetersToPoints=a*1000
end function
Sub RemplaceVirgulePoint(nombre)
Dim k as Integer
k = InStr(1, nombre, ",")
If k <> 0 Then nombre = Left$(nombre, k - 1) & "." & Right$(nombre, Len(nombre) - k)
End Sub
Sub RemplacePointVirgule(nombre)
Dim k as Integer
k = InStr(1, nombre, ".")
If k <> 0 Then nombre = Left$(nombre, k - 1) & "," & Right$(nombre, Len(nombre) - k)
End Sub
Sub MarquePointSegment(xi as single, yi as single, x0 as single, y0 as single, x1 as single, y1 as single,optional sGroupe as object)
Dim r as Single
r = Sqr((x0 - xi) * (x0 - xi) + (y0 - yi) * (y0 - yi))
if not ismissing(sgroupe) then
InsereLigne(xi - 100 * (y0 - yi) / r, yi + 100 * (x0 - xi) / r, xi + 100 * (y0 - yi) / r, yi - 100 * (x0 - xi) / r, sGroupe)
else
InsereLigne(xi - 100 * (y0 - yi) / r, yi + 100 * (x0 - xi) / r, xi + 100 * (y0 - yi) / r, yi - 100 * (x0 - xi) / r)
end if
End Sub
function max(val1,val2)
if val1>val2 then
max()=val1
else
max()=val2
end if
end function
function min(val1,val2)
if val1>val2 then
min()=val2
else
min()=val1
end if
end function
function InsereLigneLongue(l, x0, y0, x1, y1, optional sgroupe as object) as object
Dim UnObjet As object
Dim r as Single
r = Sqr((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1))
if not ismissing(sgroupe) then
InsereLigneLongue()=InsereLigne(Min(x0, x1) - Abs(l * (x0 - x1) / r), _
Min(y0, y1) - Abs(l * (y0 - y1) / r), _
max(x0, x1) + Abs(l * (x0 - x1) / r), _
max(y0, y1) + Abs(l * (y0 - y1) / r), sgroupe)
else
InsereLigneLongue()=InsereLigne(Min(x0, x1) - Abs(l * (x0 - x1) / r), _
Min(y0, y1) - Abs(l * (y0 - y1) / r), _
max(x0, x1) + Abs(l * (x0 - x1) / r), _
max(y0, y1) + Abs(l * (y0 - y1) / r))
end if
End function
function ListBoxSelected(oListBox as object, indice as integer) as boolean
Dim retour as Boolean
Dim aa
Dim i as Integer
retour=False
aa=oListBox.GetSelectedItemsPos()
for i=lbound(aa) to ubound(aa)
if aa(i)=indice then retour=True
next i
ListBoxSelected()=retour
end function
Function TraceCodageTrait(xxx as single, yyy as single, Angle as single, Optional SGroupe as object) as object
If Not IsMissing( SGroupe ) Then
TraceCodageTrait()=InsereLigne(xxx + 150 * Cos(Angle), yyy + 150 * Sin(Angle), xxx - 150 * Cos(Angle), yyy - 150 * Sin(Angle), SGroupe)
else
TraceCodageTrait()=InsereLigne(xxx + 150 * Cos(Angle), yyy + 150 * Sin(Angle), xxx - 150 * Cos(Angle), yyy - 150 * Sin(Angle))
end if
End function
Sub TrouvePiedHauteur(x0 as single, y0 as single, x1 as single, y1 as single, xs as single, ys as single, xp as single, yp as single)
Dim uangle as Double
uangle = CalculeAngle(x0,y0,x1,y1)+Pi/2
TrouveIntersection(x0, y0, x1, y1, xs, ys, xs+5000 * Cos(uangle), ys+5000 * Sin(uangle), xp, yp)
End Sub
Function TrouveIntersection(x0 as single, y0 as single, x1 as single, y1 as single, x2 as single, y2 as single, x3 as single, y3 as single, xint as single, yint as single) as Boolean
Dim a1 as single, b1 as single
Dim a0 as single, b0 as single
TrouveIntersection() = True
If x1 = x0 Then
xint = x0
If x3 = x2 Then
xint = "n"
yint = "n"
TrouveIntersection() = False
Else
a1 = (y3 - y2) / (x3 - x2)
b1 = -x2 * a1 + y2
yint = a1 * xint + b1
End If
Else
a0 = (y1 - y0) / (x1 - x0)
b0 = -x0 * a0 + y0
If x3 = x2 Then
xint = x2
yint = a0 * xint + b0
Else
a1 = (y3 - y2) / (x3 - x2)
b1 = -x2 * a1 + y2
xint = (b1 - b0) / (a0 - a1)
yint = a0 * (b1 - b0) / (a0 - a1) + b0
End If
End If
End Function
Sub CalculeOrthocentre(x0 as single, y0 as single, x1 as single, y1 as single, x2 as single, y2 as single, xh as single, yh as single)
Dim xph1 as single, xph2 as single, yph1 as single, yph2 as single
TrouvePiedHauteur(x0, y0, x1, y1, x2, y2, xph2, yph2)
TrouvePiedHauteur(x0, y0, x2, y2, x1, y1, xph1, yph1)
TrouveIntersection(x2, y2, xph2, yph2, x1, y1, xph1, yph1, xh, yh)
End Sub
function TraceHauteur(xxx0 as single, yyy0 as single, xx1 as single, yy1 as single, xx2 as single, yy2 as single, sGroupe as object, xh1 as single, yh1 as single, xh2 as single, yh2 as single, Optional ProlongerHauteurS as Boolean, Optional ProlongerHauteurP as Boolean, Optional ProlongerCote as Boolean , Optional ProlongerHauteurI as Boolean, Optional xh as single, Optional yh as single) as object
Dim pGroupe as object
Dim unObjet as Object
Dim xx as single, yy as single
Dim xx0 as single, yy0 as single
Dim p1 as single, p2 as single
Dim pp1 as single, pp2 as single
Dim test1 as Boolean, test2 as Boolean
Dim angleh as double
pGroupe=InitialiseGroupe()
xx0 = xxx0
yy0 = yyy0
TrouvePiedHauteur(xx1, yy1, xx2, yy2, xx0, yy0, xx, yy)
MarqueAngleDroit(xx, yy, xx0, yy0, pGroupe)
If Abs(xx1 - xx2) > Abs(yy1 - yy2) Then
test1 = (xx > max(xx1, xx2))
test2 = (xx < Min(xx1, xx2))
If test1 Then
p1 = MIif(xx1 > xx2, xx1, xx2)
p2 = MIif(xx1 > xx2, yy1, yy2)
End If
If test2 Then
p1 = MIif(xx1 < xx2, xx1, xx2)
p2 = MIif(xx1 < xx2, yy1, yy2)
End If
Else
test1 = (yy > max(yy1, yy2))
test2 = (yy < min(yy1, yy2))
If test1 Then
p1 = MIif(yy1 >yy2, xx1, xx2)
p2 = MIif(yy1 >yy2, yy1, yy2)
End If
If test2 Then
p1 = MIif(yy1 <yy2, xx1, xx2)
p2 = MIif(yy1 <yy2, yy1, yy2)
End If
End If
If ProlongerCote And (test1 Or test2) Then
angleh = CalculeAngle(p1, p2, xx, yy)
pp1 = xx + 5000 * Cos(angleh)
pp2 = yy + 5000 * Sin(angleh)
LaLigne=InsereLigne(p1, p2, pp1, pp2, pGroupe)
LaLigne.LineStyle = 0
End If
If ProlongerHauteurS Or ProlongerHauteurP Then
angleh = CalculeAngle(xx0, yy0, xx, yy)
If ProlongerHauteurS Then
xx0 = xx0 - 5000 * Cos(angleh)
yy0 = yy0 - 5000 * Sin(angleh)
End If
If ProlongerHauteurP Then
xx = xx + 5000 * Cos(angleh)
yy = yy + 5000 * Sin(angleh)
End If
End If
If ProlongerHauteurI Then
angleh = CalculeAngle(xx0, yy0, xx, yy)
If xh < Min(xx0, xx) Or yh < Min(yy0, yy) Then
If (xx0 < xx And xh < Min(xx0, xx)) Or (yy0 < yy And yh < Min(yy0, yy)) Then
xx0 = xh - 5000 * Cos(angleh)
yy0 = yh - 5000 * Sin(angleh)
Else
xx = xh + 5000 * Cos(angleh)
yy = yh + 5000 * Sin(angleh)
End If
End If
If xh > max(xx0, xx) Or yh > max(yy0, yy) Then
If (xx0 > xx And xh > max(xx0, xx)) Or (yy0 > yy And yh > max(yy0, yy)) Then
xx0 = xh - 5000 * Cos(angleh)
yy0 = yh - 5000 * Sin(angleh)
Else
xx = xh + 5000 * Cos(angleh)
yy = yh + 5000 * Sin(angleh)
End If
End If
End If
InsereLigne(xx0, yy0, xx, yy, pGroupe)
xh1 = xx0
yh1 = yy0
xh2 = xx
yh2 = yy
UnObjet=GroupeObjet(pGroupe)
if not ismissing(sgroupe) then
sgroupe.add(UnObjet)
end if
TraceHauteur()=UnObjet
End function
function InitialiseGroupe() as object
dim UnGroupe as object
UnGroupe = createUnoService("com.sun.star.drawing.ShapeCollection")
InitialiseGroupe()=UnGroupe
end function
function GroupeObjet(pgroupe as object) as object
Dim UnObjet as object
on error resume next
a=pgroupe.GetCount()
if a>1 then
GroupeObjet=oDocumentDessin.DrawPages.GetByIndex(0).group(pgroupe)
' GroupeObjet=ThisComponent.Drawpage.group(pgroupe)
' GroupeObjet()=ThisComponent.Drawpage.bind(pgroupe)
else
GroupeObjet=pgroupe.GetByIndex(0)
end if
end function
function TraceMediane(xxx0 as single, yyy0 as single, xx1 as single, yy1 as single, xx2 as single, yy2 as single, Optional ProlongerMedianeS as boolean, Optional ProlongerMedianeM as boolean,optional sgroupe as object) as object
dim pGroupe as object
dim xm, ym
dim xx3,yy3,xx0,yy0
dim angleh
Dim seg1 as Object, seg2 as Object
Dim lecodage as Integer
Dim unObjet as Object
pGroupe = InitialiseGroupe()
xm = (xx1 + xx2) / 2
ym = (yy1 + yy2) / 2
xx0 = xxx0
yy0 = yyy0
xx3 = xm
yy3 = ym
If ProlongerMedianeS Or ProlongerMedianeM Then
angleh = CalculeAngle(xx0, yy0, xm, ym)
If ProlongerMedianeS Then
xx0 = xx0 - 5000 * Cos(angleh)
yy0 = yy0 - 5000 * Sin(angleh)
End If
If ProlongerMedianeM Then
xx3 = xx3 + 5000 * Cos(angleh)
yy3 = yy3 + 5000 * Sin(angleh)
End If
End If
InsereLigne(xx0, yy0, xx3, yy3, pgroupe)
' on code les longueurs égales
If (CInt(CodageLabel2) <> 10) Then
Seg1 = InsereLigne(xx1, yy1, xm, ym)
Seg1.LineColor = RGB(0, 0, 255)
Seg2 = InsereLigne(xx2, yy2, xm, ym)
Seg2.LineColor = RGB(255, 0, 0)
AfficheCodageLForm
oPageDessin.remove(seg1)
oPageDessin.remove(seg2)
lecodage = CInt(CodageLabel2)
If (lecodage = 10) Then lecodage = 0
End If
If (CInt(CodageLabel2) = 10) Then
lecodage = lecodage + 1
If lecodage = 10 Then lecodage = 1
End If
If (CodageLabel2 <> "11") Then
CodeLongueur(xx1, yy1, xm, ym, lecodage, pgroupe)
CodeLongueur(xx2, yy2, xm, ym, lecodage, pgroupe)
End If
UnObjet=GroupeObjet(pgroupe)
If Not IsMissing( sgroupe ) Then
sgroupe.add(UnObjet)
end if
TraceMediane()=UnObjet
End function
function TraceCodageCercle(xxx as single, yyy as single, optional sgroupe as object) as object
If Not IsMissing( SGroupe ) Then
TraceCodageCercle()=InsereCercle(xxx, yyy, 150,sgroupe)
else
TraceCodageCercle()=InsereCercle(xxx, yyy, 150)
end if
End function
function InsereCercle(xc as single, yc as single, rayon as single, optional sgroupe as object, Optional uneImage as Object) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x=xc-rayon
aPoint.y=yc-rayon
aSize.Width=rayon*2
asize.Height=rayon*2
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
UneForme.Position=aPoint
UneForme.Size=aSize
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.FillStyle = com.sun.star.drawing.FillStyle.NONE
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
If Not IsMissing( SGroupe ) Then
SGroupe.Add(UneForme)
end if
If Not IsMissing(UneImage) Then
IOAttribut(UneForme,UneImage)
End If
InsereCercle()=UneForme
End function
function TraceMediatrice(xx0 as single, yy0 as single, xx1 as single, yy1 as single, xx2 as single, yy2 as single, sgroupe as object, Optional ProlongeMediatrice as boolean, Optional xc as single, Optional yc as single) as object
Dim xm,ym,k,x1,y1,lecodage,anglem,seg1,seg2,xx,yy
xm = (xx0 + xx1) / 2
ym = (yy0 + yy1) / 2
If (xx0 = xx1) Then
yy = ym
xx = xx2
Else
k = (yy0 - yy1) / (xx0 - xx1)
If Abs(k) > 1 Then
xx = xx2
yy = ym + (xm - xx) / k
Else
yy = yy2
xx = xm + k * ym - k * yy
End If
End If
x1 = xm + (xm - xx)
y1 = ym + (ym - yy)
If ProlongeMediatrice Then
anglem = CalculeAngle(xx, yy, x1, y1)
If x1 = xx Then
k = (yc - yy) / (y1 - yy)
Else
k = (xc - xx) / (x1 - xx)
End If
If k > 1 Then
x1 = xc + 5000 * Cos(anglem)
y1 = yc + 5000 * Sin(anglem)
End If
If k < 0 Then
xx = xc - 5000 * Cos(anglem)
yy = yc - 5000 * Sin(anglem)
End If
End If
InsereLigne(xx, yy, x1, y1, sGroupe)
' on trace l'angle droit
MarqueAngleDroit(xm, ym, xx, yy, sGroupe)
' on code les longueurs égales
If (CInt(CodageLabel2) <> 10) Then
Seg1 = InsereLigne(xx1, yy1, xm, ym)
Seg1.LineColor = RGB(0, 0, 255)
Seg2 = InsereLigne(xx0, yy0, xm, ym)
Seg2.LineColor = RGB(255, 0, 0)
AfficheCodageLForm
oDocumentDessin.DrawPages.GetByIndex(0).remove(Seg1)
oDocumentDessin.DrawPages.GetByIndex(0).Remove(Seg2)
lecodage = CInt(CodageLabel2)
If (lecodage = 10) Then lecodage = 0
End If
If (CInt(CodageLabel2) = 10) Then
Do
lecodage = lecodage + 1
If lecodage = 10 Then lecodage = 1
Loop While InStr(1, CodageLabel3, Trim(Str(lecodage))) <> 0
End If
If (CInt(CodageLabel2) < 11) Then
CodeLongueur(xx0, yy0, xm, ym, lecodage, sGroupe, "")
CodeLongueur(xx1, yy1, xm, ym, lecodage, sGroupe, "")
End If
End function
function Croix(x, y, Optional sgroupe as object) as object
Dim pGroupe As object
Dim unObjet as Object
pGroupe=InitialiseGroupe()
InsereLigne(x - 100, y - 100, x + 100, y + 100, pGroupe)
InsereLigne(x - 100, y + 100, x + 100, y - 100, pGroupe)
UnObjet=GroupeObjet(pGroupe)
if not ismissing(sgroupe) then
sgroupe.add(UnObjet)
end if
Croix=UnObjet
End function
Sub CalculeCentreCirconscrit(x0 as single, y0 as single, x1 as single, y1 as single, x2 as single, y2 as single, xc as single, yc as single)
Dim a1 as single, b1 as single, c1 as single
Dim a2 as single, b2 as single, c2 as single
a1 = 2 * (x1 - x0)
b1 = 2 * (y1 - y0)
c1 = x1 * x1 - x0 * x0 + y1 * y1 - y0 * y0
a2 = 2 * (x2 - x0)
b2 = 2 * (y2 - y0)
c2 = x2 * x2 - x0 * x0 + y2 * y2 - y0 * y0
yc = (c1 * a2 - c2 * a1) / (a2 * b1 - a1 * b2)
If a1 = 0 Then
xc = (c2 - b2 * yc) / a2
Else
xc = (c1 - b1 * yc) / a1
End If
End Sub
Function CodeLongueur(xd as single, yd as single, xa as single, ya as single, typecodage as single, optional sgroupe as object) as object
Dim xGroupe As object
Dim UnObjet As object
Dim sTypeCodage
Dim xm1, ym1, alpha, xm0,ym0, xm2, ym2
xGroupe = InitialiseGroupe()
Stypecodage = Trim(Str(typecodage))
If InStr(1, CodageLabel3, Stypecodage) = 0 Then
CodageLabel3 = CodageLabel3 + Stypecodage
If Len(CodageLabel3) = 9 Then
CodageLabel3 = ""
End If
End If
xm1 = (xd + xa) / 2
ym1 = (yd + ya) / 2
alpha = CalculeAngle(xd, yd, xa, ya)
xm0 = xm1 - 100 * Cos(alpha)
ym0 = ym1 - 100 * Sin(alpha)
xm2 = xm1 + 100 * Cos(alpha)
ym2 = ym1 + 100 * Sin(alpha)
TraceCodageTrait(xm1, ym1, alpha + Pi / 3,xGroupe)
If (typecodage Mod 3) = 2 Then
TraceCodageTrait(xm0, ym0, alpha + Pi / 3,xGroupe)
End If
If (typecodage Mod 3) = 0 Then
TraceCodageTrait(xm0, ym0, alpha + Pi / 3,xGroupe)
TraceCodageTrait(xm2, ym2, alpha + Pi / 3,xGroupe)
End If
If typecodage > 3 And typecodage < 7 Then
TraceCodageTrait(xm1, ym1, alpha + 2 * Pi / 3,xGroupe)
End If
If typecodage > 6 And typecodage < 10 Then
TraceCodageCercle(xm1, ym1,xGroupe)
End If
UnObjet=GroupeObjet(xGroupe)
If Not IsMissing( sgroupe ) Then
sgroupe.add(UnObjet)
end if
CodeLongueur()=UnObjet
End function
Sub Echange(val1, val2)
Dim Tempo
tempo = val1
val1 = val2
val2 = tempo
End Sub
function InserePart(xorig as long, yorig as long, depart as long, arrivee as long, Rayon as single, optional sgroupe as object, Optional UneImage as object) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x=xorig-Rayon
aPoint.y=yorig-Rayon
aSize.Width=Rayon*2
asize.Height=Rayon*2
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.Position=aPoint
UneForme.Size=aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
UneForme.CircleStartAngle=depart
UneForme.CircleEndAngle=arrivee
UneForme.CircleKind=com.sun.star.drawing.CircleKind.SECTION
If Not IsMissing(UneImage) Then IOAttribut UneForme, UneImage
If Not IsMissing( sgroupe ) Then sgroupe.Add(UneForme)
InserePart()=UneForme
End function
function InsereArcDeCerclePlein(xorig as single, yorig as single, depart as long, arrivee as long, Rayon as single, optional sgroupe as object, Optional UneImage as object) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x=xorig-Rayon
aPoint.y=yorig-Rayon
aSize.Width=Rayon*2
asize.Height=Rayon*2
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.Position=aPoint
UneForme.Size=aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
UneForme.CircleStartAngle=depart
UneForme.CircleEndAngle=arrivee
UneForme.CircleKind=com.sun.star.drawing.CircleKind.SECTION
If Not IsMissing(UneImage) Then
IOAttribut UneForme, UneImage
UneForme.FillStyle = com.sun.star.drawing.FillStyle.SOLID
UneForme.FillColor=UneImage.BackgroundColor
end if
If Not IsMissing( sgroupe ) Then
sgroupe.Add(UneForme)
end if
InsereArcDeCerclePlein()=UneForme
End function
function InsereArcDeCercle(xorig as single, yorig as single, depart as long, arrivee as long, Rayon as single, optional sgroupe as object, Optional UneImage as object) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x=xorig-Rayon
aPoint.y=yorig-Rayon
aSize.Width=Rayon*2
asize.Height=Rayon*2
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.Position=aPoint
UneForme.Size=aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
UneForme.CircleStartAngle=depart
UneForme.CircleEndAngle=arrivee
UneForme.CircleKind=3
If Not IsMissing(UneImage) Then
IOAttribut UneForme, UneImage
end if
If Not IsMissing( sgroupe ) Then
sgroupe.Add(UneForme)
end if
InsereArcDeCercle()=UneForme
End function
function PetitArcDeCercle(xorig as single, yorig as single, depart as single, arrivee as single, Taille as single, optional sgroupe as object, Optional UneImage as Object) as object
Dim UneForme As object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x=xorig-Taille/2
aPoint.y=yorig-Taille/2
aSize.Width=Taille
asize.Height=Taille
UneForme = oDocumentDessin.createInstance("com.sun.star.drawing.EllipseShape")
' UneForme.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
UneForme.Position=aPoint
UneForme.Size=aSize
oDocumentDessin.DrawPages.GetByIndex(0).add(UneForme)
UneForme.CircleStartAngle=depart
UneForme.CircleEndAngle=arrivee
UneForme.CircleKind=3
If Not IsMissing( UneImage ) Then
IOAttribut UneForme, UneImage
end if
If Not IsMissing( sgroupe ) Then
sgroupe.Add(UneForme)
end if
PetitArcDeCercle()=UneForme
End function
function MarqueAngle(xd1 as single, yd1 as single, xangle as single, yangle as single, xd2 as single, yd2 as single, Rentrant as boolean, NombreArc as integer, decale as integer, Optional sgroupe As object) as object
Dim UnObjet As object
Dim pGroupe as object
Dim alpha as single
Dim beta as single
Dim aa as Single
Dim nbforme as Single, toti as integer,i as integer, nombretrait as integer
pGroupe = InitialiseGroupe()
alpha = -CalculeAngle(xangle, yangle, xd1, yd1) * 180 / Pi
beta = -CalculeAngle(xangle, yangle, xd2, yd2) * 180 / Pi
if alpha>beta then Echange alpha,beta
If Rentrant Then
If alpha - beta < 180 Then
beta = beta + 360
Echange alpha,beta
End If
' Else
' If alpha - beta > 180 Then
' beta = beta + 360
' Echange alpha,beta
' End If
End If
nbforme = 0
toti = Int((NombreArc - 1) / 3) + 1
For i = 0 To toti - 1
UnObjet=PetitArcDeCercle(xangle, yangle, alpha*100, beta*100, 1000 + i * 100 + 100 * decale, pGroupe)
nbforme = nbforme + 1
Next i
nombretrait = (NombreArc Mod 3) - 1
If nombretrait = -1 Then nombretrait = 2
aa = -(alpha + beta) / 2
If nombretrait = 1 Then
aa = aa * Pi / 180
InsereLigne(xangle + (400 + 100 * decale) * Cos(aa), yangle + (400 + 100 * decale) * Sin(aa), xangle + (400 + 100 * decale + toti * 150) * Cos(aa), yangle + (400 + 100 * decale + toti * 150) * Sin(aa), pGroupe)
nbforme = nbforme + 1
End If
If nombretrait = 2 Then
ab = (aa - 2) * Pi / 180
InsereLigne(xangle + (400 + 100 * decale) * Cos(ab), yangle + (400 + 100 * decale) * Sin(ab), xangle + (400 + 100 * decale + toti * 150) * Cos(ab), yangle + (400 + 100 * decale + toti * 150) * Sin(ab), pGroupe)
ab = (aa + 2) * Pi / 180
InsereLigne(xangle + (400 + 100 * decale) * Cos(ab), yangle + (400 + 100 * decale) * Sin(ab), xangle + (400 + 100 * decale + toti * 150) * Cos(ab), yangle + (400 + 100 * decale + toti * 150) * Sin(ab), pGroupe)
nbforme = nbforme + 2
End If
UnObjet = GroupeObjet(pGroupe)
if not ismissing(sgroupe) then
sgroupe.add(UnObjet)
end if
MarqueAngle()=UnObjet
End function
Function CalculeAngle(xo as single,yo as single,xxx as single,yyy as single) as double
Dim tang as Double
Dim unAngle as Double
If Abs(xxx - xo) < 0.000001 Then
If yyy > yo Then
UnAngle = Pi / 2
Else
UnAngle = -Pi / 2
End If
Else
If Abs(yyy - yo) < 0.000001 Then
tang = 0
Else
tang = (yyy - yo) / (xxx - xo)
End If
UnAngle = Atn(tang)
If xxx < xo Then
If UnAngle < 0 Then
UnAngle = UnAngle + Pi
Else
UnAngle = UnAngle - Pi
End If
End If
End If
CalculeAngle()=UnAngle
end function
Sub IOAttribut(oShape as object, UneImage as Object)
OAttribut oShape, UneImage.BackgroundColor, ExtraitEpaisseur(UneImage.Helptext), ExtraitTypeTrait(UneImage.Helptext)
End Sub
Function ExtraitEpaisseur(LeTexte As String) As String
Dim LeTexte1
Dim i,j
i=instr(1,LeTexte," ")
j=instr(i,LeTexte,"pt")
LeTexte1 = mid(LeTexte, i+1,j-i-1)
RemplaceVirgulePoint LeTexte1
ExtraitEpaisseur = LeTexte1
End Function
Function ExtraitTypeTrait(LeTexte As String) As String
Select Case Left$(LeTexte, InStr(1, LeTexte, " ") - 1)
Case Chaine("continu")
ExtraitTypeTrait = "msoLineSolid"
Case Chaine("pointille")
ExtraitTypeTrait = "msoLineDash"
case else
ExtraitTypeTrait = ""
End Select
End Function
Function Chaine(uneChaine as String) as String
Dim oUneBoite as Object
oUneBoite = LoadDialog("OOoGdmath","ChaineForm")
Chaine = Ressource(oUneBoite.GetControl(lcase(uneChaine)).Model, rLabel)
oUneBoite.EndExecute()
End Function
Sub CalculeCentreInscrit(x0 as single, y0 as single, x1 as single, y1 as single, x2 as single, y2 as single, xc as single, yc as single)
Dim alpha as Double
Dim beta as Double
Dim xxx as single, xx as single
Dim yyy as single, yy as single
dim aa as Double
alpha = CalculeAngle(x0, y0, x1, y1) * 180 / Pi
beta = CalculeAngle(x0, y0, x2, y2) * 180 / Pi
If alpha > beta Then
If alpha - beta > 180 Then
alpha = alpha - 360
end if
Else
If beta - alpha > 180 Then
beta = beta - 360
end if
End If
aa = (alpha + beta) / 2
xx = x0 + 5000 * Cos(aa * Pi / 180)
yy = y0 + 5000 * Sin(aa * Pi / 180)
alpha = CalculeAngle(x1, y1, x0, y0) * 180 / Pi
beta = CalculeAngle(x1, y1, x2, y2) * 180 / Pi
If alpha > beta Then
If alpha - beta > 180 Then
alpha = alpha - 360
end if
Else
If beta - alpha > 180 Then
beta = beta - 360
end if
End If
aa = (alpha + beta) / 2
xxx = x1 + 5000 * Cos(aa * Pi / 180)
yyy = y1 + 5000 * Sin(aa * Pi / 180)
TrouveIntersection(x0, y0, xx, yy, x1, y1, xxx, yyy, xc, yc)
End Sub
Sub ChangeCouleur(UneImage As Object)
Dim EpaisseurTrait
Dim TexteEpaisseur
oCouleurForm=LoadDialog("OOoGdmath","CouleurForm")
Dim nCount As Integer
Dim sItems As Variant
dim oComboBox as Object
oComboBox = oCouleurForm.getControl("ComboBox1")
nCount = oComboBox.getItemCount()
oComboBox.removeItems( 0, nCount )
sItems = Array( Chaine("pointille"), Chaine("continu"))
oComboBox.addItems( sItems, 0 )
TexteEpaisseur = Trim(Str(ExtraitEpaisseur(UneImage.HelpText)))
If Left(TexteEpaisseur, 1) = "." Then
TexteEpaisseur = "0" & TexteEpaisseur
end if
oCouleurForm.Model.TextField4.Text = TexteEpaisseur
if ExtraitTypeTrait(UneImage.HelpText) = "msoLineSolid" then
ocombobox.Text = Chaine("continu")
else
ocombobox.Text = Chaine("pointille")
End If
oCouleurForm.Model.TextField1.Text=(UneImage.BackgroundColor and RGB(255,0,0))/65536
oCouleurForm.Model.TextField2.Text=(UneImage.BackgroundColor and RGB(0,255,0))/256
oCouleurForm.Model.TextField3.Text=(UneImage.BackgroundColor and RGB(0,0,255))
CouleurForm_MAJLabel()
oCouleurForm.Execute()
if (oCouleurForm.Model.Label8.Label="O") then
UneImage.Backgroundcolor=oCouleurForm.Model.Image1.BackGroundcolor
UneImage.HelpText=oCouleurForm.Model.Image1.HelpText
end if
End Sub
sub DeplaceSelection(posx as long,posy as long,UnObjet as Object)
UnObjet.Position = MakePoint(posx, posy)
end sub
Function InsereCourbe(secArray() as single, n as integer, Optional sgroupe as object, Optional UneImage as object) As object
dim oShape as Object
dim i as integer
dim groupage as object
dim oCoord as New com.sun.star.awt.Point
Redim oCoord(0 to n-1) as New com.sun.star.awt.Point
oShape=oDocumentDessin.createInstance( "com.sun.star.drawing.PolyLineShape")
for i=0 to n-1
oCoord(i).x=secArray(i,0)
oCoord(i).y=secArray(i,1)
next i
oDocumentDessin.DrawPages.GetByIndex(0).add(oShape)
oShape.PolyPolygon=Array(oCoord())
if not ismissing(UneImage) then IOAttribut oShape,UneImage
if not ismissing(sgroupe) then sgroupe.add(oShape)
InsereCourbe=oShape
End Function
Function InsereVecteur(x0,y0,x1,y1, SGroupe, Optional UneImage) as Object
dim unTrait as Object
dim ang as double
dim unPolygone as Object
Dim secArray(0 to 2, 0 to 1) as single
Dim pGroupe as Object
Dim unObjet as Object
pGroupe = InitialiseGroupe()
if ismissing(uneImage) then
unTrait=InsereLigne(x0,y0,x1,y1,pgroupe)
else
unTrait=InsereLigne(x0,y0,x1,y1,pgroupe, uneImage)
end if
ang=CalculeAngle(x0,y0,x1,y1)
secArray(0,0)=x1
secArray(0,1)=y1
secArray(1,0)=x1+200*cos(ang+5*Pi/6)
secArray(1,1)=y1+200*sin(ang+5*Pi/6)
secArray(2,0)=x1+200*cos(ang-5*Pi/6)
secArray(2,1)=y1+200*sin(ang-5*Pi/6)
if ismissing(uneImage) then
unPolygone=InserePolygoneB(secArray(),3,pgroupe)
unPolygone.FillStyle = com.sun.star.drawing.FillStyle.SOLID
unPolygone.FillColor= 0
else
unPolygone=InserePolygoneB(secArray(),3,pgroupe,uneImage)
unPolygone.FillStyle = com.sun.star.drawing.FillStyle.SOLID
unPolygone.FillColor= uneImage.BackgroundColor
end if
UnObjet = GroupeObjet(pGroupe)
sgroupe.add(unObjet)
InsereVecteur=UnObjet
End Function
function InsereLigne(x0 as single, y0 as single, x1 as single, y1 as single, optional SGroupe as object, optional UneImage as object) as object
Dim aPosition as new com.sun.star.awt.Point
Dim TheSize as new com.sun.star.awt.Size
Dim xShape as object
xShape=oDocumentDessin.createInstance("com.sun.star.drawing.LineShape")
' xShape.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
xShape.LineWidth = 20
aPosition.X = x0
aPosition.Y = y0
xShape.Position=aPosition
TheSize.width = x1-x0
TheSize.height=y1-y0
xShape.Size=TheSize
' ThisComponent.DrawPage.add( xShape )
oDocumentDessin.DrawPages.GetByIndex(0).add( xShape )
If Not IsMissing( SGroupe ) Then
SGroupe.Add(xShape)
end if
If Not IsMissing(UneImage) Then
IOAttribut(xShape, UneImage)
end if
InsereLigne()=xShape
End Function
Function InserePolygone(secArray(), n as integer, Optional sgroupe as object, Optional UneImage as object) As object
Dim Ligne as object, Shapes as object, UneCourbe as object
dim i, x0 as long, x1 as long, y0 as long, y1 as long
Shapes = InitialiseGroupe()
for i=0 to n-2
x0=secArray(i,0)
y0=secArray(i,1)
x1=secArray(i+1,0)
y1=secArray(i+1,1)
If Not IsMissing(UneImage) Then
InsereLigne x0,y0,x1,y1,Shapes,UneImage
else
InsereLigne x0,y0,x1,y1,Shapes
end if
next i
UneCourbe = GroupeObjet(Shapes)
If Not IsMissing(sgroupe) Then
sgroupe.Add(UneCourbe)
end if
InserePolygone()=UneCourbe
End Function
Function InserePolygoneB(secArray() as single, n as integer, Optional sgroupe as object, Optional UneImage as object) As object
dim oShape as Object
dim i as integer
dim groupage as object
dim oCoord as New com.sun.star.awt.Point
Redim oCoord(0 to n-1) as New com.sun.star.awt.Point
oShape=oDocumentDessin.createInstance( "com.sun.star.drawing.PolyPolygonShape")
for i=0 to n-1
oCoord(i).x=secArray(i,0)
oCoord(i).y=secArray(i,1)
next i
oDocumentDessin.DrawPages.GetByIndex(0).add(oShape)
oShape.PolyPolygon=Array(oCoord())
if not ismissing(UneImage) then IOAttribut(oShape,UneImage)
if not ismissing(sgroupe) then sgroupe.add(oShape)
InserePolygoneB=oShape
End Function
Function InsereQuadrilatere(x0 as single, y0 as single, x1 as single, y1 as single, x2 as single, y2 as single, x3 as single, y3 as single,ts As object, Optional UneImage As object) as object
Dim secArray(0 to 4,0 to 1) as single
secArray(0,0)=x0
secArray(0,1)=y0
secArray(1,0)=x1
secArray(1,1)=y1
secArray(2,0)=x2
secArray(2,1)=y2
secArray(3,0)=x3
secArray(3,1)=y3
secArray(4,0)=x0
secArray(4,1)=y0
if ismissing(UneImage) then
InsereQuadrilatere() = InserePolygone(secArray(), 5, ts)
else
InsereQuadrilatere() = InserePolygone(secArray(), 5, ts, UneImage)
end if
End function
Function InsereQuadrilatereB(x0,y0,x1,y1, Optional sgroupe as object, Optional UneImage as object) As object
Dim secArray(0 to 3,0 to 1) as single
secArray(0,0)=x0
secArray(0,1)=y0
secArray(1,0)=x1
secArray(1,1)=y0
secArray(2,0)=x1
secArray(2,1)=y1
secArray(3,0)=x0
secArray(3,1)=y1
if ismissing(UneImage) then
InsereQuadrilatereB = InserePolygoneB(secArray(), 4, sgroupe)
else
InsereQuadrilatereB = InserePolygoneB(secArray(), 4, sgroupe, UneImage)
end if
End Function
Sub ChargeNomPolice(fparam() as string)
Dim i,j,k
Dim oToolkit as Object
Dim oDevice as Variant
Dim oFontDescriptors As Variant
Dim param() as String
oToolkit = CreateUnoService("com.sun.star.awt.Toolkit")
oDevice = oToolkit.createScreenCompatibleDevice(0, 0)
oFontDescriptors = oDevice.FontDescriptors
Redim param(lbound(oFontDescriptors) to UBound(oFontDescriptors)) as string
thiscomponent.lockcontrollers
dim trouve as Boolean
k=0
for i= LBound(oFontDescriptors) to UBound(oFontDescriptors)
trouve=False
for j=0 to k-1
if param(j)=oFontDescriptors(i).Name then trouve=True
next j
if not trouve then
param(k)=oFontDescriptors(i).Name
k=k+1
end if
next i
thiscomponent.unlockcontrollers
redim fparam(0 to k-1)
for i=0 to k-1
fparam(i)=param(i)
next i
do
trouve=false
for i=0 to k-2
if fparam(i)>fparam(i+1) then
Echange(fparam(i), fparam(i+1))
trouve=True
end if
next i
loop while(trouve)
End Sub
Sub RedresseTexte()
Dim unDocument as Object
Dim unGroupe as Object, leGroupe as Object
Dim uneForme as Object
Dim i, typeForme as String
on error goto erreur
' Cette macro met à 0 l'angle de rotation de tous les textes de la sélection
unDocument=thisComponent
unGroupe=unDocument.CurrentSelection(0)
if unGroupe.ShapeType = "com.sun.star.drawing.GroupShape" Then
for i=0 to unGroupe.Count-1
uneForme = unGroupe(i)
typeForme = uneForme.ShapeType
if uneForme.ShapeType = "com.sun.star.drawing.TextShape" then
uneForme.RotateAngle = 0
end if
next i
Endif
Exit Sub
erreur:
MsgBoxP "message4"
End Sub
Function InsereTexte(UnTexte as string, x0 as single, y0 as single, Optional sgroupe as object, Optional AngleRot, Optional AlignH as integer, Optional AlignV as integer, Optional Mef as Boolean) as object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
Dim xShape as object
Dim oTexte as Object
dim ocursor as Object
if ismissing(Mef) then Mef=False
if Mef then
' On marque tous les objets du dessin
dim i
dim maPage
on error resume next
maPage=oDocumentDessin.DrawPages.GetByIndex(0)
for i=0 to maPage.Count()
maPage(i).Name=maPage(i).Name & "&"
next i
' on met en forme si demande
oCursor=oDocumentTexte.Text.CreateTextCursor
oDocumentTexte.Text.insertString(oCursor,UnTexte,True)
oCursor.goleft(len(UnTexte),True)
oDocumentTexte.CurrentController.Select(oCursor)
xShape=InsereExpression.InsereExpression(oDocumentTexte)
oDocumentTexte.CurrentController.Select(xShape)
CopierColler1()
' Le seul objet non marqué est celui qui vient d'être ajouté, il faut le sélectionner
for i=0 to maPage.Count()
if (right(maPage(i).Name,1)="&") then
maPage(i).Name=left(maPage(i).Name, len(maPage(i).Name)-1)
else
xShape=maPage(i)
end if
next i
else
xShape = oDocumentDessin.createInstance("com.sun.star.drawing.TextShape")
aPoint.x = x0
aPoint.y = y0
aSize.Width = 10
aSize.Height = 10
xShape.Position = aPoint
xShape.Size=aSize
' xShape.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
' ThisComponent.DrawPage.add(xShape)
oDocumentDessin.DrawPages.GetByIndex(0).add(xShape)
xShape.String=UnTexte
xShape.Text.CharFontName = OOoGdmath_NomPolice
xShape.Text.CharHeight = OOoGdmath_TaillePolice
xShape.Text.CharPosture = OOoGdmath_ItaliquePolice
xShape.Text.CharUnderline = OOoGdmath_SoulignePolice
xShape.Text.TextAutoGrowWidth=True
xShape.Text.TextAutoGrowHeight=True
end if
aSize=xShape.Size
if not ismissing(AlignH) then
select case AlignH
case -1
aPoint.x = x0-aSize.Width
case 0
aPoint.x = x0-aSize.Width/2
case 1
aPoint.x = x0
end Select
end if
if not ismissing(AlignV) then
select case AlignV
case -1
aPoint.y = y0-aSize.Height
case 0
aPoint.y = y0-aSize.Height/2
case 1
aPoint.y = y0
end Select
end if
xShape.Position = aPoint
If Not IsMissing(AngleRot) and AngleRot<>0 Then xShape.RotateAngle = AngleRot
If Not IsMissing(sgroupe) Then sgroupe.add(xShape)
InsereTexte()=xShape
end Function
Function InsereTriangleB(x0 as single,y0 as single,x1 as single,y1 as single, x2 as single, y2 as single,optional sgroupe as object, Optional UneImage as object) as object
Dim secArray(0 to 3, 0 to 1) as single
secArray(0,0)=x0
secArray(0,1)=y0
secArray(1,0)=x1
secArray(1,1)=y1
secArray(2,0)=x2
secArray(2,1)=y2
secArray(3,0)=x0
secArray(3,1)=y0
if ismissing(UneImage) then
InsereTriangleB() = InserePolygoneB(secArray(), 4, sgroupe)
else
InsereTriangleB() = InserePolygoneB(secArray(), 4, sgroupe, UneImage)
end if
end function
Function InsereTriangle(x0 as single,y0 as single,x1 as single,y1 as single, x2 as single, y2 as single,optional sgroupe as object, Optional UneImage as object) as object
Dim secArray(0 to 3, 0 to 1) as single
secArray(0,0)=x0
secArray(0,1)=y0
secArray(1,0)=x1
secArray(1,1)=y1
secArray(2,0)=x2
secArray(2,1)=y2
secArray(3,0)=x0
secArray(3,1)=y0
if ismissing(UneImage) then
InsereTriangle() = InserePolygone(secArray(), 4, sgroupe)
else
InsereTriangle() = InserePolygone(secArray(), 4, sgroupe, UneImage)
end if
end function
Function LoadDialog(Libname as String, DialogName as String) ', Optional oLibContainer) rem charge une boite de dialogue
Dim oLib,oLibDialog,oRuntimeDialog,oDialogModel,oVar,oVar1 as Object
Dim langue As New com.sun.star.lang.Locale
DialogLibraries.LoadLibrary(LibName)
oLib = DialogLibraries.GetByName(Libname)
oLibDialog = oLib.GetByName(DialogName)
oRuntimeDialog = CreateUnoDialog(oLibDialog)
oDialogModel=oRuntimeDialog.Model
InitialiseForm(oRuntimeDialog)
LoadDialog() = oRuntimeDialog
if (iLang <> -1) Then
select case iLang
case 0
langue.Language = "fr"
langue.Country = "FR"
case 1
langue.Language = "en"
langue.Country = "US"
case 2
langue.Language = "de"
langue.Country = "DE"
End Select
oRuntimeDialog.Model.ResourceResolver.setCurrentLocale(langue, True)
End If
laBoitedeDialogue = oRuntimeDialog
End Function
Function MakePoint( x As Long, y As Long ) As com.sun.star.awt.Point
Dim aPoint As New com.sun.star.awt.Point
aPoint.x = x
aPoint.y = y
MakePoint() = aPoint
End Function
function MarqueAngleDroit(xd as single, yd as single, xs as single, ys as single, sgroupe As object,Optional UneImage as Object) as object
Dim pgroupe As object
Dim alpha as Double
Dim unObjet as Object
pGroupe=initialisegroupe()
alpha = CalculeAngle(xd, yd, xs, ys)
if ismissing(uneImage) then
InsereLigne(xd + 200 * Cos(alpha), yd + 200 * Sin(alpha), xd + 200 * (Cos(alpha) - Sin(alpha)), yd + 200 * (Sin(alpha) + Cos(alpha)), pgroupe)
InsereLigne(xd - 200 * Sin(alpha), yd + 200 * Cos(alpha), xd + 200 * (Cos(alpha) - Sin(alpha)), yd + 200 * (Sin(alpha) + Cos(alpha)), pgroupe)
else
InsereLigne(xd + 200 * Cos(alpha), yd + 200 * Sin(alpha), xd + 200 * (Cos(alpha) - Sin(alpha)), yd + 200 * (Sin(alpha) + Cos(alpha)), pgroupe, uneImage)
InsereLigne(xd - 200 * Sin(alpha), yd + 200 * Cos(alpha), xd + 200 * (Cos(alpha) - Sin(alpha)), yd + 200 * (Sin(alpha) + Cos(alpha)), pgroupe, uneImage)
End if
UnObjet = GroupeObjet(pGroupe)
if not ismissing(sgroupe) then
sgroupe.add(UnObjet)
end if
MarqueAngleDroit()=UnObjet
End function
sub PointInsertion(posx,posy)
posx=3000
posy=3000
end sub
function TraceBissectrice(xx1 as single, yy1 as single, xxx0 as single, yyy0 as single, xx2 as single, yy2 as single, sgroupe as object, Optional ProlongeBissectriceS as boolean, Optional ProlongeBissectriceI as boolean, Optional xci as integer, Optional yci as integer) as object
dim pgroupe as object
dim xx0, yy0
dim alpha,beta
dim xx,yy
dim angleh
Dim seg1 as Object, seg2 as Object, seg3 as Object, seg4 as Object
Dim unObjet as Object
Dim lecodage
dim aa
if (ismissing(ProlongeBissectriceS)) then ProlongeBissectriceS=False
if (ismissing(ProlongeBissectriceI)) then ProlongeBissectriceI=False
pgroupe=InitialiseGroupe()
xx0 = xxx0
yy0 = yyy0
alpha = CalculeAngle(xx0, yy0, xx2, yy2) * 180 / Pi
beta = CalculeAngle(xx0, yy0, xx1, yy1) * 180 / Pi
If alpha > beta Then
If alpha - beta > 180 Then
alpha = alpha - 360
end if
Else
If beta - alpha > 180 Then
beta = beta - 360
end if
End If
aa = (alpha + beta) / 2
xx = xx0 + 5000 * Cos(aa * Pi / 180)
yy = yy0 + 5000 * Sin(aa * Pi / 180)
If ProlongeBissectriceS Then
angleh = CalculeAngle(xx0, yy0, xx, yy)
xx0 = xx0 - 5000 * Cos(angleh)
yy0 = yy0 - 5000 * Sin(angleh)
End If
If ProlongeBissectriceI Then
angleh = CalculeAngle(xx0, yy0, xx, yy)
If xx0 > xx Or yy0 > yy Then
If xci < xx Or yci < yy Then
xx = xci + 5000 * Cos(angleh)
yy = yci + 5000 * Sin(angleh)
End If
End If
If xx0 < xx Or yy0 < yy Then
If xci > xx Or yci > yy Then
xx = xci + 5000 * Cos(angleh)
yy = yci + 5000 * Sin(angleh)
End If
End If
End If
InsereLigne(xx0, yy0, xx, yy, pgroupe)
If (CInt(CodageALabel2) <> 10) Then
Seg1 = InsereLigne(xx0, yy0, xx1, yy1)
Seg1.LineColor = RGB(0, 0, 255)
Seg2 = InsereLigne(xx0, yy0, xx, yy)
Seg2.LineColor = RGB(0, 0, 255)
Seg3 = InsereLigne(xx0, yy0, xx2, yy2)
Seg3.LineColor = RGB(255, 0, 0)
Seg4 = InsereLigne(xx0, yy0, xx + 1, yy)
Seg4.LineColor = RGB(255, 0, 0)
AfficheCodageAForm
oDocumentDessin.DrawPages.GetByIndex(0).remove(Seg1)
oDocumentDessin.DrawPages.GetByIndex(0).remove(Seg2)
oDocumentDessin.DrawPages.GetByIndex(0).remove(Seg3)
oDocumentDessin.DrawPages.GetByIndex(0).remove(Seg4)
lecodage = CInt(CodageALabel2)
If (lecodage = 10) Then lecodage = 0
End If
If (CInt(CodageALabel2) = 10) Then
lecodage = lecodage + 1
If lecodage = 10 Then
lecodage = 1
end if
End If
If (CodageALabel2 <> "11") Then
MarqueAngle(xx1, yy1, xx0, yy0, xx, yy, (aa > 180), lecodage, 0, pgroupe)
MarqueAngle(xx, yy, xx0, yy0, xx2, yy2, (aa > 180), lecodage, 1, pgroupe)
End If
UnObjet=GroupeObjet(pgroupe)
if not ismissing(sgroupe) then
sgroupe.add(UnObjet)
end if
TraceBissectrice()=UnObjet
End function
function TraceParallele(xx0, yy0, xx1, yy1, xx2, yy2, optional sgroupe as object) as object
UnAngle = CalculeAngle(xx0, yy0, xx1, yy1)
ll = 4000
if not ismissing(sgroupe) then
UnObjet=InsereLigne(xx2 - ll * Cos(UnAngle), yy2 - ll * Sin(UnAngle), xx2 + ll * Cos(UnAngle), yy2 + ll * Sin(UnAngle), sgroupe)
else
UnObjet=InsereLigne(xx2 - ll * Cos(UnAngle), yy2 - ll * Sin(UnAngle), xx2 + ll * Cos(UnAngle), yy2 + ll * Sin(UnAngle))
end if
TraceParallele()=UnObjet
End function
function TracePerpendiculaire(xx0 as Single, yy0 as Single, xx1 as Single, yy1 as Single, xx2 as Single, yy2 as Single, optional sgroupe as object) as object
dim pgroupe as object
Dim xx as Single, yy as Single
Dim unAngle as Double
pGroupe=InitialiseGroupe()
TrouvePiedHauteur(xx0, yy0, xx1, yy1, xx2, yy2, xx, yy)
UnAngle = CalculeAngle(xx0, yy0, xx1, yy1) + Pi / 2
InsereLigne(xx - 5000 * Cos(UnAngle), yy - 5000 * Sin(UnAngle), xx + 5000 * Cos(UnAngle), yy + 5000 * Sin(UnAngle), pgroupe)
MarqueAngleDroit(xx, yy, MIif(xx = xx0, xx1, xx0), MIif(yy = yy0, yy1, yy0), pgroupe)
UnObjet=GroupeObjet(pGroupe)
if not ismissing(sgroupe) then
sgroupe.add(UnObjet)
end if
TracePerpendiculaire()=UnObjet
End function
Function SelectionneForme(oDocument as Object, uneForme as Object) as Boolean
on error goto fin
SelectionneForme=False
oDocument.CurrentController.Select(uneForme)
SelectionneForme=True
fin:
end Function
Sub ExtraitPoint(texte$, i, np$, xx, yy, Optional txx as String, Optional tyy as string)
Dim a, b, c, coord1$, coord2$, num, den
if ismissing(txx) then txx=""
if ismissing(tyy) then tyy=""
a = InStr(i, texte$, "(")
' If a = 0 Or a - i > 1 Then
If a = 0 Then
i = -1
Else
b = InStr(a, texte$, ";")
If b = 0 Then
i = -1
Else
c = InStr(b, texte$, ")")
If c = 0 Then
i = -1
Else
np$ = ""
If a > 1 Then np$ = Left(texte$, a - 1)
coord1$ = Mid$(texte$, a + 1, b - a - 1)
If txx <> "" Then txx = coord1$
RemplaceVirgulePoint coord1$
coord2$ = Mid$(texte$, b + 1, c - b - 1)
If tyy <> "" Then tyy = coord2$
RemplaceVirgulePoint coord2$
If InStr(1, coord1$, "/") <> 0 Then
AACExtraitNDF coord1$, num, den
xx = Val(num) / Val(den)
Else
xx = Val(coord1$)
End If
If InStr(1, coord2$, "/") <> 0 Then
AACExtraitNDF coord2$, num, den
yy = Val(num) / Val(den)
Else
yy = Val(coord2$)
End If
i = c + 1
End If
End If
End If
End Sub
Sub OAttribut(oShape As Object, Couleur, epaisseur, style)
Dim i
if oShape.ShapeType = "com.sun.star.drawing.GroupShape" Then
for i=0 to oShape.Count-1
OAttribut(oShape(i), Couleur, epaisseur, style)
next i
else
OAttributB(oShape, Couleur, epaisseur, style)
End if
End Sub
Sub OAttributB(oShape as Object, Couleur, epaisseur, style)
Dim mesTirets as new com.sun.star.drawing.LineDash
with mesTirets
.Style = com.sun.star.drawing.DashStyle.RECT
.Dots = 0
.DotLen = 0
.Dashes = 1
.DashLen = 100
.Distance = 100
End With
if (style="msoLineSolid") then oShape.LineStyle = com.sun.star.drawing.LineStyle.SOLID
if (style="msoLineDash") then
oShape.LineStyle = com.sun.star.drawing.LineStyle.DASH
oShape.LineDash = mesTirets
end if
oShape.LineWidth = val(epaisseur)*17639/500
oShape.LineColor = Couleur
End Sub
Sub ExtraitVecteur(texte$, i, x0, y0, x1, y1)
Dim param() as string
i=-1
if left(texte$,1)="{" and right(texte$,1)="}" then
i=ChargeParametre(mid(texte$,2,len(texte$)-2), param(), ";")
RemplaceVirgulePoint param(0)
RemplaceVirgulePoint param(1)
RemplaceVirgulePoint param(2)
RemplaceVirgulePoint param(3)
x0 = Val(param(0))
y0 = Val(param(1))
x1 = Val(param(2))
y1 = Val(param(3))
End If
End Sub
Sub ExtraitSegment(texte$, i, x0, y0, x1, y1)
Dim param() as string
i=-1
if left(texte$,1)="[" and right(texte$,1)="]" then
i=ChargeParametre(mid(texte$,2,len(texte$)-2), param(), ";")
RemplaceVirgulePoint param(0)
RemplaceVirgulePoint param(1)
RemplaceVirgulePoint param(2)
RemplaceVirgulePoint param(3)
x0 = Val(param(0))
y0 = Val(param(1))
x1 = Val(param(2))
y1 = Val(param(3))
End If
End Sub
Sub MarqueExtremites(x0, y0, x1, y1, Shapes as Object, Optional trait1 As object, Optional trait2 As object)
Dim xm, ym, r
xm = (x0 + x1) / 2
ym = (y0 + y1) / 2
r = Sqr((x0 - xm) * (x0 - xm) + (y0 - ym) * (y0 - ym))
trait1=InsereLigne(x0 - 100 * (y0 - ym) / r, y0 + 100 * (x0 - xm) / r, x0 + 100 * (y0 - ym) / r, y0 - 100 * (x0 - xm) / r, Shapes)
trait2=InsereLigne(x1 - 100 * (y0 - ym) / r, y1 + 100 * (x0 - xm) / r, x1 + 100 * (y0 - ym) / r, y1 - 100 * (x0 - xm) / r, Shapes)
End Sub
Sub ExtraitDroite(texte$, i, a, b, c, eqdroite$)
Dim ffx$, x1, y1, x2, y2, Defini, ffy$
If UCase(Left(texte$, 1)) = "Y" Then
' y=f(x)
ffx$ = Right(texte$, Len(texte$) - InStr(1, texte$, "="))
RemplaceTexte ffx$, "x", "(-1)"
x1 = -1
y1 = CalculeFonction(ffx$, Defini)
ffx = Right(texte$, Len(texte$) - InStr(1, texte$, "="))
RemplaceTexte ffx$, "x", "(+1)"
x2 = 1
y2 = CalculeFonction(ffx$, Defini)
Else
'x=f(y)
If UCase(Left(texte$, 1)) = "X" Then
ffy$ = Right(texte$, Len(texte$) - InStr(1, texte$, "="))
RemplaceTexte ffy$, "y", "(-1)"
y1 = -1
x1 = CalculeFonction(ffy$, Defini)
ffy$ = Right(texte$, Len(texte$) - InStr(1, texte$, "="))
RemplaceTexte ffy$, "y", "(+1)"
y2 = 1
x2 = CalculeFonction(ffy$, Defini)
Else
i = -1
End If
End If
If i <> -1 Then
If x1 <> x2 Then
a = (y1 - y2) / (x1 - x2)
b = -1
c = y1 - a * x1
Else
a = 1
b = 0
c = -x1
End If
eqdroite$ = texte$
End If
End Sub
Function getModuleText(LibN As String, ModN As String) As String
Dim LibContainer As Object
Dim Lib1 As Object
dim texte as String
dim stexte as string
dim atexte as String
LibContainer = GlobalScope.BasicLibraries
Lib1 = LibContainer.getByName(LibN)
if Lib1.hasByName(ModN) then
stexte = Lib1.getByName(ModN)
atexte = stexte
if instr(1, stexte, "OOoGdmath_NomPolice") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_NomPolice = " & chr(34) & "Times New Roman" & chr(34) & chr(10)
if instr(1, stexte, "OOoGdmath_TaillePolice") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_TaillePolice = 12" & chr(10)
if instr(1, stexte, "OOoGdmath_ItaliquePolice") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_ItaliquePolice = 0" & chr(10)
if instr(1, stexte, "OOoGdmath_SoulignePolice") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_SoulignePolice = 0" & chr(10)
if instr(1, stexte, "OOoGdmath_GrasPolice") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_GrasPolice = 0" & chr(10)
if instr(1, stexte, "OOoGdmath_SensNommage") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_SensNommage = 0" & chr(10)
if instr(1, stexte, "OOoGdmath_TypeNommage") = 0 Then stexte = stexte & chr(10) & "Public Const OOoGdmath_TypeNommage = 0" & chr(10)
if instr(1, stexte, "Sub OOoGdmath()") = 0 Then stexte = stexte & chr(10) & chr(10) & "Sub OOoGdmath()" & chr(10) & "Print " & chr(34) & "OOoGdmath" & chr(34) & chr(10) & "End Sub" & chr(10)
if atexte <> stexte then saveModuleText LibN, ModN, stexte
else
texte = chr(10)
texte = texte & "Public Const OOoGdmath_NomPolice = " & chr(34) & "Times New Roman" & chr(34) & chr(10)
texte = texte & "Public Const OOoGdmath_TaillePolice = 12" & chr(10)
texte = texte & "Public Const OOoGdmath_ItaliquePolice = 0" & chr(10)
texte = texte & "Public Const OOoGdmath_SoulignePolice = 0" & chr(10)
texte = texte & "Public Const OOoGdmath_GrasPolice = 0" & chr(10)
texte = texte & "Public Const OOoGdmath_SensNommage = 0" & chr(10)
texte = texte & "Public Const OOoGdmath_TypeNommage = 0" & chr(10)
texte = texte & chr(10) & chr(10) & "Sub OOoGdmath()" & chr(10)
texte = texte & "Print " & chr(34) & "OOoGdmath" & chr(34) & chr(10)
texte = texte & "End Sub" & chr(10)
Lib1.InsertByName(ModN, texte)
stexte = texte
end if
getModuleText() = stexte
End Function
' returns true if successful
Function saveModuleText(LibN As String, ModN As String, newText As String) As Boolean
Dim LibContainer As Object
Dim Lib1 As Object
LibContainer = GlobalScope.BasicLibraries
Lib1 = LibContainer.getByName(LibN)
if Lib1.hasByName(ModN) then
Lib1.replacebyName(ModN, newText)
saveModuleText = true
else
Lib1.insertByName(ModN, "")
saveModuleText = saveModuleText(LibN, ModN, newText)
end if
End Function
Sub RemplaceX(texte$, X)
Dim tx
RemplaceTexte texte$, "exp", "esp"
tx = InStr(1, UCase(texte$), "X")
While tx > 0
texte$ = Left$(texte$, tx - 1) + "(" + Str(X) + ")" + Right$(texte$, Len(texte$) - tx)
tx = InStr(tx + 1, UCase(texte$), "X")
Wend
RemplaceTexte texte$, "esp", "exp"
End Sub
Sub RemplaceY(texte, X)
Dim tx
tx = InStr(1, UCase(texte), "Y")
While tx > 0
texte = Left(texte, tx - 1) + X + Right(texte, Len(texte) - tx)
tx = InStr(tx + 1, UCase(texte), "Y")
Wend
End Sub
Sub RemplaceT(texte$, X)
Dim tx
RemplaceTexte texte$, "tan", "xan"
tx = InStr(1, UCase(texte$), "T")
While tx > 0
texte$ = Left(texte$, tx - 1) + X + Right(texte$, Len(texte$) - tx)
tx = InStr(tx + 1, UCase(texte$), "T")
Wend
RemplaceTexte texte$, "xan", "tan"
End Sub
Sub CalculeCoordonnees(xx, yy, posx, posy, dx, dy, angleaxe)
Dim xxx, yyy
xxx = posx + xx * dx + yy * dy * Cos(angleaxe)
yyy = posy - yy * dy * Sin(angleaxe)
xx = xxx
yy = yyy
End Sub
Sub RemplissageForme(zone1, couleur, Transparence)
zone1.zOrder = -1
zone1.LineStyle = com.sun.star.drawing.LineStyle.NONE
zone1.FillStyle = com.sun.star.drawing.FillStyle.SOLID
zone1.FillColor = couleur
zone1.FillTransparence = Transparence
End Sub
Function NombreTexte(Debut, texte1, texte2) As Integer
Dim a, i
a = Debut
i = 0
While (a > 0)
a = InStr(a, texte1, texte2)
If a > 0 Then
a = a + 1
i = i + 1
End If
If texte2 = "\s\do" Then
If a > 0 Then
If Mid(texte1, a + 6, 2) = "\f" Then
i = i - 1
End If
End If
End If
Wend
NombreTexte = i
End Function
Function MIif(unEtat as Boolean, valeur1, valeur2) as variant
If unEtat then
MIif() = valeur1
Else
MIif() = valeur2
End If
End Function
Sub TraceLigneGroupe(unGroupe as Object, position as String, uneImage As Object)
Dim Group as Object
Dim px,py,lx,ly
Dim i
Group = oDocumentDessin.DrawPages.GetByIndex(0).group(unGroupe)
lx = Group.Size.Width
ly = Group.Size.Height
px = Group.Position.x
py = Group.Position.y
oDocumentDessin.DrawPages.GetByIndex(0).ungroup(Group)
for i=1 to len(position)
select case mid(position, i, 1)
case "s"
InsereLigne px-lx*0.1, py+ly+100, px+lx+lx*0.1, py+ly+100, unGroupe, uneImage
case "n"
InsereLigne px-lx*0.1, py, px+lx+lx*0.1, py, unGroupe, uneImage
End Select
Next i
End Sub
Sub NormaliseCoordonnees(x, y, x1, y1, x0, y0, x2, y2, Optional sens)
Dim n
if ismissing(sens) then sens = 300
n = sqr((2 * x0 - x1 - x2) ^ 2 + (2 * y0 - y1 - y2) ^ 2)
x = (2 * x0 - x1 - x2) / n
y = (2 * y0 - y1 - y2) / n
x = x0 + sens * x
y = y0 + sens * y
End Sub
Function MVal(unTexte as string)
RemplaceVirgulePoint unTexte
Mval = val(unTexte)
End Function
</script:module>
|