'************************************************ 'Copyright (C) 2006-2010 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 oChoixrepinstallation, 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(9,2) as String Public sRepertoireDmaths as String Public const iVersion = " 3.4.2.2 " Public const iNumVersionDmaths = 3422 rem à changer également dans Dmaths Tools Public const iNbreThemesIcones = 5

Sub LanceFinInstallation (bOnMetAJour as Boolean) DialogLibraries.loadLibrary( "DmInstall") oDmProgInst = CreateUnoDialog(DialogLibraries.DmInstall.DmProgInst) oDmProgInst.Visible = True Wait 500 oDmProgInst.getControl("ProgressBar1").Value = 0

If bOnMetAJour Then rem on fait une mise a jour bPremInstall = FALSE bMiseAJour = TRUE Else rem on fait une premiere installation bPremInstall = TRUE bMiseAJour = FALSE Endif

iLangInstall = TrouveLang rem on charge les langues

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

Call TestPresencesMath rem verifie que le module math est installé Call AfficheChoixRepertoireInstallation

End Sub

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

Sub AfficheChoixRepertoireInstallation

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

oChoixrepinstallation = CreateUnoDialog( DialogLibraries.DmInstall.Choixrepinstallation )

rem recherche des logiciels installes LoadAppsPref(oChoixrepinstallation,bPremInstall,False,PreselectionneNumeroTheme)

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

Call Fininstallation rem nouveauté End sub

Sub Fininstallation

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

BasicLibraries.loadLibrary("Dmaths") 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") EndIf Endif

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

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

rem----------------------------------------------------------------------------------- ' copie des fontes Cmath rem Fontes

rem------------------------------------------------------------------------------------ 'regler le numerotation des icones et choix du theme d'icones RegleNumerotationIcones rem cette macro regle lors de l'installation la numerotation des icones de la barre dmaths RegleIconesAppsPref(oChoixrepinstallation,DeterminesThemeIcons(oChoixrepinstallation)) rem regle les icones des 3 applications preferees ChoisirThemeIcone(DeterminesThemeIcons(oChoixrepinstallation)) rem met en place le theme d'icones choisi oDmProgInst.getControl("ProgressBar1").Value = 50

rem --------------------------------------------------------------------------------------------------------------------------- 'regler les icones du menu dmaths MaJIconesDuMenuDmaths oDmProgInst.getControl("ProgressBar1").Value = 65

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

' If (iNumVersionDmathsCourante > 1000 and iNumVersionDmathsCourante < 3415) Then

'Print "OK" 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

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") Then LaBarre = ConfigRegistry.getByName("private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D") 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

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

' Endif

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

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

If bPremInstall Then Options Else OptionsUtilisateur If bPremInstall Then OptionsBackup oDmProgInst.getControl("ProgressBar1").Value = 85

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 = 90

oChoixrepinstallation.Dispose()

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 = 95

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 If (TestInstallRezo and ControleDroits(GetRepertoirePath("inst")) and Len(sLeChemindeDmaths)<>0) Then RegleCheminDesIcones(sLeChemindeDmaths) Endif oDmProgInst.getControl("ProgressBar1").Value = 100

' Wait 3000 oFinInst = CreateUnoDialog(DialogLibraries.DmInstall.FinInst )

oFinInst.GetControl("Label1").Peer.Text = oFinInst.GetControl("Label1").Peer.Text & chr(13) & chr(13) & chr(13) & "Version " & iVersion

oDmProgInst.Dispose() oFinInst.execute()

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 "it" ' iLangT = 4 ' Case "da" ' 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 écrite par Jérôme Ortais 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 écrite par Jérôme Ortais 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 sCheminSoftware1, sCheminSoftware2, sCheminSoftware3, sNomPoliceCursive, sUsingDispatcher as String If oChoixrepinstallation.Model.FileControl2.Text <> sNotfound then sCheminSoftware1 = oChoixrepinstallation.Model.FileControl2.Text If oChoixrepinstallation.Model.FileControl3.Text <> sNotfound then sCheminSoftware2 = oChoixrepinstallation.Model.FileControl3.Text If oChoixrepinstallation.Model.FileControl4.Text <> sNotfound then sCheminSoftware3 = oChoixrepinstallation.Model.FileControl4.Text rem on utilise le dispatcher si la version de OOo est > 230 sUsingDispatcher = "FALSE" If GetguiType = 4 Then sCheminSoftware1 = RegleAppsSousLinux(sCheminSoftware1) sCheminSoftware2 = RegleAppsSousLinux(sCheminSoftware2) sCheminSoftware3 = RegleAppsSousLinux(sCheminSoftware3) Endif

