'************************************************ 'Copyright (C) 2006-2017 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 *****

Public oDmProgInst as Object Public iLangInstall as Integer Public sLang as String Public sNotfound as String rem sInstallOpen, rem sInstallOpen est la racine du rep utilisateur, Public sUserPath as String Public oDeskTop,oSheetLangues,oCalcLangues as Object Public mFileProperties(0) As New com.sun.star.beans.PropertyValue Public sUrl,sMotVar as String Public bPremInstall, bMiseAJour as Boolean Public AppsPref(19,2) as String Public AppsPrefUbount As Integer Public sRepertoireDmaths as String Public PI, PF As Integer rem sert à la configuration de la position des barres d'outils Public positionBarre as New com.sun.star.awt.Point rem sert à la configuration de la position des barres d'outils Public const sPositionDesBarresdOutilsParDefaut = "0,5:1070,0:0,4:821,4:950,0:16,1:72,1:16,2:14,1:" Public const iVersion = " 4.4.0.0 " Public const iNumVersionDmaths = 4400 rem à changer également dans Dmaths Tools ainsi que dans le fichier dmoptions.txt des options par défaut Public const iNumVersionDmathsPlus = 4400 rem correspond à la version de DmathsPlus.dotm Rem permet la mise aux normes Dmaths Rem module6d.IntegreOOoAHmath3D à ajouter à la fin de la macro OOoAHmath3D.ahOutils.PosObjetFinal Rem module ChangerStylesAretes chargement de la boite aoDlg Style -> style pour fonctionnement sous Linux Public const iNbreThemesIcones = 5 Public Const bTraitementErreurInstallation = True

Sub LanceFinInstallation (bOnMetAJour as Boolean, Optional bProgressVisible as Boolean)

rem traitement des erreurs If bTraitementErreurInstallation Then On Error GoTo TraitementErreurFinInstallation

If IsMissing(bProgressVisible) Then bProgressVisible = True

rem on charge le dictionnaire ChargementDuVocabulaire

rem on trouve la langue d'installation iLangInstall = TrouveLang

rem Print "entre LanceFinInstallation" DialogLibraries.loadLibrary( "DmInstall") oDmProgInst = CreateUnoDialog(DialogLibraries.DmInstall.DmProgInst) oDmProgInst.Visible = bProgressVisible Wait 500 oDmProgInst.getControl("ProgressBar1").Value = 0

bMiseAJour = bOnMetAJour bPremInstall = Not bOnMetAJour

BasicLibraries.loadLibrary("Dmaths") oDmProgInst.getControl("ProgressBar1").Value = 5

Call TestPresencesMath rem verifie que le module math est installé

oDmProgInst.getControl("ProgressBar1").Value = 10

sUserPath = GetRepertoirePath("user") rem utilité a revoir

oDmProgInst.getControl("ProgressBar1").Value = 20

Rem revoir cette ligne qui sert aux installations multiutilisateurs ' sLeChemindeDmaths = sCheminDmaths

rem--------------------------------------------------------------------------------------- ' en cas d'installation reseau ' Print TestInstallRezo

If bPremInstall Then If TestInstallRezo Then If Not FileExists(GetRepertoirePath("user")+GetPathSeparator+"Dmaths") Then MkDir GetRepertoirePath("user")+GetPathSeparator+"Dmaths" If FileExists(GetRepertoirePath("user")+GetPathSeparator+"Dmaths"+GetPathSeparator+"dmaths.ods") Then Kill GetRepertoirePath("user")+GetPathSeparator+"Dmaths"+GetPathSeparator+"dmaths.ods" FileCopy fChemindmaths+"dmaths.ods", ConvertToURL(GetRepertoirePath("user")+"/dmaths/dmaths.ods") DoubleSwitchF4F8 rem change deux fois cette configuration pour être sur que les touches F9 et F10 sont actives. EndIf Endif

oDmProgInst.getControl("ProgressBar1").Value = 30

rem configure les raccourcis clavier pour les MAC If IsMacOS Then Config4Mac(True) EndIf

rem configure les raccourcis claviers pour OOo < 3.1 If OOONumVersion < 310 Then RaccourcisClavier End if

oDmProgInst.getControl("ProgressBar1").Value = 40

rem------------------------------------------------------------------------------------ ' Renomme les anciennes configurations des barres d'Addon

dim ConfigRegistry as object dim LaBarre as object dim Letiquette as String globalScope.basicLibraries.loadLibrary("Tools")

REM ------- modul:writer Dmaths ConfigRegistry = getRegistryKeyContent("/org.openoffice.Office.UI.WriterWindowState/UIElements/States",True)

Letiquette = "Dmaths" If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre") LaBarre."UIName" = Letiquette ConfigRegistry.commitChanges() End if

REM ------- modul:writer Dmaths on/off Select Case iLangInstall Case 0 Letiquette = "Dmaths Afficher/Masquer" Case 2 Letiquette = "Dmaths an/aus-Schalter" Case Else Letiquette = "Dmaths on/off switch" End Select If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre") LaBarre."UIName" = Letiquette ConfigRegistry.commitChanges() End if

REM ------- modul:writer OOoTep Letiquette = "OOoTep-Gdmath" If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath") LaBarre."UIName" = Letiquette ConfigRegistry.commitChanges() End if

oDmProgInst.getControl("ProgressBar1").Value = 45

REM ------- modul:writer OOoGdmath If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1") LaBarre."UIName" = "Gdmath" ConfigRegistry.commitChanges() End if

Rem -------modul:writer AHmath3D If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar") LaBarre."UIName" = "AHmath3D" ConfigRegistry.commitChanges() End if

REM ------- modul:draw OOoGdmath ConfigRegistry = getRegistryKeyContent("/org.openoffice.Office.UI.DrawWindowState/UIElements/States", True )

If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1") LaBarre."UIName" = "Gdmath" ConfigRegistry.commitChanges() End if

oDmProgInst.getControl("ProgressBar1").Value = 50

REM ------- modul:draw OOoTep Letiquette = "OOoTep-Gdmath" If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath") LaBarre."UIName" = Letiquette ConfigRegistry.commitChanges() End if

REM ------- modul:draw Dmaths on/off Select Case iLangInstall Case 0 Letiquette = "Dmaths Afficher/Masquer" Case 2 Letiquette = "Dmaths an/aus-Schalter" Case Else Letiquette = "Dmaths on/off switch" End Select If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre") LaBarre."UIName" = Letiquette ConfigRegistry.commitChanges() End if

REM ------- modul:impress InsertWriter ConfigRegistry = getRegistryKeyContent("/org.openoffice.Office.UI.ImpressWindowState/UIElements/States", True ) Select Case iLangInstall Case 0 Letiquette = "Inserer un document Writer" Case Else Letiquette = "Insert a Writer Document" End Select If ConfigRegistry.hasByName("private:resource/toolbar/addon_org.openoffice.Office.addon.InsertDocumentWriter") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.InsertDocumentWriter") LaBarre."UIName" = Letiquette ConfigRegistry.commitChanges() End if

oDmProgInst.getControl("ProgressBar1").Value = 55

rem ---------------------------------------------------------------------------------- ' mise en place des barres d'icônes si besoin If bMiseAJour Then If (sPositionDesBarresdOutilsParDefaut<>sPositionDesBarresdOutilsMemorisee And Len(sPositionDesBarresdOutilsMemorisee)>0) Then PositionneLesBarresdOutils End If End if

oDmProgInst.getControl("ProgressBar1").Value = 60

