/usr/lib/libreoffice/share/extensions/DmathsAddon/DmathsBup/Module1.xba is in libreoffice-dmaths 3.4+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | <?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="Module1" script:language="StarBasic">'************************************************
'Copyright (C) 2005 Didier Dorange-Pattoret
'8, impasse du Châtelet
'74100 Ambilly
'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 ListeRep(100) as string
Public sRepertoireSource,sRepertoireBackup, sMessageErreur,sZipFile as String
Public iNombreRepertoire,iIndexRepertoire,inombrefichiercopies,inombrerepertoirecopies,iNombreErreurs,iNombreRepertoireExamine as Integer
Public inombrefichiersupprimes,inombrerepertoiresupprimes as integer
Public iDimListeRep, iSyncro as integer
Public oDocument, oPage, oDialog1, oChampProgress as Object
Public bNettoie, bRestaure as Boolean
Sub Sauvegarde
Dim RepTraites as Integer
Call VerifOperationnel
' On error resume next
DialogLibraries.loadLibrary("DmathsBup")
oDialog1 = CreateUnoDialog( DialogLibraries.DmathsBup.Dialog1 )
oChampProgress = oDialog1.GetControl("ProgressBar1")
oChampProgress.Value = 1
If oDialog2.GetControl("OptionButton2").State = True Then iSyncro = 2 Else iSyncro = 1
oDialog1.GetControl("Label1").Text = Trad(iLangNumber,27)
oDialog1.GetControl("Label2").Text = Trad(iLangNumber,24)
oDialog1.GetControl("Label3").Text = Trad(iLangNumber,25)
iDimListeRep = 100
iNombreErreurs = 0
iNombreRepertoireExamine = 1
sRepertoireSource = oDialog2.GetControl("TextField1").Text
sRepertoireBackup = oDialog2.GetControl("TextField2").Text
If Right(sRepertoireSource,1)<>getPathSeparator Then
oDialog2.GetControl("TextField1").Text=oDialog2.GetControl("TextField1").Text+getPathSeparator
sRepertoireSource=sRepertoireSource+getPathSeparator
Endif
If Right(sRepertoireBackup,1)<>getPathSeparator Then
oDialog2.GetControl("TextField2").Text=oDialog2.GetControl("TextField2").Text+getPathSeparator
sRepertoireBackup=sRepertoireBackup+getPathSeparator
Endif
inombrefichiercopies = 0
inombrerepertoirecopies = 0
inombrefichiersupprimes = 0
inombrerepertoiresupprimes = 0
sRepertoireSource = ConvertToUrl(sRepertoireSource)
sRepertoireBackup = ConvertTourl(sRepertoireBackup)
If oDialog2.GetControl("OptionButton3").State = False Then 'Pas de restauration
If ControleDroits(sRepertoireBackup)=False Then
MsgBox(Trad(iLangNumber,12),16,"Dmaths Backup")
Exit Sub
Endif
oDialog2.Visible = False
oDialog1.Visible = True
iIndexRepertoire = 0
iNombreRepertoire = 0
ListeRep(0) = ""
If Not FileExists(sRepertoireBackup) Then Mkdir sRepertoireBackup
Do
TraiteRepertoire(sRepertoireSource+ListeRep(iIndexRepertoire),sRepertoireBackup+ListeRep(iIndexRepertoire),iIndexRepertoire)
iIndexRepertoire = iIndexRepertoire+1
Loop until iIndexRepertoire > iNombreRepertoire
Endif
iNombreRepertoireExamine = iNombreRepertoire+1
RepTraite = iNombreRepertoireExamine rem memorise le nombre pour le module DmBackup
rem si synchronisation des fichiers demandées ou restauration
If (oDialog2.GetControl("OptionButton2").State = True or oDialog2.GetControl("OptionButton3").State = True) Then
If ControleDroits(sRepertoireSource)=False Then
MsgBox(Trad(iLangNumber,13),16,"Dmaths Backup")
Exit Sub
Endif
If Not FileExists(sRepertoireSource) Then MkDir sRepertoireSource
If (oDialog2.GetControl("CheckBox4").State = 1 and oDialog2.GetControl("OptionButton3").State = False) Then bNettoie = True
If oDialog2.GetControl("OptionButton3").State = True Then rem on restaure
If MsgBox(Trad(iLangNumber,14)+chr(10)+chr(10)+Trad(iLangNumber,15),256+48+1,"Dmaths Backup")=2 Then Goto Fin
If Not FileExists(sRepertoireBackup) Then
MkDir sRepertoireBackup
Call ChoosesZipFile
unzipArchive(ConvertToUrl(sZipFile),sRepertoireBackup)
Endif
iNombreRepertoireExamine = 0
Endif
oDialog2.Visible = False
oDialog1.Visible = True
iIndexRepertoire = 0
iNombreRepertoire = 0
ListeRep(0) = ""
Do
TraiteRepertoire(sRepertoireBackup+ListeRep(iIndexRepertoire),sRepertoireSource+ListeRep(iIndexRepertoire), iIndexRepertoire)
iIndexRepertoire = iIndexRepertoire+1
Loop until iIndexRepertoire > iNombreRepertoire
iNombreRepertoireExamine = iNombreRepertoireExamine + iNombreRepertoire
RepTraite = iNombreRepertoireExamine/2 rem memorise le nombre traite pour le module DmBackup
Endif
If oDialog2.GetControl("CheckBox2").State = 1 Then ' CheckBox2
sZipFile = Mid(sRepertoireBackup,1,Len(sRepertoireBackup)-1)+".zip"
ZipTree(sZipFile,sRepertoireBackup)
If oDialog2.GetControl("CheckBox3").State = 1 Then RmDir sRepertoireBackup '
Endif
If oDialog2.GetControl("OptionButton3").State = False Then
sMessage = Trad(iLangNumber,16)
Else
sMessage = Trad(iLangNumber,17)
Endif
sMessage = sMessage+chr(10)+chr(10)+ inombrerepertoirecopies+Trad(iLangNumber,18)+chr(10)
sMessage = sMessage + inombrefichiercopies+Trad(iLangNumber,19)+chr(10)
sMessage = sMessage+ inombrerepertoiresupprimes+Trad(iLangNumber,20)+chr(10)
sMessage = sMessage +inombrefichiersupprimes+Trad(iLangNumber,21)+chr(10)
sMessage = sMessage + iNombreRepertoireExamine +Trad(iLangNumber,22)+chr(10)+chr(10)
sMessage = sMessage + Trad(iLangNumber,23) +iNombreErreurs + chr(10)
sMessage = sMessage + sMessageErreur
oDialog1.Visible = False
oDialog1.EndExecute()
MsgBox (sMessage,64,"Dmaths Backup")
rem insere un module contenant la date de la derniere sauvegarde
If Globalscope.BasicLibraries.HasByName("Dmaths") Then
Dim sSource, sMod, sDate as String
Dim oLib as Object
Globalscope.BasicLibraries.loadLibrary("Dmaths")
sDate = Date()
sSource="Rem (C) Didier Dorange-Pattoret www.dmaths.org 2005"+Chr(13)
sSource=sSource+"Public const sDateSauvegarde = """+sDate+""""+Chr(13)
If oDialog2.GetControl("CheckBox1").State = 1 Then oDialog2.GetControl("TextField2").Text = Mid(oDialog2.GetControl("TextField2").Text,1,Len(oDialog2.GetControl("TextField2").Text)-10)
sSource=sSource+"Public Const sRepertoireSourceDefaut = """+oDialog2.GetControl("TextField1").Text+""""+Chr(13)
sSource=sSource+"Public Const sRepertoireBackupDefaut = """+oDialog2.GetControl("TextField2").Text+""""+Chr(13)
sSource=sSource+"Public Const iNombreRepertoiresTraites = "+ RepTraite +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)
Endif
rem processus de fin de sauvegarde
Fin:
oDialog2.EndExecute()
End Sub
Sub TraiteRepertoire(sRepertoireSource,sRepertoireBackup as String,iIndexRepertoire as Integer)
REM Traite les fichiers et les dossiers d'un répertoire
Rem Les noms des répertoires paramètres finissent par un séparateur
On Error Goto TraitementErreurRep
Dim sValue as String
sValue = Dir$(sRepertoireSource,16)
Do Until sValue = ""
If Mid(sValue,1,1)<>"." Then
If FileExists(sRepertoireBackup+sValue+"/") Then
iNombreRepertoire = iNombreRepertoire+1
ListeRep(iNombreRepertoire)=ListeRep(iIndexRepertoire)+sValue+"/"
If iNombreRepertoire+1 > iDimListeRep Then
iDimListeRep = iDimListeRep + 100
Redim Preserve ListeRep(iDimListeRep)
Endif
Elseif bNettoie = True Then
RmDir sRepertoireSource+ sValue
inombrerepertoiresupprimes = inombrerepertoiresupprimes + 1
Else
FileCopy(sRepertoireSource+sValue,sRepertoireBackup+sValue)
inombrerepertoirecopies = inombrerepertoirecopies + 1
Endif
Endif
sValue = Dir
Loop
On Error Goto TraitementErreurFic
sValue = Dir$(sRepertoireSource,0)
Do Until sValue = ""
If FileExists(sRepertoireBackup+sValue) Then
If cDate(FileDateTime(sRepertoireSource+sValue)) > cDate(FileDateTime(sRepertoireBackup+sValue)) Then
FileCopy(sRepertoireSource+sValue,sRepertoireBackup+sValue)
inombrefichiercopies = inombrefichiercopies+1
Endif
Elseif bNettoie = True Then
Kill sRepertoireSource+ sValue
inombrefichiersupprimes = inombrefichiersupprimes + 1
Else
FileCopy(sRepertoireSource+sValue,sRepertoireBackup+sValue)
inombrefichiercopies = inombrefichiercopies+1
Endif
sValue = Dir
Loop
'Xray.Xray oDialog1.GetControl("Label2")
oDialog1.GetControl("Label2").Text = Trad(iLangNumber,24)+cstr(iNombreRepertoireExamine+iIndexRepertoire)
oDialog1.GetControl("Label3").Text = Trad(iLangNumber,25)+ cstr(inombrerepertoirecopies+inombrefichiercopies)
If iNombreRepertoiresTraites > 10 Then
oChampProgress.Value = 100*((iNombreRepertoireExamine+iIndexRepertoire)/(iNombreRepertoiresTraites*iSyncro))
Else
oChampProgress.Value = (iNombreRepertoireExamine+iIndexRepertoire)/5
Endif
Exit Sub
TraitementErreurRep:
If iNombreErreurs = 0 Then sMessageErreur = Trad(iLangNumber,26)
iNombreRepertoire = iNombreRepertoire+1
ListeRep(iNombreRepertoire)=ListeRep(iIndexRepertoire)+sValue+"/"
If iNombreRepertoire+1 > iDimListeRep Then
iDimListeRep = iDimListeRep + 100
Redim Preserve ListeRep(iDimListeRep)
Endif
inombrerepertoirecopies = inombrerepertoirecopies - 1
sMessageErreur = sMessageErreur+chr(10) + ConvertFromUrl(sRepertoireSource+sValue)
iNombreErreurs = iNombreErreurs + 1
Resume Next
TraitementErreurFic:
If iNombreErreurs = 0 Then sMessageErreur = Trad(iLangNumber,26)
inombrefichiercopies = inombrefichiercopies-1
sMessageErreur = sMessageErreur+chr(10) + ConvertFromUrl(sRepertoireSource+sValue)
iNombreErreurs = iNombreErreurs + 1
Resume Next
End sub
Sub ChooseFolderSource 'As String
dim sFolderPickerArgs as Variant
dim oFolderPicker as Object
sFolderPickerArgs = Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE )
oFolderPicker = CreateUnoService( "com.sun.star.ui.dialogs.FolderPicker" )
oFolderPicker.setTitle( "Dmaths Backup - Choix du répertoire source" )
If FileExists(oDialog2.GetControl("TextField1").Text) Then
oFolderPicker.setDisplayDirectory(ConvertTourl(oDialog2.GetControl("TextField1").Text))
Else
oFolderPicker.setDisplayDirectory(ConvertToUrl(GetWorkPath))
Endif
If oFolderPicker.execute() Then
oDialog2.GetControl("TextField1").Text = ConvertFromUrl(oFolderPicker.Directory)
End If
End Sub
Sub ChooseFolderCible 'As String
dim sFolderPickerArgs as Variant
dim oFolderPicker as Object
sFolderPickerArgs = Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE )
oFolderPicker = CreateUnoService( "com.sun.star.ui.dialogs.FolderPicker" )
oFolderPicker.setTitle( "Dmaths Backup - Choix du répertoire cible" )
If FileExists(oDialog2.GetControl("TextField2").Text) Then
oFolderPicker.setDisplayDirectory(ConvertTourl(oDialog2.GetControl("TextField2").Text))
Else
oFolderPicker.setDisplayDirectory(ConvertToUrl(GetWorkPath))
Endif
' Print getIndexByName("TextBox2")
If oFolderPicker.execute() Then
oDialog2.GetControl("TextField2").Text = ConvertFromUrl(oFolderPicker.Directory)
End If
End Sub
Sub ChoosesZipFile 'As String
dim sFilePickerArgs as Variant
dim oFilePicker as Object
sFilePickerArgs = Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE )
oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" )
oFilePicker.setTitle( "Dmaths Backup - Choix du fichier à dézipper" )
oFilePicker.appendFilter("Fichiers zip","*.zip")
' Xray.Xray oFilePicker
oFilePicker.setDisplayDirectory(ConvertToUrl(GetWorkPath))
If oFilePicker.execute() Then
sZipFile = ConvertFromUrl(oFilePicker.Files(0))
End If
End Sub
Sub Click_ArchiveDatee
If oDialog2.GetControl("CheckBox1").State = 1 Then
If Right(oDialog2.GetControl("TextField2").Text,1)<>getPathSeparator Then oDialog2.GetControl("TextField2").Text=oDialog2.GetControl("TextField2").Text+getPathSeparator
oDialog2.GetControl("TextField2").Text = oDialog2.GetControl("TextField2").Text+Mid(Date(),1,2)+Mid(Date(),4,2)+"-"+Mid(Time(),1,2)+Mid(Time(),4,2)+getPathSeparator
Else
oDialog2.GetControl("TextField2").Text = Mid(oDialog2.GetControl("TextField2").Text,1,Len(oDialog2.GetControl("TextField2").Text)-10)
Endif
End Sub
Sub Click_RadioGroup1
oDialog2.GetControl("CheckBox4").Enable = False
oDialog2.GetControl("CheckBox2").Enable = True
If oDialog2.GetControl("CheckBox2").State = 0 Then oDialog2.GetControl("CheckBox3").Enable = False
oDialog2.GetControl("CheckBox1").Enable = True
End Sub
Sub Click_RadioGroup2
oDocument = ThisComponent
oDialog2.GetControl("CheckBox4").Enable = True
oDialog2.GetControl("CheckBox2").Enable = True
If oDialog2.GetControl("CheckBox2").State = 0 Then oDialog2.GetControl("CheckBox3").Enable = False
oDialog2.GetControl("CheckBox1").Enable = False
oDialog2.GetControl("CheckBox4").State = 0
oDialog2.GetControl("CheckBox3").State = 0
If oDialog2.GetControl("CheckBox1").State = 1 Then oDialog2.GetControl("TextField2").Text = Mid(oDialog2.GetControl("TextField2").Text,1,Len(oDialog2.GetControl("TextField2").Text)-10)
oDialog2.GetControl("CheckBox1").State = 0
End Sub
Sub Click_RadioGroup3
If oDialog2.GetControl("CheckBox1").State = 1 Then oDialog2.GetControl("TextField2").Text = Mid(oDialog2.GetControl("TextField2").Text,1,Len(oDialog2.GetControl("TextField2").Text)-10)
oDialog2.GetControl("CheckBox4").Enable = False
oDialog2.GetControl("CheckBox2").Enable = False
oDialog2.GetControl("CheckBox3").Enable = False
oDialog2.GetControl("CheckBox1").Enable = False
oDialog2.GetControl("CheckBox4").State = 0
oDialog2.GetControl("CheckBox2").State = 0
oDialog2.GetControl("CheckBox3").State = 0
oDialog2.GetControl("CheckBox1").State = 0
End Sub
Sub Click_CheckBox2
If oDialog2.GetControl("CheckBox2").State = 1 Then
oDialog2.GetControl("CheckBox3").Enable = True
Else
oDialog2.GetControl("CheckBox3").Enable = False
oDialog2.GetControl("CheckBox3").State = 0
Endif
End Sub
Function GetWorkPath as String
Dim oPathSubstSrv as Object
Dim sWorkPath as String
oPathSubstSrv = createUnoService("com.sun.star.comp.framework.PathSubstitution")
sWorkPath = ConvertFromUrl(oPathSubstSrv.getSubstituteVariableValue("$(work)"))
GetWorkPath = sWorkPath
End Function
Function GetIndexByName(leNom As String) As Long
Dim I,iIndex As Long
For I = 0 to oPage.Count -1
if oPage.GetByIndex(I).Control.Name = leNom then
getIndexByName = I ' renvoyer l'index correspondant au nom
Exit Function
end if
next
End Function
Function FindObjectByName(nomObj As String, Optional service As String) As Object
Dim objX As Object, x As Long
For x = 0 To oPage.Count - 1
objX = oPage.GetByIndex(x)
If objX.Control.Name = nomObj Then
if IsMissing(service) then
FindObjectByName = objX ' objet trouvé
Exit Function
else
if objX.supportsService(service) then
FindObjectByName = objX ' objet trouvé
Exit Function
end if
end if
EndIf
Next
End Function ' renvoie Null en cas d'échec
'**************************************************************************************
'rem cette fonction contrôle les droits d'écriture dans le répertoire d'installation
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
'******************************************************************************
</script:module>
|