File: Un_Install.xba

package info (click to toggle)
dmaths 4.4.0.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 29,500 kB
  • sloc: xml: 169; makefile: 2
file content (430 lines) | stat: -rw-r--r-- 24,143 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<?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="Un_Install" script:language="StarBasic">&apos;************************************************
&apos;Copyright (C) 2006-2017 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;************************************************


Sub Desinstaller
	Dim LeMessage, NomdelAddonEnPlace as String  rem contient le nom de l&apos;addon installé
	Dim sCheminUnopkg as String
	Dim oAC As Object

	BasicLibraries.LoadLibrary(&quot;Dmaths&quot;)
	Call ChargementDuVocabulaire
	LeMessage = Trad(iLang,2) &amp; &quot;   &quot; 
	rem si abandon goto fin
	If Msgbox(LeMessage,33,&quot;Dmaths&quot;)=2 Then Goto Fin
	
	LeMessage = Trad(iLang,4)  &amp; &quot;  &quot;  &amp; chr(13) &amp; chr(13) &amp; Trad(iLang,6)
	
	rem mise en place d&apos;une progressbar
	Globalscope.DialogLibraries.loadLibrary(&quot;DmInstall&quot;)
	oDmProgInst = CreateUnoDialog(DialogLibraries.DmInstall.DmProgInst)
	oDmProgInst.getControl(&quot;Label1&quot;).Visible = False
	
	rem remet la configuration clavier à l&apos;origine
	If Not IsMacOS Then
		Config4Mac(False)
	EndIf
	
	
	If Not TestInstallRezo Then
	
		oDmProgInst.Visible = True
		oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 0
		
		Call Nettoyer rem macro ci-dessous
	
		sCheminUnopkg = TrouveCheminUnopkg	
	
		oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 90

		If OOoNumVersion() &lt; 400 Then
			NomdelAddonEnPlace = TrouveNomAddon rem a la fin du module uninstall
			Shell(sCheminUnopkg &amp;&quot; remove &quot; &amp; NomdelAddonEnPlace,0)
		Else
	 	oCmdEnv = CreateUnoListener( &quot;CmdEnv_&quot;, &quot;com.sun.star.deployment.XCommandEnvironment&quot; )
  	 	GetPMF = GetDefaultContext.getByName(&quot;/singletons/com.sun.star.deployment.thePackageManagerFactory&quot;)
  	 	GetPMF.getPackageManager(&quot;user&quot;).removePackage(&quot;Dmaths&quot;,&quot;DmathsAddon.oxt&quot;,oAC,oCmdEnv)
	 	Endif
		oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 100
		Wait 2000
	
	Elseif ControleDroits(GetRepertoirePath(&quot;inst&quot;)) Then
	
		
		oDmProgInst.Visible = True
		oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 0
		
		Call NettoieLesComptes
		
		sCheminUnopkg = TrouveCheminUnopkg	
	
		oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 85

		If OOoNumVersion() &lt; 400 Then
			NomdelAddonEnPlace = TrouveNomAddon rem a la fin du module uninstall
			Shell(sCheminUnopkg &amp;&quot; remove --shared &quot; &amp; NomdelAddonEnPlace,0)
		Else
 	 		oCmdEnv = CreateUnoListener( &quot;CmdEnv_&quot;, &quot;com.sun.star.deployment.XCommandEnvironment&quot; )
  	 		GetPMF = GetDefaultContext.getByName(&quot;/singletons/com.sun.star.deployment.thePackageManagerFactory&quot;) 
	 		GetPMF.getPackageManager(&quot;shared&quot;).removePackage(&quot;Dmaths&quot;,&quot;DmathsAddon.oxt&quot;,oAc,oCmdEnv)
		EndIf
		
		Rem supprssion du fichier DmathsPlus.dotm
		If getGuitype = 1 Then
			If FileExists(Mid(GetRepertoirePath(&quot;inst&quot;),1,Len(GetRepertoirePath(&quot;inst&quot;))-10) &amp; &quot;share\Dmaths\DmathsPlus.dotm&quot;) Then
				Kill Mid(GetRepertoirePath(&quot;inst&quot;),1,Len(GetRepertoirePath(&quot;inst&quot;))-10) &amp; &quot;share\Dmaths\DmathsPlus.dotm&quot;
				Rmdir Mid(GetRepertoirePath(&quot;inst&quot;),1,Len(GetRepertoirePath(&quot;inst&quot;))-10) &amp; &quot;share\Dmaths\&quot;
			Endif
		Endif
		
		oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 100
		Wait 2000		
	
	Else		
		LeMessage = Trad(iLang,1)  &amp; &quot;  &quot; 
		Msgbox(LeMessage,48,&quot;Dmaths&quot;)
		Goto Fin	
	Endif
	
	oDmProgInst.Dispose()
	Msgbox(LeMessage,48,&quot;Dmaths&quot;)
	Wait 2000	
	
		Rem anihile le quicstarter 
	If Getguitype = 1 Then	
		NePasChargerLODemarrage
		StarDesktop.SuspendQuickstartVeto = True
	&apos;	StarDesktop.terminate
	Endif
	
	Fin:
End Sub


rem lance la procedure en mode multiutilisateurs
Sub NettoieLesComptes
	Dim sPath, sRacine, sValue, sCheminDuCompte, sCheminUnopkg as String
	
	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
	rem determine les comptes et appelle la procedure de nettoyage de chacun
	sValue = Dir$(sRacine+GetPathSeparator,16)
		Do 
			If oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value &lt; 80 Then
				oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value + 10 
			Endif
	rem 		Print sValue
			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 NettoieLeCompte(sCheminDuCompte)
				EndIf
			End If
			sValue = Dir$
		Loop Until sValue = &quot;&quot;
	If (GetGuiType = 4 and not IsMacOS) Then
		NettoieLeCompte(&quot;/root&quot;)
		If oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value &lt; 80 Then
			oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value + 10 
		Endif
	Endif
	
End Sub

rem nettoie un compte
Sub NettoieLeCompte(sCheminLeDuCompte as String)

	Dim sCheminUser,  sLine as String &apos; contient le chemin de l&apos;utilisateur en cours
	rem Print sCheminLeDuCompte
	sCheminUser = sCheminLeDuCompte + SuffixeDuCompte + GetPathSeparator
	rem Print sCheminUser
	rem Print sSuffixeDuCompte
	rem Print sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmBackup.xba&quot;
	
	If bTraitementErreurInstallation Then On Error goto ErreurNettoieLeCompte
	
	rem suppression des modules
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmBackup.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmBackup.xba&quot;
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptions.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptions.xba&quot;
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptionsTrace.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptionsTrace.xba&quot;
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptionsFenetre.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptionsFenetre.xba&quot;	
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;Lang.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;Lang.xba&quot;
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptionsTableau.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;DmOptionsTableau.xba&quot;
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;Gdmath_Dyn.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;Gdmath_Dyn.xba&quot;
	If FileExists(sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;OOoTep_dyn.xba&quot;) Then Kill sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;OOoTep_dyn.xba&quot;

	rem suppression des références aux modules
	aFile = sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;script.xlb&quot;
	rem Print aFile
	If FileExists(aFile) Then
		aFileNew = sCheminUser+&quot;basic&quot;+GetPathSeparator+&quot;Standard&quot;+GetPathSeparator+&quot;script.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
	rem		Print sLine
			If (InStr(sLine,&quot;Gdmath_Dyn&quot;)+InStr(sLine,&quot;OOoTep_dyn&quot;)+InStr(sLine,&quot;Lang&quot;)+InStr(sLine,&quot;DmOptions&quot;)+InStr(sLine,&quot;DmOptionsTrace&quot;)+InStr(sLine,&quot;DmOptionsFenetre&quot;)+InStr(sLine,&quot;DmBackup&quot;)+InStr(sLine,&quot;DmOptionsTableau&quot;))=0  then Print #iNumberNew, sLine		
		wend
		Close #iNumber
		Close #iNumberNew
		kill (aFile)
		Name aFileNew as aFile
	End If
	
	rem suppression des références aux autotextes et aux galeries
	aFile = sCheminUser+&quot;registry&quot;+GetPathSeparator+&quot;data&quot;+GetPathSeparator+&quot;org&quot;+GetPathSeparator+&quot;openoffice&quot;+GetPathSeparator+&quot;Office&quot;+GetPathSeparator+&quot;Common.xcu&quot;
	rem Print aFile
	If FileExists(aFile) Then
		aFileNew = Mid(aFile,1,(Len(aFile)-3)) &amp; &quot;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
	rem		Print sLine
			If (InStr(sLine,&quot;DmathsAddon.oxt/Fichiers/autotext&quot;)+InStr(sLine,&quot;DmathsAddon.oxt/Fichiers/gallery&quot;))=0  then Print #iNumberNew, sLine		
		wend
		Close #iNumber
		Close #iNumberNew
		kill (aFile)
		Name aFileNew as aFile
	End If
	
	
	rem suppression du repertoire dmaths
	If FileExists(sCheminUser+&quot;dmaths&quot;) Then RmDir sCheminUser+&quot;dmaths&quot;
	If FileExists(sCheminUser+&quot;Dmaths&quot;) Then RmDir sCheminUser+&quot;Dmaths&quot;
	rem suppression de l&apos;autotexte
	If FileExists(sCheminUser+&quot;autotext&quot;+GetPathSeparator+&quot;dmaths.bau&quot;) Then Kill sCheminUser+&quot;autotext&quot;+GetPathSeparator+&quot;dmaths.bau&quot;
	rem suppression des raccourcis claviers
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;accelerator&quot;+GetPathSeparator+&quot;fr&quot;+GetPathSeparator+&quot;current.old&quot;) Then
		If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;accelerator&quot;+GetPathSeparator+&quot;fr&quot;+GetPathSeparator+&quot;current.xml&quot;) Then
			Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;accelerator&quot;+GetPathSeparator+&quot;fr&quot;+GetPathSeparator+&quot;current.xml&quot;
		Endif
		FileCopy sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;accelerator&quot;+GetPathSeparator+&quot;fr&quot;+GetPathSeparator+&quot;current.old&quot;,sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;accelerator&quot;+GetPathSeparator+&quot;fr&quot;+GetPathSeparator+&quot;current.xml&quot;
	Endif 
	rem suppression des custom_toolbar eventuelles
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;images&quot;) Then RmDir sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;images&quot; 
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;toolbar&quot;) Then RmDir sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;soffice.cfg&quot;+GetPathSeparator+&quot;modules&quot;+GetPathSeparator+&quot;swriter&quot;+GetPathSeparator+&quot;toolbar&quot;	

	rem suppression des icones eventuelles
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;icons&quot;) Then RmDir sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;icons&quot; 
	
	rem suppression des fichiers dmoptions.txt et relanceooo
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;dmoptions.txt&quot;) Then Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;dmoptions.txt&quot; 
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;relanceooo.sh&quot;) Then Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;relanceooo.sh&quot; rem linux	
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;relanceOOo.scpt&quot;) Then Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;relanceOOo.scpt&quot; rem mac
	
	rem suppression d&apos;un éventuel fichier Figures.docx ou Formules.docx
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;Figures.docx&quot;) Then Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;Figures.docx&quot;
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;Formules.docx&quot;) Then Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;Formules.docx&quot;
	If FileExists(sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;Formules.odt&quot;) Then Kill sCheminUser+&quot;config&quot;+GetPathSeparator+&quot;Formules.odt&quot;
		rem suppression du fichier DmathsPlus.dotm si présent sous Windows
		&apos;Print sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Templates\DmathsPlus.dotm&quot;
		&apos;Print sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Word\STARTUP\DmathsPlus.dotm&quot;, FileExists(sCheminLeDuCompte  &amp; &quot;AppData\Roaming\Microsoft\Word\STARTUP\DmathsPlus.dotm&quot;)
	If GetGuiType = 1 Then
		If FileExists(sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Templates\DmathsPlus.dotm&quot;) Then
			Kill (sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Templates\DmathsPlus.dotm&quot;)
		EndIf
		If FileExists(sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Word\STARTUP\DmathsPlus.dotm&quot;) Then
			Kill (sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Word\STARTUP\DmathsPlus.dotm&quot;)
		Endif
		Rem la portion de code qui suit crée un plantage dans la ligne ci-dessus RmDir sCheminUser+&quot;dmaths&quot; 
		Rem suppression du démarrage rapide ou quickstarter 
	&apos;	sRaccourci = sCheminLeDuCompte  &amp; &quot;\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\&quot; &amp; OOoNameAndVersion &amp; &quot;.lnk&quot;
	&apos;	If FileExists(sRaccourci) Then
	&apos;		Kill sRaccourci
	&apos;	Endif
	Endif
	
	rem nettoyage du fichier registrymodifications.xcu
	aFile = sCheminUser &amp; &quot;registrymodifications.xcu&quot;
	If FileExists(aFile) Then 
		aFileNew = sCheminUser &amp; &quot;registrymodifications2.xcu&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			
				If (InStr(sLine, &quot;ImageIdentifier&quot;) = 0 Or InStr(sLine, &quot;/config/icons&quot;) = 0 Or InStr(sLine, &quot;/Dmaths/icons&quot;) = 0) And (InStr(sLine, &quot;Dmaths.Module1&quot;) = 0 ) then
					Print #iNumberNew, sLine			
				end if						
			Wend
			Close #iNumber
			Close #iNumberNew
			On Error Resume Next
			Kill aFile
			Name aFileNew as aFile
			On Error GoTo 0
	EndIf 

	rem suppression des galeries
	For I = 1 To 7	
	If FileExists(sCheminUser+&quot;gallery&quot;+GetPathSeparator+&quot;sg100&quot;+cStr(I)+&quot;.sdg&quot;) Then Kill sCheminUser+&quot;gallery&quot;+GetPathSeparator+&quot;sg100&quot;+cStr(I)+&quot;.sdg&quot;
	If FileExists(sCheminUser+&quot;gallery&quot;+GetPathSeparator+&quot;sg100&quot;+cStr(I)+&quot;.sdv&quot;) Then Kill sCheminUser+&quot;gallery&quot;+GetPathSeparator+&quot;sg100&quot;+cStr(I)+&quot;.sdv&quot;
	If FileExists(sCheminUser+&quot;gallery&quot;+GetPathSeparator+&quot;sg100&quot;+cStr(I)+&quot;.thm&quot;) Then Kill sCheminUser+&quot;gallery&quot;+GetPathSeparator+&quot;sg100&quot;+cStr(I)+&quot;.thm&quot;
	Next I
	
	Exit Sub	
	
	ErreurNettoieLeCompte:
	Print &quot;Erreur dans NettoieLeCompte : ligne &quot; &amp; erl &amp;  &quot;   &quot; &amp; Error
	Resume next	
	