rem------------------------------------------------------------------------------------- 'installation des options en cas de première installation

If bPremInstall Then Options MemoriseCheminIcasOptions Else OptionsUtilisateur If Len(sCheminIcas) = 0 Then MemoriseCheminIcasOptions Endif

oDmProgInst.getControl("ProgressBar1").Value = 70

rem ------------------------------------------------------------------------------------ ' repositione les fichiers Dmaths dans <user>/Dmaths If Not FileExists(ConvertToURL(GetRepertoirePath("user")&"/Dmaths/")) Then Mkdir ConvertToURL(GetRepertoirePath("user")&"/Dmaths/") If FileExists(ConvertToURL(GetRepertoirePath("user")&"/config/dmoptions.txt")) Then FileCopy ConvertToURL(GetRepertoirePath("user")&"/config/dmoptions.txt") , ConvertToURL(GetRepertoirePath("user")&"/Dmaths/dmoptions.txt") Kill ConvertToURL(GetRepertoirePath("user")&"/config/dmoptions.txt") Endif

rem ----------------------------------------------------------------------------------- rem regle le mode d'affichage des icones et la securité des macros en cas de première installation If bPremInstall Then ChangeModeAffichageIconesAndMacroSecurity

rem ------------------------------------------------------------------------------------------------------------------ rem supprime le test de nouvelle version au demarrage oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Events/ApplicationEvents/Bindings", True ) If oConfigAccess.hasByName("OnStartApp") Then If oConfigAccess.OnStartApp.hasByName("BindingURL") Then If InStr(oConfigAccess.OnStartApp.BindingURL,"TestNewVersionDemarrage") > 0 Then oConfigAccess.RemoveByName("OnStartApp") oConfigAccess.commitChanges() Endif Endif Endif rem fin de la suppression

oDmProgInst.getControl("ProgressBar1").Value = 80

rem on recharge la bibliothèque Standard et on supprime le module DmCloseQuick If GetguiType = 1 Then BasicLibraries.loadLibrary("Standard") oLib = GlobalScope.BasicLibraries.Standard If oLib.hasByName("DmCloseQuick") Then oLib.removeByName("DmCloseQuick") EndIf Endif oDmProgInst.getControl("ProgressBar1").Value = 90

rem met à jour le fichier description.xml si DmathsClub presente MetAJourDescription

rem ---------------------------------------------------------------------------- rem regle le chemin des icones des autres comptes dans les installations multiutilisateurs ' On Error GoTo 0 ' If (TestInstallRezo and ControleDroits(GetRepertoirePath("inst")) and Len(sLeChemindeDmaths)<>0) Then ' RegleCheminDesIcones(sLeChemindeDmaths) ' Endif ' On Error GoTo TraitementErreurFinInstallation

If Not bInstallationParExeWin Then Rem on ferme eventuellement le progressbar oDmProgInst.getControl("ProgressBar1").Value = 100 oDmProgInst.Dispose() Rem on n'affiche pas le message de fin si on installe par win.exe oFinInst = CreateUnoDialog(DialogLibraries.DmInstall.FinInst ) oFinInst.GetControl("Label1").Peer.Text = oFinInst.GetControl("Label1").Peer.Text & chr(13) & chr(13) & chr(13) & "Version " & iVersion oFinInst.execute() EndIf

Rem charge les options de Dmaths Call Dmaths.DmathsOptions.LoadOptionsDmaths Rem --------------------------------------------------------------------------------------------------------------------------------------------

Rem --------------------------------------------------------------------------------------------------------------------------------------------- Rem pour les mises à jour à partir de versions <= 3599 on supprime le module dmOptions et on remet les options par défaut If (Not bPremInstall And iNumVersionDmathsCourante <= 3599 And iNumVersionDmathsCourante > 0 ) Then sMessage = Trad(iLangChoisie,0) msgbox(sMessage,64,"Dmaths") If IsMacOS Then ReLanceOOoMac ElseIf GetGuiType = 1 Then ReLanceOOoWin Else ReLanceOOo End if Endif rem ----------------------------------------------------------------------------------------------------------------------------------------------

Exit Sub

rem traitement des erreurs TraitementErreurFinInstallation: Print Trad(iLang,14) & erl & chr(13) & Error Resume next

End sub

Sub TestPresencesMath Dim sCheminMath, sAvertoMessage As String sCheminMath = GetRepertoirePathprog & "smath" If GetGuiType = 1 Then sCheminMath = sCheminMath & ".exe" If (Not FileExists(sCheminMath) and Not IsMacOs) Then MsgBox("Le module Math n'est pas installé"+chr(13)+chr(13)+"Math module is not installed",48,"Dmaths") Stop Endif End Sub

Function TrouveLang as Integer 'retourne un nombre correspondant a la langue de l'utilisateur. Dim iLangT as Integer Dim oLibT as Object rem sLang est un variable Public oLibT = GlobalScope.BasicLibraries.Standard If oLibT.hasByName("DmOptions") Then iLangT = iLang Else sLang = GetRepertoirePath("vlang") Select Case sLang Case "fr" iLangT = 0 Case "de" iLangT = 2 Case "es" iLangT = 3 Case "pt" iLangT = 4 Case "et" iLangT = 5 ' Case "sk" ' iLangT = 6 Case Else iLangT = 1 End Select Endif If iLangT <> 2 Then sLang = "fr" rem pour l'installation des autotextes TrouveLang = iLangT End Function

Sub RaccourcisClavier rem modifiee par Didier Dorange-Pattoret le 24 fevririer 2008 Dim sNomFichier as String, iF1 as Integer, sLigne as String, sDebut as String, sFin as String sNomFichier=GetRepertoirePath("user")+"/config/soffice.cfg/modules/swriter/accelerator/"+GetRepertoirePath("vlang")+"/current.xml" sNomFichierOld=GetRepertoirePath("user")+"/config/soffice.cfg/modules/swriter/accelerator/"+GetRepertoirePath("vlang")+"/current.old"

If Not FileExists(sNomFichier) Then MkDir GetRepertoirePath("user")+"/config/soffice.cfg/modules/swriter/accelerator/"+GetRepertoirePath("vlang") FileCopy fCheminDmaths+"current.xml", sNomFichier Elseif Not FileExists(sNomFichierOld) Then FileCopy sNomFichier, sNomFichierOld EndIf