If (GetguiType = 4 and FileExists("/Users")) Then sNomPoliceCursive = "Apple Chancery" Else sNomPoliceCursive = "Atalante" Endif

sSource="Rem (C) Didier Dorange-Pattoret www.dmaths.org"+Chr(13) sSource=sSource+"Global const iLang = "+iLangInstall+Chr(13) sSource=sSource+"Public const iNumVersionDmathsCourante = "+ iNumVersionDmaths +""+Chr(13) sSource=sSource+"Public const sChemindmaths = """ + DetermineRepertoireDmaths + """"+Chr(13) sSource=sSource+"Public const sChemindmathsODS = """ + fCheminduFichierDmathsODS + """" + Chr(13) rem sChemindmathsODS est le fichier dmaths.ods sSource=sSource+"Public const bItalic = TRUE"+Chr(13) sSource=sSource+"Public const bEdroit = TRUE"+Chr(13) sSource=sSource+"Public const bIdroit = TRUE"+Chr(13) sSource=sSource+"Public const bChiffresDroits = TRUE"+Chr(13) sSource=sSource+"Public const bVecteursItalic = TRUE"+Chr(13) sSource=sSource+"Public const bAnglesItalic = TRUE"+Chr(13) sSource=sSource+"Public const bMesuresAlgItalic = TRUE"+Chr(13) sSource=sSource+"Public const bLettresAreScalaires = TRUE"+Chr(13) sSource=sSource+"Public const sLettresScalaires = """ + "abcdexyzt" + """" +Chr(13) sSource=sSource+"Public const bFormulesGras = FALSE"+Chr(13) sSource=sSource+"Public const iTailleFormules = "+Cstr(12)+Chr(13) sSource=sSource+"Public const bTailleFormCarac = TRUE"+Chr(13) sSource=sSource+"Public const bPoliceFormCarac = TRUE"+Chr(13) sSource=sSource+"Public const iMargesFormules = " + Cstr(0) + Chr(13) sSource=sSource+"Public const bConcateneFormules = TRUE"+Chr(13) sSource=sSource+"Public const iMarqHorPoints = " + Cstr(40)+ Chr(13) sSource=sSource+"Public const iMarqVerPoints = "+ Cstr(0)+ Chr(13) sSource=sSource+"Public const sBorneInfIntegrales = ""from"""+Chr(13) sSource=sSource+"Public const sBorneSupIntegrales = ""to"""+Chr(13) sSource=sSource+"Public const bTextMode = FALSE"+Chr(13) sSource=sSource+"Public const bCoordColonne = FALSE"+Chr(13) sSource=sSource+"Public const bSystemesAlignes = FALSE"+Chr(13) sSource=sSource+"Public const bMatricesRondes = TRUE"+Chr(13) sSource=sSource+"Public const bFormulesEspacees = FALSE"+Chr(13) sSource=sSource+"Public const bFormulesEncadrees = FALSE"+Chr(13) sSource=sSource+"Public const bGrandesParentheses = TRUE"+Chr(13) sSource=sSource+"Public const bModeFactoriel = FALSE"+Chr(13) sSource=sSource+"Public const bFractions = FALSE"+Chr(13) If iLangInstall = 0 Then sSource=sSource+"Public const bXpointaulieux = FALSE"+Chr(13) Else sSource=sSource+"Public const bXpointaulieux = TRUE"+Chr(13) Endif sSource=sSource+"Public const bUsingDispatcher = "+ sUsingDispatcher +Chr(13) sSource=sSource+"Public const iDelaiEntreSauvegardes = "+ Cstr(0) + Chr(13) sSource=sSource+"Public const sThemeIcons = """+DeterminesThemeIcons(oChoixrepinstallation)+""""+Chr(13) sSource=sSource+"Public const sCheminSoftware1 = """+sCheminSoftware1+""""+Chr(13) sSource=sSource+"Public const sCheminSoftware2 = """+sCheminSoftware2+""""+Chr(13) sSource=sSource+"Public const sCheminSoftware3 = """+sCheminSoftware3+""""+Chr(13) sSource=sSource+"Public const sNomPoliceCursive = """+sNomPoliceCursive+""""+Chr(13) sSource=sSource+"Sub MyTest2" & Chr(13) & "Print ""Vive Dmaths !""" & Chr(13) & "End Sub"