End Sub


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


Sub Nettoyer
	Dim oLibContainer as Object
    Dim sLib as String
    
	rem suppression de smodules
	DeleteBasicModule(&quot;DmOptions&quot;,&quot;Standard&quot;)
	DeleteBasicModule(&quot;DmOptionsTrace&quot;,&quot;Standard&quot;)
	DeleteBasicModule(&quot;DmOptionsFenetre&quot;,&quot;Standard&quot;)
	DeleteBasicModule(&quot;DmBackup&quot;,&quot;Standard&quot;)
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 10
	DeleteBasicModule(&quot;Lang&quot;,&quot;Standard&quot;)
	DeleteBasicModule(&quot;DmOptionsTableau&quot;,&quot;Standard&quot;)
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 15
	DeleteBasicModule(&quot;Gdmath_Dyn&quot;,&quot;Standard&quot;)
	DeleteBasicModule(&quot;OOoTep_dyn&quot;,&quot;Standard&quot;)
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 20
	
	rem suppression des autotextes
	If FileExists(ConvertFromURL(GetRepertoirePath(&quot;user&quot;)+&quot;/autotext/dmaths.bau&quot;)) Then Kill ConvertFromURL(GetRepertoirePath(&quot;user&quot;)+&quot;/autotext/dmaths.bau&quot;)
	SetGalleryAndAutotext(&quot;AutoText&quot;)
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 30
		
	rem suppression des galeries
	For I = 1 To 8	
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdg&quot;)) Then Kill ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdg&quot;)
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdv&quot;)) Then Kill ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.sdv&quot;)
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.thm&quot;)) Then Kill ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/gallery/sg100&quot;+cStr(I)+&quot;.thm&quot;)
	Next I
	SetGalleryAndAutotext(&quot;Gallery&quot;)
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 40
	
	rem des raccourcis claviers
	sNomFichier=ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/soffice.cfg/modules/swriter/accelerator/&quot;+GetRepertoirePath(&quot;vlang&quot;)+&quot;/current.xml&quot;)
	sNomFichierOld=ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/soffice.cfg/modules/swriter/accelerator/&quot;+GetRepertoirePath(&quot;vlang&quot;)+&quot;/current.old&quot;)

	If FileExists(sNomFichierOld) Then
		If FileExists(sNomFichier) Then Kill sNomFichier 
		FileCopy(sNomFichierOld,sNomFichier)
		Kill sNomFichierOld
	Endif
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 50
	
	rem suppression du dossier Dmaths
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/Dmaths&quot;)) Then RmDir ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/Dmaths&quot;)
	
	
	rem suppression du dossier icons
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/icons&quot;)) Then RmDir ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/icons&quot;)
	
		rem suppression d&apos;un éventuel fichier Figures.docx ou Formules.docx
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/Figures.docx&quot;)) Then Kill ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/Figures.docx&quot;)
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/Formules.docx&quot;)) Then Kill ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/Formules.docx&quot;)
	If FileExists(ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/Formules.odt&quot;)) Then Kill ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/Formules.odt&quot;)	
	
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 60
	
	rem suppression de la custom_toolbar eventuelle
	sNomFichier = ConvertToURL(GetRepertoirePath(&quot;user&quot;)+&quot;/config/soffice.cfg/modules/swriter/&quot;)
	If FileExists(sNomFichier + &quot;images&quot;) Then RmDir sNomFichier + &quot;images&quot;
	If FileExists(sNomFichier + &quot;toolbar&quot;) Then RmDir sNomFichier + &quot;toolbar&quot;
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 70

	rem suppression du process mise à jour automatique
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Events/ApplicationEvents/Bindings&quot;, True )
	If oConfigAccess.hasByName(&quot;OnStartApp&quot;) Then oConfigAccess.removeByName(&quot;OnStartApp&quot;)
	oConfigAccess.CommitChanges
	oDmProgInst.getControl(&quot;ProgressBar1&quot;).Value = 80
	
	rem suppression du fichier DmathsPlus.dotm si présent sous Windows
	If GetGuiType = 1 Then
		If FileExists(Environ(&quot;APPDATA&quot;) &amp; &quot;\Microsoft\Templates\DmathsPlus.dotm&quot;) Then
			Kill ConverttoURL(Environ(&quot;APPDATA&quot;) &amp; &quot;\Microsoft\Templates\DmathsPlus.dotm&quot;)
		EndIf
		If FileExists(Environ(&quot;APPDATA&quot;) &amp; &quot;\Microsoft\Word\STARTUP\DmathsPlus.dotm&quot;) Then
			Kill ConverttoURL(Environ(&quot;APPDATA&quot;) &amp; &quot;\Microsoft\Word\STARTUP\DmathsPlus.dotm&quot;)
		Endif
	Endif
	