iF1=FreeFile Open sNomFichier For Input As #iF1 For iCpt = 1 to 3 Line Input #iF1, sLigne sDebut=sDebut+sLigne If iCpt<3 Then sDebut=sDebut+Chr(10) Next While Not Eof(iF1) Line Input #iF1, sLigne If (InStr(sLigne,"vnd.sun.star.script:Dmaths.")=0 and InStr(sLigne,"vnd.sun.star.script:DmathsInstall.")=0 and InStr(sLigne,"vnd.sun.star.script:CmathOOo.")=0 and InStr(sLigne,"vnd.sun.star.script:OOoGdmath.")=0 and InStr(sLigne,"vnd.sun.star.script:OOoTep.")=0) Then sFin=sFin+sLigne+Chr(10) 'Ne garde que les lignes ne concernant pas DMaths, pour éviter les doublons. WEnd Close #iF1 iF1=FreeFile Open sNomFichier For Output As #iF1 Print #iF1, sDebut 'Ajoute les raccourcis clavier Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_T"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Tableau.LanceCreationTableau?language=Basic&amp;location=application"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F10"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenFormule?language=Basic&amp;location=application"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F9"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetentreAccolades?language=Basic&amp;location=application"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F10"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetentreAccolades?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_V"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenVecteur?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_E"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenMesureAlgebrique?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_A"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenAngle?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_L"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenLimite?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_I"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenIntegrale?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_S"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenSomme?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_R"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenRacine?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_X"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenSysteme?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_M"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetenMatrice?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F10"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.MetentreParentheses?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" If iLangInstall = 0 Then Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F3"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.RaccAutotextes.SuperAutotexte?language=Basic&amp;location=application"+Chr(34)+"/>" Else Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F3"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.LoadParCro?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Endif Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F3"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Tools.MetenItalic?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_F4"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Tools.MetenAtalante?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_Z"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:Dmaths.Module1.LoadParCro?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, " <accel:item accel:code="+Chr(34)+"KEY_O"+Chr(34)+" xlink:href="+Chr(34)+"vnd.sun.star.script:DmInstall.Options.ChoixOptionsDmaths?language=Basic&amp;location=application"+Chr(34)+" accel:shift="+Chr(34)+"true"+Chr(34)+" accel:mod1="+Chr(34)+"true"+Chr(34)+"/>" Print #iF1, sFin Close #iF1 End Sub

Sub Fontes

End Sub

Sub Autotextes rem modifiée par Didier Dorange-Pattoret Dim sFrom as String, sTo as String On error resume next sTo=ConvertFromURL(GetRepertoirePath("user")+"/autotext/dmaths.bau") If FileExists(sTo) Then Kill sTo On error goto 0 SetGalleryAndAutotext("AutoText", sLang, True ) End Sub

Sub Galeries On error resume next For I = 1 To 8 If FileExists(ConvertToURL(sUserPath+"/gallery/sg100"+cStr(I)+".sdg")) Then Kill ConvertToURL(sUserPath+"/gallery/sg100"+cStr(I)+".sdg") If FileExists(ConvertToURL(sUserPath+"/gallery/sg100"+cStr(I)+".sdv")) Then Kill ConvertToURL(sUserPath+"/gallery/sg100"+cStr(I)+".sdv") If FileExists(ConvertToURL(sUserPath+"/gallery/sg100"+cStr(I)+".thm")) Then Kill ConvertToURL(sUserPath+"/gallery/sg100"+cStr(I)+".thm") Next I On error goto 0 SetGalleryAndAutotext("Gallery", sLang, True ) End Sub

Sub Options rem cette macro installe les options par défaut Dim sFichierModule as String sFichierModule = GetRepertoirePath("user") & getPathSeparator & "Dmaths" & getPathSeparator If Not FileExists(sFichierModule) Then Mkdir ConvertToUrl(sFichierModule) sFichierModule = sFichierModule & "dmoptions.txt" If FileExists(sFichierModule) Then Kill ConvertToUrl(sFichierModule) FileCopy fCheminDmaths & "Options/dmoptions.txt" , ConvertToURL(sFichierModule) If getGuiType = 1 Then

Endif End Sub

rem cette macro met a jour les options en gardant celles de l utilisateur Sub OptionsUtilisateur

If bTraitementErreurInstallation Then On error Goto TraitementErreurOptionsUtilisateurs

BasicLibraries.loadLibrary("Dmaths") bIconesChangees = False bAfficherMasquerIcones = False oDmOptions = Dmaths.Module5.LoadDialog("DmInstall","DmOptions") rem la ligne suivante permet de remplir par besoin le champ des scalaires. If Len(oDmOptions.GetControl("TextField7").Peer.Text) = 0 Then oDmOptions.GetControl("TextField7").Peer.Text = "abcdexyztαβγω" Rem gere l'introduction de la prise en charge des autotextes pour les lettres grecques ex al be ga etc. Ajouté le 13 décembre 2015 If iNumVersionDmathsCourante <= 3570 Then oDmOptions.GetControl("CheckBox3").State = 1

DmInstall.Install_Addon.LoadAppsPref(oDmOptions,sThemeIcons) rem bPremInstall=False DmInstall.Install_Addon.RegleIconesAppsPref(oDmOptions,sThemeIcons)

Rem les options utilisateur ne sont reprises que si Dmaths >= 3600 If iNumVersionDmathsCourante >= 3600 Then ValidOptionsDmaths Else DeleteModuleDmOptions sCheminDmOptions = GetRepertoirePath("user") & GetPathSeparator & "Dmaths" & GetPathSeparator & "dmoptions.txt" If FileExists(sCheminDmOptions) Then Kill sCheminDmOptions FileCopy fCheminDmaths & "Options/dmoptions.txt" , ConvertToURL(sCheminDmOptions) Endif

oDmOptions.Dispose

Exit Sub

rem traitement des erreurs TraitementErreurOptionsUtilisateurs: Print Trad(iLang,14) & erl & chr(13) & Error Resume next

End Sub

Rem macro ecrite le 1er novembre 2015 Rem cette macro calcule la position des barres d'outils de Dmaths. Ecrite le 31 octobre 2015 Function PositionDesBarresdOutils as String Dim maPos,sUrl As String Dim bPosReelle As Boolean rem ce booleen vaut true si on lit la position instantanée

bPosReelle = False If Not bInstallationParExeWin Then On Error Goto Passe: If ThisComponent.CurrentController.ImplementationName = "SwXTextView" Then bPosReelle = True GoTo Suite: Passe: bPosRelle = False On Error GoTo 0 Suite: EndIf

rem dans Writer oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.WriterWindowState/UIElements/States", True ) rem position instantanéé If bPosReelle Then oFrame = ThisComponent.CurrentController.Frame layout = oFrame.LayoutManager sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre" If oConfigAccess.HasByName(sUrl) Then maPos = Cstr(layout.getElementPos(sUrl).X & "," & Cstr(layout.getElementPos(sUrl).Y)) Endif sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre" If oConfigAccess.HasByName(sUrl) Then maPos = maPos & ":" & Cstr(layout.getElementPos(sUrl).X & "," & Cstr(layout.getElementPos(sUrl).Y)) Endif sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1" If oConfigAccess.HasByName(sUrl) Then maPos = maPos & ":" & Cstr(layout.getElementPos(sUrl).X & "," & Cstr(layout.getElementPos(sUrl).Y)) Endif sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar" If oConfigAccess.HasByName(sUrl) Then maPos = maPos & ":" & Cstr(layout.getElementPos(sUrl).X & "," & Cstr(layout.getElementPos(sUrl).Y)) EndIf rem posiotn mémorisée Else sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre" If oConfigAccess.HasByName(sUrl) Then maPos = oConfigAccess.getByName(sURL).DockPos EndIf sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf Endif

Rem dans Draw oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.DrawWindowState/UIElements/States/", True )

sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf

Rem dans Impress oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.ImpressWindowState/UIElements/States/", True )

sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.InsertDocumentWriter" If oConfigAccess.HasByName(sUrl) Then maPos = maPos &":"& oConfigAccess.getByName(sURL).DockPos EndIf

PositionDesBarresdOutils = maPos & ":"

End Function

Rem macro ecrite le 1er novembre 2015 Sub PositionneBarredOutilDansConfiguration(oConfigAccess As Object, sUrl As String) Dim sDockPos as String If oConfigAccess.HasByName(sUrl) Then PI = PF + 1 PF = Instr(PI,sPositionDesBarresdOutilsMemorisee,":") sDockPos = Mid(sPositionDesBarresdOutilsMemorisee,PI,PF-PI) oConfigAccess.getByName(sURL).DockPos = sDockPos EndIf End Sub