EcritFichierDmOptionsTXT(sSource) rem ecrit le fichier dmoptions InsertModuleDmOptions(sSource) rem cree le module des options

End Sub

rem cette macro met a jour les options en gardant celles de l utilisateur Sub OptionsUtilisateur 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" DmInstall.Install_Addon.LoadAppsPref(oDmOptions,False,True,sThemeIcons) rem bPremInstall=False bRegleOptions = True ValidOptionsDmaths oDmOptions.Dispose() End Sub

Sub OptionsBackup sSource="Rem (C) Didier Dorange-Pattoret www.dmaths.org 2005"+Chr(13) sSource=sSource+"Public const sDateSauvegarde = """+Date()+""""+Chr(13) sSource=sSource+"Public Const sRepertoireSourceDefaut = """+GetRepertoirePath("home")+""""+Chr(13) sSource=sSource+"Public Const sRepertoireBackupDefaut = """+GetRepertoirePath("home")+""""+Chr(13) sSource=sSource+"Sub MyTest3" & Chr(13) & "Print ""Vive Dmaths !""" & Chr(13) & "End Sub" sMod = "DmBackup" oLib = GlobalScope.BasicLibraries.Standard If oLib.hasByName(sMod) Then oLib.removeByName(sMod) EndIf oLib.InsertByName(sMod,sSource) End Sub

Sub LoadAppsPref(oBoiteApps as Object, bParDefaut, bRegleOptions as Boolean,sThemeIcons as String)

If bParDefaut Then rem on charge les applications reconnues par defaut If (GetguiType = 4 and Not IsMacOs) Then Call LoadAppsLinux Elseif GetguiType = 1 Then Call LoadAppsWin rem charge les noms des applications préférées End If oBoiteApps.Model.FileControl4.Text = "" oBoiteApps.Model.FileControl3.Text = "" oBoiteApps.Model.FileControl2.Text = "" For I = 9 To 0 Step -1 If FileExists(AppsPref(I,0)) Then oBoiteApps.Model.FileControl4.Text = oBoiteApps.Model.FileControl3.Text oBoiteApps.Model.FileControl3.Text = oBoiteApps.Model.FileControl2.Text oBoiteApps.Model.FileControl2.Text = AppsPref(I,0) Endif Next I rem on charge les icones par defaut si OS<>Mac ' If (GetguiType = 1 or Not FileExists("/Users")) Then If oBoiteApps.Model.FileControl2.Text <> "" Then oBoiteApps.GetControl("SoftButton1").Visible = True rem si l'icone existe dans la base on la passe en image du bouton If FileExists(AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),1)) Then oBoiteApps.GetControl("SoftButton1").Model.ImageURL = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),1) rem si l'image n'est pas dans la base donnée on la fabrique FabriqueImages(oBoiteApps,oBoiteApps.GetControl("SoftButton1").Model.ImageURL,1) Else rem si l'image ne peut etre fabriquee on met l'image par defaut oBoiteApps.GetControl("SoftButton1").Model.ImageURL = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware1_16.bmp" Endif End If If oBoiteApps.Model.FileControl3.Text <> "" Then oBoiteApps.GetControl("SoftButton2").Visible = True If FileExists(AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),1)) Then oBoiteApps.GetControl("SoftButton2").Model.ImageURL = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),1) FabriqueImages(oBoiteApps,oBoiteApps.GetControl("SoftButton2").Model.ImageURL,2) Else oBoiteApps.GetControl("SoftButton2").Model.ImageURL = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware2_16.bmp" Endif End If If oBoiteApps.Model.FileControl4.Text <> "" Then oBoiteApps.GetControl("SoftButton3").Visible = True If FileExists(AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),1)) Then oBoiteApps.GetControl("SoftButton3").Model.ImageURL = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),1) FabriqueImages(oBoiteApps,oBoiteApps.GetControl("SoftButton3").Model.ImageURL,3) Else oBoiteApps.GetControl("SoftButton3").Model.ImageURL = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware3_16.bmp" Endif End If ' Endif Else rem on charge les applications que l'utilisateur a deja installées oBoiteApps.Model.FileControl2.Text = sCheminSoftware1 oBoiteApps.Model.FileControl3.Text = sCheminSoftware2 oBoiteApps.Model.FileControl4.Text = sCheminSoftware3

