I want to update the image in a document by manipulating the data/XML under the hood (scripted approach because it’s the same task again and again…). So I have this in the file:
Pictures/1002B314000048A8000037DC206113FE1EF04F6E.emf
The emf file is generated somehow outside of libreoffice. Obviously I did not call it so. Now I generate a new one and want to update the document by replacing the old one (same dimensions and everything, just different content). Problem: It needs a “special” name (looks like a hash) which is calculated by libreoffice.
I can’t just dump a file with the same name as above nor call it Pictures/0.emf
and then in content.xml
link it to this file and update META-INF/manifest.xml
accordingly. Doing so will prompt “File is broken, repair it?” Everything is fine once repaired (the proper cryptic filename gets there), but I want to skip that trivial repair part. The good news is that the emf file in the repaired file has the same sha1sum as that I generated, meaning that no conversion/modifications are implied.
Question: Any idea on how this filename is generated? Quickly checked md5, sha1: No, that’s not it.
I checked the standard. Really hard to find, and there is nothing in there.
I glanced at odfpy (python API) to add pictures. There’s a thing to insert a file in the zipped document, but it generates a random identifier, which is unlikely to behave correctly.