Ask Your Question
0

LibreOffice 6.0 unzip - zip open document file?

asked 2019-03-06 23:51:12 +0200

xenon1 gravatar image

updated 2019-03-06 23:52:16 +0200

In LibreOffice 5.0 I used to be able to open an Open Document file (e.g. *.ods or *.odb) on a low level by unzipping it. Then I could change something there on the "low level", zip it again and use it. I used the Ubuntu archive manager to do that.

Since Ubuntu 18.4 and LibreOffice 6.0 this does not work any more. The archive manager does not open it ("archive type is not supported"). However, if I open it with the utility "unzip" into a folder (that still works!) and, without changing anything, zip it again (put it into a zip-archive "Filename.zip" and change the extension from ".zip" to e.g., ".odb"), then LibreOffice cannot open it; it considers the file corrupt.

a) Did the file format change?

b) What can I do if I need to make low level changes to an Open Document file?

Thanks for an answer!

Xenon1

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2019-03-07 00:46:07 +0200

erAck gravatar image

updated 2019-03-08 12:40:13 +0200

Likely that version of archive manager has some broken means what could be a zip file.. the file format did not change, it still is a zip container, otherwise the unzip utility would refuse to run on it.

When (re)zipping an ODF document you must ensure that the mimetype file is the very first file in the archive and not compressed, it must be plain text. If that is not the case (compressed file or different position in the zip directory) then it is not a valid ODF file.

To achieve that, easiest is to freshen the existing zip with the modified file(s) instead of creating a new zip, i.e. use the -f option, for example zip -f /path/to/filename.ods content.xml

When creating a new zip, add and store only the mimetype file first using the -0 (numeric zero, not letter O) option. Then add other files using the -u option.

edit flag offensive delete link more

Comments

Fwiw, I just tried with file-roller 3.22.3 (which is Archive Manager) and indeed already that doesn't accept for example an .ods document, and also not one that is 10 years old.

erAck gravatar imageerAck ( 2019-03-07 00:54:56 +0200 )edit

"When (re)zipping an ODF document you must ensure that the mimetype file is the very first file in the archive and not compressed, it must be plain text." How do I do that? - And thank you for your fast answer, erAck!

xenon1 gravatar imagexenon1 ( 2019-03-07 09:12:48 +0200 )edit

Maybe saving those, with the flat format can make easy edit the files (only fodt, fods, fodp).

m.a.riosv gravatar imagem.a.riosv ( 2019-03-08 04:16:38 +0200 )edit

I updated my answer with "how to do that".

erAck gravatar imageerAck ( 2019-03-08 12:40:49 +0200 )edit

Hi! The method mentioned below xenon1: rename .odt to .zip and use Engrampa is working to me too but the "zip" command from terminal not freshening neither updating the context.xml in it. If I just run the zip without -f or -u option then the .odt (or the .zip) updated but seems to be corrupted as xenon1 mentioned in the question. Unfortunately I think I should use the "zip" command later to do the changes. (I plan to call it from PHP by shell_exec) So someone have tips what could be the problem and what the solution with "zip"? (I use Ubuntu 18.04.4 LTS, Libreoffice Writer 6.0.7.3, ODF1.2 .odt)

Thanks! Roland

froli78 gravatar imagefroli78 ( 2020-06-05 02:13:27 +0200 )edit

What command exactly do you use to freshen the zip, and does the content.xml file you want to freshen in the zip actually have a newer timestamp than the one in the .odt zip container?

erAck gravatar imageerAck ( 2020-06-05 12:48:23 +0200 )edit

Hi! I tried it some way. At the end - because i read somewhere that it important to use the same folder to compress where the .odt created (for some internal relative path reason?) i used the following method: 1. SavedAs the .odt to a "decompresslib" library. 2. Decompressed with unzip 3. Edited the contetnt.xml and saved it 4. run the zip: zip -f ./decompresslib/X.odt ./decompresslib/content.xml When i tried to open with LibreOffice it denied to open it because it find that it corrupted. Last time i changed the working directory and surprisingly the zip echoed CRC warning:

$ zip -f ./ModX.odt ./content.xml freshening: content.xml zip warning: Local Entry CRC does not match CD: content.xml (deflated 90%) I don't know how can correct this i don't find CRC related option in man zip...

froli78 gravatar imagefroli78 ( 2020-06-05 13:56:17 +0200 )edit

The zip -f ./decompresslib/X.odt ./decompresslib/content.xml is wrong, content.xml must be without path, otherwise there's noting to refresh (and adding the file would be wrong). So either the zip command be invoked in its (content.xml) actual directory decompresslib/ and omitting the directory, or the -j junk directory names option be used, so zip -f -j ./decompresslib/X.odt ./decompresslib/content.xml (be careful you don't use that with other files that actually need a correct directory prefix).

The non-matching CRC does not harm, it will be corrected with freshening the zip.

erAck gravatar imageerAck ( 2020-06-05 16:02:24 +0200 )edit

Thanks you erAck! That's wokr!

froli78 gravatar imagefroli78 ( 2020-06-05 19:55:32 +0200 )edit
0

answered 2019-07-09 15:02:35 +0200

xenon1 gravatar image

Just found the solution: Rename file: a) replace *.ods with *.zip. Or, even easier: b) add .zip to file name.

Now the archive program opens it easily! It seems that the Linux-program archive does not want to open files with the "wrong" file extension.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2019-03-06 23:51:12 +0200

Seen: 1,960 times

Last updated: Jul 09 '19