If Not bRegleOptions Then oBoiteApps.GetControl("Label1").Visible = False oBoiteApps.GetControl("FileControl2").Enable = False oBoiteApps.GetControl("FileControl3").Enable = False oBoiteApps.GetControl("FileControl4").Enable = False For I = 1 To iNbreThemesIcones oBoiteApps.GetControl("OptionButton"+Cstr(I)).Visible = False Next I oBoiteApps.GetControl("Label3").Visible = False End if

rem recherche des icônes des apps preferees sauf sous Mac ' If (GetguiType = 1 or Not FileExists("/Users")) Then 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") If sCheminSoftware1 <> "" Then oBoiteApps.GetControl("SoftButton1").Visible = True If Not bRegleOptions Then oBoiteApps.GetControl("SoftButton1").Enable = False If FileExists(oAddon.getByName("soft1").ImageIdentifier & "_16.bmp") Then oBoiteApps.GetControl("SoftButton1").Model.ImageURL = oAddon.getByName("soft1").ImageIdentifier & "_16.bmp" Else oBoiteApps.GetControl("SoftButton1").Model.ImageURL = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware1_16.bmp" Endif Endif If sCheminSoftware2 <> "" Then oBoiteApps.GetControl("SoftButton2").Visible = True If Not bRegleOptions Then oBoiteApps.GetControl("SoftButton2").Enable = False If FileExists(oAddon.getByName("soft2").ImageIdentifier & "_16.bmp") Then oBoiteApps.GetControl("SoftButton2").Model.ImageURL = oAddon.getByName("soft2").ImageIdentifier & "_16.bmp" Else oBoiteApps.GetControl("SoftButton2").Model.ImageURL = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware2_16.bmp" Endif Endif If sCheminSoftware3 <> "" Then oBoiteApps.GetControl("SoftButton3").Visible = True If Not bRegleOptions Then oBoiteApps.GetControl("SoftButton3").Enable = False If FileExists(oAddon.getByName("soft3").ImageIdentifier & "_16.bmp") Then oBoiteApps.GetControl("SoftButton3").Model.ImageURL = oAddon.getByName("soft3").ImageIdentifier & "_16.bmp" Else oBoiteApps.GetControl("SoftButton3").Model.ImageURL = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware3_16.bmp" Endif Endif Endif ' Endif Endif End Sub

Sub RegleIconesAppsPref(oBoiteApps as Object,sThemeIcons as String) 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")

If oBoiteApps.Model.FileControl2.Text <> "" Then rem le contexte puis l'icone 'oAddon.getByName("soft1").Context = "com.sun.star.text.TextDocument" If oBoiteApps.GetControl("SoftButton1").Model.ImageURL <>"" Then oAddon.getByName("soft1").ImageIdentifier = Mid(oBoiteApps.GetControl("SoftButton1").Model.ImageURL,1,Len(oBoiteApps.GetControl("SoftButton1").Model.ImageURL)-7) Else oAddon.getByName("soft1").ImageIdentifier = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware1" Endif rem l'infobulle If GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text) = -1 Then oAddon.getByName("soft1").Title = getFileNameOnly(ConvertToURL(oBoiteApps.GetControl("FileControl2").Text)) Elseif AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),2)<>"" Then oAddon.getByName("soft1").Title = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),2) Else oAddon.getByName("soft1").Title = "Software 1" End If Else oAddon.getByName("soft1").Context = "hidden" End If

