/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths/Tools.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 | <?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="Tools" script:language="StarBasic">'Copyright (C) 2008 Didier Dorange-Pattoret
'38, chemin de l'Abbaye
'74940 Annecy le Vieux
'France
'ddorange@dmaths.com
'module créé le 25 novembre 2003
'********************************************************************************
Public Const listeCar = "Ç ü é â ä à å ç ê ë è ï î ì Ä Å É æ Æ ô ö ò û ù ÿ Ö Ü ø £ Ø × ƒ á í ó ú ñ Ñ ª º ¿ ® ¬ ½ ¼ ¡ « » Á Â À © ¢ ¥ ã Ã Ê Ë È ı Í Î Ï Ì Ó ß Ô Ò õ Õ µ Ú Û Ù ý Ý § "
Public Const CarUTF8 = "Çüéâäà åçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áÃóúñѪº¿®¬½¼¡«» ÃÂÀ© ¢¥ ãà ÊËÈıÃÃŽÃ ÃŒ ÓßÔÒõÕµ ÚÛÙýà §"
Public Const iNumVersionDmathsNew = 3400
Global iNombreInstallDmOptions as Integer rem compte le nombre de fois ou les options sont reinstallees à partir de celle sauvegardee dans Dmoptions.txt
Sub Avertir(iNumero as integer) rem affiche un avertissement
Dim sAvertissement as String
Dim iParaMsgBox as Integer
Dim oAverto As Object
' Print IsNull(iLang)
iParaMsgBox = 0
' oAverto = LoadDialog("Dmaths","Avertir")
sAvertissement = sVocab(iLang,iNumero)
' sAvertissement = oAverto.GetControl("Label"+Cstr(iNumero)).Peer.Text
msgbox(sAvertissement,256+48+iParaMsgBox,"Dmaths")
End Sub
Function IndexChaine(Mot as String,iNbreOver as Integer,maChaine as String) as Integer
' fournit la position du premier caractere de la iNbreOver ieme occurence de maChaine dans Mot
' renvoie 0 si maChaine n'est pas trouvee, 1 si NbreOver = 0.
Dim iPointVar, iCompteur as Integer ' Tant que maChaine n'a pas ete trouvee, renvoit 0.
iPointVar = 0
iCompteur=0
If iNbreOver > 0 Then
' Renvoit 1 si iNbreOver=0.
If InStr(Mot,maChaine)> 0 Then
' iPointVar reste a 0 si maChaine n'est pas trouvee.
Do Until (iPointVar=0 And iCompteur >0) Or iCompteur=iNbreOver
' Compte le nombre de fois ou on trouve maChaine jusqu'a ce qu'on atteigne iNbreOver ou qu'on
' ne trouve plus d'occurence de maChaine.
iPointVar=InStr(iPointVar+Len(maChaine),Mot,maChaine)
' iPointVar prend la valeur de la position de la prochaine occurence de maChaine dans Mot
' (0 si on ne le trouve plus).
iCompteur=iCompteur+1
Loop
EndIf
Else
iPointVar=1
EndIf
IndexChaine = iPointVar
End Function
Function RemplaceChaine(ByVal chaine As String, src As String, dest As String, casse As Boolean)
' fournit une chaine dont toutes les occurences de src ont été remplacées par dest
'casse = true pour distinguer majuscules/minuscules, = false sinon
Dim lsrc As Integer, i As Integer, kas As Integer
dim limite as string
limite=""
kas = iif(casse, 0, 1)
lsrc = len(src)
i = instr(1, chaine, src, kas)
while i<>0
while i<0
limite=limite+left(chaine,32000)
chaine=mid(chaine,32001)
i=instr(1, chaine, src, kas)
wend
' ici i est toujours positif non nul
if i>1 then
limite = limite + Left(chaine, i-1) +dest
else ' ici i vaut toujours 1
limite = limite +dest
endif
' raccourcir en deux temps car risque : i+src > 32767
chaine = Mid(chaine, i)
chaine = Mid(chaine, 1+lsrc)
i = instr(1, chaine, src, kas)
wend
RemplaceChaine = limite + chaine
End Function
rem cree le 3 decembre 2003
sub HideUserDefBar
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dim Array(0) as new com.sun.star.beans.PropertyValue
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:ConfigureDialog", "", 0, Array())
end sub
Sub MultipleTextSelectionExample
Dim oSelections As Object, oSel As Object, oText As Object
Dim lSelCount As Long, lWhichSelection As Long
' La sélection courante dans le contrôleur courant.
'S'il n'y a pas de contrôleur courant, retourne null.
oSelections = ThisComponent.getCurrentSelection()
If Not IsNull(oSelections) Then
oText = ThisComponent.Text
lSelCount = oSelections.getCount()
For lWhichSelection = 0 To lSelCount - 1
oSel = oSelections.getByIndex(lWhichSelection)
MsgBox oSel.getString()
Next
End If
End Sub
Sub Bordure_Selection rem macro initiée par Agnès Simonet et complétée le 25 novembre 2006 par Didier Dorange-Pattoret
Call VerifOperationnel
Dim MonDocument As Object, MonTexte As Object
Dim MonCurseur,Moncurseur2 As Object
Dim CurseurVisible As Object
Dim CurseurFormat As Object
Dim MonRectangle, TexteRectangle As Object
Dim TailleRectangle As New com.sun.star.awt.Size
Dim TexteDeLaSelection As String
Dim iLongueurdeSelection as Integer
Dim CurseurRectangle As Object
Dim CurseurDebut As Object
Dim CurseurFin As Object
'récupère la sélection (4 lignes)
MonDocument = StarDeskTop.CurrentComponent
CurseurVisible = MonDocument.currentcontroller.ViewCursor
MonTexte = CurseurVisible.Text
'crée et positionne le curseur permettant de récupérer le format (1 ligne)
CurseurFormat = MonTexte.createTextCursorByRange(CurseurVisible.Start)
' cree et positionne le curseur d'insertion de blanc en debut de paragraphe
'cela regle le bug qui se produit lorsque la selection comprend le premier caractère du paragraphe
MonCurseur2 = MonTexte.createTextCursorByRange(CurseurVisible)
' ce curseur sert à gérer les débuts de paragraphe
TexteDeLaSelection = CurseurVisible.String
iLongueurdeSelection = Len(TexteDeLaSelection)
'cas où rien n'est séctionné (sélection supposée < à 64 ko !) (4 lignes)
If iLongueurdeSelection = 0 Then
MsgBox(sVocab(iLang,376),48,"Dmaths")
Exit Sub
Else
' cree un blanc en debut de paragraphe si la selection comprend le premier caractere du paragraphe
If Not MonCurseur2.IsStartofParaGraph Then Moncurseur2.Goleft(Len(TexteDeLaSelection),False)
If MonCurseur2.IsStartofParaGraph Then
Montexte.InsertString(MonCurseur2," ",False)
Moncurseur2.Goleft(1,False)
Endif
Dim police(1 to iLongueurdeSelection) as String
Dim taille(1 to iLongueurdeSelection) as Single
Dim gras(1 to iLongueurdeSelection) as Single
Dim italique(1 to iLongueurdeSelection) as Integer
Dim souligne(1 to iLongueurdeSelection) as Integer
Dim lcouleur(1 to iLongueurdeSelection) as Long
Dim ombre(1 to iLongueurdeSelection) as Boolean
Dim contour(1 to iLongueurdeSelection) as Boolean
Dim relief(1 to iLongueurdeSelection) as Integer
rem recupere le format de chaque caractere
For I = 1 To iLongueurdeSelection
CurseurFormat.goRight(1,true)
police(I) = CurseurFormat.CharFontName
taille(I) = CurseurFormat.CharHeight
gras(I) = CurseurFormat.CharWeight
italique(I) = CurseurFormat.CharPosture
souligne(I) = CurseurFormat.CharUnderLine
lcouleur(I) = CurseurFormat.CharColor
ombre(I) = CurseurFormat.CharShadowed
contour(I) = CurseurFormat.CharContoured
relief(I) = CurseurFormat.CharRelief
CurseurFormat.goRight(0,false)
Next I
'crée et positionne le curseur d'écriture (1 ligne)
MonCurseur = MonTexte.createTextCursorByRange(CurseurVisible)
'crée un mini rectangle (5 lignes hors commentaires)
TailleRectangle.Width = 1
TailleRectangle.Height = 1
MonRectangle=MonDocument.createInstance("com.sun.star.drawing.TextShape")
MonTexte.insertTextContent( MonCurseur,MonRectangle,true)
MonRectangle.Size = TailleRectangle
'ancrage comme caractère (1 ligne)
MonRectangle.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
'contour (1 ligne)
MonRectangle.LineStyle = com.sun.star.drawing.LineStyle.SOLID
'centre le rectangle (1 ligne)
MonRectangle.VertOrient = com.sun.star.text.VertOrientation.CHAR_CENTER
'centre verticalement le texte du rectangle (1 ligne)
MonRectangle.TextVerticalAdjust = com.sun.star.drawing.TextVerticalAdjust.CENTER
'adapte la taille du rectangle à celle du texte (2 lignes)
MonRectangle.TextAutoGrowWidth = true
MonRectangle.TextAutoGrowHeight = true
' place le rectangle au premier plan
MonRectangle.LayerId = 1
'place un curseur dans le rectangle (2 lignes)
TexteRectangle = MonRectangle.Text
CurseurRectangle = TexteRectangle.createTextCursor
TexteRectangle.insertString(CurseurRectangle,TexteDeLaSelection,true)
CurseurRectangle.goleft(iLongueurdeSelection,false)
rem écrit le format de chaque caractere
For I = 1 To iLongueurdeSelection
CurseurRectangle.goright(1,true)
CurseurRectangle.CharFontName = police(I)
CurseurRectangle.CharHeight = taille(I)
CurseurRectangle.CharWeight = gras(I)
CurseurRectangle.CharPosture = italique(I)
CurseurRectangle.CharUnderLine = souligne(I)
CurseurRectangle.CharColor = lcouleur(I)
CurseurRectangle.CharShadowed = ombre(I)
CurseurRectangle.CharContoured = contour(I)
CurseurRectangle.CharRelief = relief(I)
CurseurRectangle.goright(0,false)
Next I
'supprime le blanc cree en debut de paragraphe
If MonCurseur2.IsStartofParaGraph Then
MonCurseur2.Goright(1,True)
Montexte.InsertString(MonCurseur2,"",True)
Endif
EndIf
End sub
Sub MetenItalic rem cette macro met en italique le caractère précédent le curseur visible ou la selection.
Dim Mondocument, CurseurVisible, CurseurFormat as Object
Call VerifOperationnel
MonDocument = StarDeskTop.CurrentComponent
CurseurVisible = MonDocument.currentcontroller.ViewCursor
MonTexte = CurseurVisible.Text
If CurseurVisible.IsCollapsed Then
'crée et positionne le curseur permettant de récupérer le format (1 ligne)
CurseurFormat = MonTexte.createTextCursorByRange(CurseurVisible)
CurseurFormat.GoLeft(1,TRUE)
If CurseurFormat.CharPosture = com.sun.star.awt.FontSlant.NONE Then
CurseurFormat.CharPosture = com.sun.star.awt.FontSlant.ITALIC
Else
CurseurFormat.CharPosture = com.sun.star.awt.FontSlant.NONE
End If
CurseurFormat.GoRight(1,False)
Else 'met en italique la partie sélectionnée
If CurseurVisible.CharPosture = com.sun.star.awt.FontSlant.NONE Then
CurseurVisible.CharPosture = com.sun.star.awt.FontSlant.ITALIC
Else
CurseurVisible.CharPosture = com.sun.star.awt.FontSlant.NONE
End If
CurseurVisible.CollapseToEnd
Endif
If CurseurVisible.IsAtEndOfLine Then CurseurVisible.CharPosture = com.sun.star.awt.FontSlant.NONE
End Sub
Sub Metensurligne rem cette macro met en surligné le caractère précédent le curseur visible ou la selection.
Dim Mondocument, CurseurVisible, CurseurFormat as Object
Call VerifOperationnel
MonDocument = StarDeskTop.CurrentComponent
CurseurVisible = MonDocument.currentcontroller.ViewCursor
MonTexte = CurseurVisible.Text
If CurseurVisible.IsCollapsed Then
'crée et positionne le curseur permettant de récupérer le format (1 ligne)
CurseurFormat = MonTexte.createTextCursorByRange(CurseurVisible)
CurseurFormat.GoLeft(1,TRUE)
If CurseurFormat.CharOverline = com.sun.star.awt.FontUnderline.NONE Then
CurseurFormat.CharOverline = com.sun.star.awt.FontUnderline.SINGLE
Elseif CurseurFormat.CharOverline = com.sun.star.awt.FontUnderline.SINGLE Then
CurseurFormat.CharOverline = com.sun.star.awt.FontUnderline.DOUBLE
Else
CurseurFormat.CharOverline = com.sun.star.awt.FontUnderline.NONE
End If
CurseurFormat.GoRight(1,False)
Else 'met en italique la partie sélectionnée
If CurseurVisible.CharOverline = com.sun.star.awt.FontUnderline.NONE Then
CurseurVisible.CharOverline = com.sun.star.awt.FontUnderline.SINGLE
Elseif CurseurVisible.CharOverline = com.sun.star.awt.FontUnderline.SINGLE Then
CurseurVisible.CharOverline = com.sun.star.awt.FontUnderline.DOUBLE
Else
CurseurVisible.CharOverline = com.sun.star.awt.FontUnderline.NONE
End If
CurseurVisible.CollapseToEnd
Endif
If CurseurVisible.IsAtEndOfLine Then CurseurVisible.CharOverline = com.sun.star.awt.FontUnderline.NONE
End Sub
Sub MetenAtalante rem cette macro met en caractère arrondi ATALANTE le caractère précédent le curseur visible ou la selection.
Dim Mondocument, CurseurVisible, CurseurFormat as Object
Dim PoliceDefaut, CheminAtalanteUser, CheminAtalanteRezo, CheminAtalante as String
Dim AtalanteTelechargee, DroitsAdmin as Boolean
Call VerifOperationnel
rem ce qui suit teste la presence de la police Atalante et propose de la telecharger si besoin
CheminAtalanteUser = GetRepertoirePath("user") & GetPathSeparator & "fonts" & GetPathSeparator & "Atalante.ttf"
CheminAtalanteRezo = GetRepertoirePath("inst") & GetPathSeparator & "share" & GetPathSeparator & "fonts" & GetPathSeparator & "truetype" & GetPathSeparator & "Atalante.ttf"
DroitsAdmin = ControleDroits(GetRepertoirePath("inst") & GetPathSeparator & "share" & GetPathSeparator & "fonts")
If Len(sNomPoliceCursive) = 0 Then
Monmessage = sVocab(iLang,421)
MsgBox(Monmessage , 64 + 0 , "Dmaths installation")
Exit Sub
Endif
If Not PoliceScriptTrouvee(sNomPoliceCursive) Then
If sNomPoliceCursive = "Atalante" Then
Monmessage = sVocab(iLang,422) &"." + Chr(13)
Monmessage = Monmessage & sVocab(iLang,423) + Chr(13)+ Chr(13)
Monmessage = Monmessage & sVocab(iLang,424) + Chr(13)
Monmessage = Monmessage & sVocab(iLang,425) + Chr(13)
If MsgBox(Monmessage , 48 + 4 , "Dmaths installation") = 6 Then
If DroitsAdmin or GetGuiType <> 1 Then
Monmessage = sVocab(iLang,426) + Chr(13)
If MsgBox(Monmessage , 32 + 4 , "Dmaths installation") = 6 Then
If DroitsAdmin then CheminAtalante = CheminAtalanteRezo Else CheminAtalante = CheminAtalanteUser
If FileExistsLG("http://www.cdprof.com/telecharger/At______.ttf") Then
FileCopyLG("http://www.cdprof.com/telecharger/At______.ttf", CheminAtalante)
AtalanteTelechargee = True
Elseif FileExistsLG("http://archives.ac-strasbourg.fr/database/articles/fichiers/atalante.TTF") Then
FileCopyLG("http://archives.ac-strasbourg.fr/database/articles/fichiers/atalante.TTF", CheminAtalante)
AtalanteTelechargee = True
Else
Print "Fichier non trouvé"
Exit Sub
Endif
Endif
Else
MonMessage = sVocab(iLang,427)
MsgBox(Monmessage , 64 + 1 , "Dmaths installation") = 6
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
oDesktop=createUnoService("com.sun.star.frame.Desktop")
sGraphPlotter=sChemindmaths+"install_atalante.odt"
mFileProperties(0).Name="MacroExecutionMode"
mFileProperties(0).Value=com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
oDocument = oDesktop.LoadComponentFromURL(sGraphPlotter,"_blank",0,mFileProperties())
Endif
Endif
If AtalanteTelechargee Then
BasicLibraries.loadLibrary("DmInstall")
If (GetGuiType = 1 or Not FileExists("/Users")) Then Call DmInstall.CloseAndLaunchOOo.RelanceOOo
Endif
Else
Monmessage = sVocab(iLang,428) &" " & sNomPoliceCursive & " " & sVocab(iLang,429)
MsgBox(Monmessage , 64 + 0 , "Dmaths installation")
Exit Sub
Endif
Endif
MonDocument = StarDeskTop.CurrentComponent
CurseurVisible = MonDocument.currentcontroller.ViewCursor
PoliceDefaut = CurseurVisible.CharFontName
MonTexte = CurseurVisible.Text
If CurseurVisible.IsCollapsed Then
'crée et positionne le curseur permettant de récupérer le format (1 ligne)
CurseurFormat = MonTexte.createTextCursorByRange(CurseurVisible)
CurseurFormat.GoLeft(1,TRUE)
CurseurFormat.CharFontName = sNomPoliceCursive
CurseurFormat.GoRight(1,False)
Else 'met en italique la partie sélectionnée
CurseurVisible.CharFontName = sNomPoliceCursive
CurseurVisible.CollapseToEnd
Endif
If CurseurVisible.IsAtEndOfLine Then CurseurVisible.CharFontName = PoliceDefaut
End Sub
Function PoliceScriptTrouvee(sLeNomPoliceScript as String) as Boolean rem Détecte la présence de Atalante
Dim oWindow 'The container window supports the awt XDevice interface.
Dim oDescript 'Array of awt FontDescriptor structures
Dim s$ 'Temporary string variable to hold all of the string names.
Dim i% 'General index variable
Dim Presente as Boolean
Presente = False
oWindow = ThisComponent.getCurrentController().getFrame().getContainerWindow()
oDescript = oWindow.getFontDescriptors()
s = ""
For i = LBound(oDescript) to UBound(oDescript)
s = s & oDescript(i).Name & ", "
If oDescript(i).Name = sLeNomPoliceScript Then Presente = True
Next
PoliceScriptTrouvee = Presente
End Function
Sub Aide
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
mFileProperties(0).Name="MacroExecutionMode"
mFileProperties(0).Value=com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
Dim oDesktop,oDocument as object
Dim mNoArgs()
Call VerifOperationnel
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl=sChemindmaths+"userguides/"+sVocab(iLang,216)
oDocument=oDesktop.loadComponentFromUrl(sUrl,"_blank",0, mFileProperties())
End Sub
Sub FAQ
'Macro enregistrée : jeudi 23 fevrier 2006
Dim oDesktop,oDocument as object
Dim mNoArgs()
Call VerifOperationnel
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl=sChemindmaths+"Faq/"+sVocab(iLang,404)
oDocument=oDesktop.loadComponentFromUrl(sUrl,"_blank",0, mNoArgs())
End Sub
Sub Hotomaths
'Macro enregistrée : lundi 6 décembre 2004, modifiee le 14 decembre 2008
Dim oDesktop,oDocument as object
Dim mNoArgs()
Call VerifOperationnel
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl=sChemindmaths+"userguides/how-to_math.odt"
oDocument=oDesktop.loadComponentFromUrl(sUrl,"_blank",0, mNoArgs())
End Sub
Sub FormulaReference
'Macro écrite le vendredi 17 mars 2006, , modifiee le 14 decembre 2008
Call VerifOperationnel
Dim oDesktop,oDocument as object
Dim mNoArgs()
Call VerifOperationnel
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl=sChemindmaths+"userguides/Formula_Command.odt"
oDocument=oDesktop.loadComponentFromUrl(sUrl,"_blank",0, mNoArgs())
End Sub
Sub ReglesTypoGraphiques rem macro ecrite le 14 decembre 2008 permet d ouvrir les fichiers sur les regles typographiques
Dim sUrl as String
dim sFilePickerArgs as Variant
dim oFilePicker as Object
Call VerifOperationnel
sUrl = sChemindmaths + "userguides" & getPathseparator & "reglestypo"
If FileExists(sUrl) Then
sFilePickerArgs = Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE )
oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )
oFilePicker.setTitle( "Regles typographiques" )
oFilePicker.setDisplayDirectory(ConvertToUrl(sUrl))
If oFilePicker.execute() Then
On Error Goto ImpLancer
Dim sys As Object
Dim iFlags As Integer
sys = CreateUnoService("com.sun.star.system.SystemShellExecute")
iFlags = com.sun.star.system.SystemShellExecuteFlags.NO_SYSTEM_ERROR_MESSAGE ' = 0
sys.execute(ConvertToUrl(oFilePicker.Files(0))," ", iFlags)
Exit Sub
ImpLancer:
MsgBox(" Dmaths n'a pas pu ouvrir le fichier ",48,"Dmaths")
Endif
Else
MsgBox(" Répertoire des règles typographiques non trouvé ",48,"Dmaths")
Endif
End Sub
Sub LanceMiliFred
Call VerifOperationnel
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
Dim oDocument as Object
oDocumentCourant = ThisComponent
' oGrille.Visible = False
' Call FinRepreGrille
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sGraphPlotter = sChemindmaths + "milifred.otg"
mFileProperties(0).Name = "MacroExecutionMode"
mFileProperties(0).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
oDocument = oDesktop.LoadComponentFromURL(sGraphPlotter,"_blank",0,mFileProperties())
End Sub
Sub FermeMilifred
Dim oMaGrille, goDoc as Object
On error resume Next
' MRI Thiscomponent
For I = 0 To ThisComponent.Drawpages(0).Count-1
If ThisComponent.Drawpages(0).getByIndex(I).getImplementationName = "SvxShape" Then
oMaGrille = ThisComponent.Drawpages(0).getByIndex(I)
End if
Next I
goDoc = ThisComponent
If Not IsEmpty(oMaGrille) Then
' Print "uouo"
goDoc.CurrentController.Select(oMaGrille)
ClipboardCopy(goDoc)
ClipboardPaste(oDocumentCourant)
End if
' ToucheEchap(oDocumentCourant)
goDoc.Dispose()
On error Goto 0
End Sub
Sub LanceBPH
Call VerifOperationnel
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
Dim oDocument as Object
oDesktop=createUnoService("com.sun.star.frame.Desktop")
sGraphPlotter=sChemindmaths+"BPH.ots"
mFileProperties(0).Name="MacroExecutionMode"
mFileProperties(0).Value=com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
oDocument = oDesktop.LoadComponentFromURL(sGraphPlotter,"_blank",0,mFileProperties())
End Sub
Sub Lancefitoo
Call VerifOperationnel
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
Dim oDocument as Object
oDesktop=createUnoService("com.sun.star.frame.Desktop")
sGraphPlotter=sChemindmaths+"fitoo.ots"
mFileProperties(0).Name="MacroExecutionMode"
mFileProperties(0).Value=com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
oDocument = oDesktop.LoadComponentFromURL(sGraphPlotter,"_blank",0,mFileProperties())
End Sub
Sub LanceBackup
BasicLibraries.loadLibrary("DmathsBup")
Call DmathsBup.Module3.Initialisation
End Sub
Sub LanceBatchConv
BasicLibraries.loadLibrary("BatchConv")
Call BatchConv.Module1.Main
End Sub
sub InsereObjetWriterdsPresentation rem cette macro permet linsertion du objet writer dans une presentation
rem ajoutee le 16 mai 2010
dim obj, controller as object
dim aPos as variant
dim aSize as variant
obj = ThisComponent.CreateInstance("com.sun.star.drawing.OLE2Shape")
aPos = obj.position
aPos.x = 2000
aPos.y = 2000
obj.position = aPos
aSize = obj.size
aSize.height = 1000
aSize.width = 1000
obj.size = aSize
obj.CLSID = "8BC6B165-B1B2-4EDD-aa47-dae2ee689dd6"
obj.name = "WriterObj"
thisComponent.drawpages(0).add(obj)
obj.EmbeddedObject.Component.Text.String= ""
ThisComponent.CurrentController.Select(obj)
controller = thisComponent.currentController
if (not isNull(controller)) then
if (controller.select(obj)) then
dim args1(0) as new com.sun.star.beans.PropertyValue
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
args1(0).Name = "VerbID"
args1(0).Value = 65535
dispatcher.executeDispatch(controller.frame, ".uno:ObjectMenue", "", 0, args1())
end if
end if
end sub
Sub ChangebExecCoordColonne
bExecCoordColonne = Not bExecCoordColonne
End Sub
' cette fonction convertit la plupart des caractères nationaux ( en, fr, d, es, it notamment )
' utilise deux tables dépendant du jeu de caractères en cours : listeCar et CarUTF8
' arg2 : conversion de certains caractères en entités caractères xml prédéfinies
Function convertToUTF8(unTexte As String, entites As Boolean) As String
Dim x1 As Integer, y2 As Integer
Dim Texte8 As String, c1 As String
Dim xmlEntites()
Const listeEntites = "&'><""" ' caractères en conflit avec des délimiteurs de balisage
xmlEntites = Array("&amp;", "&apos;", "&gt;", "&lt;", "&quot;")
Texte8 = ""
for x1 = 1 to Len(unTexte)
c1 = Mid(unTexte, x1, 1)
if entites then
y2 = InStr(1, listeEntites, c1, 0)
if y2 > 0 then
Texte8 = Texte8 & xmlEntites(y2 -1)
else ' conversion éventuelle en UTF-8
if ASC(c1) < 128 then
Texte8 = Texte8 & c1 ' code UTF-8 identique au code ASCII
else
y2 = Instr(1, listeCar, c1, 0)
if y2 > 0 then
Texte8 = Texte8 & Mid(CarUTF8, y2, 2) ' equivalent UTF-8 ( deux octets )
else
Texte8 = Texte8 & "?" ' caractère non traduit en UTF-8
end if
end if
end if
end if
next
convertToUTF8 = Texte8
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
'--------------------------------------------------------------------------------------------------
Function ControleDroits(byVal optional LeChemin as string) as boolean
on error goto PasDroit
leChemin=convertToURL(leChemin)+"/"
open leChemin+"temp" for output as #1
Print #1,cstr(now)
close #1
Kill LeChemin+"temp"
ControleDroits=True
Exit function
PasDroit:
ControleDroits=false
end function
Function GetConfigAccess( ByVal cNodePath As String,ByVal bWriteAccess As Boolean,Optional bEnableSync,Optional bLazyWrite) As Object
If IsMissing(bEnableSync) Then bEnableSync = True
If IsMissing( bLazyWrite ) Then bLazyWrite = False
Dim oConfigProvider, oConfigAccess as Object
oConfigProvider = GetProcessServiceManager.createInstanceWithArguments("com.sun.star.configuration.ConfigurationProvider",Array( MakePropertyValue( "enableasync", bEnableSync)))
If bWriteAccess Then
cServiceName = "com.sun.star.configuration.ConfigurationUpdateAccess"
Else
cServiceName = "com.sun.star.configuration.ConfigurationAccess"
EndIf
oConfigAccess = oConfigProvider.createInstanceWithArguments( cServiceName, Array( MakePropertyValue( "nodepath", cNodePath ), MakePropertyValue( "lazywrite", bLazyWrite )))
GetConfigAccess() = oConfigAccess
End Function
'----------
' Create and return a new com.sun.star.beans.PropertyValue.
'
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
Rem ces macros permettent de convertir une zone en adresse textuelle
Function adrZoneString(maDoc As Object, adrZone As Object) As String
Dim resu As String
resu = alphaXY(adrZone.StartColumn, adrZone.StartRow)&":"& alphaXY(adrZone.EndColumn, adrZone.EndRow)
adrZoneString = resu
End Function
' convertit une adresse de cellule en adresse textuelle
Function adresseString(maDoc As Object, adrCellule As Object) As String
adresseString = maDoc.Sheets(adrCellule.Sheet).Name & "." & alphaXY(adrCellule.Column, adrCellule.Row)
End Function
' convertit une coordonnée XY en coordonnée alphanumérique
Function alphaXY(X As Long, Y As Long) As String
if (Y>=0) and (Y<32000) then
alphaXY = lettreColonne(X) & CStr(Y +1)
else
alphaXY = lettreColonne(X) & "??"
end if
End Function
' convertit numéro de colonne 0...255 en lettres A...IV
Function lettreColonne(n As Long) As String
Select Case n
Case > 255
lettreColonne = "??"
Case < 0
lettreColonne = "??"
Case < 26
lettreColonne = _Lettre(n)
Case Else
lettreColonne = _Lettre((n \ 26) -1) & _Lettre(n Mod 26)
End Select
End Function
' fonction interne
Function _Lettre(p As Long) As String
_Lettre = chr(Asc("A") +p)
End Function
Sub Display_Dmaths_barre
Dim sUrl, sUrl1 as String
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.WriterWindowState/UIElements/States", True )
If oConfigAccess.HasByName( "private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre") Then
sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre"
Elseif oConfigAccess.HasByName("private:resource/toolbar/addon_2") Then
sUrl="private:resource/toolbar/addon_0"
Elseif oConfigAccess.HasByName("private:resource/toolbar/Add-on 3") Then
sUrl="private:resource/toolbar/Add-on 1"
Endif
If oConfigAccess.HasByName( "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath") Then
sUrl1="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath"
Elseif oConfigAccess.HasByName("private:resource/toolbar/addon_2") Then
sUrl1="private:resource/toolbar/addon_2"
Elseif oConfigAccess.HasByName("private:resource/toolbar/Add-on 3") Then
sUrl1="private:resource/toolbar/Add-on 3"
Endif
If layout.IsElementVisible(sUrl) Then
layout.hideElement(sUrl)
layout.hideElement(sUrl1)
Else
layout.showElement(sUrl)
layout.showElement(sUrl1)
Endif
End Sub
Sub Display_Gdmath_barre
Dim sUrl, sUrl1 as String
oFrame = ThisComponent.CurrentController.Frame
layout = oFrame.LayoutManager
oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.WriterWindowState/UIElements/States", True )
If oConfigAccess.HasByName( "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1") Then
sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1"
Elseif oConfigAccess.HasByName("private:resource/toolbar/addon_2") Then
sUrl="private:resource/toolbar/addon_0"
Elseif oConfigAccess.HasByName("private:resource/toolbar/Add-on 3") Then
sUrl="private:resource/toolbar/Add-on 1"
Endif
If layout.IsElementVisible(sUrl) Then
layout.hideElement(sUrl)
layout.hideElement(sUrl1)
Else
layout.showElement(sUrl)
REM layout.showElement(sUrl1)
Endif
End Sub
Sub VerifOperationnel
If DictionnaireCharge = False Then Call ChargementDuDictionnaire rem on charge le dictionnaire si pas encore fait
Dim MyLibStandard as Object
On error resume next
MyLibStandard = BasicLibraries.Standard
BasicLibraries.LoadLibrary(MyLibStandard)
If (MyLibStandard.hasByName("DmOptions") and iNombreInstallDmOptions = 0) Then
If iNumVersionDmathsNew > iNumVersionDmathsCourante Then
BasicLibraries.loadLibrary("DmInstall")
Call DmInstall.Install_Addon.LanceFinInstallation(TRUE) rem le parametre est True si on met à jour
Endif
Else
BasicLibraries.loadLibrary("DmInstall")
Call DmInstall.Install_Addon.LanceFinInstallation(FALSE) rem le parametre est False si ne met pas à jour
Endif
If ((Len(MyLibStandard.getByName("DmOptions")) < 10) or (Len(cstr(iTailleFormules)) = 0)) Then rem installe dmoptions si module Dmoptions vide
BasicLibraries.loadLibrary("DmInstall")
'Print "passe"
iNombreInstallDmOptions = iNombreInstallDmOptions + 1 rem ce parametre compte le nombre dinstalation des options faites a partir de options.txt
CloseAndLaunchOOo.InstallDmOptions
Else
iNombreInstallDmOptions = 0 rem on remet les compteurs à 0 si pas doptions reinstallee
Endif
' If iNombreInstallDmOptions > 1 Then
'Avertir(100)
' BasicLibraries.loadLibrary("DmInstall")
' Call DmInstall.Install_Addon.LanceFinInstallation(FALSE)
' Endif
On error goto 0
End Sub
Function OOoNumVersion() As Integer
'Retreives the running OOO version
Dim aSettings, aConfigProvider
Dim aParams2(0) As new com.sun.star.beans.PropertyValue
Dim sProvider$, sAccess$
sProvider = "com.sun.star.configuration.ConfigurationProvider"
sAccess = "com.sun.star.configuration.ConfigurationAccess"
aConfigProvider = createUnoService(sProvider)
aParams2(0).Name = "nodepath"
aParams2(0).Value = "/org.openoffice.Setup/Product"
aSettings = aConfigProvider.createInstanceWithArguments(sAccess, aParams2())
If aSettings.hasbyname("ooSetupVersionAboutBox") Then
sOOOVersion = aSettings.getbyname("ooSetupVersionAboutBox")
Else
sOOOVersion = aSettings.getbyname("ooSetupVersion")
EndIf
If Len(sOOOVersion) = 3 Then sOOOVersion = sOOOVersion & ".0"
OOoNumVersion = Cint(Mid(sOOOVersion,1,1))*100 + Cint(Mid(sOOOVersion,3,1))*10 + Cint(Mid(sOOOVersion,5,1))
End Function
rem cette fonction convertit un entier dans son ecriture en base 100
function ConvertEntier(iEntier as integer) as String
ConvertEntier = cStr(iEntier)
If iEntier < 10 Then ConvertEntier = "0"&ConvertEntier
end function
Function Arrondir(x as Double, nbre as integer) rem cette fonction arrondi les singles
Dim y as Double
y = Int(x*10^nbre+0.5)/(10^nbre)
Arrondir = y
End Function
Function FileExistsLG(myURL) as boolean
on error goto outWithError
oFileRead = createUnoService("com.sun.star.ucb.SimpleFileAccess")
FichInput = oFileRead.openfileread(convertToURL(myURL))
FileExistsLG = true
exit function
outWithError:
FileExistsLG = false
End Function
Sub FileCopyLG(src as string, dst as string, optional pgb)
dim oFileRead, FichInput
dim oFileWrite, FichOut
dim unTab(), unTab2()
dim BlockRead as long
dim MajPgb as boolean
BlockRead=10240
MajPgb= Not IsMissing(pgb)
oFileRead = createUnoService("com.sun.star.ucb.SimpleFileAccess")
FichInput = oFileRead.openfileread(convertToURL(src))
oFileWrite=createUnoService("com.sun.star.ucb.SimpleFileAccess")
FichOut=oFileWrite.openfilewrite(convertToURL(dst))
retour=BlockRead
while retour=BlockRead
'redim untab()
retour=fichInput.readbytes(unTab,BlockRead)
if retour=BlockRead then
FichOut.writebytes(unTab())
else
redim untab2(0 to retour-1)
for i=0 to retour-1
untab2(i)=untab(i)
next i
FichOut.writebytes(unTab2())
endif
if MajPgb then
pgb.setvalue(pgb.value+retour)
endif
wend
fichInput.closeinput
fichout.closeoutput
end sub
Function DetermineOS as Integer rem renvoie 1 si win, 3 si Mac, 4 si Linux
If GetGuiType = 1 Then
DetermineOS = 1
ElseIf GetGuiType = 3 or (GetGuiType = 4 and FileExists("/Users")) Then
DetermineOS = 3
Else
DetermineOS = 4
Endif
End Function
Function IsMacOS as Boolean
If GetGuiType = 3 or (GetGuiType = 4 and FileExists("/Users")) Then IsMacOS = True Else IsMacOS = False
End Function
Function GetDocumentFrame( oDoc As Object ) As Object
Dim oFrame As Object
Dim oCtrl As Object
' If the caller gave us the document model...
If oDoc.supportsService( "com.sun.star.document.OfficeDocument" ) Then
' ...then get the controller from that.
oCtrl = oDoc.getCurrentController()
' ...then get the frame from the controller.
oFrame = oCtrl.getFrame()
' If the caller gave us a document controller...
ElseIf HasUnoInterfaces( oDoc, "com.sun.star.frame.XController" ) Then
oCtrl = oDoc
' ...then get the frame from the controller.
oFrame = oCtrl.getFrame()
' If the caller gave us the document frame...
ElseIf HasUnoInterfaces( oDoc, "com.sun.star.frame.XFrame" ) Then
' ...thanks! That's just what we wanted!
oFrame = oDoc
Else
' The caller did not give us what we expected!
MsgBox( "GetDocumentFrame called with incorrect parameter." )
EndIf
GetDocumentFrame() = oFrame
End Function
'----------
' An easy to use Dispatch on an office document.
' Arguments are similar to the args for the com.sun.star.frame.XDispatchHelper
' interface of com.sun.star.frame.DispatchHelper.
' What makes this so easy to use are two things:
' 1. The fact that the oDocumentFrame parameter can actually accept
' either the document model or one of its controllers.
' 2. The optional parameters.
' For an example of how simple this routine is to use, see
' routines such as ClipboardCopy().
'
' Parameters:
' oDocumentFrame - An office document frame.
' But wait! It could be the document controller
' or the document model. This routine will find
' the document frame from either of these.
' cURL - The dispatch URL.
' Optional:
' cTargetFrameName - Defaults to blank.
' nSearchFlags - Defaults to zero.
' aDispatchArgs - Defaults an an empty sequence.
'
Sub DocumentDispatch( ByVal oDocumentFrame As Object,_
ByVal cURL As String,_
Optional cTargetFrameName,_
Optional nSearchFlags,_
Optional aDispatchArgs )
dim oDispatchHelper
' If they gave us the wrong parameter...
If Not HasUnoInterfaces( oDocumentFrame, "com.sun.star.frame.XFrame" ) Then
' Be sure that we've got the document frame.
' Someone might have passed us the document model or one of
' its controller's.
oDocumentFrame = GetDocumentFrame( oDocumentFrame )
EndIf
If IsMissing( cTargetFrameName ) Then
cTargetFrameName = ""
EndIf
If IsMissing( nSearchFlags ) Then
nSearchFlags = 0
EndIf
If IsMissing( aDispatchArgs ) Then
aDispatchArgs = Array()
EndIf
oDispatchHelper = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatchHelper.executeDispatch( oDocumentFrame, cURL, cTargetFrameName, nSearchFlags, aDispatchArgs )
End Sub
'############################################################
' Clipboard manipulation
'############################################################
Sub ClipboardPaste( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Paste" )
End Sub
Sub ClipboardCopy( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Copy" )
End Sub
Sub ClipboardCut( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Cut" )
End Sub
Sub ToucheEchap ( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Escape" )
End Sub
Sub ToucheSuppr ( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Delete" )
End Sub
Sub LanceMacroDansDocument ( oDocumentFrame, sLaMacro )
DocumentDispatch( oDocumentFrame, "macro://" & sLaMacro )
End Sub
</script:module>
|