Rem macro ecrite le 1er novembre 2015 Sub PositionneBarredOutilDansFrame(oConfigAccess, layout As Object, sUrl As String) If oConfigAccess.HasByName(sUrl) Then PI = PF+1 PF = Instr(PI,sPositionDesBarresdOutilsMemorisee,",") positionBarre.X = Mid(sPositionDesBarresdOutilsMemorisee,PI,PF-PI) PI = PF+1 PF = Instr(PI,sPositionDesBarresdOutilsMemorisee,":") positionBarre.Y = Mid(sPositionDesBarresdOutilsMemorisee,PI,PF-PI) layout.dockWindow(sUrl,docArea,positionBarre) EndIf End Sub

Rem macro ecrite le 1er novembre 2015 Sub PositionneLesBarresdOutils Dim sUrl as String Dim bPosReelle As Boolean rem ce booleen vaut true si on lit la position instantanée bPosReelle = False If Not bInstallationParExeWin Then On Error Goto Passe: If ThisComponent.CurrentController.ImplementationName = "SwXTextView" Then bPosReelle = True GoTo Suite: Passe: bPosRelle = False On Error GoTo 0 Suite: EndIf PI = 0 PF = 0

' Print bPosReelle Rem si on travaille sur la position instantanée If bPosReelle Then oFrame = ThisComponent.CurrentController.Frame layout = oFrame.LayoutManager Rem positionne dans Writer oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.WriterWindowState/UIElements/States", True )

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre" PositionneBarredOutilDansFrame(oConfigAccess, layout, sUrl) 'Print positionBarre.X," ",positionBarre.Y

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre" PositionneBarredOutilDansFrame(oConfigAccess, layout, sUrl) 'Print positionBarre.X," ",positionBarre.Y

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1" PositionneBarredOutilDansFrame(oConfigAccess, layout, sUrl) 'Print positionBarre.X," ",positionBarre.Y

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar" PositionneBarredOutilDansFrame(oConfigAccess, layout, sUrl) 'Print positionBarre.X," ",positionBarre.Y

Rem si l'installation se fait par l'executable windows Else

Rem positionne dans Writer oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.WriterWindowState/UIElements/States", True )

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos

oConfigAccess.commitChanges()

EndIf

Rem positionne dans Draw oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.DrawWindowState/UIElements/States/", True )

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos = sDockPos

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos = sDockPos

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos = sDockPos

sUrl = "private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos

oConfigAccess.commitChanges()

Rem positionne dans Impress oConfigAccess = GetConfigAccess("/org.openoffice.Office.UI.ImpressWindowState/UIElements/States/", True )

sUrl="private:resource/toolbar/addon_org.openoffice.Office.addon.InsertDocumentWriter" PositionneBarredOutilDansConfiguration(oConfigAccess,sUrl) 'Print oConfigAccess.getByName(sURL).DockPos = sDockPos

oConfigAccess.commitChanges()

Rem regle le mode (taille) d'affichage des icones Dim sNodePath As String Dim oCP, oCUA sNodePath = "/org.openoffice.Office.Common/Misc" Dim aProps(0) As New com.sun.star.beans.PropertyValue oCP = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" ) aProps(0).Name = "nodepath" aProps(0).Value = sNodePath oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps ) oCUA.SymbolSet = iModeAffichageIcones oCUA.commitChanges()

End Sub

Function ModeAffichageIcones As Integer Dim sNodePath As String Dim oCP, oCUA sNodePath = "/org.openoffice.Office.Common/Misc" Dim aProps(0) As New com.sun.star.beans.PropertyValue oCP = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" ) aProps(0).Name = "nodepath" aProps(0).Value = sNodePath oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps ) ModeAffichageIcones = oCUA.SymbolSet End Function

Rem macro entièrement réécrite le 11 janvier 2016 Sub LoadAppsPref(oBoiteApps as Object, sThemeIcons as String)

rem traitement des erreurs If bTraitementErreurInstallation Then On Error GoTo TraitementErreurLoadAppsPref

Dim ApplicationsUtilisateur(1 To 3) As String Dim sSourceIcone, sNomdeLapps As String Dim iIndiceAppsPref As Integer sRepertoireDmathsIcons = GetRepertoirePath("user")+GetPathSeparator+"Dmaths"+GetPathSeparator+"icons" sRepertoireDmathsIcons = ConvertToURL(sRepertoireDmathsIcons)

oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Addons/AddonUI/OfficeToolBar", True ) If oConfigAccess.hasByName("org.openoffice.Office.addon.DMathsBarre") Then oAddon = oConfigAccess.getByName("org.openoffice.Office.addon.DMathsBarre") oAddon = getToolBarItems(oAddon) For I = 1 To 3 oDmOptions.GetControl("CheckBox3" & Cstr(I)).State = IIf(oAddon.getByName("soft" & Cstr(I)).Context = "com.sun.star.text.TextDocument",1,0) oDmOptions.GetControl("SoftButton" & Cstr(I)).Enable = IIf(oAddon.getByName("soft" & Cstr(I)).Context = "com.sun.star.text.TextDocument",1,0) oDmOptions.GetControl("ListBox" & Cstr(I+1)).Enable = IIf(oAddon.getByName("soft" & Cstr(I)).Context = "com.sun.star.text.TextDocument",1,0) If oDmOptions.GetControl("CheckBox31").State = 0 And oDmOptions.GetControl("CheckBox32").State = 0 And oDmOptions.GetControl("CheckBox33").State = 0 Then oDmOptions.GetControl("FileControl2").Enable = 0 Endif Next I Endif

If IsMacOs Then Call LoadAppsMac ElseIf GetguiType = 4 Then Call LoadAppsLinux Elseif GetguiType = 1 Then Call LoadAppsWin rem charge les noms des applications préférées End If

ApplicationsUtilisateur(1) = sCheminSoftware1 : ApplicationsUtilisateur(2) = sCheminSoftware2 : ApplicationsUtilisateur(3) = sCheminSoftware3

Rem le tableau AppsPref est complété avec les applications que l'utilisateur a définies For I = 1 To 3 If Len(ApplicationsUtilisateur(I)) > 0 And GetIndiceAppsPref(ApplicationsUtilisateur(I)) = -1 Then AppsPref(I,0) = ApplicationsUtilisateur(I) AppsPref(I,1) = sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) sNomdeLapps = getFileNameOnly(ConvertToUrl(ApplicationsUtilisateur(I))) AppsPref(I,2) = Ucase(Mid(sNomdeLapps,1,1)) & Mid(sNomdeLapps,2,Len(sNomdeLapps)-1) Endif Next I

Rem remplis la listebox2 en rangeant les items dans l'ordre alphabétique. For I = 1 To AppsPrefUbount If FileExists(AppsPref(I,0)) Then J = 0 If oBoiteApps.getControl("ListBox2").ItemCount > 0 Then Do While (oBoiteApps.getControl("ListBox2").Items(J) < AppsPref(I,2)) J = J+1 If J = oBoiteApps.getControl("ListBox2").ItemCount Then Exit Do Loop Endif oBoiteApps.getControl("ListBox2").AddItem(AppsPref(I,2),J) Endif Next I

oBoiteApps.getControl("ListBox3").AddItems(oBoiteApps.getControl("ListBox2").Items,0) oBoiteApps.getControl("ListBox4").AddItems(oBoiteApps.getControl("ListBox2").Items,0)