If oBoiteApps.Model.FileControl3.Text <> "" Then rem le contexte puis l'icone 'oAddon.getByName("soft2").Context = "com.sun.star.text.TextDocument" If oBoiteApps.GetControl("SoftButton2").Model.ImageURL <>"" Then oAddon.getByName("soft2").ImageIdentifier = Mid(oBoiteApps.GetControl("SoftButton2").Model.ImageURL,1,Len(oBoiteApps.GetControl("SoftButton2").Model.ImageURL)-7) Else oAddon.getByName("soft2").ImageIdentifier = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware2" Endif rem l'infobulle If GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text) = -1 Then oAddon.getByName("soft2").Title = getFileNameOnly(ConvertToURL(oBoiteApps.GetControl("FileControl3").Text)) Elseif AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),2)<>"" Then oAddon.getByName("soft2").Title = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),2) Else oAddon.getByName("soft2").Title = "Software 2" End If Else oAddon.getByName("soft2").Context = "hidden" End If

If oBoiteApps.Model.FileControl4.Text <> "" Then rem le contexte puis l'icone 'oAddon.getByName("soft3").Context = "com.sun.star.text.TextDocument" If oBoiteApps.GetControl("SoftButton3").Model.ImageURL <>"" Then oAddon.getByName("soft3").ImageIdentifier = Mid(oBoiteApps.GetControl("SoftButton3").Model.ImageURL,1,Len(oBoiteApps.GetControl("SoftButton3").Model.ImageURL)-7) Else oAddon.getByName("soft3").ImageIdentifier = fCheminDmaths+"icons/"+sThemeIcons+"/launchsoftware3" Endif rem l'info bulle If GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text) = -1 Then oAddon.getByName("soft3").Title = getFileNameOnly(ConvertToURL(oBoiteApps.GetControl("FileControl4").Text)) Elseif AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),2)<>"" Then oAddon.getByName("soft3").Title = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),2) Else oAddon.getByName("soft3").Title = "Software 3" End If Else oAddon.getByName("soft3").Context = "hidden" End If Endif oConfigAccess.commitChanges() 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

Sub RegleNumerotationIcones rem cette macro regle lors de l'installation la numerotation des icones de la barre dmaths NomIcone = Array("writeformula","lancecreationtableau","metenformule","metenvecteur","metenmesurealgebrique","metenangle","metenlimite","metenintegrale","metensomme","metenproduit","metenpointe","metendoublepointe","metenracine","metensysteme","metenmatrice","systemegraphique","matricegraphique","formulegraphique","formulegraphique2",_ "loadparcro","metentreaccolades","metentreparentheses","metenitalic","atalante","bordure_selection","affectetailleformule","encadreformule","augmentetailleformule","diminuetailleformule","repregraphique","lancetablevar","repregrille","reprediagbox","fairefigure","changemodeformule","lancebackup") 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") Dim sCheminImages$ Dim sElementNames$(),sTheme$, sCheminIcones$ Dim iPosition as Integer sElementNames = oAddon.getElementNames() iPosition = Instr(oAddon.getByname(oAddon.ElementNames(1)).ImageIdentifier,"theme") sTheme = iif(iPosition<>0 , Mid(oAddon.getByname(oAddon.ElementNames(1)).ImageIdentifier,iPosition,6),"theme1") sCheminIcones = fCheminDmaths & "icons/" & sTheme & "/"

For I = LBound(sElementNames()) To UBound(sElementNames())-3 rem car il y a les trois images des applications preferees oAddon.getByname(sElementNames(I)).ImageIdentifier = sCheminIcones & NomIcone(I) Next I Endif oConfigAccess.commitChanges() End Sub

Sub MaJIconesDuMenuDmaths rem cette macro ecrite le 20/02/2007 regle lors de l'installation les icones du menu dmaths NomIcone = Array("aide","faq","ref","addon","update","choixoptionsdmaths","update","info") oConfigAccess = GetConfigAccess( "/org.openoffice.Office.Addons/AddonUI/OfficeMenuBar", True )