End Sub


Sub DeleteBasicModule(srcname,libname) rem supprime le module srcname dans la biblio libname
	Dim oGlobalLib, oLib as Object
	oGlobalLib = GlobalScope.BasicLibraries
	oLib = oGlobalLib.GetByName(libname)
	If oLib.HasByName(srcname) Then oLib.RemoveByName(srcname)
End Sub


rem macro ecrite le 3 novembre 2013
Function TrouveNomAddon as String
	If InStr(fCheminDmaths,&quot;DmathsAddon.zip&quot;)&gt;0 Then
			TrouveNomAddon = &quot;DmathsAddon.zip&quot; 
	Else	
			TrouveNomAddon = &quot;DmathsAddon.oxt&quot; 		
	Endif
End Function

Sub SupprimeCheminAutotextLangue rem macro ecrite le 8 decembre 2013
	Dim oConfigAccess,Lelement as Object 
	Dim sLeCheminGaleAuto() as String
	oConfigAccess = GetConfigAccess( &quot;/org.openoffice.Office.Paths/Paths/org.openoffice.Office.Paths:NamedPath[&apos;AutoText&apos;]&quot;, True)

	sLeCheminGaleAuto() = oConfigAccess.getByName(&quot;InternalPaths&quot;).ElementNames()
	For I = LBound(sLeCheminGaleAuto()) To Ubound(sLeCheminGaleAuto())
			If Instr(sLeCheminGaleAuto(I),&quot;DmathsAddon&quot;) &gt; 0 Then
				oConfigAccess.getByName(&quot;InternalPaths&quot;).removeByName(sLeCheminGaleAuto(I))
			Endif	
	Next I
	oConfigAccess.Commitchanges()
End Sub
</script:module>