<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Install_Addon" script:language="StarBasic">&apos;************************************************
&apos;Copyright (C) 2006-2014 Didier Dorange-Pattoret
&apos;38, chemin de l&apos;Abbaye 
&apos;74940 Annecy le Vieux
&apos;France
&apos;ddorange@dmaths.com
&apos;
&apos;
&apos;This library is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public Licence (GPL)
&apos;as published by the Free Software Foundation; either
&apos;version 2.1 of the License, or (at your option) any later version.

&apos;This library is distributed in the hope that it will be useful,
&apos;but WITHOUT ANY WARRANTY; without even the implied warranty of
&apos;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
&apos;General Public License for more details.

&apos;You should have received a copy of the GNU General Public Licence (GPL)
&apos;along with this library; if not, write to the Free Software
&apos;Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
&apos;************************************************



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 = &quot; 3.5.4.0 &quot;
Public const iNumVersionDmaths = 3540 rem à changer également dans Dmaths Tools
Public const iNbreThemesIcones = 5



Sub LanceFinInstallation (bOnMetAJour as Boolean)
	rem Print &quot;entre LanceFinInstallation&quot;
	DialogLibraries.loadLibrary( &quot;DmInstall&quot;)
	oDmProgInst = CreateUnoDialog(DialogLibraries.DmInstall.DmProgInst)
	oDmProgInst.Visible = True
	Wait 500	
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).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(&quot;Dmaths&quot;)
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).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 &amp; &quot;smath&quot;
	If GetGuiType = 1 Then sCheminMath = sCheminMath &amp; &quot;.exe&quot;
	If  (Not FileExists(sCheminMath) and Not IsMacOs) Then
		MsgBox(&quot;Le module Math n&apos;est pas installé&quot;+chr(13)+chr(13)+&quot;Math module is not installed&quot;,48,&quot;Dmaths&quot;)	
		Stop	
	Endif
End Sub



Sub AfficheChoixRepertoireInstallation	

	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 10
	
	oChoixrepinstallation = CreateUnoDialog( DialogLibraries.DmInstall.Choixrepinstallation )


rem Print &quot;arrive avant LoadAppsPref          &quot;, PreselectionneNumeroTheme

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

 	
    sUserPath = GetRepertoirePath(&quot;user&quot;)                         rem utilité a revoir

	Call Fininstallation                                           rem nouveauté
End sub



Sub Fininstallation

	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 15

	BasicLibraries.loadLibrary(&quot;Dmaths&quot;)
	
	
	
	sLeChemindeDmaths = sCheminDmaths 

	rem Print &quot;entree finstallation&quot;

	
rem---------------------------------------------------------------------------------------
&apos; en cas d&apos;installation reseau
&apos;	Print TestInstallRezo

	If bPremInstall Then
		If  TestInstallRezo   Then
			If Not FileExists(GetRepertoirePath(&quot;user&quot;)+GetPathSeparator+&quot;dmaths&quot;) Then MkDir GetRepertoirePath(&quot;user&quot;)+GetPathSeparator+&quot;dmaths&quot;
			If FileExists(GetRepertoirePath(&quot;user&quot;)+GetPathSeparator+&quot;dmaths&quot;+GetPathSeparator+&quot;dmaths.ods&quot;) Then Kill GetRepertoirePath(&quot;user&quot;)+GetPathSeparator+&quot;dmaths&quot;+GetPathSeparator+&quot;dmaths.ods&quot;
			FileCopy fChemindmaths+&quot;dmaths.ods&quot;, ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/dmaths/dmaths.ods&quot;)
		EndIf
	Endif
	
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 35
	

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

rem configure les raccourcis claviers pour OOo &lt;  3.1

If OOONumVersion &lt; 310 Then
	RaccourcisClavier
End if



rem-----------------------------------------------------------------------------------
&apos; copie des fontes Cmath
rem Fontes


rem------------------------------------------------------------------------------------
&apos;regler le numerotation des icones et choix du theme d&apos;icones 	
	RegleNumerotationIcones rem cette macro regle lors de l&apos;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&apos;icones choisi
	rem Print &quot;FinInstallation&quot;
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 50



	
rem ---------------------------------------------------------------------------------------------------------------------------	
&apos;regler les icones du menu dmaths
	MaJIconesDuMenuDmaths
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 65

	
	
rem------------------------------------------------------------------------------------
&apos; Renomme les anciennes configurations des barres d&apos;Addon

