/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths/Module1.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 | <?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="Module1" script:language="StarBasic">'************************************************
'Copyright (C) 2008 Didier Dorange-Pattoret
'38, chemin de l'Abbaye
'74940 Annecy le Vieux
'France
'ddorange@dmaths.com
'
'
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public Licence (GPL)
'as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
'This library 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 Licence (GPL)
'along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'************************************************
REM ***** BASIC *****
'Option Explicit
Global bVerifSauvegarde as Boolean
Global bExecCoordColonne as Boolean rem Coordonnées en colonne si True
Public sEq as String
Public Erreur,bBoite as Boolean 'bBoite=True si la boite existe
'Global bTaquetPose as Boolean ' prend la valeur true si un taquet est pose
'Global oCursorTaquet as Object 'le curseur au taquet pose
Public iAverto as Integer 'iTaille contient la taille de la formule
Public Brac1,Brac2,Brac3,Brac4,Brac5,Brac6 as String 'Brac1 à gauche, 2 à droite, 3 le 4, 4 pour \, 5 pour left, 6 pour right.
rem iAverto contient le numéro de ligne du message
Private sNomPolice as String 'contient le nom de la police du curseur visible.
Public aSel as New com.sun.star.awt.Selection 'GF pour Metentre Form et Form1
Public aSel0 as New com.sun.star.awt.Selection 'GF pour Metentre Form
Public aSel1 as New com.sun.star.awt.Selection 'GF pour Metentre Form1
Public CursorPos as Integer 'for TextField1 in FormuleGraphique GF may 2007
REM Insert HelpText of any CommandButton, allow space before and after, GF Sept.2008
REM Same method possible with property Tag (in german: Zusatzinformation): CBevent.Tag
Sub MetHelptext(event)
'Xray event
CBevent = event.source.Peer
MetEntre(" " + CBevent.AccessibleContext.ToolTipText + " ","")
End Sub
REM the following is needed for visible accolades in many dialogues (formule, racine...)
Sub MetentreAccolades2 'GF
MetEntre("\{","\}")
End Sub
Sub Metgeslant 'GF
MetEntre("`geslant`","")
End Sub
Sub Metleslant 'GF
MetEntre("`leslant`","")
End Sub
Sub MetentreExp
MetEntre("^{","}")
End Sub
Sub MetentreIndex
MetEntre("_{","}")
End Sub
Sub LoadParCro
Call VerifOperationnel
oBoite=LoadDialog("Dmaths","ParCro" )
oBoite.Execute()
End Sub
Sub MetLPi
MetEntre(" pi ","")
End Sub
Sub MetLcdot
MetEntre("`cdot`","")
End Sub
Sub MetLtimes
MetEntre("`times`","")
End Sub
Sub InsertBlanc
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oCursor = oDocument.currentcontroller.getViewCursor()
oCursor.getText().insertString(oCursor.getStart()," ",false)
End Sub
Function recul(N as Integer)
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oCursor = oDocument.currentcontroller.getViewCursor()
oCursor.Goleft(N,False)
End Function
Sub recul1
recul(1)
End Sub
Sub recul2
recul(2)
End Sub
Sub recul5
recul(5)
End Sub
Sub recul6
recul(6)
End Sub
Sub recul8
recul(8)
End Sub
Sub recul10
recul(10)
End Sub
Sub recul11
recul(11)
End Sub
Sub recul12
recul(12)
End Sub
Sub recul3
recul(3)
End Sub
Sub recul14
recul(14)
End Sub
Sub recul21
recul(21)
End Sub
Sub recul22
recul(22)
End Sub
Sub recul26
recul(26)
End Sub
Sub recul32
recul(32)
End Sub
rem Traite norme et valeur absolue
Function TraitNoVa(sMot,Indice,LongMot,bNorme)
If bModeFactoriel = False Then
If Mid(sMot,Indice,1)="!" and Mid(sMot,Indice+1,1)<>"!" and bNorme=False Then
sMot=Mid(sMot,1,Indice-1)+" left lline "+Mid(sMot,Indice+1,LongMot-Indice)
Indice=Indice+11
LongMot=LongMot+11
bNorme=True
Endif
If Mid(sMot,Indice,1)="!" and Mid(sMot,Indice+1,1)<>"!" and bNorme=True Then
sMot=Mid(sMot,1,Indice-1)+" right lline "+Mid(sMot,Indice+1,LongMot-Indice)
Indice=Indice+12
LongMot=LongMot+12
bNorme=False
Endif
If Mid(sMot,Indice,2)="!!" and bNorme=False Then
sMot=Mid(sMot,1,Indice-1)+" left ldline "+Mid(sMot,Indice+2,LongMot-Indice-1)
Indice=Indice+12
LongMot=LongMot+12
bNorme=True
Endif
If Mid(sMot,Indice,2)="!!" and bNorme=True Then
sMot=Mid(sMot,1,Indice-1)+" right ldline "+Mid(sMot,Indice+2,LongMot-Indice-1)
Indice=Indice+13
LongMot=LongMot+13
bNorme=False
Endif
Else
If Mid(sMot,Indice,1)="!" Then
sMot=Mid(sMot,1,Indice-1)+" nitalic "+Mid(sMot,Indice,LongMot-Indice+1)
Indice=Indice+9
LongMot=LongMot+9
Endif
Endif
End Function
Function StopCar(oCurs as Object, iCar as Long, bGauche as Boolean) as Boolean
Rem ecrite le 18 septembre 2010, sert a arreter le curseur
Dim bResul as Boolean, iVar as Integer
bResul = False
If ((Not bGauche and oCurs.isEndOfParagraph) or (bGauche and oCurs.isStartOfParagraph)) Then bResul = True
If (iCar = 9 or iCar = 10 or iCar = 13 or iCar = 32 or iCar = -2) Then bResul = True
If bGauche and iCar=45 Then
oCurs.Goleft(1,True)
If oCurs.string = "-" Then bResul = True
oCurs.Goleft(0,False)
oCurs.Goright(1,False)
Endif
If bGauche and iCar=95 Then
oCurs.Goleft(1,True)
If oCurs.string = "_" Then bResul = True
oCurs.Goleft(0,False)
oCurs.Goright(1,False)
Endif
If bGauche and iCar=46 then
oCurs.Goleft(3,True)
' Print oCurs.string,Len(oCurs.string),"ici"
If Mid(oCurs.String,3,1)="." and Mid(oCurs.String,2,1)="." and Mid(oCurs.String,1,1)<>")" and Mid(oCurs.String,1,1)<>"]" _
and Mid(oCurs.String,1,1)<>"+" and Mid(oCurs.String,1,1)<>"*" and Mid(oCurs.String,1,1)<>"×" Then
bResul = True
' Print "arret"
End if
If Mid(oCurs.String,1,1)="…" or Mid(oCurs.String,2,1)="…" Then
bResul = True
End if
iVar = Len(oCurs.string)
' Print "iVar",iVar
oCurs.Goleft(0,False)
oCurs.Goright(iVar,False)
Endif
StopCar = bResul
End Function
Function Selec
Dim LongsEq as Integer,I as Integer,N as Integer,NbreBlanc as Integer
Dim Test as String
Dim oDesktop as Object, oDocument as Object,oText as Object, oVCursor as Object, oTextActif as Object
Dim oCursor as Object, oCursor2 as Object, oCursorBarre as Object
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oVCursor = oDocument.currentcontroller.getViewCursor()
oTextActif = oVCursor.Text ' la zone de texte actif page ou cellule ....
oCursor = oTextActif.createTextCursorByRange(oVCursor)
oCursor2 = oTextActif.createTextCursorByRange(oCursor)
Erreur=False
If oVCursor.IsCollapsed Then
If oCursor.isEndOfParagraph and oCursor.isStartOfParagraph Then Goto Probleme1
Dim Car as Long
Car = -1
Do until StopCar(oCursor,Car,False)
oCursor.Goright(1,True)
If Len(oCursor.String())<>0 Then Car = Asc(oCursor.String()) Else Car = -2
oCursor.Goright(0,False)
Loop
If (Not oCursor.isEndOfParagraph and Car<>-1) Then oCursor.Goleft(1,False)
Car = -1
Do Until StopCar(oCursor2,Car,True)
oCursor2.Goleft(1,True)
If Len(oCursor2.String())<>0 Then Car = Asc(oCursor2.String()) Else Car = -2
oCursor2.Goleft(0,False)
Loop
If (Not oCursor2.isStartOfParagraph and Car<>-1) Then oCursor2.Goright(1,False)
If Car = -2 Then oCursor2.Goright(1,False)
If Car = 9 and oCursor2.isStartOfParagraph Then oCursor2.Goright(1,False)
oCursor.GotoRange(oCursor2,True)
sEq=oCursor.GetString()
If Len(sEq) = 0 Then Goto Probleme1
oVCursor.gotoRange(oCursor,True)
' Print sEq
Else
sEq=oCursor.getString()
Endif
rem dans cette partie on traite les caractères surlignés ou double surlignés Remarque uniquement pour OOo >= 3.1
If OOoNumVersion >=310 Then
oCursorBarre = oTextActif.createTextCursorByRange(oCursor)
oCursorBarre.CollapseToStart
Dim bOuv, bdOuv as Boolean, iCompteur, J as Integer
bOuv = False : bdOuv = False : iCompteur = Len(SEq) : J = 0
For I=1 To iCompteur
J = J + 1
oCursorBarre.goRight(1,True)
If (oCursorBarre.CharOverline = com.sun.star.awt.FontUnderline.SINGLE and bOuv = False) Then
bOuv = Not bOuv
sEq = Mid(sEq,1,J-1) & " overline{" & Mid(sEq,J,Len(sEq)-J+1)
J = J + 9
Endif
If (oCursorBarre.CharOverline <> com.sun.star.awt.FontUnderline.SINGLE and bOuv = True) Then
bOuv = Not bOuv
sEq = Mid(sEq,1,J) & "}" & Mid(sEq,J+1,Len(sEq)-J)
J = J + 2
Endif
If (oCursorBarre.CharOverline = com.sun.star.awt.FontUnderline.DOUBLE and bdOuv = False) Then
bdOuv = Not bdOuv
sEq = Mid(sEq,1,J-1) & " overline{overline{" & Mid(sEq,J,Len(sEq)-J+1)
J = J + 18
Endif
If (oCursorBarre.CharOverline <> com.sun.star.awt.FontUnderline.DOUBLE and bdOuv = True) Then
bdOuv = Not bdOuv
sEq = Mid(sEq,1,J) & "}}" & Mid(sEq,J+1,Len(sEq)-J)
J = J + 3
Endif
If (I = iCompteur and bOuv ) Then sEq = sEq & "}"
If (I = iCompteur and bdOuv) Then sEq = sEq & "}}" rem Ferme l'accolade au dernier caractère
oCursorBarre.goRight(0,False)
Next I
Endif
rem fin du traitement des caractères surlignés
If sEq= " " Then Goto Probleme1
rem vérifie le parenthésage
If bModeFactoriel = FALSE Then ' à vérifier en mode non factoriel seulement
N=0
For I=1 To Len(sEq)
If Mid(sEq,I,1)="!" Then N=N+1
Next I
If Int(N/2)<>Int(N)/2 Then
If msgbox(sVocab(iLang,3),256+48+1,"Dmaths")=2 Then Goto Probleme2 Else Goto FinVerifPar
Endif
Endif
N=0
For I=1 To Len(sEq)
If Mid(sEq,I,1)="$" Then N=N+1
Next I
If Int(N/2)<>Int(N)/2 Then
If msgbox(sVocab(iLang,3),256+48+1,"Dmaths")=2 Then Goto Probleme2 Else Goto FinVerifPar
Endif
N=0
For I=1 To Len(sEq)
If Mid(sEq,I,1)="(" or Mid(sEq,I,1)=")" Then N=N+1
Next I
If Int(N/2)<>Int(N)/2 Then
If msgbox(sVocab(iLang,3),256+48+1,"Dmaths")=2 Then Goto Probleme2 Else Goto FinVerifPar
Endif
N=0
For I=1 To Len(sEq)
If Mid(sEq,I,1)="[" or Mid(sEq,I,1)="]" Then N=N+1
Next I
If Int(N/2)<>Int(N)/2 Then
If msgbox(sVocab(iLang,3),256+48+1,"Dmaths")=2 Then Goto Probleme2 Else Goto FinVerifPar
Endif
N=0
For I=1 To Len(sEq)
If Mid(sEq,I,1)="&" Then N=N+1
Next I
If Int(N/2)<>Int(N)/2 Then
If msgbox(sVocab(iLang,3),256+48+1,"Dmaths")=2 Then Goto Probleme2 Else Goto FinVerifPar
Endif
rem fin vérification du parenthésage
FinVerifPar:
rem traitement du §
LongsEq=Len(sEq)
For I=1 to LongsEq
If Mid(sEq,I,1)="§" Then
sEq=Mid(sEq,1,I-1)+"&§&"+Mid(sEq,I+1,LongsEq-I)
LongsEq=LongsEq+2
I=I+2
Endif
Next I
Goto Fin
rem Edition du message d'erreur
Probleme1: Avertir(iAverto)
oVCursor.CollapseToEnd()
Goto Finp
Probleme2: oVCursor.CollapseToEnd()
Finp:
Erreur=True
Fin:
If Erreur=False Then oCursor.setString("")
Selec=sEq
End Function
rem fin de Selec
Function CoefficientsVecteurs(Mot$,iPos as Integer) as String
' Jerome Ortais
' Selectionne et traite avec Dixio une zone dans un calcul de vecteurs. Vérifie que les caractères binaires
'(*, =, /) en debut ou fin de Mot ne sont pas traites par Dixio. Renvoie la position du dernier caractere traite.
Dim sMot$, iCurseur as Integer
Dim bEstVecteurNul as Boolean, iLong as integer
Const cOperateurs="+-.=≃≈~≠ ", cNombres="0123456789,+-*/=≃≈~≠<≤≥>:;){}[]", cInterdits="*/=≃≈~≠<≤≥>"
sMot=Mot
iLong=Len(sMot)
iCurseur=1
bEstVecteurNul=False
Do While InStr(cNombres,Mid(sMot,iPos+iCurseur,1))>0 And iPos+iCurseur<=iLong And Not bEstVecteurNul
If Mid(sMot,iCurseur+iPos,1)="0" Then
'Verifie si un 0 est un vecteur nul ou un chiffre.
If iPos+iCurseur<iLong Then
bEstVecteurNul=(InStr(cOperateurs,Mid(sMot,iPos+iCurseur-1,1))>0) And (InStr(cOperateurs,Mid(sMot,iPos+iCurseur+1,1))>0)
Else
bEstVecteurNul=(InStr(cOperateurs,Mid(sMot,iPos+iCurseur-1,1))>0)
EndIf
EndIf
iCurseur=iCurseur+1
Loop
If bEstVecteurNul Then iCurseur=iCurseur-2 Else iCurseur=iCurseur-1
Car=Mid(sMot,iPos+iCurseur,1)
Select Case iCurseur
Case 0
If InStr(cInterdits,Mid(sMot,iPos,1))>0 Then
CoefficientsVecteurs=Dixio2(Mid(sMot,iPos,1))
Else
CoefficientsVecteurs=Dixio(Mid(sMot,iPos,1))
EndIf
Case 1
If InStr(cInterdits,Mid(sMot,iPos,1))>0 Then
If InStr(cInterdits,Mid(sMot,iPos+1,1))>0 Then
' Gere le cas de >=, <=, <>
CoefficientsVecteurs=Dixio(Mid(sMot,iPos,2))
Else
CoefficientsVecteurs=Dixio2(Mid(sMot,iPos,1))_
+Dixio(Mid(sMot,iPos+1,1))
EndIf
Else
If InStr(cInterdits,Mid(sMot,iPos+1,1))>0 Then
CoefficientsVecteurs=Dixio(Mid(sMot,iPos,1))_
+Dixio2(Mid(sMot,iPos+1,1))
Else
CoefficientsVecteurs=Dixio(Mid(sMot,iPos,2))
EndIf
EndIf
Case Else
If InStr(cInterdits,Mid(sMot,iPos,1))>0 Then
If InStr(cInterdits,Mid(sMot,iPos+iCurseur,1))>0 Then
CoefficientsVecteurs=Dixio2(Mid(sMot,iPos,1))_
+Dixio(Mid(sMot,iPos+1,iCurseur-1))_
+Dixio2(Mid(sMot,iPos+iCurseur,1))
Else
CoefficientsVecteurs=Dixio2(Mid(sMot,iPos,1))_
+Dixio(Mid(sMot,iPos+1,iCurseur))
EndIf
Else
If InStr(cInterdits,Mid(sMot,iPos+iCurseur,1))>0 Then
CoefficientsVecteurs=Dixio(Mid(sMot,iPos,iCurseur))_
+Dixio2(Mid(sMot,iPos+iCurseur,1))
Else
CoefficientsVecteurs=Dixio(Mid(sMot,iPos,iCurseur+1))
EndIf
EndIf
End Select
iPos=iPos+iCurseur
End Function
Function TraiteGeometrie(Chaine$,Param$) as String
' Jerome Ortais
' Gere l'affichage des angles, vecteurs et derives pointees.
Const cOperateurs = "+-. =≃≈~≠"
Dim sChaine$, sParam$, sCar$, cScalaires$
Dim iLongueur as Integer, iPos as Integer, iPos1 as Integer, iPos2 as Integer, iFin as Integer
Dim bEstVecteurNul as Boolean
Rem permet de considerer si option choisie les lettres comme scalaires
cScalaires = "0123456789,.+-×*:/=≠≃≈<≤≥>;#\})]^∧° '"
If bLettresAreScalaires = TRUE Then cScalaires = cScalaires & sLettresScalaires &""
rem ---------------------------------------------------------------------------
sChaine=Chaine
sParam=Param
If sChaine="" Then Goto SortieFonction
iLongueur=Len(sChaine)
sCar=Mid(sChaine,1,1)
Select Case sCar
Case "$"
' Ce qui est entre $...$ doit etre traite comme une formule.
iFin=InStr(2,sChaine,"$")
sChaine=Dmaths.Module2.Dixio(Mid(sChaine,2,iFin-2))_
+TraiteGeometrie(Mid(sChaine,iFin+1),sParam)
Case "("
If InStr(sParam,"widehat")>0 Then
' Les valeurs entre parentheses sont des vecteurs.
' On appelle TraiteGeometrie sur le contenu des parentheses.
iFin=Dmaths.Module2.TrouvePaire(sChaine,1,"(")
sChaine=sParam+"{("_
+TraiteGeometrie(Mid(sChaine,2,iFin-2)," widevec ")+")}"_
+TraiteGeometrie(Mid(sChaine,iFin+1),sParam)
Else
iPos=1
sChaine=CoefficientsVecteurs(sChaine,iPos)_
+TraiteGeometrie(Mid(sChaine,iPos+1),sParam)
EndIf
Case "."
' Gestion des ..., produits scalaires et . A ameliorer.
If iLongueur>=3 Then
If Mid(sChaine,1,3)="..." Then
sChaine=" dotslow "_
+TraiteGeometrie(Mid(sChaine,4),sParam)
Else
sChaine=" cdot "+TraiteGeometrie(Mid(sChaine,2),sParam)
EndIf
Else sChaine=" cdot "+TraiteGeometrie(Mid(sChaine,2),sParam)
EndIf
Case "0"
' Gestion du vecteur nul (un peu basique)
bEstVecteurNul=False
If InStr(sParam,"widevec")>0 Then
If iLongueur=1 Then
bEstVecteurNul=True
Else
bEstVecteurNul=(InStr(cOperateurs,Mid(sChaine,2,1))>0)
EndIf
EndIf
If bEstVecteurNul Then
sChaine=sParam+"{0}"+TraiteGeometrie(Mid(sChaine,2),sParam)
Else
iPos=1
sChaine=CoefficientsVecteurs(sChaine,iPos)_
+TraiteGeometrie(Mid(sChaine,iPos+1),sParam)
EndIf
Case "%"
' Gestion du caractere %. On le supprime pour l'ajouter plus tard.
sChaine=TraiteGeometrie(Mid(sChaine,2),sParam)
Case Else
' Gestion des normes de vecteurs
If iLongueur>1 Then
If Mid(sChaine,1,2)="!!" Then
iPos=InStr(3,sChaine,"!!")
sChaine=" left ldline "+_
TraiteGeometrie(Mid(sChaine,3,iPos-3),sParam)+_
" right ldline " +_
TraiteGeometrie(Mid(sChaine,iPos+2),sParam)
Goto SortieFonction
' Gestion de pi
ElseIf Mid(sChaine,1,2)="pi" Then
sChaine="%pi"+TraiteGeometrie(Mid(sChaine,3),sParam)
Goto SortieFonction
EndIf
EndIf
' Si le caractere n'est pas un nombre, c'est un vecteur ou un angle.
If InStr(1,cScalaires,sCar,0)=0 Then
If iLongueur>1 Then
iFin=1
While (InStr(".+-×*:/=≠≃≈<≤≥>;#\{}()[]^∧° ",Mid(sChaine,iFin+1,1))=0) And iFin<iLongueur
iFin=iFin+1
WEnd
sChaine=sParam+"{"+Dixio2(Mid(sChaine,1,iFin))_
+"}"+TraiteGeometrie(Mid(sChaine,iFin+1),sParam)
Else sChaine=sParam+"{"+Dixio2(sChaine)+"}"
EndIf
' Le caractere est un nombre ou une operation. On cherche la fin de cette
' operation sans vecteur et on lui applique Dixio.
Else
iPos=1
sChaine=CoefficientsVecteurs(sChaine,iPos)_
+TraiteGeometrie(Mid(sChaine,iPos+1),sParam)
EndIf
End Select
SortieFonction:
TraiteGeometrie=sChaine
Erreur=False
End Function
Rem la macro ci-dessous corrige le CharPosture des scalaires
Rem ecrite le 8 septembre 2010
Function TraiteItalicScalVect(MaSource as String,bVecI, bScaI as boolean) as String
Dim sResultat, sIorNotI as String
Dim iPos1, iPos2, iLong as Integer
iLong = Len(MaSource)
iPos1 = 1
sResultat = Masource
If (Not bvecI and bScaI) Then
sIorNotI = " italic{"
ElseIf (bvecI and Not bScaI) Then
sIorNotI = " nitalic{"
Else
Goto RienaFaire
Endif
Do while iPos1 <= iLong
If CarIsScalaire(iPos1,sResultat) Then
iPos2 = iPos1 + 1
'Print iPos2, CarIsScalaire(iPos2,sResultat)
Do while CarIsScalaire(iPos2,sResultat)
iPos2 = iPos2 + 1
Loop
sResultat = Mid(sResultat,1,iPos1-1) & sIorNotI & Mid(sResultat,iPos1,iPos2-iPos1) & "} " & Mid(sResultat,iPos2,iLong-iPos2+1)
iPos1 = iPos1 + Len(sIorNotI) + 2
iLong = iLong + Len(sIorNotI) + 2
Endif
iPos1 = iPos1 + 1
Loop
RienAFaire:
TraiteItalicScalVect = sResultat
End Function
Rem determine si le caractere est un scalaire
Function CarIsScalaire(iPos as Integer, MaSource As String) as Boolean
rem macro cree le 8 septembre
Dim sCar as String
Dim bReponse as Boolean
bReponse = FALSE
sCar = Mid(MaSource,iPos,1)
If Instr(1,sLettresScalaires,sCar,0) > 0 Then
saEviter = Array("widevec","widehat","overline","italic","nitalic")
bReponse = TRUE
For I = LBound(saEviter) To UBound(saEviter)
If iPos = 1 Then
If Mid(MaSource,1,3) = Mid(saEviter(I),1,3) then
bReponse = FALSE : Goto Termine
Endif
ElseIf iPos = Len(MaSource) Then
If Mid(MaSource,Len(MaSource)-2,3) = Mid(saEviter(I),Len(saEviter(I))-2,3) then
bReponse = FALSE : Goto Termine
Endif
Else
If iPos < Len(MaSource)-1 Then
If Mid(MaSource,iPos,3) = Mid(saEviter(I),1,3) then
bReponse = FALSE : Goto Termine
Endif
Endif
If iPos > 2 Then
If Mid(MaSource,iPos-2,3) = Mid(saEviter(I),Len(saEviter(I))-2,3) then
bReponse = FALSE : Goto Termine
Endif
Endif
For J=2 To Len(saEviter(I))-1
If Mid(MaSource,iPos-1,3) = Mid(saEviter(I),J-1,3) then
bReponse = FALSE : Goto Termine
Endif
Next J
Endif
Next I
End if
Termine:
CarIsScalaire = bReponse
End Function
Function TraiteVecWidevec(MaSource as String) as String
rem cette macro transforme widevec en vec si un seul caractère ex widevec {u} devient vec {u}
rem macro ecrite le 30 aout 2010
Dim iPos1,iPos2 as Integer
iPos1 = InStr(MaSource,"widevec")
While iPos1 > 0
iPos2 = Instr(iPos1,MaSource,"}")
If (iPos2-iPos1 = 10 or (iPos2-iPos1 = 18 and Mid(MaSource,iPos1+10,6)="italic")) Then
MaSource = Mid(MaSource,1,iPos1-1) & Mid(MaSource,iPos1+4,Len(MaSource)-iPos1-3)
Endif
iPos1 = InStr(iPos2,MaSource,"widevec")
Wend
TraiteVecWidevec = MaSource
End Function
Sub MetenPointe
Call VerifOperationnel
rem macro modifiée le 15 novembre 2003
iAverto=323
bPointe=True
IsFormuleItalic = bItalic
InsertSourceFormule()
End Sub
Sub MetenDoublePointe
Call VerifOperationnel
rem macro modifiée le 15 novembre 2003
iAverto=323
bDPointe=True
IsFormuleItalic = bItalic
InsertSourceFormule()
End Sub
Sub MetenVecteur
Call VerifOperationnel
rem macro modifiée le 15 novembre 2003
iAverto=4
bVecteur=True
IsFormuleItalic = bVecteursItalic
InsertSourceFormule()
End Sub
Sub MetenVecteurColonne (sChaine as String)
rem macro crée le samedi 21 novembre 2003
rem cette macro modifie la source d'un vecteur mettre les coordonnées en colonne
On Error Goto Fin
Dim iLongChaine as Integer, I as Integer, iGdePar as Integer
Dim bParent as Boolean, bPointVirgule as Boolean
iLongChaine = Len (sChaine)
bPointVirgule=(InStr(sChaine,";")>0)
bParent=(InStr(sChaine,"(")>0)
If bParent = True and bPointVirgule = True Then
I=1
I=InStr(I,sChaine,"(")
iGdePar=InStr(sChaine,"left(")
Do While I>0
If iGdePar=0 Or iGdePar+4<>I Then
sChaine = Mid(sChaine,1,I-1)+" left(matrix{"+Mid(sChaine,I+1,iLongChaine-I)
iGdePar=InStr(I+13,sChaine,"left(")
I=InStr(I+13,sChaine,"(")
iLongChaine = iLongChaine+12
Else
sChaine = Mid(sChaine,1,I)+"matrix{"+Mid(sChaine,I+1,iLongChaine-I)
iGdePar=InStr(I+7,sChaine,"left(")
I=InStr(I+7,sChaine,"(")
EndIf
Loop
I=1
I=InStr(I,sChaine,"`")
Do While I>0
sChaine = Mid(sChaine,1,I-1)+Mid(sChaine,I+1)
I=InStr(I,sChaine,"`")
iLongChaine = iLongChaine - 1
Loop
I=1
I=InStr(I,sChaine,"nitalic;")
Do While I>0 and I<iLongChaine
sChaine = Mid(sChaine,1,I-1)+"##"+Mid(sChaine,I+8)
I=InStr(I+2,sChaine,"nitalic;")
iLongChaine = iLongChaine + 1
Loop
I=1
I=InStr(I,sChaine,";")
Do While I>0 and I<iLongChaine
sChaine = Mid(sChaine,1,I-1)+"##"+Mid(sChaine,I+1)
I=InStr(I+2,sChaine,";")
iLongChaine = iLongChaine + 1
Loop
I=1
I=InStr(I,sChaine,")")
iGdePar=InStr(sChaine,"right)")
Do While I>1
If iGdePar=0 Or iGdePar+5<>I Then
sChaine=Mid(sChaine,1,I-1)+"}right"+Mid(sChaine,I)
iGdePar=InStr(I+7,sChaine,"right)")
I=InStr(I+7,sChaine,")")
iLongChaine = iLongChaine+6
Else
sChaine=Mid(sChaine,1,iGdePar-1)+"}"+Mid(sChaine,iGdePar)
iGdePar=InStr(I+2,sChaine,"right)")
I=InStr(I+2,sChaine,")")
EndIf
Loop
Endif
Goto FinMacro
Fin:
Print sVocab(iLang,305)
FinMacro:
End Sub
Sub MetenMesureAlgebrique
Call VerifOperationnel
rem macro modifiée le 15 novembre 2003
iAverto=5
bMesureAlg=True
IsFormuleItalic = bMesuresAlgItalic
InsertSourceFormule()
End Sub
Sub MetenAngle
Call VerifOperationnel
rem macro modifiée le 15 novembre 2003
iAverto=6
bVecteur=False 'ajoute le 7 dec 04
bAngle=True
IsFormuleItalic = bAnglesItalic
InsertSourceFormule()
End Sub
Sub MetenFormule
Call VerifOperationnel
rem macro modifiée le 6 fevrier 2005
If bVerifSauvegarde = False and BasicLibraries.Standard.HasByname("DmOptions") Then Call VerifDateSauvegarde
bVerifSauvegarde = True
iAverto=7
IsFormuleItalic = bItalic
InsertSourceFormule()
End Sub
Function Lissm(sMot,sModule) as string
rem etudie la chaine et insere limite,integrale,somme,systeme,matrice
Dim sVar as string
Compteur=0
LongsMot=Len(sMot)
rem determine la présence de $
For N=1 to LongsMot
If Mid(sMot,N,1)="$" Then Compteur=Compteur+1
Next N
If Compteur=0 Then
sMot=TraiteModule(sMot,sModule)
Else
N=1
Do until N=LongsMot+1
If Mid(sMot,N,1)="$" Then
sMot=Mid(sMot,1,N-1)+Mid(sMot,N+1,LongsMot)
LongsMot=LongsMot-1
Do until Mid(sMot,N,1)="$"
N=N+1
Loop
sMot=Mid(sMot,1,N-1)+Mid(sMot,N+1,LongsMot)
LongsMot=LongsMot-1
N=N-1
Else
M=N
Do until Mid(sMot,M,1)="$" or M=LongsMot
M=M+1
Loop
If N<>1 and M<>LongsMot Then
sVar=TraiteModule(Mid(sMot,N,M-N),sModule)
sMot=Mid(sMot,1,N-1)+sVar+Mid(sMot,M,LongsMot-M+1)
Elseif N=1 Then
sVar=TraiteModule(Mid(sMot,N,M-N),sModule)
sMot=sVar+Mid(sMot,M,LongsMot-M+1)
Else
sVar=TraiteModule(Mid(sMot,N,M-N+1),sModule)
sMot=Mid(sMot,1,N-1)+sVar
Endif
LongsMot=Len(sMot)
N=N-1+Len(sVar)
Endif
N=N+1
Loop
Endif
If Erreur=True Then goto fin
sMot=Dmaths.Module2.Dixio(sMot)
InsertSourceIntegrale(sMot)
fin:
Erreur=False
End Function
Function TraiteModule(Chaine,Module)
Dim LongChaine,Mode as integer
Dim Resul,sV as string
LongChaine=Len(Chaine)
Mode=1
For I=1 To LongChaine
If Mid(Chaine,I,1)=";" Then Mode=Mode+1
Next I
If Module="Limite" Then
rem lim from{x rightarrow } {}
Dim BI as Integer ' rem determine si limite supperposee
BI=1
Do until Mid(Chaine,BI,1)="#" or BI = LongChaine
BI = BI + 1
Loop
If Mode>3 Then Goto Pb
Resul="} "
N=LongChaine
M=N
Do until Mid(Chaine,M,1)=";" or M=1
M=M-1
Loop
If M=1 Then
Goto Pb
Else
Resul=" } { "+Mid(Chaine,M+1,N-M)+Resul
N=M-1
M=M-1
Endif
Do until Mid(Chaine,M,1)=";" or M=1
M=M-1
Loop
If BI = LongChaine Then
If M=1 Then
Resul=" Lim from{ x rightarrow "+Mid(Chaine,1,N)+Resul
Else
Resul=" Lim from{ "+Mid(Chaine,1,M-1)+" rightarrow "+Mid(Chaine,M+1,N-M)+Resul
Endif
Else
If M=1 Then
Resul=" Lim from{ binom {x rightarrow "+Mid(Chaine,1,BI-1)+"}{"+Mid(Chaine,BI+1,N-BI)+"}"+Resul
Else
Resul=" Lim from{ binom {"+Mid(Chaine,1,M-1)+" rightarrow "+Mid(Chaine,M+1,BI-M-1)+"}{"+Mid(Chaine,BI+1,N-BI)+"}"+Resul
Endif
Endif
Endif
rem fin limite
If Module="Integrale" Then
If Mode>4 Then Goto Pb
If Mode=1 Then Resul=" int "+sBorneInfIntegrales+" {} "+sBorneSupIntegrales+" {} { "+Chaine+" } nitalic{d}x "
If Mode=2 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
Resul=" int "+sBorneInfIntegrales+" {} "+sBorneSupIntegrales+" {} { "+Mid(Chaine,1,M-1)+" } nitalic{d}"+Mid(Chaine,M+1,LongChaine-M)
Endif
rem int from{} to {} {} dx
If Mode=3 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
Resul=" int "+sBorneInfIntegrales+" {"+Mid(Chaine,1,M-1)+"} "+sBorneSupIntegrales+" {"
MP=M+1
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M+1,MP-M-1)+"} { "+Mid(Chaine,MP+1,LongChaine-MP)+" } nitalic{d}x "
Endif
rem int from{} to {} {} dx
If Mode=4 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
Resul=" int "+sBorneInfIntegrales+" {"+Mid(Chaine,1,M-1)+"} "+sBorneSupIntegrales+" {"
MP=M+1
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M+1,MP-M-1)+"} { "
MP=MP+1
M=MP
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M,LongChaine-M-1)+" } nitalic{d}"+Mid(Chaine,MP+1,LongChaine-MP)+" "
Endif
Endif
rem fin integrale
If Module="Somme" Then
If Mode>4 or Mode=2 Then Goto Pb
If Mode=1 Then Resul=" sum from {} to {} { "+Chaine+" } "
rem sum{} to {} {} dx
If Mode=3 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
Resul=" sum from {"+Mid(Chaine,1,M-1)+"} to {"
MP=M+1
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M+1,MP-M-1)+"} { "+Mid(Chaine,MP+1,LongChaine-MP)+" } "
Endif
rem sum from{} to {} {} dx
If Mode=4 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
sV=Mid(Chaine,1,M-1)
Resul=" sum from {"+Mid(Chaine,1,M-1)+"="
MP=M+1
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M+1,MP-M-1)+"} to { "+sV+"="
MP=MP+1
M=MP
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M,MP-M)+" } { "+Mid(Chaine,MP+1,LongChaine-MP)+" } "
Endif
Endif
rem fin somme
If Module="Produit" Then
If Mode>4 or Mode=2 Then Goto Pb
If Mode=1 Then Resul=" prod from {} to {} { "+Chaine+" } "
rem sum{} to {} {} dx
If Mode=3 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
Resul=" prod from {"+Mid(Chaine,1,M-1)+"} to {"
MP=M+1
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M+1,MP-M-1)+"} { "+Mid(Chaine,MP+1,LongChaine-MP)+" } "
Endif
rem sum from{} to {} {} dx
If Mode=4 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
sV=Mid(Chaine,1,M-1)
Resul=" prod from {"+Mid(Chaine,1,M-1)+"="
MP=M+1
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M+1,MP-M-1)+"} to { "+sV+"="
MP=MP+1
M=MP
Do until Mid(Chaine,MP,1)=";"
MP=MP+1
Loop
Resul=Resul+Mid(Chaine,M,MP-M)+" } { "+Mid(Chaine,MP+1,LongChaine-MP)+" } "
Endif
Endif
rem fin produit
If Module="Racine" Then
If Mode>2 Then Goto Pb
If Mode=1 Then Resul=" sqrt{"+Chaine+"}"
If Mode=2 Then
M=1
Do until Mid(Chaine,M,1)=";"
M=M+1
Loop
Resul="nroot{"+Mid(Chaine,1,M-1)+"}{"+Mid(Chaine,M+1,LongChaine)+"}"
Endif
Endif
rem fin racine
If Module="Systeme" Then
If Mode=1 Then Goto Pb
Resul="left lbrace stack{{ "
M=1
MP=1
Do until MP=LongChaine+1
Do until Mid(Chaine,MP,1)=";" or MP=LongChaine
MP=MP+1
Loop
If MP<>LongChaine Then
Resul=Resul+Mid(Chaine,M,MP-M)+"} # {"
Else
Resul=Resul+Mid(Chaine,M,MP-M+1)+" }} right none"
Endif
MP=MP+1
M=MP
Loop
Endif
rem fin systeme
If Module="Matrice" Then
If Mode=1 Then Goto Pb
If bMatricesRondes = True Then Resul="left( matrix{ " Else Resul="left[ matrix{ "
M=1
MP=1
Do until MP=LongChaine+1
Do until Mid(Chaine,MP,1)=";" or MP=LongChaine or Mid(Chaine,MP,1)="^"
MP=MP+1
Loop
If MP<>LongChaine Then
If Mid(Chaine,MP,1)="^" Then
Resul=Resul+Mid(Chaine,M,MP-M)+" } "
If bMatricesRondes = True Then Resul=Resul+"right)" Else Resul=Resul+"right]"
Resul=Resul+"^"
Else
Resul=Resul+Mid(Chaine,M,MP-M)+"#"
Endif
Else
If Mid(Chaine,M-1,1)="^" Then
Resul=Resul+Mid(Chaine,M,MP-M+1)
Else
Resul=Resul+Mid(Chaine,M,MP-M+1)+" } "
If bMatricesRondes = True Then Resul=Resul+"right)" Else Resul=Resul+"right]"
Endif
Endif
MP=MP+1
M=MP
Loop
Endif
rem fin matrice
If Module="MatriceSysteme" Then
If Mode=1 Then Goto Pb
Resul="alignr left lbrace matrix{ "
M=1
MP=1
Do until MP=LongChaine+1
Do until Mid(Chaine,MP,1)=";" or MP=LongChaine ' or Mid(Chaine,MP,1)="^"
MP=MP+1
Loop
If MP<>LongChaine Then
Resul=Resul+Mid(Chaine,M,MP-M)+"#"
Else
Resul=Resul+Mid(Chaine,M,MP-M+1)+" } "
Resul = Resul + "right none"
Endif
MP=MP+1
M=MP
Loop
Endif
rem fin matricesysteme
TraiteModule=Resul
Goto finT
Pb: Avertir(iAverto)
Erreur = True
finT:
End Function
Sub MetenLimite
Call VerifOperationnel
rem Macro enregistrée : vendredi 23 novembre 2001, 21:00
iAverto=8
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
Lissm(sEq,"Limite")
Fin:
End Sub
Sub MetenIntegrale
Call VerifOperationnel
rem Macro enregistrée : vendredi 23 novembre 2001, 21:00
iAverto=9
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
Lissm(sEq,"Integrale")
Fin:
End Sub
Sub MetenSomme
Call VerifOperationnel
rem Macro enregistrée : vendredi 23 novembre 2001, 21:00
iAverto=10
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
Lissm(sEq,"Somme")
Fin:
End Sub
Sub MetenProduit
Call VerifOperationnel
rem Macro enregistrée : mercredi 10 décembre 2003
iAverto=317
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
Lissm(sEq,"Produit")
Fin:
End Sub
Sub MetenRacine
Call VerifOperationnel
rem Macro enregistrée : vendredi 23 novembre 2001, 21:00
iAverto=11
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
Lissm(sEq,"Racine")
Fin:
End Sub
Sub MetenSysteme
Call VerifOperationnel
rem Macro enregistrée : vendredi 23 novembre 2001, 21:00
bSystemesEspaces = bSystemesAlignes
iAverto=12
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
If bSystemesAlignes = True Then Lissm(sEq,"MatriceSysteme") Else Lissm(sEq,"Systeme")
Fin:
End Sub
Sub MetenMatrice
Call VerifOperationnel
rem Macro enregistrée : vendredi 23 novembre 2001, 21:00
iAverto=13
IsFormuleItalic = bItalic
sEq=Dmaths.Module1.Selec
If Erreur=True Then Goto Fin
Lissm(sEq,"Matrice")
Fin:
End Sub
Sub MetenRacineBleue
MetEntre(" nroot{}{","} ")
End Sub
Sub MetLInfini
MetEntre(" inf ","")
End Sub
Sub MetLBlanc
MetEntre(" ` ","")
End Sub
Sub MetLLBlanc 'GF does not yet work
MetEntre(" \~ ","")
End Sub
Sub MetentreAccolades
Call VerifOperationnel
MetEntre("{","}")
End Sub
Sub MetentreAccoladesVariables
MetEntre("left lbrace "," right rbrace")
End Sub
Sub MetentreCrochets
oBoite=LoadDialog("Dmaths","ParCro" )
oBoite.Execute()
End Sub
Sub MetentreParentheses
Call VerifOperationnel
MetEntre("(",")")
End Sub
Sub MetentreParenthesesVariables
MetEntre(" left(","right)")
End Sub
Sub MetentreCrochets1
MetEntre("[","]")
End Sub
Sub MetentreCrochets2
MetEntre("\[","\[")
End Sub
Sub MetentreCrochets3
MetEntre("\]","\]")
End Sub
Sub MetentreCrochets4
MetEntre("\]","\[")
End Sub
Sub MetentreCrochets1Variables
MetEntre(" left[","right]")
End Sub
Sub MetentreCrochets2Variables
MetEntre(" left[","right[")
End Sub
Sub MetentreCrochets3Variables
MetEntre(" left]","right]")
End Sub
Sub MetentreCrochets4Variables
MetEntre(" left]","right[")
End Sub
Sub MetenValeurAbsolue
MetEntre(" abs{","}")
End Sub
Sub MetenNorme
MetEntre(" ldline "," rdline ")
End Sub
Sub MetenConjugue
MetEntre(" overline{","}")
End Sub
Sub InsereObjetFormule
Dim iTailleDElaFormule as Integer
Dim oTextActif as Object, oCursor as Object
Dim oDesktop as Object, oDocument as Object, oVCursor as Object
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oVCursor = oDocument.currentcontroller.getViewCursor()
sEq = oVCursor.String()
If Len(sEq)>0 Then
oTextActif = oVcursor.Text
oCursor = oTextActif.createTextCursorByRange(oVCursor.getstart())
If oVCursor.CharHeight <> 0 Then iTailleDElaFormule = oVCursor.CharHeight Else iTailleDElaFormule = oDocument.Text.End.CharHeight
If Len(oVCursor.CharFontName)>0 Then sNomPolice = oVCursor.CharFontName Else sNomPolice = oDocument.Text.End.CharFontName
rem memorise la police du curseur. rem la taille est provisoirement celle du caractère précédent la formule.
rem ----------------------------------------------------------------------------------
' on fixe la taille de la formule à la taille imposée si option choisie.
If Not bTailleFormCarac Then iTailleDElaFormule = iTailleFormules
If Not bUsingDispatcher Then oVCursor.String() = ""
WriteFormula(oDocument,oVCursor,oCursor,sEq,iTailleDElaFormule,sNomPolice)
Else
oDispHelper = createUnoService("com.sun.star.frame.DispatchHelper")
oProvider = ThisComponent.CurrentController.Frame
oDispHelper.executeDispatch(oProvider, ".uno:InsertObjectStarMath", "", 0, Array())
Endif
End Sub
rem cette macro insere la formule
rem elle a ete reecrite le 26 decembre
Sub WriteFormula(oDoc as object, oViewCursor as Object, oTextCursor as Object, sFormule as String, iTaille as Integer, sNomPolice as string)
dim obj as object, document as object
' Print bUsingDispatcher
If bUsingDispatcher Then
oProvider = ThisComponent.CurrentController.Frame
oDispHelper = createUnoService("com.sun.star.frame.DispatchHelper")
dim Array(0) as new com.sun.star.beans.PropertyValue
oDispHelper.executeDispatch(oProvider, ".uno:InsertObjectStarMath", "", 0, Array())
obj = ThisComponent.getCurrentSelection()
rem on regle les marges
obj.LeftMargin = cint(iMargesFormules)*100
obj.RightMargin = cint(iMargesFormules)*100
document = oDoc.CurrentController
oDoc.getCurrentController().select(oTextCursor)
obj.EmbeddedObject.BaseFontHeight= iTaille
rem la police de la formule est celle de la ligne si option choisie
If (bPoliceFormCarac = True and obj.model.FontNameVariables <> sNomPolice) Then
obj.EmbeddedObject.FontNameVariables=sNomPolice
obj.EmbeddedObject.FontNameNumbers=sNomPolice
obj.EmbeddedObject.FontNameText=sNomPolice
obj.EmbeddedObject.FontNameFunctions=sNomPolice
EndIf
' If bVecteur = True and obj.embeddedobject.FontVariablesIsItalic<>bVecteursItalic Then
' obj.embeddedobject.FontVariablesIsItalic = bVecteursItalic
' ElseIf bAngle = True and obj.embeddedobject.FontVariablesIsItalic<>bAnglesItalic Then
' obj.embeddedobject.FontVariablesIsItalic = bAnglesItalic
' ElseIf bMesureAlg = True and obj.embeddedobject.FontVariablesIsItalic<>bMesuresAlgItalic Then
' obj.embeddedobject.FontVariablesIsItalic = bMesuresAlgItalic
' ElseIf bVecteur = False and bAngle=False and bMeseureAlg = False and obj.embeddedobject.FontVariablesIsItalic<>bItalic Then
obj.embeddedobject.FontVariablesIsItalic = IsFormuleItalic
' EndIf
If obj.embeddedobject.IsTextMode <> bTextMode Then
obj.embeddedobject.IsTextMode = bTextMode
EndIf
If bFormulesGras = TRUE Then
obj.embeddedobject.FontTextIsBold = TRUE
obj.embeddedobject.FontFunctionsIsBold = TRUE
obj.embeddedobject.FontNumbersIsBold = TRUE
obj.embeddedobject.FontVariablesIsBold = TRUE
End If
If bFormulesEncadrees = TRUE Then
EncadrerFormule(obj,2)
Endif
rem rehausse la barre de surlignage
If InStr(obj.embeddedObject.Formula,"overline")>0 or InStr(obj.embeddedObject.Formula,"bar")>0 Then
obj.embeddedObject.RelativeSymbolPrimaryHeight = 10
Endif
obj.EmbeddedObject.formula= sFormule
obj.embeddedObject.setmodified(true)
oDispHelper.executeDispatch(oProvider, ".uno:Escape", "", 0, Array())
Else
obj=ThisComponent.CreateInstance("com.sun.star.text.TextEmbeddedObject")
obj.CLSID="078B7ABA-54FC-457F-8551-6147e776a997"
obj.AnchorType=com.sun.star.text.TextContentAnchorType.AS_CHARACTER
rem regle la marge des formules
obj.LeftMargin = cint(iMargesFormules)*100
obj.RightMargin = cint(iMargesFormules)*100
document = oDoc.CurrentController
oDoc.getCurrentController().select(oTextCursor)
oTextCursor.Text.insertTextContent(oTextCursor, obj, true)
obj.EmbeddedObject.BaseFontHeight= iTaille
rem la police de la formule est celle de la ligne si option choisie
If (bPoliceFormCarac = True and obj.model.FontNameVariables <> sNomPolice) Then
obj.EmbeddedObject.FontNameVariables=sNomPolice
obj.EmbeddedObject.FontNameNumbers=sNomPolice
obj.EmbeddedObject.FontNameText=sNomPolice
obj.EmbeddedObject.FontNameFunctions=sNomPolice
EndIf
' If bVecteur = True and obj.embeddedobject.FontVariablesIsItalic<>bVecteursItalic Then
' obj.embeddedobject.FontVariablesIsItalic = bVecteursItalic
' ElseIf bAngle = True and obj.embeddedobject.FontVariablesIsItalic<>bAnglesItalic Then
' obj.embeddedobject.FontVariablesIsItalic = bAnglesItalic
' ElseIf bMesureAlg = True and obj.embeddedobject.FontVariablesIsItalic<>bMesuresAlgItalic Then
' obj.embeddedobject.FontVariablesIsItalic = bMesuresAlgItalic
' ElseIf bVecteur = False and bAngle=False and bMeseureAlg = False and obj.embeddedobject.FontVariablesIsItalic<>bItalic Then
obj.embeddedobject.FontVariablesIsItalic = IsFormuleItalic
' EndIf
If obj.embeddedobject.IsTextMode <> bTextMode Then
obj.embeddedobject.IsTextMode = bTextMode
EndIf
If bFormulesGras = TRUE Then
obj.embeddedobject.FontTextIsBold = TRUE
obj.embeddedobject.FontFunctionsIsBold = TRUE
obj.embeddedobject.FontNumbersIsBold = TRUE
obj.embeddedobject.FontVariablesIsBold = TRUE
End If
If bFormulesEncadrees = TRUE Then
EncadrerFormule(obj,2)
Endif
rem rehausse la barre de surlignage
If InStr(obj.embeddedObject.Formula,"overline")>0 or InStr(obj.embeddedObject.Formula,"bar")>0 Then
obj.embeddedObject.RelativeSymbolPrimaryHeight = 10
Endif
obj.EmbeddedObject.formula=sFormule
obj.embeddedObject.setmodified(true)
oViewCursor.goLeft(1,False)
oViewCursor.goRight(1,False)
Endif
Goto FinSub:
Fin: MsgBox sVocab(iLang,305)
FinSub:
End sub
'**************************************************************************************
' macro écrite le 15 novembre 2003.
' Elle insert la source de la formule et éventuellement l'écrit
'**************************************************************************************
Sub InsertSourceFormule
'Dim bNorme as Boolean
Dim LongsEq, iTailleDElaFormule, iNbrePas as Integer
Dim oTextActif as Object, oCursor as Object
Dim oDesktop as Object, oDocument as Object, oVCursor as Object
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oVCursor = oDocument.currentcontroller.getViewCursor()
' MRI oVCursor
oTextActif = oVcursor.Text
oCursor = oTextActif.createTextCursorByRange(oVCursor.getstart())
If IsNull(bExecCoordColonne) Then bExecCoordColonne = bCoordColonne Rem Initialise ce boolean
If oVCursor.CharHeight <> 0 Then iTailleDElaFormule = oVCursor.CharHeight Else iTailleDElaFormule = oDocument.Text.End.CharHeight
If Len(oVCursor.CharFontName)>0 Then sNomPolice = oVCursor.CharFontName Else sNomPolice = oDocument.Text.End.CharFontName
rem memorise la police du curseur. rem la taille est provisoirement celle du caractère précédent la formule.
sEq = Selec
If Erreur = True Then goto fin
If bAngle = True Then
sEq = TraiteGeometrie(sEq," widehat ")
sEq = TraiteItalicScalVect(sEq,bAnglesItalic,bItalic) rem corrige le Charposture des scalaires
Elseif bVecteur = True Then
sEq =TraiteGeometrie(sEq," widevec ")
sEq = TraiteVecWidevec(sEq) Rem Choisit Vec ou Widevec
sEq = TraiteItalicScalVect(sEq,bVecteursItalic,bItalic) rem corrige le Charposture des scalaires
If bExecCoordColonne = True Then MetenVecteurColonne (sEq)
Elseif bMesureAlg = True Then
sEq=TraiteGeometrie(sEq," overline ")
sEq = TraiteItalicScalVect(sEq,bMesuresAlgItalic,bItalic) rem corrige le Charposture des scalaires
If bExecCoordColonne = True Then MetenVecteurColonne (sEq)
Elseif bPointe = True Then
sEq=TraiteGeometrie(sEq," dot ")
Elseif bDPointe = True Then
sEq=TraiteGeometrie(sEq," ddot ")
Else
sEq = Dmaths.Module2.Dixio(sEq)
Endif
rem ----------------------------------------------------------------------------------
' on fixe la taille de la formule à la taille imposée si option choisie.
If Not bTailleFormCarac Then iTailleDElaFormule = iTailleFormules
PostTraitementFormule(oCursor,oTextActif ,sEq, iNbrePas) rem permet de traiter les caractères et/ou formules précédentes
oTextActif.insertString(oCursor,sEq,True)
oVCursor.GoLeft(iNbrePas,True)
If bManuelFormula = FALSE Then WriteFormula(oDocument,oVCursor,oCursor,sEq,iTailleDElaFormule,sNomPolice)
fin:
Erreur=False
End Sub
Sub InsertSourceIntegrale ( sMot as String)
Dim iTailleDElaFormule, iNbrePas as Integer
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oVCursor = oDocument.currentcontroller.getViewCursor()
oTextActif = oVcursor.Text
oCursor = oTextActif.createTextCursorByRange(oVCursor.getstart())
If oVCursor.CharHeight <> 0 Then iTailleDElaFormule = oVCursor.CharHeight Else iTailleDElaFormule = oDocument.Text.End.CharHeight
If Len(oVCursor.CharFontName)>0 Then sNomPolice = oVCursor.CharFontName Else sNomPolice = oDocument.Text.End.CharFontName
rem memorise la police du curseur. rem la taille est provisoirement celle du caractère précédent la formule.
If Erreur=True Then goto fin
rem ----------------------------------------------------------------------------------
' on fixe la taille de la formule à la taille imposée si option choisie.
If Not bTailleFormCarac Then iTailleDElaFormule = iTailleFormules
PostTraitementFormule(oCursor,oTextActif ,sMot, iNbrePas) rem permet de traiter les caractères et/ou formules précédentes
oTextActif.insertString(oCursor,sMot,True)
oVCursor.GoLeft(iNbrePas,True)
'print iNbrePas
If bManuelFormula = FALSE Then WriteFormula(oDocument,oVCursor,oCursor,sMot,iTailleDElaFormule,sNomPolice)
fin:
Erreur=False
End Sub
' ecrite par Didier Dorange-Pattoret
Sub PostTraitementFormule(oTextCursor, oTextActif as Object,sFormule as String, iNbreCaracteres as Integer)
Dim iNbreFormulesPassees as integer
Dim sFormulaPre as String 'contient le code de la formule précedente
Dim Car as Long
iNbreCaracteres = Len(sFormule)
oTextCursor2 = oTextCursor
if (Not oTextCursor2.isStartOfSentence and bConcateneFormules = TRUE) Then
iNbreFormulesPassees = 0
Car = -1
do until (oTextCursor2.isStartOfSentence()= True or Car=9 or Car=10 or Car=13 or Car=32 or Car=46 or Car=95 ) ' (oTextCursor2.getString()=" ")) ' or (Asc(oTextCursor2.getString())=9))
oTextCursor2.goLeft(0,False)
oTextCursor2.goLeft(1,True)
If oTextCursor2.getString()<>"" Then Car = Asc(oTextCursor2.getString)
' Print oTextCursor2.getString, Car
if (Car=9 or Car=10 or Car=13 or Car=32 or Car=46 or Car=95) Then
' if (oTextCursor2.getString()=" ") Then ' or oTextCursor2.getString()="." ) Then
iNbreCaracteres = iNbreCaracteres + iNbreFormulesPassees
oTextActif.insertString(oTextCursor,Chr(Car),False)
elseif oTextCursor2.getString()<>"" Then rem il y a un caractère
sFormule = oTextCursor2.getString() + sFormule
iNbreCaracteres = iNbreCaracteres + 1
oTextActif.insertString(oTextCursor2,"",True)
else rem il s'agit d'une formule
Objets=oTextCursor2.createContentEnumeration("com.sun.star.text.TextContent")
if Objets.HasMoreElements then
obj = Objets.NextElement
if obj.getImplementationName="SwXTextEmbeddedObject" then
if obj.embeddedObject.getImplementationName="com.sun.star.comp.math.FormulaDocument" then
sFormulaPre = obj.embeddedobject.Formula
If Left(sFormule,4) = "size" Then
iNbreCaracteres = iNbreCaracteres - Instr(sFormule,"{")-1
sFormule = Mid(sFormule,Instr(sFormule,"{")+1,Len(sFormule)-Instr(sFormule,"{")-1)
Endif
If Left(sFormulaPre,4) = "size" Then
sFormule = Mid(sFormulaPre,1,Len(sFormulaPre)-1) & sFormule & "}"
Else
sFormule = sFormulaPre + sFormule
Endif
iNbreCaracteres = iNbreCaracteres + Len(obj.embeddedobject.Formula) '+ 1
iNbreFormulesPassees = iNbreFormulesPassees + 1
If bUsingDispatcher Then oTextCursor2.String()=" " Else oTextCursor2.String()=""
endif
endif
endif
end if
If Car=45 Then rem cette partie traite le cas du caractere -
oTextCursor2.goLeft(0,False)
oTextCursor2.goLeft(1,True)
If oTextCursor2.String = "-" Then
oTextActif.insertString(oTextCursor,"-",False)
' oTextCursor2.goright(1,False)
Exit Do
Else
oTextCursor2.goright(1,False)
Endif
Endif
loop
Elseif (Not bConcateneFormules) Then
oTextCursor2.goLeft(0,False)
oTextCursor2.goLeft(1,True)
oTextCursor2.goRight(1,False)
Endif
End Sub
Sub MetEntre (ChaineG,ChaineD as String) ' improved with insertion at position of cursor GF may 2007
If Form=True or Form1=True Then
If Form1=True Then
fSel1 = oBoite.GetControl(TF)
aSel = fSel1.Selection
Else
fSel0 = oBoiteFormuleGraphique.GetControl(TF)
aSel = fSel0.Selection
End If
oTextIndex.Text = Left(oTextIndex.Text,aSel.MIN)+ChaineG+ChaineD+Right(oTextIndex.Text,Len(oTextIndex.Text)-aSel.MIN)
' must not loose the focus! therefore buttons metLcdot etc must have FocusOnClick=False
' new position of cursor:
aSel.MIN=aSel.MIN+Len(ChaineG) 'between brackets
aSel.MAX=aSel.MIN
If Form1=True Then
oBoite.GetControl(TF).Selection = aSel
Else
oBoiteFormuleGraphique.GetControl(TF).Selection = aSel
End If
Else
oDesktop = createUnoService("com.sun.star.frame.Desktop")
oDocument= oDesktop.getCurrentComponent()
oText = oDocument.Text
oVCursor = oDocument.currentcontroller.getViewCursor()
oTextActif = oVCursor.Text ' la zone de texte actif page ou cellule ....
oCursor = oTextActif.createTextCursorByRange(oVCursor.Getstart())
If oVCursor.iscollapsed Then
oTextActif.insertString(oCursor,ChaineG+ChaineD,True)
oVCursor.Goleft(Len(ChaineD),False)
Else
oCursor.GotoRange(oVCursor.GetEnd(),True)
oTextActif.insertString(oCursor,ChaineG+oCursor.GetString()+ChaineD,True)
Endif
Endif
If bBoite=True Then oBoite.Endexecute()
End Sub
Sub VerifDateSauvegarde
if iDelaiEntreSauvegardes<>0 Then
Dim iLadifdedate as Long
iLadifdedate = DateValue(date()) - DateValue(sDateSauvegarde)
rem iLadifdedate = iLadifdedate - DateValue(sDateSauvegarde)
if iLadifdedate >= iDelaiEntreSauvegardes Then MsgBox(sVocab(iLang,382)+" "+sDateSauvegarde,48,"Dmaths Backup")
End If
End Sub
</script:module>
|