If oConfigAccess.hasByName("org.openoffice.Office.addon.aide") Then oAddon = oConfigAccess.getByName("org.openoffice.Office.addon.aide").Submenu Dim sCheminImages$ Dim sElementNames$(),sTheme$, sCheminIcones$ Dim iPosition as Integer sElementNames = oAddon.getElementNames() iPosition = Instr(oAddon.getByname(oAddon.ElementNames(1)).ImageIdentifier,"theme") sTheme = iif(iPosition<>0 , Mid(oAddon.getByname(oAddon.ElementNames(1)).ImageIdentifier,iPosition,6),"theme1") sCheminIcones = fCheminDmaths & "icons/" & sTheme & "/" For I = LBound(sElementNames()) To UBound(sElementNames()) oAddon.getByname(sElementNames(I)).ImageIdentifier = sCheminIcones & NomIcone(I) Next I Endif oConfigAccess.commitChanges() End Sub

Sub ChoisirThemeIcone(sTheme as String) rem cette macro permet choisir le theme des icones affichées

sRepertoireDmaths = DetermineRepertoireDmaths rem sRepertoireDmaths donne l adresse des fichiers Dim sElementNames$()

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 = oAddon.getElementNames() For I = LBound(sElementNames()) To UBound(sElementNames()) oAddon.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oAddon.getByname(sElementNames(I)).ImageIdentifier , sTheme) ' oAddon.getByname(sElementNames(I)).Context = "com.sun.star.text.TextDocument" 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 = oAddon.getElementNames() For I = LBound(sElementNames()) To UBound(sElementNames()) oAddon.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oAddon.getByname(sElementNames(I)).ImageIdentifier , sTheme) ' oAddon.getByname(sElementNames(I)).Context = "com.sun.star.text.TextDocument" 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()) oAddon.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oAddon.getByname(sElementNames(I)).ImageIdentifier , sTheme) Next I Endif oConfigAccess.commitChanges()

End Sub

Sub PreselectionneNumeroTheme as String Dim iNumeroTheme, iPos as Integer iNumeroTheme = 1 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") iPos = Instr(oAddon.getByname(oAddon.ElementNames(0)).ImageIdentifier,"theme") If iPos > 0 Then iNumeroTheme = Cint(Mid(oAddon.getByname(oAddon.ElementNames(0)).ImageIdentifier,iPos+5,1) Endif End If oChoixrepinstallation.GetControl("OptionButton"&Cstr(iNumeroTheme)).State = 1 PreselectionneNumeroTheme = "theme" & Cstr(iNumeroTheme) End Sub

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 cette macro fabrique l'image identifier Function ReplacesTheme(sCheminImage,sTheme as String) as String Dim iPos,iLen as Integer iPos = Instr(sCheminImage,"theme") iLen = Len(sCheminImage) if iPos > 0 Then ReplacesTheme = sRepertoireDmaths & "icons/" & sTheme & Mid(sCheminImage,iPos+6,iLen-iPos-5) Else ReplacesTheme = sCheminImage Endif End Function

rem macros gérant les boutons soft après changement du texte d'un filecontrol Sub GereSoftButton1 GereSoftButton(oChoixrepinstallation,1) End Sub

Sub GereSoftButton2 GereSoftButton(oChoixrepinstallation,2) End Sub

Sub GereSoftButton3 GereSoftButton(oChoixrepinstallation,3) End Sub

Sub GereSoftButton(oBoiteApps as Object, iNumero as Integer) If oBoiteApps.GetControl("FileControl"+Cint(iNumero+1)).Text <> "" Then If Len(oBoiteApps.GetControl("FileControl"+Cint(iNumero+1)).Model.Text) = 1 Then oBoiteApps.GetControl("SoftButton"+Cint(iNumero)).Model.ImageURL = fCheminDmaths & "icons/launchsoftware" & Cint(iNumero) &"_16.bmp" oBoiteApps.GetControl("SoftButton"+Cint(iNumero)).Visible = True oBoiteApps.GetControl("SoftButton"+Cint(iNumero)).Enable = True Else oBoiteApps.GetControl("SoftButton"+Cint(iNumero)).Visible = False oBoiteApps.GetControl("SoftButton"+Cint(iNumero)).Enable = False Endif End Sub

rem donne l'indice correspondant a l'application Function GetIndiceAppsPref(sAppsPref as String) as Integer GetIndiceAppsPref = -1 rem valeur si pas dans la liste prédéfinie For I = 0 To 9 If AppsPref(I,0) = sAppsPref Then GetIndiceAppsPref = I Exit For End If Next I End Function