&apos;	If  (iNumVersionDmathsCourante &gt; 1000 and  iNumVersionDmathsCourante &lt; 3415) Then

	&apos;Print &quot;OK&quot;
		dim ConfigRegistry as object
		dim LaBarre as object	
		dim Letiquette as String
		globalScope.basicLibraries.loadLibrary(&quot;Tools&quot;)
		
		
	REM ------- modul:writer Dmaths
		ConfigRegistry = getRegistryKeyContent(&quot;/org.openoffice.Office.UI.WriterWindowState/UIElements/States&quot;,True)
	
		Letiquette = &quot;Dmaths&quot;			
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsBarre&quot;)
			LaBarre.&quot;UIName&quot; = Letiquette
			ConfigRegistry.commitChanges()		
		End if
	
	REM ------- modul:writer Dmaths on/off 
		Select Case iLangInstall
			Case 0
				Letiquette = &quot;Dmaths Afficher/Masquer&quot;
			Case 2
				Letiquette = &quot;Dmaths an/aus-Schalter&quot;
			Case Else 
				Letiquette = &quot;Dmaths on/off switch&quot;
		End Select
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre&quot;)
			LaBarre.&quot;UIName&quot; = Letiquette
			ConfigRegistry.commitChanges()		
		End if		
	
	REM ------- modul:writer OOoTep 
		Letiquette = &quot;OOoTep-Gdmath&quot;
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath&quot;)
			LaBarre.&quot;UIName&quot; = Letiquette
			ConfigRegistry.commitChanges()		
		End if	
	
	REM ------- modul:writer OOoGdmath
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1&quot;)
			LaBarre.&quot;UIName&quot; = &quot;Gdmath&quot;
			ConfigRegistry.commitChanges()		
		End if
	
	Rem -------modul:writer AHmath3D
			If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoAHmath3D.OfficeToolBar&quot;)
			LaBarre.&quot;UIName&quot; = &quot;AHmath3D&quot;
			ConfigRegistry.commitChanges()		
		End if
		
			
	
	REM ------- modul:draw OOoGdmath
		ConfigRegistry = getRegistryKeyContent(&quot;/org.openoffice.Office.UI.DrawWindowState/UIElements/States&quot;, True )
		
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoGdmathBarre1&quot;)
			LaBarre.&quot;UIName&quot; = &quot;Gdmath&quot;
			ConfigRegistry.commitChanges()		
		End if

	
	REM ------- modul:draw OOoTep
		Letiquette = &quot;OOoTep-Gdmath&quot;		
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.OOoTep-Gdmath&quot;)
			LaBarre.&quot;UIName&quot; = Letiquette
			ConfigRegistry.commitChanges()		
		End if			
	
	REM ------- modul:draw Dmaths on/off
		Select Case iLangInstall
			Case 0
				Letiquette = &quot;Dmaths Afficher/Masquer&quot;
			Case 2
				Letiquette = &quot;Dmaths an/aus-Schalter&quot;
			Case Else 
				Letiquette = &quot;Dmaths on/off switch&quot;
		End Select
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.DMathsDisplayBarre&quot;)
			LaBarre.&quot;UIName&quot; = Letiquette
			ConfigRegistry.commitChanges()		
		End if		
		
	REM ------- modul:impress InsertWriter
		ConfigRegistry = getRegistryKeyContent(&quot;/org.openoffice.Office.UI.ImpressWindowState/UIElements/States&quot;, True )
		Select Case iLangInstall
			Case 0
				Letiquette = &quot;Inserer un document Writer&quot;
			Case Else 
				Letiquette = &quot;Insert a Writer Document&quot;
		End Select
		If ConfigRegistry.hasByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.InsertDocumentWriter&quot;) Then
			LaBarre = ConfigRegistry.getByName(&quot;private:resource/toolbar/addon_org.openoffice.Office.addon.InsertDocumentWriter&quot;)
			LaBarre.&quot;UIName&quot; = Letiquette
			ConfigRegistry.commitChanges()		
		End if	



&apos;	Endif

	
	
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 80
	
	
rem-------------------------------------------------------------------------------------
&apos;installation des options en cas de première installation


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



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

	
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 90
	

	oChoixrepinstallation.Dispose()

	
rem on recharge la bibliothèque Standard et on supprime le module DmCloseQuick
	If GetguiType = 1 Then
		BasicLibraries.loadLibrary(&quot;Standard&quot;)
		oLib = GlobalScope.BasicLibraries.Standard
		If oLib.hasByName(&quot;DmCloseQuick&quot;) Then
	    oLib.removeByName(&quot;DmCloseQuick&quot;)
	    EndIf
    Endif
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).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(&quot;inst&quot;)) and Len(sLeChemindeDmaths)&lt;&gt;0) Then 
	RegleCheminDesIcones(sLeChemindeDmaths)
	Endif 
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 100
	
	
   &apos; Wait 3000
    oFinInst = CreateUnoDialog(DialogLibraries.DmInstall.FinInst )

	oFinInst.GetControl(&quot;Label1&quot;).Peer.Text = oFinInst.GetControl(&quot;Label1&quot;).Peer.Text &amp; chr(13) &amp; chr(13) &amp; chr(13)  &amp; &quot;Version &quot; &amp; iVersion

	oDmProgInst.Dispose()
	oFinInst.execute()
	
		
End sub