For I = 1 To 3 If Len(ApplicationsUtilisateur(I)) > 0 Then oBoiteApps.GetControl("SoftButton" & Cstr(I)).Model.ImageURL = sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_26.bmp" iIndiceAppsPref = GetIndiceAppsPref(ApplicationsUtilisateur(I)) oBoiteApps.getControl("ListBox" & Cstr(I+1)).SelectItem(AppsPref(iIndiceAppsPref,2),True) Endif Next I

Exit Sub

rem traitement des erreurs TraitementErreurLoadAppsPref: Print "Erreur dans la macro LoadAppsPref à la : ligne " & erl & " " & Error Resume next

End Sub

Rem macro écrite le 16 janvier 2016 Rem après choix dans la listbox, ajuste l'image en conséquence Sub ChangeAppsPreferee (oEvt As object) bIconesAppsPrefChoisies = True Dim iIndiceAppsPref As Integer Dim sNumSoftButton As String iNumListBox = Cint(Right(oEvt.Source.Model.Name,1)) iIndiceAppsPref = GetIndiceAppsPref(oDmOptions.GetControl(oEvt.Source.Model.Name).SelectedItem) sNumSoftButton = Cstr(Cint(Right(oEvt.Source.Model.Name,1))-1) oDmOptions.GetControl("SoftButton" & sNumSoftButton).Model.ImageURL = AppsPref(iIndiceAppsPref,1) & "_26.bmp" End Sub

Rem gere la listbox qui reçoit le clic lorsque le FileControle2 n'est pas vide. Sub GereFileControlDmOptions(oEVt As Object) Dim sCheminNouvelleApps As String Dim iIndiceAppsPref, iNumSoftButton As Integer sCheminNouvelleApps = oDmOptions.GetControl("FileControl2").Peer.Text

If Len(sCheminNouvelleApps) > 0 Then If FileExists(sCheminNouvelleApps) Then iNumSoftButton = Cint(Right(oEvt.Source.Model.Name,1))-1 iIndiceAppsPref = GetIndiceAppsPref(oDmOptions.GetControl("TextField2").Peer.Text)

If iIndiceAppsPref = -1 Then AppsPref(iNumSoftButton,0) = sCheminNouvelleApps AppsPref(iNumSoftButton,1) = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware" & iNumSoftButton AppsPref(iNumSoftButton,2) = oDmOptions.GetControl("TextField2").Peer.Text oDmOptions.getControl(oEvt.Source.Model.Name).AddItem(AppsPref(iNumSoftButton,2),0) oDmOptions.getControl(oEvt.Source.Model.Name).SelectItem(AppsPref(iNumSoftButton,2),True) oDmOptions.getControl("SoftButton" & Cstr(iNumSoftButton)).Model.ImageURL = AppsPref(iNumSoftButton,1) & "_26.bmp" Else AppsPref(iIndiceAppsPref,0) = sCheminNouvelleApps oDmOptions.getControl(oEvt.Source.Model.Name).AddItem(AppsPref(iIndiceAppsPref,2),0) oDmOptions.getControl(oEvt.Source.Model.Name).SelectItem(AppsPref(iIndiceAppsPref,2),True) oDmOptions.getControl("SoftButton" & Cstr(iNumSoftButton)).Model.ImageURL = AppsPref(iIndiceAppsPref,1) & "_26.bmp" EndIf Else ChargementDuVocabulaire MsgBox (" " & Trad(iLand,13),48 , "Dmaths (C) Didier Dorange-Pattoret") Endif oEvt.Source.Context.GetControl("FileControl2").Peer.Text = "" oEvt.Source.Context.GetControl("TextField2").Peer.Text = "" oDmOptions.GetControl("TextField2").Enable = 0 Endif End Sub

Sub CalculeNomExecutable Dim sNomExecutable As string oDmOptions.getControl("TextField2").Enable = 1 If FileExists(oDmOptions.GetControl("FileControl2").Model.Text) Then sNomExecutable = ConvertFromURL(getFileNameOnly(ConvertToURL(oDmOptions.GetControl("FileControl2").Model.Text))) oDmOptions.GetControl("TextField2").Peer.Text = Ucase(Mid(sNomExecutable,1,1)) & Mid(sNomExecutable,2,Len(sNomExecutable)-1) oDmOptions.GetControl("FileControl2").Model.HelpText = oDmOptions.GetControl("FileControl2").Model.Text Else oDmOptions.GetControl("TextField2").Peer.Text = "" oDmOptions.GetControl("FileControl2").Model.HelpText = "" Endif End Sub

Sub RegleIconesAppsPref(oBoiteApps as Object,sThemeIcons as String) Dim UnFich as String

If bTraitementErreurInstallation Then On Error Goto TraitementErreurRegleIconesAppsPref

sRepertoireDmathsIcons = GetRepertoirePath("user")+GetPathSeparator+"Dmaths"+GetPathSeparator+"icons" sRepertoireDmathsIcons = ConvertToURL(sRepertoireDmathsIcons) If Not FileExists(sRepertoireDmathsIcons) Then Mkdir sRepertoireDmathsIcons Rem GetConfigAccess2 pour tenir compte de la langue utilisateur oConfigAccess = GetConfigAccess2( "/org.openoffice.Office.Addons/AddonUI/OfficeToolBar", True ) If oConfigAccess.hasByName("org.openoffice.Office.addon.DMathsBarre") Then oAddon = oConfigAccess.getByName("org.openoffice.Office.addon.DMathsBarre") oAddon = getToolBarItems(oAddon)

FileCopy sRepertoireDmathsIcons, sRepertoireDmathsIcons & "_save"

For I = 1 To 3

If oBoiteApps.GetControl("ListBox" & Cstr(I+1)).SelectedItem <> "" Then iIndiceAppsPref = GetIndiceAppsPref(oBoiteApps.GetControl("ListBox" & Cstr(I+1)).SelectedItem)

rem le contexte puis l'icone If Instr(AppsPref(iIndiceAppsPref,1),sRepertoireDmathsIcons) = 0 Then FileCopy AppsPref(iIndiceAppsPref,1) & "_16.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_16.bmp" FileCopy AppsPref(iIndiceAppsPref,1) & "_26.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_26.bmp" FileCopy AppsPref(iIndiceAppsPref,1) & "_16h.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_16h.bmp" FileCopy AppsPref(iIndiceAppsPref,1) & "_26h.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_26h.bmp" ElseIf I <> iIndiceAppsPref Then FileCopy sRepertoireDmathsIcons & "_save" & "/launchsoftware" & Cstr(iIndiceAppsPref) & "_16.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_16.bmp" FileCopy sRepertoireDmathsIcons & "_save" & "/launchsoftware" & Cstr(iIndiceAppsPref) & "_26.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_26.bmp" FileCopy sRepertoireDmathsIcons & "_save" & "/launchsoftware" & Cstr(iIndiceAppsPref) & "_16h.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_16h.bmp" FileCopy sRepertoireDmathsIcons & "_save" & "/launchsoftware" & Cstr(iIndiceAppsPref) & "_26h.bmp", sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I) & "_26h.bmp" Endif

oAddon.getByName("soft" & Cstr(I)).ImageIdentifier = sRepertoireDmathsIcons & "/launchsoftware" & Cstr(I)

rem l'infobulle oAddon.getByName("soft" & Cstr(I)).Title = AppsPref(iIndiceAppsPref,2)

