eea / odfpy

API for OpenDocument in Python
GNU General Public License v2.0
308 stars 63 forks source link

Load remove space between user fields #52

Closed davyrouillard closed 7 years ago

davyrouillard commented 7 years ago

Hi all,

I have a problem when loading/saving a document that contains user fields separated by a space (see variables_with_space.odt in zip archive) It seems that the call to odf.opendocument.load() deletes the space between the variables.

The odt file has been created with Libreoffice 5.3.1.2

Please see as evidence material, the small program "test_load_save.py" that only load a document and immediately save it. you can found the result in the file "saved_variables_with_space.odt".

I obtain the same result with various version of odfpy (1.3.4, 1.3.2, 1.2.0) and python (2.7.6, 3.4.4).

It's a very annoying problem as I use the excellent library odfpy to automatically produced reports and this problem makes it useless. Please, could you help me on that point ?

Best regard, Davy

bug_report.zip

joostvanzwieten commented 7 years ago

I just stumbled upon this myself. It's caused by the xml parser eating whitespace in <text:span> </text:span>. I've created a quick fix here.

icemac commented 7 years ago

@joostvanzwieten Could you create a pull request from your change or do you consider it to be too hackish?

davyrouillard commented 7 years ago

@joostvanzwieten Thanks you very much ! After two hours, I haven't succeed to solve the problem myself. You have saved my application based on odfpy. Thanks you !!

joostvanzwieten commented 7 years ago

@icemac Sure! I have too little knowledge about ODF to judge if this is the proper solution. However, preserving whitespace seems harmless to me and LibreOffice appears to produce files without unnecessary whitespace anyhow.

icemac commented 7 years ago

@joostvanzwieten No problem, making it a PR allows to discuss it or even improve it.

sorenroug commented 7 years ago

Pull request accepted and version 1.3.5 published.