Function TrouveLang as Integer &apos;retourne un nombre correspondant a la langue de l&apos;utilisateur.
	Dim iLangT as Integer
	Dim oLibT as Object rem sLang est un variable Public	
	oLibT = GlobalScope.BasicLibraries.Standard
	If oLibT.hasByName(&quot;DmOptions&quot;) Then
		iLangT = iLang
	Else
		sLang = GetRepertoirePath(&quot;vlang&quot;)    
		Select Case sLang
			Case &quot;fr&quot;
				iLangT = 0
			Case &quot;de&quot;
				iLangT = 2
			Case &quot;es&quot;
				iLangT = 3		
			Case &quot;pt&quot;
				iLangT = 4
			Case &quot;et&quot;
				iLangT = 5
		&apos;	Case &quot;sk&quot;
		&apos;		iLangT = 6
			Case Else 
				iLangT = 1
		End Select
	Endif
	If iLangT &lt;&gt; 2 Then sLang = &quot;fr&quot; rem pour l&apos;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(&quot;user&quot;)+&quot;/config/soffice.cfg/modules/swriter/accelerator/&quot;+GetRepertoirePath(&quot;vlang&quot;)+&quot;/current.xml&quot;
	sNomFichierOld=GetRepertoirePath(&quot;user&quot;)+&quot;/config/soffice.cfg/modules/swriter/accelerator/&quot;+GetRepertoirePath(&quot;vlang&quot;)+&quot;/current.old&quot;

	If Not FileExists(sNomFichier) Then
		MkDir GetRepertoirePath(&quot;user&quot;)+&quot;/config/soffice.cfg/modules/swriter/accelerator/&quot;+GetRepertoirePath(&quot;vlang&quot;)
		FileCopy fCheminDmaths+&quot;current.xml&quot;, 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&lt;3 Then sDebut=sDebut+Chr(10)
	Next
	While Not Eof(iF1)
		Line Input #iF1, sLigne
		If (InStr(sLigne,&quot;vnd.sun.star.script:Dmaths.&quot;)=0 and InStr(sLigne,&quot;vnd.sun.star.script:DmathsInstall.&quot;)=0  and InStr(sLigne,&quot;vnd.sun.star.script:CmathOOo.&quot;)=0 and InStr(sLigne,&quot;vnd.sun.star.script:OOoGdmath.&quot;)=0 and InStr(sLigne,&quot;vnd.sun.star.script:OOoTep.&quot;)=0) Then sFin=sFin+sLigne+Chr(10) &apos;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
	&apos;Ajoute les raccourcis clavier
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_T&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Tableau.LanceCreationTableau?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F10&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenFormule?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F9&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetentreAccolades?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F10&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetentreAccolades?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_V&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenVecteur?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_E&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenMesureAlgebrique?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_A&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenAngle?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_L&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenLimite?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_I&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenIntegrale?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_S&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenSomme?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_R&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenRacine?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_X&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenSysteme?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_M&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetenMatrice?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F10&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.MetentreParentheses?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	If iLangInstall = 0 Then
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F3&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.RaccAutotextes.SuperAutotexte?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot;/&gt;&quot;
	Else
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F3&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.LoadParCro?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Endif
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F3&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Tools.MetenItalic?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_F4&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Tools.MetenAtalante?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_Z&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:Dmaths.Module1.LoadParCro?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	Print #iF1, &quot; &lt;accel:item accel:code=&quot;+Chr(34)+&quot;KEY_O&quot;+Chr(34)+&quot; xlink:href=&quot;+Chr(34)+&quot;vnd.sun.star.script:DmInstall.Options.ChoixOptionsDmaths?language=Basic&amp;amp;location=application&quot;+Chr(34)+&quot; accel:shift=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot; accel:mod1=&quot;+Chr(34)+&quot;true&quot;+Chr(34)+&quot;/&gt;&quot;
	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(&quot;user&quot;)+&quot;/autotext/dmaths.bau&quot;)
	If FileExists(sTo) Then Kill sTo
	On error goto 0
	SetGalleryAndAutotext(&quot;AutoText&quot;, sLang, True )	
End Sub


