/usr/lib/libreoffice/share/extensions/DmathsAddon/DmathsBup/Module2.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 | <?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="Module2" script:language="StarBasic">REM ***** BASIC *****
'********************************************************************************
'This module is Copyright (C) 2004 Laurent Godard and Bernard Marcelly
'This module is free software; you can redistribute it and/or
'modify it under the terms of the GNU Lesser General Public
'License as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
'This module 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
'Lesser General Public License for more details.
'http://www.opensource.org/licenses/lgpl-license.php
'You should have received a copy of the GNU Lesser General Public
'License along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'******************************************************************************
Sub ZipTree(URLzip As String, URLtree As String)
Dim args(0) As Variant, p As Long
Dim ZipService As Object, ZipPackageFolder As Object, FileService As Object
args(0) = URLzip
ZipService = createUnoService("com.sun.star.packages.Package")
ZipService.initialize(args()) ' initialisation du zip
FileService = createUnoService("com.sun.star.ucb.SimpleFileAccess")
ZipPackageFolder = ZipService.GetByHierarchicalName("")
p = Len(URLtree) +1
ScanFilesToZip(URLtree, ZipService, FileService, ZipPackageFolder, p)
ZipService.commitChanges
End Sub
' attention : appel récursif entre ScanFilesToZip et ScanDirsToZip
Sub ScanFilesToZip(thisDir As String, zs As Object, fs As Object, zpf As Object, rootP As Long)
Dim f2 As String, fileInZip As Object, Stream1 As Object
Dim args(0) As Variant
args(0) = false ' pour stocker un fichier dans le zip
f2 = Dir(thisDir & "*", 0) ' chercher tous les fichiers
Do While Len(f2) > 0
Stream1 = fs.OpenFileRead(thisDir & f2)
fileInZip = zs.createInstanceWithArguments(args())
fileInZip.SetInputStream(Stream1)
if zpf.HasByName(f2) then
zpf.replaceByName(f2, fileInZip)
else
zpf.insertByName(f2, fileInZip)
end if
f2 = Dir ' fichier suivant
Loop
' appel récursif !
ScanDirsToZip(thisDir, zs, fs, zpf, rootP)
End Sub
Sub ScanDirsToZip(thisDir As String, zs As Object, fs As Object, zpf As Object, rootP As Long)
Dim args(0) As Variant
Dim d2 As String, ZipPackageFolder As Object
Dim newFolder As Object, newDir As String, listDir As String, x As Long
args(0) = true 'pour créer un dossier dans le zip
d2 = Dir(thisDir, 16) ' chercher tous les répertoires
Do While Len(d2) > 0 ' mémoriser les sous-répertoires car Dir n'est pas récursif
if (d2 <> ".") and (d2 <> "..") then
listDir = listDir & d2 & "*"
end if
d2 = Dir ' fichier suivant
Loop
x = 1
d2 = nextDirElmt(listDir, x)
Do While Len(d2) > 0
if not zpf.HasByName(d2) then ' créer le répertoire d2 dans le répertoire courant
newFolder = zs.createInstanceWithArguments(args())
zpf.insertByName(d2, newFolder)
end if
' ouvrir le dossier dans le zip
newDir = thisDir & d2 & "/"
ZipPackageFolder = zs.GetByHierarchicalName(Mid(newDir, rootP))
' appel récursif !
ScanFilesToZip(newDir, zs, fs, ZipPackageFolder, rootP)
d2 = nextDirElmt(listDir, x)
Loop
End Sub
' renvoie l'élément suivant et modifie startP
Function nextDirElmt(listElements As String, startP As Long)
Dim x2 As Long
x2 = InStr(startP, listElements, "*")
if x2 = 0 then
nextDirElmt = ""
else
nextDirElmt = Mid(listElements, startP, x2 -startP)
startP = x2 +1
end if
End Function
Sub unzipArchive(URLzip As String, URLtree As String)
Dim args(0) As Variant, ZipService As Object
Dim ThePackageStream As Object
ZipService = createUnoService("com.sun.star.packages.Package")
args(0) = URLzip
ZipService.initialize(args())
'xray.xray zipservice
' obtenir le flux empaqueté
ThePackageStream = ZipService.GetByHierarchicalName("")
exploreZip(ThePackageStream, URLtree, "")
End Sub
Sub exploreZip(thePack As Object, URLtree As String, ByVal ZipFolder As String)
Dim listFF As Object, fileOrFolder As Object, Zipff As String
Dim f1 As Object, MyInputStream As Object
listFF = thePack.createEnumeration
Do While listFF.hasMoreElements
fileOrFolder = listFF.nextElement
Zipff = ZipFolder & fileOrFolder.Name
if fileOrFolder.SupportsService("com.sun.star.packages.PackageFolder") then
exploreZip(fileOrFolder, URLtree, Zipff & "/") ' appel récursif
else
MyInputStream = thePack.GetByName(fileOrFolder.Name).InputStream
' écrire un fichier normal à partir du flux dézippé
f1 = createUnoService("com.sun.star.ucb.SimpleFileAccess")
f1.WriteFile(URLtree & Zipff, MyInputStream)
end if
Loop
End Sub
</script:module>
|