Sub LoadAppsLinux rem les images incluses dans l'addon n'ont pas d'extension. AppsPref(0,0) = "/usr/bin/dia" AppsPref(0,1) = fCheminDmaths+"icons/appspref/launchdia_16.bmp" AppsPref(0,2) = " Dia " AppsPref(1,0) = "/usr/bin/drgeo" AppsPref(1,1) = "" AppsPref(1,2) = " Dr Geo " AppsPref(2,0) = "/usr/local/Declic/declic.sh" AppsPref(2,1) = "" AppsPref(2,2) = " Déclic " AppsPref(3,0) = CurDir+"/Declic/declic.sh" AppsPref(3,1) = "" AppsPref(3,2) = " Déclic " AppsPref(4,0) = "/usr/bin/konqueror" AppsPref(4,1) = fCheminDmaths+"icons/appspref/konqueror_16.bmp" AppsPref(4,2) = " Konqueror " AppsPref(5,0) = "/usr/bin/konsole" AppsPref(5,1) = "" AppsPref(5,2) = " Konsole " AppsPref(6,0) = "/usr/bin/kmail" AppsPref(6,1) = "" AppsPref(6,2) = " Kmail " AppsPref(7,0) = CurDir+"/Declic/declic.sh" AppsPref(7,1) = "" AppsPref(7,2) = " Declic " End Sub

Sub LoadAppsWin AppsPref(0,0) = "C:\Program Files\GeoGebra\Geogebra.exe" AppsPref(0,1) = "" AppsPref(0,2) = " GeoGebra " AppsPref(1,0) = "C:\Program Files\dia\bin\dia.bat" AppsPref(1,1) = fCheminDmaths+"icons/appspref/launchdia_16.bmp" AppsPref(1,2) = " Dia " AppsPref(2,0) = "C:\Program Files\ATELIERS\geom3D\Geom3d.exe" AppsPref(2,1) = "" AppsPref(2,2) = " Atelier géomtrie 3D " AppsPref(3,0) = "C:\Program Files\ATELIERS\geom2D\Geom96.exe" AppsPref(3,1) = "" AppsPref(3,2) = " Atelier géométrie 2D " 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 = DetermineRepertoireDmaths 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 ' Dim GetPIP as Object, repExt as String ' GetPIP = GetDefaultContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider") ' repExt = GetPIP.getPackageLocation("Dmaths") ' fCheminDmaths = repExt & "/Fichiers/" Dim xContext, LeRep as String rem modifiee le 20 mars 2009 Dim oAC As Object oCmdEnv = CreateUnoListener( "CmdEnv_","com.sun.star.deployment.XCommandEnvironment" ) GetPMF = GetDefaultContext.getValueByName("/singletons/com.sun.star.deployment.thePackageManagerFactory") If TestInstallRezo Then xContext = "shared" Else xContext = "user" LeRep = GetPMF.getPackageManager(xContext).getDeployedPackage("Dmaths","DmathsAddon.oxt",oAc,oCmdEnv).URL & "/Fichiers/" fCheminDmaths = LeRep 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

Rem devra etre remplacee par fChemindmaths Function DetermineRepertoireDmaths as String rem cette fonction determine le fichier racine pour le choix des icones, autotext, galleries Dim xContext, LeRep as String rem modifiee le 20 mars 2009 Dim oAC As Object oCmdEnv = CreateUnoListener( "CmdEnv_","com.sun.star.deployment.XCommandEnvironment" ) GetPMF = GetDefaultContext.getValueByName("/singletons/com.sun.star.deployment.thePackageManagerFactory") If TestInstallRezo Then xContext = "shared" Else xContext = "user" LeRep = GetPMF.getPackageManager(xContext).getDeployedPackage("Dmaths","DmathsAddon.oxt",oAc,oCmdEnv).URL & "/Fichiers/" DetermineRepertoireDmaths = LeRep End Function

Function IsMacOS as Boolean IsMacOS = False If Getguitype = 3 or (Getguitype = 4 and FileExists("/Users")) Then IsMacOS = True 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, aFile, aNewFile, 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 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