Sub Galeries
	On error resume next
	For I = 1 To 8
	If FileExists(ConvertToURL(sUserPath+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdg&quot;)) Then Kill ConvertToURL(sUserPath+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdg&quot;)
	If FileExists(ConvertToURL(sUserPath+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdv&quot;)) Then Kill ConvertToURL(sUserPath+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdv&quot;)
	If FileExists(ConvertToURL(sUserPath+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.thm&quot;)) Then Kill ConvertToURL(sUserPath+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.thm&quot;)
	Next I
	On error goto 0
	SetGalleryAndAutotext(&quot;Gallery&quot;, 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 &lt;&gt; sNotfound then sCheminSoftware1 = oChoixrepinstallation.Model.FileControl2.Text
	If oChoixrepinstallation.Model.FileControl3.Text &lt;&gt; sNotfound then sCheminSoftware2 = oChoixrepinstallation.Model.FileControl3.Text
	If oChoixrepinstallation.Model.FileControl4.Text &lt;&gt; sNotfound then sCheminSoftware3 = oChoixrepinstallation.Model.FileControl4.Text
	rem on utilise le dispatcher si la version de OOo est &gt; 230
	sUsingDispatcher = &quot;FALSE&quot;
	If GetguiType = 4 Then 
	sCheminSoftware1 = RegleAppsSousLinux(sCheminSoftware1)
	sCheminSoftware2 = RegleAppsSousLinux(sCheminSoftware2)
	sCheminSoftware3 = RegleAppsSousLinux(sCheminSoftware3)
	Endif
	
	If (GetguiType = 4 and FileExists(&quot;/Users&quot;)) Then 
		sNomPoliceCursive = &quot;Apple Chancery&quot;
	Else
		sNomPoliceCursive = &quot;Atalante&quot;
	Endif	

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

	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(&quot;Dmaths&quot;)
	bIconesChangees = False	
	bAfficherMasquerIcones = False
	oDmOptions = Dmaths.Module5.LoadDialog(&quot;DmInstall&quot;,&quot;DmOptions&quot;)
	rem la ligne suivante permet de remplir par besoin le champ des scalaires.
	If Len(oDmOptions.GetControl(&quot;TextField7&quot;).Peer.Text) = 0 Then oDmOptions.GetControl(&quot;TextField7&quot;).Peer.Text = &quot;abcdexyzt&quot;
	DmInstall.Install_Addon.LoadAppsPref(oDmOptions,False,True,sThemeIcons) rem bPremInstall=False bRegleOptions = True
	ValidOptionsDmaths
	oDmOptions.Dispose()
End Sub



Sub OptionsBackup
	sSource=&quot;Rem (C) Didier Dorange-Pattoret www.dmaths.org 2005&quot;+Chr(13)
	sSource=sSource+&quot;Public const sDateSauvegarde = &quot;&quot;&quot;+Date()+&quot;&quot;&quot;&quot;+Chr(13)
	sSource=sSource+&quot;Public Const sRepertoireSourceDefaut = &quot;&quot;&quot;+GetRepertoirePath(&quot;home&quot;)+&quot;&quot;&quot;&quot;+Chr(13)
		sSource=sSource+&quot;Public Const sRepertoireBackupDefaut = &quot;&quot;&quot;+GetRepertoirePath(&quot;home&quot;)+&quot;&quot;&quot;&quot;+Chr(13) 
		sSource=sSource+&quot;Sub MyTest3&quot; &amp; Chr(13) &amp; &quot;Print &quot;&quot;Vive Dmaths !&quot;&quot;&quot; &amp; Chr(13) &amp; &quot;End Sub&quot;
	    sMod = &quot;DmBackup&quot;
	    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 = &quot;&quot;
			oBoiteApps.Model.FileControl3.Text = &quot;&quot;
			oBoiteApps.Model.FileControl2.Text = &quot;&quot;
			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&lt;&gt;Mac 
		&apos;	If (GetguiType = 1 or Not FileExists(&quot;/Users&quot;))  Then
				If oBoiteApps.Model.FileControl2.Text &lt;&gt; &quot;&quot; Then
					oBoiteApps.GetControl(&quot;SoftButton1&quot;).Visible = True
				rem	si l&apos;icone existe dans la base on la passe en image du bouton
					If FileExists(AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),1)) Then 
						oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),1)
				rem		si l&apos;image n&apos;est pas dans la base donnée on la fabrique
						FabriqueImages(oBoiteApps,oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL,1)
					Else
					rem si l&apos;image ne peut etre fabriquee on met l&apos;image par defaut 
						oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware1_16.bmp&quot;
					Endif		
				End If 
				If oBoiteApps.Model.FileControl3.Text &lt;&gt; &quot;&quot; Then
					oBoiteApps.GetControl(&quot;SoftButton2&quot;).Visible = True
					If FileExists(AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),1)) Then 
						oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),1)
						FabriqueImages(oBoiteApps,oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL,2)
					Else
						oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware2_16.bmp&quot;
					Endif		
				End If 
				If oBoiteApps.Model.FileControl4.Text &lt;&gt; &quot;&quot; Then
					oBoiteApps.GetControl(&quot;SoftButton3&quot;).Visible = True
					If FileExists(AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),1)) Then 
						oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),1)
						FabriqueImages(oBoiteApps,oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL,3)
					Else
						oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware3_16.bmp&quot;
					Endif		
				End If
		&apos;	Endif
	Else rem on charge les applications que l&apos;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(&quot;Label1&quot;).Visible = False
			oBoiteApps.GetControl(&quot;FileControl2&quot;).Enable = False
			oBoiteApps.GetControl(&quot;FileControl3&quot;).Enable = False
			oBoiteApps.GetControl(&quot;FileControl4&quot;).Enable = False
			For I = 1 To iNbreThemesIcones
			oBoiteApps.GetControl(&quot;OptionButton&quot;+Cstr(I)).Visible = False
			Next I
			oBoiteApps.GetControl(&quot;Label3&quot;).Visible = False			
			End if
			
			rem recherche des icônes des apps preferees sauf sous Mac
		&apos;	If (GetguiType = 1 or Not FileExists(&quot;/Users&quot;))  Then
				oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeToolBar&quot;, True )
				If oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;) Then
					oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;)
					oAddon = getToolBarItems(oAddon)
					If sCheminSoftware1 &lt;&gt; &quot;&quot; Then 
						oBoiteApps.GetControl(&quot;SoftButton1&quot;).Visible = True
						If Not bRegleOptions Then oBoiteApps.GetControl(&quot;SoftButton1&quot;).Enable = False
						If FileExists(oAddon.getByName(&quot;soft1&quot;).ImageIdentifier &amp; &quot;_16.bmp&quot;) Then	
							oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL = oAddon.getByName(&quot;soft1&quot;).ImageIdentifier &amp; &quot;_16.bmp&quot;
						Else
							oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware1_16.bmp&quot;
						Endif
					Endif
					If sCheminSoftware2 &lt;&gt; &quot;&quot; Then 
						oBoiteApps.GetControl(&quot;SoftButton2&quot;).Visible = True
						If Not bRegleOptions Then oBoiteApps.GetControl(&quot;SoftButton2&quot;).Enable = False
						If FileExists(oAddon.getByName(&quot;soft2&quot;).ImageIdentifier &amp; &quot;_16.bmp&quot;) Then	
							oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL = oAddon.getByName(&quot;soft2&quot;).ImageIdentifier &amp; &quot;_16.bmp&quot;
						Else
							oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware2_16.bmp&quot;
						Endif
					Endif
					If sCheminSoftware3 &lt;&gt; &quot;&quot; Then 
						oBoiteApps.GetControl(&quot;SoftButton3&quot;).Visible = True
						If Not bRegleOptions Then oBoiteApps.GetControl(&quot;SoftButton3&quot;).Enable = False	
						If FileExists(oAddon.getByName(&quot;soft3&quot;).ImageIdentifier &amp; &quot;_16.bmp&quot;) Then	
							oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL = oAddon.getByName(&quot;soft3&quot;).ImageIdentifier &amp; &quot;_16.bmp&quot;
						Else
							oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware3_16.bmp&quot;
						Endif
					Endif
				Endif
		&apos;	Endif
	Endif



End Sub