Rem Affichée ou non oAddon.getByName("soft" & Cstr(I)).Context = IIf(oDmOptions.GetControl("CheckBox3" & Cstr(I)).State = 1,"com.sun.star.text.TextDocument","hidden")

Else oAddon.getByName("soft" & Cstr(I)).Context = "hidden" End If Next I

' Print sRepertoireDmathsIcons & "_save/" unFich = Dir(sRepertoireDmathsIcons & "_save/*",0) Do While Len(unFich) > 0 ' Print unFich Kill sRepertoireDmathsIcons & "_save/" & unFich unFich = Dir Loop Rmdir sRepertoireDmathsIcons & "_save/"

Endif oConfigAccess.commitChanges()

Exit Sub

rem traitement des erreurs TraitementErreurRegleIconesAppsPref: Print Trad(iLang,14) & erl & chr(13) & Error Resume next

End Sub

Sub ChangeActivate(oEvt As Object) Dim sNumero As String bIconesAppsPrefChoisies = True sNumero = Right(oEvt.Source.Model.Name,1) oDmOptions.GetControl("SoftButton" & sNumero).Enable = (oEvt.Source.Model.State = 1) oDmOptions.GetControl("ListBox" & Cstr(Cint(sNumero)+1)).Enable = (oEvt.Source.Model.State = 1) If oDmOptions.GetControl("CheckBox31").State = 0 And oDmOptions.GetControl("CheckBox32").State = 0 And oDmOptions.GetControl("CheckBox33").State = 0 Then oDmOptions.GetControl("FileControl2").Enable = 0 Else oDmOptions.GetControl("FileControl2").Enable = 1 Endif End Sub

Function RegleAppsSousLinux(sCheminApps as String)as String If (InStr(sCheminApps,"konqueror") > 0 and InStr(sCheminApps,"home") = 0) Then sCheminApps = sCheminApps & " " & GetRepertoirePath("home") If (getFileExt(ConvertToURL(sCheminApps)) = ".jar" and Mid(sCheminApps,1,4) <> "file") Then sCheminApps = sCheminJava & " -jar " & sCheminApps RegleAppsSousLinux = sCheminApps End Function

rem cette macro permet choisir le theme des icones affichées ecrite le 31 octobre 2015 Function ChoisirThemeIcone(sTheme as String) As boolean

sRepertoireDmaths = fChemindmaths rem sRepertoireDmaths donne l adresse des fichiers If Not TestInstallRezo Or ControleDroits(getRepertoirePath("inst")) Then If FileExists(sRepertoireDmaths & "icons/theme") Then RmDir sRepertoireDmaths & "icons/theme" FileCopy sRepertoireDmaths & "icons/" & sTheme , sRepertoireDmaths & "icons/theme"

Else 'If bIconesChangees Then

Rem cas des comptes ordinaires dans les installations multiutilisateurs TheMsg = Trad(iLang,1) & chr(13) & Trad(iLang,7) & chr(13) & chr(13) & Trad(iLang,8) If MsgBox (TheMsg, 256 + 32 +1, "Dmaths Installation (C) Didier Dorange-Pattoret") = 1 Then sRepertoireConfigUser = ConvertToURL( getRepertoirePath("user")) & "/Dmaths/" If FileExists(sRepertoireConfigUser & "icons/theme") Then RmDir sRepertoireConfigUser & "icons/theme" If Not FileExists(sRepertoireConfigUser & "icons") Then Mkdir sRepertoireConfigUser & "icons" MkDir sRepertoireConfigUser & "icons/theme" FileCopy sRepertoireDmaths & "icons/" & sTheme , sRepertoireConfigUser & "icons/theme" Dim sElementNames$() Dim oToolBarItems as Object

oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Addons/AddonUI/OfficeToolBar", True ) If oConfigAccess.hasByName("org.openoffice.Office.addon.DMathsBarre") Then oAddon = oConfigAccess.getByName("org.openoffice.Office.addon.DMathsBarre") sElementNames = getElementNamesofToolbar(oAddon) oToolBarItems = getToolBarItems(oAddon) For I = LBound(sElementNames()) To UBound(sElementNames()) oToolBarItems.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oToolBarItems.getByname(sElementNames(I)).ImageIdentifier,sRepertoireConfigUser) Next I Endif oConfigAccess.commitChanges()

oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Addons/AddonUI/OfficeToolBar", True ) If oConfigAccess.hasByName("org.openoffice.Office.addon.DMathsDisplayBarre") Then oAddon = oConfigAccess.getByName("org.openoffice.Office.addon.DMathsDisplayBarre") sElementNames = getElementNamesofToolbar(oAddon) oToolBarItems = getToolBarItems(oAddon) Rem on ne change que l'icone relative à la barre Dmaths oToolBarItems.getByname(sElementNames(0)).ImageIdentifier = ReplacesTheme(oToolBarItems.getByname(sElementNames(0)).ImageIdentifier,sRepertoireConfigUser) 'For I = LBound(sElementNames()) To UBound(sElementNames()) ' oToolBarItems.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oToolBarItems.getByname(sElementNames(I)).ImageIdentifier,sRepertoireConfigUser) 'Next I Endif oConfigAccess.commitChanges()

oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Addons/AddonUI/OfficeMenuBar", True ) If oConfigAccess.hasByName("org.openoffice.Office.addon.aide") Then oConfigAccess.getByName("org.openoffice.Office.addon.aide").Context = "com.sun.star.text.TextDocument" oAddon = oConfigAccess.getByName("org.openoffice.Office.addon.aide").SubMenu sElementNames = oAddon.getElementNames() For I = LBound(sElementNames()) To UBound(sElementNames()) oMenu = oAddon.GetByName(sElementNames(I)) oMenu.ImageIdentifier = ReplacesTheme(oMenu.ImageIdentifier,sRepertoireConfigUser) Next I EndIf oConfigAccess.commitChanges() Else Rem evite un redemarrage si l'utilisateur clique sur annuler. ChoisirThemeIcone = True EndIf End if

End Function

rem cette macro fabrique l'image identifier Function ReplacesTheme(sCheminImage,sRepertoireConfigUser As String) as String Dim iPos,iLen as Integer iPos = Instr(sCheminImage,"theme/") iLen = Len(sCheminImage) if iPos > 0 Then ReplacesTheme = sRepertoireConfigUser & "icons/theme/" & Mid(sCheminImage,iPos+6,iLen-iPos-5) Else ReplacesTheme = sCheminImage EndIf End Function

Sub ChangeModeAffichageIconesAndMacroSecurity Dim sNodePath As String Dim oCP, oCUA Dim aProps(0) As New com.sun.star.beans.PropertyValue oCP = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" ) aProps(0).Name = "nodepath" rem change le mode d'affichage des icones sNodePath = "/org.openoffice.Office.Common/Misc" aProps(0).Value = sNodePath oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps ) oCUA.SymbolSet = 0 oCUA.commitChanges() rem change le mode de sécurité des macros sNodePath = "/org.openoffice.Office.Common/Security/Scripting" aProps(0).Value = sNodePath oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps ) oCUA.MacroSecurityLevel = 1 oCUA.commitChanges() rem regle l'espacement des doubles barres de surlignement par défaut sNodePath = "/org.openoffice.Office.Math/StandardFormat/Distance" aProps(0).Value = sNodePath oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps ) oCUA.OrnamentSpace = 8 oCUA.commitChanges() rem supprime l'insertion des inspace insécable. sNodePath = "/org.openoffice.Office.Common/AutoCorrect" aProps(0).Value = sNodePath oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps ) oCUA.AddNonBreakingSpace = False oCUA.commitChanges() End Sub

