Denver Gingerich wrote: > Is it possible to construct a zip file from the extracted contents of > an ods or odt file that is identical to the original ods/odt file? I > would like to be able to do something like the following: > > $ unzip doc.odt -d doc > $ cd doc > $ zip [options] ../doc2.zip * > $ diff ../doc.odt ../doc2.zip && echo match > match > > I tried the following with [options] being -9Xr, but the resulting zip > file was 7163 bytes and the original odt was 6741 bytes.
Can you explain why it should be important that the files are completely identical? > I've attempted to determine the sequence of operations that OOo uses > to create its zip files by analyzing the source code, but I haven't > figured out exactly how it does it. There seems to be some > compression going on in AddXMLAsZipToTheStorage in > binfilter/bf_sfx2/source/doc/sfx2_objstor.cxx, which uses the ZCodec > class implemented in tools/source/zcodec/zcodec.cxx (which in turn > uses zlib), but I'm not sure if this is the code that handles all the > zip file stuff and I don't know where it gets the list of files to > compress. This is dead code not used anymore. Binfilter is code for writing the old binary StarOffice file formats, "AddXMLAsZipToTheStorage" was a hack from very early OOo version with an incomplete XML file format where the XML streams had been stored into the binary files to have both formats in one file. > Does someone know of a set of zlib operations that will produce a zip > file identical to the one OOo produces? Or is there a set of options > I can pass to a common zip command-line tool that will do this? > > This has been discussed to some extent before > (http://www.openoffice.org/servlets/BrowseList?list=dev&by=thread&from=1243563), > but it was specifically in relation to storing OOo files in > Subversion, which is in the end what I'm interested in. It would be > nice to commit OOo files to Subversion, have it store the XML files > individually, and then get it to reproduce an identical OOo file from > the XML files when a user checks it out. Perhaps you should use the built-in code that OOo itself uses to store its files. This is done with the UNO service com.sun.star.embed.Storage. That means that you need OOo available (not necessarily installed) to do the work for you. Is that an option? Theoretically it could be possible to extract the Storage service and some other needed services from OOo and use the URE to create an application using it but that would be some effort. Also theoretically it should be possible to study the implementation of the Storage and Package components and see how they use the zlib functionality to store the file. But that's perhaps a tedious work. In case you want to do it: the services are implemented in the "package" project. Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
