How to pack a proper zip file with Basic
Heiko Tietze
tietze.heiko at googlemail.com
Sat Mar 18 23:18:30 UTC 2017
Although it's a FAQ I cannot find an answer. I'm trying to create an extension with Basic. Everything works fine when I pack the stuff with "zip -r foo.oxt ." given that I'm in the right directory, otherwise the parent dirs are included. But ChDir() is not available anymore in Basic so I have to go the hard way.
With com.sun.star.packages.Package the zip is always corrupt and cannot be read, even what PackageFormat is set to false. Any idea how to solve this?
Sub addToZip(oZipPackage, path$, file$)
Dim xInputStream
Dim sDestName As String
Dim oZipPackageStream, oZipPackageFolder
xInputStream=createUNOService("com.sun.star.ucb.SimpleFileAccess").OpenFileRead(convertToURL(path$ & file$))
oZipPackageStream=oZipPackage.createInstance()
oZipPackageStream.setInputStream(xInputStream)
oZipPackageFolder=oZipPackage.getByHierarchicalName("")
oZipPackageFolder.insertByName(file$,oZipPackageStream)
oZipPackage.commitChanges()
End Sub
...
oZipPackage = createUnoService("com.sun.star.packages.Package")
Dim aArg As New com.sun.star.beans.NamedValue
aArg.Name = "PackageFormat"
aArg.Value = True 'plain Zip format
oZipPackage.initialize(Array(oFileDialog.Files(0),aArg))
addToZip(oZipPackage,sTempPath,"/description.xml")
addToZip(oZipPackage,sTempPath,"/config.xcu")
addToZip(oZipPackage,sTempPath,"/META-INF/manifest.xml")
addToZip(oZipPackage,sTempPath,"/palettes/" & sPaletteName & ".soc")
Full code is at http://pastebin.com/e1rt0rSM but for only 1 day.
TIA,
Heiko
--
Dr. Heiko Tietze
UX Designer
Tel. +49 (0)179/1268509
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20170319/cfcbc32c/attachment.sig>
More information about the LibreOffice
mailing list