Rem Macro cree le 1 novembre 2013 Function DetermineImageIdentifierByName(oAddon as Object,Identifiant As String) as String DetermineImageIdentifierByName = getToolBarItems(oAddon).getByName(Identifiant).ImageIdentifier End Function

Rem Macro cree le 1 novembre 2013 Function DetermineImageIdentifierByNumber(oAddon as Object, iIndice as Integer) as String Dim Identifiant Identifiant = getToolBarItems(oAddon).ElementNames(iIndice) DetermineImageIdentifierByNumber = DetermineImageIdentifierByName(oAddon,Identifiant) End Function

Rem Macro cree le 2 novembre 2013 Function getElementNamesofToolbar(oAddon as Object) getElementNamesofToolbar = getToolBarItems(oAddon).getElementNames() End Function

Rem Macro cree le 2 novembre 2013 Function getToolBarItems(oAddon as Object) as Object If OOoName()<>"OpenOffice" Then getToolBarItems = oAddon Else getToolBarItems = oAddon.getByName("ToolBarItems") Endif End Function

rem cette macro détermine la chaine theme 1, 2 ou 3 ... choisie dans la boite Function DeterminesThemeIcons(oBoiteApps as Object) as String Dim sResult as String sResult = "theme1" For I = 2 To iNbreThemesIcones If oBoiteApps.GetControl("OptionButton"&Cstr(I)).State = True then sResult = "theme"& Cstr(I) Next I DeterminesThemeIcons = sResult End Function

rem donne l'indice correspondant a l'application modifiée le 22 ajnvier 2016 Function GetIndiceAppsPref(sAppsPref as String) as Integer GetIndiceAppsPref = -1 rem valeur si pas dans la liste prédéfinie For I = 1 To AppsPrefUbount If AppsPref(I,0) = sAppsPref Then GetIndiceAppsPref = I Exit For End If Next I For I = 1 To AppsPrefUbount If AppsPref(I,2) = sAppsPref And FileExists(AppsPref(I,0)) Then GetIndiceAppsPref = I Exit For End If Next I End Function

Sub LoadAppsLinux Dim sCheminDmaths As String sCheminDmaths = fCheminDmaths AppsPrefUbount = 10 rem les images incluses dans l'addon n'ont pas d'extension. AppsPref(4,0) = "/usr/bin/geogebra" AppsPref(4,1) = sCheminDmaths & "icons/appspref/geogebra" AppsPref(4,2) = "Geogebra" AppsPref(5,0) = "/usr/bin/algobox" AppsPref(5,1) = sCheminDmaths & "icons/appspref/algobox" AppsPref(5,2) = "Algobox" AppsPref(6,0) = TrouveCheminIcas(True) '"C:\xcas\xcas.exe" '"/usr/bin/xcas" AppsPref(6,1) = sCheminDmaths & "icons/appspref/xcas" AppsPref(6,2) = "Xcas" AppsPref(7,0) = "/usr/bin/firefox" AppsPref(7,1) = sCheminDmaths+"icons/appspref/firefox" AppsPref(7,2) = "Firefox" AppsPref(8,0) = "/usr/bin/thunderbird" AppsPref(8,1) = sCheminDmaths+"icons/appspref/thunderbird" AppsPref(8,2) = "Thunderbird" AppsPref(9,0) = "/usr/bin/google-chrome" AppsPref(9,1) = sCheminDmaths+"icons/appspref/chrome" AppsPref(9,2) = "Chrome" AppsPref(10,0)= "/usr/bin/wabbitemu" AppsPref(10,1)= sCheminDmaths+"icons/appspref/wabbitemu" AppsPref(10,2)= "Wabbitemu" AppsPref(11,0)= "" AppsPref(11,1)= "" AppsPref(11,2)= "" End Sub

Sub LoadAppsMac Dim sCheminDmaths As String sCheminDmaths = fCheminDmaths AppsPrefUbount = 11 rem les images incluses dans l'addon n'ont pas d'extension. AppsPref(4,0) = "/Applications/GeoGebra 5.app" AppsPref(4,1) = sCheminDmaths & "icons/appspref/geogebra" AppsPref(4,2) = "Geogebra" AppsPref(5,0) = "/Applications/Algobox.app" AppsPref(5,1) = sCheminDmaths & "icons/appspref/algobox" AppsPref(5,2) = "Algobox" AppsPref(6,0) = "/Applications/usr/bin/xcas.app" AppsPref(6,1) = sCheminDmaths & "icons/appspref/xcas" AppsPref(6,2) = "Xcas" AppsPref(7,0) = "/Applications/Firefox.app" AppsPref(7,1) = sCheminDmaths+"icons/appspref/firefox" AppsPref(7,2) = "Firefox" AppsPref(8,0) = "/Applications/Thunderbird.app" AppsPref(8,1) = sCheminDmaths+"icons/appspref/thunderbird" AppsPref(8,2) = "Thunderbird" AppsPref(9,0) = "/Applications/Google Chrome.app" AppsPref(9,1) = sCheminDmaths+"icons/appspref/chrome" AppsPref(9,2) = "Chrome" AppsPref(10,0)= "/Applications/WabbitEmu.app" AppsPref(10,1)= sCheminDmaths+"icons/appspref/wabbitemu" AppsPref(10,2)= "WabbitEmu" AppsPref(11,0)= "/Applications/Scratch 2.app" AppsPref(11,1)= sCheminDmaths+"icons/appspref/scratch" AppsPref(11,2)= "Scratch" End Sub

Sub LoadAppsWin Dim sCheminDmaths As String sCheminDmaths = fCheminDmaths AppsPrefUbount = 19 rem les images incluses dans l'addon n'ont pas d'extension. AppsPref(4,0) = environ("programfiles(x86)")&"\GeoGebra 5.0\GeoGebra.exe" AppsPref(4,1) = sCheminDmaths & "icons/appspref/geogebra" AppsPref(4,2) = "Geogebra" AppsPref(6,0) = environ("programfiles(x86)")&"\Algobox\algobox.exe" AppsPref(6,1) = sCheminDmaths & "icons/appspref/algobox" AppsPref(6,2) = "Algobox" AppsPref(8,0) = TrouveCheminIcas(True) '"C:\xcas\xcas.exe" AppsPref(8,1) = sCheminDmaths & "icons/appspref/xcas" AppsPref(8,2) = "Xcas" AppsPref(9,0) = environ("programfiles(x86)")&"\Mozilla Firefox\firefox.exe" AppsPref(9,1) = sCheminDmaths+"icons/appspref/firefox" AppsPref(9,2) = "Firefox" AppsPref(11,0)= environ("programfiles(x86)")&"\Mozilla Thunderbird\thunderbird.exe" AppsPref(11,1)= sCheminDmaths+"icons/appspref/thunderbird" AppsPref(11,2)= "Thunderbird" AppsPref(13,0)= environ("programfiles(x86)")&"\Google\Chrome\Application\chrome.exe" AppsPref(13,1)= sCheminDmaths+"icons/appspref/chrome" AppsPref(13,2)= "Chrome" AppsPref(15,0)= environ("programfiles(x86)")&"\Sine qua non\sinequanon.exe" AppsPref(15,1)= sCheminDmaths+"icons/appspref/sinequanon" AppsPref(15,2)= "Sine qua non" AppsPref(17,0)= environ("USERPROFILE")&"\Wabbitemu.exe" AppsPref(17,1)= sCheminDmaths+"icons/appspref/wabbitemu" AppsPref(17,2)= "Wabbitemu" AppsPref(18,0)= environ("programfiles(x86)")&"\Scratch 2\Scratch 2.exe" AppsPref(18,1)= sCheminDmaths+"icons/appspref/scratch" AppsPref(18,2)= "Scratch"