Sub RegleIconesAppsPref(oBoiteApps as Object,sThemeIcons as String)
		oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeToolBar&quot;, True )
		If oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;) Then
			oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;)
			oAddon = getToolBarItems(oAddon)
		
			
			If oBoiteApps.Model.FileControl2.Text &lt;&gt; &quot;&quot; Then
				rem le contexte puis l&apos;icone
				&apos;oAddon.getByName(&quot;soft1&quot;).Context = &quot;com.sun.star.text.TextDocument&quot;
				If oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL &lt;&gt;&quot;&quot; Then
					oAddon.getByName(&quot;soft1&quot;).ImageIdentifier = Mid(oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL,1,Len(oBoiteApps.GetControl(&quot;SoftButton1&quot;).Model.ImageURL)-7)
				Else
					oAddon.getByName(&quot;soft1&quot;).ImageIdentifier = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware1&quot;
				Endif
				rem l&apos;infobulle
				If GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text) = -1 Then
					oAddon.getByName(&quot;soft1&quot;).Title = getFileNameOnly(ConvertToURL(oBoiteApps.GetControl(&quot;FileControl2&quot;).Text))
				Elseif AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),2)&lt;&gt;&quot;&quot; Then
				 	oAddon.getByName(&quot;soft1&quot;).Title = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl2.Text),2) 
				Else 	oAddon.getByName(&quot;soft1&quot;).Title = &quot;Software 1&quot;
				End If
			Else
				oAddon.getByName(&quot;soft1&quot;).Context = &quot;hidden&quot;
			End If
			
			If oBoiteApps.Model.FileControl3.Text &lt;&gt; &quot;&quot; Then
				rem le contexte puis l&apos;icone
				&apos;oAddon.getByName(&quot;soft2&quot;).Context = &quot;com.sun.star.text.TextDocument&quot;
				If oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL &lt;&gt;&quot;&quot; Then
					oAddon.getByName(&quot;soft2&quot;).ImageIdentifier = Mid(oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL,1,Len(oBoiteApps.GetControl(&quot;SoftButton2&quot;).Model.ImageURL)-7)
				Else
					oAddon.getByName(&quot;soft2&quot;).ImageIdentifier = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware2&quot;
				Endif
				rem l&apos;infobulle
				If GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text) = -1 Then
					oAddon.getByName(&quot;soft2&quot;).Title = getFileNameOnly(ConvertToURL(oBoiteApps.GetControl(&quot;FileControl3&quot;).Text))
				Elseif AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),2)&lt;&gt;&quot;&quot; Then
				 	oAddon.getByName(&quot;soft2&quot;).Title = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl3.Text),2) 
				Else 	oAddon.getByName(&quot;soft2&quot;).Title = &quot;Software 2&quot;
				End If
			Else
				oAddon.getByName(&quot;soft2&quot;).Context = &quot;hidden&quot;
			End If
			
			If oBoiteApps.Model.FileControl4.Text &lt;&gt; &quot;&quot; Then
				rem le contexte puis l&apos;icone
				&apos;oAddon.getByName(&quot;soft3&quot;).Context = &quot;com.sun.star.text.TextDocument&quot;
				If oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL &lt;&gt;&quot;&quot; Then
					oAddon.getByName(&quot;soft3&quot;).ImageIdentifier = Mid(oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL,1,Len(oBoiteApps.GetControl(&quot;SoftButton3&quot;).Model.ImageURL)-7)
				Else
					oAddon.getByName(&quot;soft3&quot;).ImageIdentifier = fCheminDmaths+&quot;icons/&quot;+sThemeIcons+&quot;/launchsoftware3&quot;
				Endif
				rem l&apos;info bulle
				If GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text) = -1 Then
					oAddon.getByName(&quot;soft3&quot;).Title = getFileNameOnly(ConvertToURL(oBoiteApps.GetControl(&quot;FileControl4&quot;).Text))
				Elseif AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),2)&lt;&gt;&quot;&quot; Then
				 	oAddon.getByName(&quot;soft3&quot;).Title = AppsPref(GetIndiceAppsPref(oBoiteApps.Model.FileControl4.Text),2) 
				Else 	oAddon.getByName(&quot;soft3&quot;).Title = &quot;Software 3&quot;
				End If
			Else
				oAddon.getByName(&quot;soft3&quot;).Context = &quot;hidden&quot;
			End If
		Endif		
		oConfigAccess.commitChanges()
End Sub

Function RegleAppsSousLinux(sCheminApps as String)as String
	If (InStr(sCheminApps,&quot;konqueror&quot;) &gt; 0 and InStr(sCheminApps,&quot;home&quot;) = 0) Then sCheminApps = sCheminApps &amp; &quot; &quot; &amp; GetRepertoirePath(&quot;home&quot;)
	If (getFileExt(ConvertToURL(sCheminApps)) = &quot;.jar&quot; and Mid(sCheminApps,1,4) &lt;&gt; &quot;file&quot;)  Then sCheminApps = sCheminJava &amp; &quot; -jar &quot; &amp;  sCheminApps 
	RegleAppsSousLinux = sCheminApps
End Function

Sub RegleNumerotationIcones rem cette macro regle lors de l&apos;installation la numerotation des icones de la barre dmaths
	NomIcone = Array(&quot;writeformula&quot;,&quot;lancecreationtableau&quot;,&quot;metenformule&quot;,&quot;metenvecteur&quot;,&quot;metenmesurealgebrique&quot;,&quot;metenangle&quot;,&quot;metenlimite&quot;,&quot;metenintegrale&quot;,&quot;metensomme&quot;,&quot;metenproduit&quot;,&quot;metenpointe&quot;,&quot;metendoublepointe&quot;,&quot;metenracine&quot;,&quot;metensysteme&quot;,&quot;metenmatrice&quot;,&quot;systemegraphique&quot;,&quot;matricegraphique&quot;,&quot;formulegraphique&quot;,&quot;formulegraphique2&quot;,_
				&quot;loadparcro&quot;,&quot;metentreaccolades&quot;,&quot;metentreparentheses&quot;,&quot;metenitalic&quot;,&quot;atalante&quot;,&quot;bordure_selection&quot;,&quot;affectetailleformule&quot;,&quot;encadreformule&quot;,&quot;augmentetailleformule&quot;,&quot;diminuetailleformule&quot;,&quot;repregraphique&quot;,&quot;lancetablevar&quot;,&quot;repregrille&quot;,&quot;reprediagbox&quot;,&quot;fairefigure&quot;,&quot;changemodeformule&quot;,&quot;lancebackup&quot;)
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeToolBar&quot;, True )

	If  oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;) Then
		oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;)
		Dim sCheminImages$
		Dim sElementNames$(),sTheme$, sCheminIcones$
		Dim iPosition as Integer
		Dim oToolBarItems as Object
		sElementNames = getElementNamesofToolbar(oAddon)
			
		iPosition = Instr(DetermineImageIdentifierByNumber(oAddon,1),&quot;theme&quot;)
		sTheme = iif(iPosition&lt;&gt;0 , Mid(DetermineImageIdentifierByNumber(oAddon,1),iPosition,6),&quot;theme1&quot;)
		sCheminIcones = fCheminDmaths &amp; &quot;icons/&quot; &amp; sTheme &amp; &quot;/&quot;
		oToolBarItems = getToolBarItems(oAddon)
	
		
		For I = LBound(sElementNames()) To UBound(sElementNames())-3 rem car il y a les trois images des applications preferees
				oToolBarItems.getByname(sElementNames(I)).ImageIdentifier = sCheminIcones &amp; NomIcone(I)				
		Next I
	Endif
	oConfigAccess.commitChanges()		
End Sub

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

	If  oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.aide&quot;) Then
		oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.aide&quot;).Submenu
		Dim sCheminImages$
		Dim sElementNames$(),sTheme$, sCheminIcones$
		Dim iPosition as Integer
		sElementNames = oAddon.getElementNames()
		iPosition = Instr(oAddon.getByname(oAddon.ElementNames(1)).ImageIdentifier,&quot;theme&quot;)
		sTheme = iif(iPosition&lt;&gt;0 , Mid(oAddon.getByname(oAddon.ElementNames(1)).ImageIdentifier,iPosition,6),&quot;theme1&quot;)
		sCheminIcones = fCheminDmaths &amp; &quot;icons/&quot; &amp; sTheme &amp; &quot;/&quot;
		For I = LBound(sElementNames()) To UBound(sElementNames())
			oAddon.getByname(sElementNames(I)).ImageIdentifier = sCheminIcones &amp; 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 = fChemindmaths rem sRepertoireDmaths donne l adresse des fichiers
	Dim sElementNames$()
	Dim oToolBarItems as Object	
	
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeToolBar&quot;, True )
	If  oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;) Then
		oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;)
		sElementNames = getElementNamesofToolbar(oAddon)
		oToolBarItems = getToolBarItems(oAddon)	
		For I = LBound(sElementNames()) To UBound(sElementNames())		
		oToolBarItems.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oToolBarItems.getByname(sElementNames(I)).ImageIdentifier , sTheme)
		Next I
	Endif
	oConfigAccess.commitChanges()
	
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeToolBar&quot;, True )
	If  oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.DMathsDisplayBarre&quot;) Then
		oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.DMathsDisplayBarre&quot;)	
		sElementNames = getElementNamesofToolbar(oAddon)
		oToolBarItems = getToolBarItems(oAddon)
		For I = LBound(sElementNames()) To UBound(sElementNames())
		oToolBarItems.getByname(sElementNames(I)).ImageIdentifier = ReplacesTheme(oToolBarItems.getByname(sElementNames(I)).ImageIdentifier , sTheme)
		Next I
	Endif
	oConfigAccess.commitChanges()
	
	
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeMenuBar&quot;, True )
	If  oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.aide&quot;) Then
		oConfigAccess.getByName(&quot;org.openoffice.Office.addon.aide&quot;).Context = &quot;com.sun.star.text.TextDocument&quot;
		oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.aide&quot;).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