Rem la ligne suivante est utile pour éviter les doublons dans les ListBox123 If environ("programfiles") = environ("programfiles(x86)") Then Exit Sub

AppsPref(5,0) = environ("programfiles")&"\GeoGebra 5.0\GeoGebra.exe" AppsPref(5,1) = sCheminDmaths & "icons/appspref/geogebra" AppsPref(5,2) = "Geogebra" AppsPref(7,0) = environ("programfiles")&"\Algobox\algobox.exe" AppsPref(7,1) = sCheminDmaths & "icons/appspref/algobox" AppsPref(7,2) = "Algobox" AppsPref(10,0)= environ("programfiles")&"\Mozilla Firefox\firefox.exe" AppsPref(10,1)= sCheminDmaths+"icons/appspref/firefox" AppsPref(10,2)= "Firefox" AppsPref(12,0)= environ("programfiles")&"\Mozilla Thunderbird\thunderbird.exe" AppsPref(12,1)= sCheminDmaths+"icons/appspref/thunderbird" AppsPref(12,2)= "Thunderbird" AppsPref(14,0)= environ("programfiles")&"\Google\Chrome\Application\chrome.exe" AppsPref(14,1)= sCheminDmaths+"icons/appspref/chrome" AppsPref(14,2)= "Chrome" AppsPref(16,0)= environ("programfiles")&"\Sine qua non\sinequanon.exe" AppsPref(16,1)= sCheminDmaths+"icons/appspref/sinequanon" AppsPref(16,2)= "Sine qua non" AppsPref(19,0)= environ("programfiles")&"\Scratch 2\Scratch 2.exe" AppsPref(19,1)= sCheminDmaths+"icons/appspref/scratch" AppsPref(19,2)= "Scratch"

End Sub

Sub SetGalleryAndAutotext(sModule, Optional sLangue as String, Optional bInst as Boolean) Dim I, J, Nbre as integer Dim sLeCheminGaleAuto(), sSuffixe as String sRepertoireDmaths = fChemindmaths rem sRepertoireDmaths donne l adresse des fichiers If IsMissing(bInst) Then bInst = False If IsMissing(sLangue) Then sLangue = "fr" If sModule = "Gallery" Then sSuffixe = "gallery" Else sSuffixe = "autotext/" & sLangue oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Common", True ) sLeCheminGaleAuto() = oConfigAccess.getByName("Path").getByName("Current").getByName(sModule) rem suppression du chemin inutile J = -1 If Not IsEmpty(sLeCheminGaleAuto()) Then For I = LBound(sLeCheminGaleAuto()) To Ubound(sLeCheminGaleAuto()) If Instr(sLeCheminGaleAuto(I),"DmathsAddon") = 0 Then J = J+1 sLeCheminGaleAuto(J) = sLeCheminGaleAuto(I) Endif Next I Endif rem ajout du nouveau chemin If bInst = True Then ReDim Preserve sLeCheminGaleAuto(J+1) sLeCheminGaleAuto(J+1) = sRepertoireDmaths & sSuffixe ElseIf J>=0 Then ReDim Preserve sLeCheminGaleAuto(J) Endif oConfigAccess.getByName("Path").getByName("Current").replaceByName(sModule,sLeCheminGaleAuto()) oConfigAccess.Commitchanges() End Sub

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 fCheminDmaths() as String rem écrite par Didier Dorange-Pattoret modifiée le 25 février 2013 Dim GetPIP as Object, repExt as String GetPIP = GetDefaultContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider") repExt = GetPIP.getPackageLocation("Dmaths") fCheminDmaths = repExt & "/Fichiers/" End Function

Function fCheminduFichierDmathsODS as String rem cette fonction donne le chemin du fichier dmaths.ods utilise pour les tracer point par point If TestInstallRezo Then fCheminduFichierDmathsODS = ConvertToURL(GetRepertoirePath("user")+"/dmaths/dmaths.ods") Else fCheminduFichierDmathsODS = fChemindmaths & "dmaths.ods" 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 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

Function OOoName As String '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()) ' Print aSettings.getbyname("ooName") OOoName = aSettings.getbyname("ooName") End Function

rem****************************************************************************************************************** 'Sub RegleCheminDesIcones(sLeChemindeDmaths as String) rem cette macro regle le chemin des icones des comptes non admin dans les install multi rem à reprendre pour Mac ' Dim sPath, sRacine, sValue, sCheminDuCompte as String ' sLeNouveauChemindeDmaths = fCheminDmaths rem determine les comptes et appelle la procedure de nettoyage de chacun ' If GetGuitype = 1 Then ' sPath = GetRepertoirePath("home") ' sRacine = GetRepertoire(sPath) ' ElseIf IsMacOS Then ' sRacine = "/Users" ' Else ' sRacine = "/home" ' EndIf ' sValue = Dir$(sRacine+GetPathSeparator,16) ' Do ' If sValue<>".." and Mid(sValue,1,1)<>"." Then ' If (GetAttr(sRacine+GetPathSeparator+sValue) AND 16 > 0) Then ' sCheminDuCompte = sRacine+GetPathSeparator+sValue ' Call RegleChemin(sCheminDuCompte,sLeChemindeDmaths,sLeNouveauChemindeDmaths) ' EndIf ' End If ' sValue = Dir$ ' Loop Until sValue = "" 'End Sub

'Sub RegleChemin(sCheminDuCompte,src,dest as String) ' Dim sCheminUser, sLine as String ' contient le chemin de l'utilisateur en cours ' sCheminUser = sCheminDuCompte + SuffixeDuCompte ' ' aFile = ConvertToUrl(sCheminUser & "/registry/data/org/openoffice/Office/Addons.xcu") ' 'Print aFile 'Print FileExists(aFile) ' If FileExists(aFile) Then ' aFileNew = ConvertToUrl(sCheminUser & "/registry/data/org/openoffice/Office/Addons.new") ' iNumberNew = Freefile ' Open aFileNew For Output As iNumberNew ' iNumber = Freefile ' Open aFile For Input As iNumber ' While not eof(iNumber) ' Line Input #iNumber, sLine ' ' If InStr(sLine,src)>0 then print "on change" ' sLine = RemplaceChaine(sLine,src,dest,False) ' Print #iNumberNew, sLine ' wend ' Close #iNumber ' Close #iNumberNew ' kill (aFile) ' Name aFileNew as aFile ' End If 'End Sub

Function SuffixeDuCompte as String Dim iPos , iLong as Integer If GetGuitype = 1 Then iPos = Len(GetRepertoire(GetRepertoirePath("home")&"\"))+1 Else iPos = Len(GetRepertoirePath("home"))+1 iLong = Len(GetRepertoirePath("user")) SuffixeDuCompte = Mid(GetRepertoirePath("user"),iPos,iLong-iPos+1) 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

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 GetRepertoire (thePath as String) as String rem donne le repertoire situe deux branches en aval Dim newSplit() ReDim NewSplit(0) splitted = split(thePath,GetPathSeparator) newSplit() = splitted() ReDim Preserve newSplit(0 to ubound(splitted)-2) GetRepertoire = join(NewSplit(),GetPathSeparator) End Function