Function PreselectionneNumeroTheme as String
		Dim iNumeroTheme, iPos as Integer
		iNumeroTheme = 1
		oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Addons/AddonUI/OfficeToolBar&quot;, True )
		If oConfigAccess.hasByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;) Then
			oAddon = oConfigAccess.getByName(&quot;org.openoffice.Office.addon.DMathsBarre&quot;)
			iPos = Instr(DetermineImageIdentifierByNumber(oAddon,0),&quot;theme&quot;)
			If iPos &gt; 0 Then
			iNumeroTheme = Cint(Mid(DetermineImageIdentifierByNumber(oAddon,0),iPos+5,1)
			Endif
		End If
		oChoixrepinstallation.GetControl(&quot;OptionButton&quot;&amp;Cstr(iNumeroTheme)).State = 1
		PreselectionneNumeroTheme = &quot;theme&quot; &amp; Cstr(iNumeroTheme)		
End Function


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()&lt;&gt;&quot;OpenOffice&quot; Then
			getToolBarItems = oAddon
		Else
			getToolBarItems = oAddon.getByName(&quot;ToolBarItems&quot;)
		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 = &quot;theme1&quot;
		For I = 2 To iNbreThemesIcones
		If oBoiteApps.GetControl(&quot;OptionButton&quot;&amp;Cstr(I)).State = True then sResult = &quot;theme&quot;&amp; Cstr(I)
		Next I
		DeterminesThemeIcons = sResult
End Function


rem cette macro fabrique l&apos;image identifier
Function ReplacesTheme(sCheminImage,sTheme as String) as String
	Dim iPos,iLen as Integer	
	iPos = Instr(sCheminImage,&quot;theme&quot;) 
	iLen = Len(sCheminImage)
	if iPos &gt; 0 Then 
	ReplacesTheme = sRepertoireDmaths &amp; &quot;icons/&quot; &amp; sTheme &amp; 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&apos;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(&quot;FileControl&quot;+Cint(iNumero+1)).Text &lt;&gt; &quot;&quot; Then
		If Len(oBoiteApps.GetControl(&quot;FileControl&quot;+Cint(iNumero+1)).Model.Text) = 1 Then oBoiteApps.GetControl(&quot;SoftButton&quot;+Cint(iNumero)).Model.ImageURL = fCheminDmaths &amp; &quot;icons/launchsoftware&quot; &amp; Cint(iNumero) &amp;&quot;_16.bmp&quot;
		oBoiteApps.GetControl(&quot;SoftButton&quot;+Cint(iNumero)).Visible = True
		oBoiteApps.GetControl(&quot;SoftButton&quot;+Cint(iNumero)).Enable = True	
	Else
		oBoiteApps.GetControl(&quot;SoftButton&quot;+Cint(iNumero)).Visible = False
		oBoiteApps.GetControl(&quot;SoftButton&quot;+Cint(iNumero)).Enable = False
	Endif
End Sub

rem donne l&apos;indice correspondant a l&apos;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&apos;addon n&apos;ont pas d&apos;extension.
	AppsPref(0,0) = &quot;/usr/bin/dia&quot;
	AppsPref(0,1) = fCheminDmaths+&quot;icons/appspref/launchdia_16.bmp&quot;
	AppsPref(0,2) = &quot; Dia &quot;
	AppsPref(1,0) = &quot;/usr/bin/drgeo&quot;
	AppsPref(1,1) = &quot;&quot;
	AppsPref(1,2) = &quot; Dr Geo &quot;
	AppsPref(2,0) = &quot;/usr/local/Declic/declic.sh&quot;
	AppsPref(2,1) = &quot;&quot;
	AppsPref(2,2) = &quot; Déclic &quot;
	AppsPref(3,0) =  CurDir+&quot;/Declic/declic.sh&quot;
	AppsPref(3,1) = &quot;&quot;
	AppsPref(3,2) = &quot; Déclic &quot;
	AppsPref(4,0) = &quot;/usr/bin/konqueror&quot;
	AppsPref(4,1) = fCheminDmaths+&quot;icons/appspref/konqueror_16.bmp&quot;
	AppsPref(4,2) = &quot; Konqueror &quot;
	AppsPref(5,0) = &quot;/usr/bin/konsole&quot;
	AppsPref(5,1) = &quot;&quot;
	AppsPref(5,2) = &quot; Konsole &quot;	
	AppsPref(6,0) = &quot;/usr/bin/kmail&quot;
	AppsPref(6,1) = &quot;&quot;
	AppsPref(6,2) = &quot; Kmail &quot;
	AppsPref(7,0) =  CurDir+&quot;/Declic/declic.sh&quot;
	AppsPref(7,1) = &quot;&quot;
	AppsPref(7,2) = &quot; Declic &quot;				
End Sub

Sub LoadAppsWin
	AppsPref(0,0) = &quot;C:\Program Files\GeoGebra\Geogebra.exe&quot;
	AppsPref(0,1) = &quot;&quot;
	AppsPref(0,2) = &quot; GeoGebra &quot;
	AppsPref(1,0) = &quot;C:\Program Files\dia\bin\dia.bat&quot;
	AppsPref(1,1) = fCheminDmaths+&quot;icons/appspref/launchdia_16.bmp&quot;
	AppsPref(1,2) = &quot; Dia &quot;
	AppsPref(2,0) = &quot;C:\Program Files\ATELIERS\geom3D\Geom3d.exe&quot;
	AppsPref(2,1) = &quot;&quot;
	AppsPref(2,2) = &quot; Atelier géomtrie 3D &quot;
	AppsPref(3,0) = &quot;C:\Program Files\ATELIERS\geom2D\Geom96.exe&quot;
	AppsPref(3,1) = &quot;&quot;
	AppsPref(3,2) = &quot; Atelier géométrie 2D &quot;
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 = &quot;fr&quot;
	If sModule = &quot;Gallery&quot; Then sSuffixe = &quot;gallery&quot; Else sSuffixe = &quot;autotext/&quot; &amp; sLangue
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Common&quot;, True )
	sLeCheminGaleAuto() = oConfigAccess.getByName(&quot;Path&quot;).getByName(&quot;Current&quot;).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),&quot;DmathsAddon&quot;) = 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 &amp; sSuffixe
	ElseIf J&gt;=0 Then
		 ReDim Preserve sLeCheminGaleAuto(J)
	Endif	
	oConfigAccess.getByName(&quot;Path&quot;).getByName(&quot;Current&quot;).replaceByName(sModule,sLeCheminGaleAuto())
	oConfigAccess.Commitchanges()
End Sub




Function GetRepertoirePath(sInstPath as String) as String &apos;donne le répertoire correspondant
Dim  oPathSubstSrv as Object
Dim sPath as String
	sInstPath = &quot;$(&quot;+sInstPath+&quot;)&quot;
  oPathSubstSrv = createUnoService(&quot;com.sun.star.comp.framework.PathSubstitution&quot;)
  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(&quot;/singletons/com.sun.star.deployment.PackageInformationProvider&quot;) 
	 &apos; 	MRI GetPIP
	  	repExt = GetPIP.getPackageLocation(&quot;Dmaths&quot;)
		fCheminDmaths = repExt &amp; &quot;/Fichiers/&quot;	
	&apos;	Dim xContext, LeRep as String						rem modifiee le 20 mars 2009
	&apos;	Dim oAC  As Object
 	&apos;	oCmdEnv = CreateUnoListener( &quot;CmdEnv_&quot;,&quot;com.sun.star.deployment.XCommandEnvironment&quot; )
 	&apos;	GetPMF = GetDefaultContext.getValueByName(&quot;/singletons/com.sun.star.deployment.thePackageManagerFactory&quot;)
	&apos;	If TestInstallRezo Then xContext = &quot;shared&quot; Else xContext = &quot;user&quot;
	&apos;	LeRep = GetPMF.getPackageManager(xContext).getDeployedPackage(&quot;Dmaths&quot;,&quot;DmathsAddon.oxt&quot;,oAc,oCmdEnv).URL &amp; &quot;/Fichiers/&quot;
	&apos;	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(&quot;user&quot;)+&quot;/dmaths/dmaths.ods&quot;)
	Else
		fCheminduFichierDmathsODS = fChemindmaths &amp; &quot;dmaths.ods&quot;
	EndIf
End function


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




Function IsMacOS as Boolean
	IsMacOS = False
	If Getguitype = 3 or (Getguitype = 4 and FileExists(&quot;/Users&quot;)) Then IsMacOS = True
End Function


Function OOoNumVersion() As Integer
  &apos;Retreives the running OOO version
  Dim aSettings, aConfigProvider
  Dim aParams2(0) As new com.sun.star.beans.PropertyValue
  Dim sProvider$, sAccess$
  sProvider = &quot;com.sun.star.configuration.ConfigurationProvider&quot;
  sAccess   = &quot;com.sun.star.configuration.ConfigurationAccess&quot;
  aConfigProvider = createUnoService(sProvider)
  aParams2(0).Name = &quot;nodepath&quot;
  aParams2(0).Value = &quot;/org.openoffice.Setup/Product&quot;
  aSettings = aConfigProvider.createInstanceWithArguments(sAccess, aParams2())
  If aSettings.hasbyname(&quot;ooSetupVersionAboutBox&quot;) Then
  sOOOVersion = aSettings.getbyname(&quot;ooSetupVersionAboutBox&quot;)
  Else
  sOOOVersion = aSettings.getbyname(&quot;ooSetupVersion&quot;)
  EndIf
  If Len(sOOOVersion) = 3 Then sOOOVersion = sOOOVersion &amp; &quot;.0&quot;
  OOoNumVersion = Cint(Mid(sOOOVersion,1,1))*100 + Cint(Mid(sOOOVersion,3,1))*10 + Cint(Mid(sOOOVersion,5,1))  
End Function

Function OOoName As String
  &apos;Retreives the running OOO version
  Dim aSettings, aConfigProvider
  Dim aParams2(0) As new com.sun.star.beans.PropertyValue
  Dim sProvider$, sAccess$
  sProvider = &quot;com.sun.star.configuration.ConfigurationProvider&quot;
  sAccess   = &quot;com.sun.star.configuration.ConfigurationAccess&quot;
  aConfigProvider = createUnoService(sProvider)
  aParams2(0).Name = &quot;nodepath&quot;
  aParams2(0).Value = &quot;/org.openoffice.Setup/Product&quot;
  aSettings = aConfigProvider.createInstanceWithArguments(sAccess, aParams2())
&apos;  Print aSettings.getbyname(&quot;ooName&quot;)
  OOoName = aSettings.getbyname(&quot;ooName&quot;)
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(&quot;home&quot;)
		sRacine = GetRepertoire(sPath)
	ElseIf IsMacOS Then
		sRacine = &quot;/Users&quot;
	Else
		sRacine = &quot;/home&quot;
	EndIf
	sValue = Dir$(sRacine+GetPathSeparator,16)
		Do 	
			If sValue&lt;&gt;&quot;..&quot; and Mid(sValue,1,1)&lt;&gt;&quot;.&quot;  Then
					If (GetAttr(sRacine+GetPathSeparator+sValue) AND 16 &gt; 0) Then
						sCheminDuCompte = sRacine+GetPathSeparator+sValue			
						Call RegleChemin(sCheminDuCompte,sLeChemindeDmaths,sLeNouveauChemindeDmaths)						
					EndIf
			End If
			sValue = Dir$
		Loop Until sValue = &quot;&quot;	
End Sub


Sub RegleChemin(sCheminDuCompte,src,dest as String)
	Dim sCheminUser, aFile, aNewFile, sLine as String &apos; contient le chemin de l&apos;utilisateur en cours
	sCheminUser = sCheminDuCompte + SuffixeDuCompte 

	aFile = ConvertToUrl(sCheminUser &amp; &quot;/registry/data/org/openoffice/Office/Addons.xcu&quot;)
	&apos;Print aFile
	&apos;Print FileExists(aFile)
	If FileExists(aFile) Then
		aFileNew = ConvertToUrl(sCheminUser &amp; &quot;/registry/data/org/openoffice/Office/Addons.new&quot;)
		iNumberNew = Freefile
		Open aFileNew For Output As iNumberNew
		iNumber = Freefile
		Open aFile For Input As iNumber
		While not eof(iNumber)
			Line Input #iNumber, sLine
		&apos;	If InStr(sLine,src)&gt;0 then print &quot;on change&quot;
			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(&quot;home&quot;)&amp;&quot;\&quot;))+1 Else iPos = Len(GetRepertoirePath(&quot;home&quot;))+1 
		iLong = Len(GetRepertoirePath(&quot;user&quot;))
		SuffixeDuCompte = Mid(GetRepertoirePath(&quot;user&quot;),iPos,iLong-iPos+1)			
End Function


Function RemplaceChaine(ByVal chaine As String, src As String, dest As String, casse As Boolean)        
&apos; fournit une chaine dont toutes les occurences de src ont été remplacées par dest      
&apos;casse = true pour distinguer majuscules/minuscules, = false sinon
Dim lsrc As Integer, i As Integer, kas As Integer
dim limite as string

  limite=&quot;&quot;
  kas = iif(casse, 0, 1)
  lsrc = len(src)
  i = instr(1, chaine, src, kas)
  while i&lt;&gt;0
    while i&lt;0
      limite=limite+left(chaine,32000)
      chaine=mid(chaine,32001)
      i=instr(1, chaine, src, kas)
    wend
    &apos; ici i est toujours positif non nul
    if i&gt;1 then
       limite = limite + Left(chaine, i-1) +dest
    else &apos; ici i vaut toujours 1
       limite = limite +dest
    endif   
    &apos; raccourcir en deux temps car risque : i+src &gt; 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)+&quot;/&quot;
open  leChemin+&quot;temp&quot; for output as #1
	Print #1,cstr(now)
close #1
Kill LeChemin+&quot;temp&quot;
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




</script:module>