Bug 75914

Summary: Opening document properties dialog removes line breaks from custom properties
Product: LibreOffice Reporter: sergio.callegari
Component: frameworkAssignee: Not Assigned <libreoffice-bugs>
Status: UNCONFIRMED --- QA Contact:
Severity: enhancement    
Priority: medium CC: jmadero.dev
Version: 4.1.5.3 release   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description sergio.callegari 2014-03-08 17:45:23 UTC
This is seen on current 4.1.5 and 4.2.2 RC1. May be ultimately inherited from Openoffice.  

May appear as a corner case or even a little abuse of properties, but current behavior is breaking an extension. Furthermore, current behavior may be non conforming to the opendocument standard.


Issue description.
------------------

Libreoffice documents can have custom properties associated to them. These properties can be edited using the File->Properties dialog and the Custom Properties tab. Alternatively, custom properties may be set by macros via the available interfaces.

Custom properties have a name, a type and a value, that is set according to the type. Among the possible types, there is the string type (named Text in the user interface dialog).

The programmatic interface allows to set a string type custom property whose value is a string containing line breaks, tabs, etc. When a value containing a line break is programmatically set, it can be programmatically retrieved and used by other macros without any issues.

The user interface for setting custom properties has an issue with this, though. It is sufficient to open the File->Properties dialog (without actually editing any custom property) to have all the line breaks removed from custom properties.

This breaks those extensions that need to store pieces of text that may include line breaks as custom properties. One known example is the Texmaths extensions that stores the so called 'LaTex preamble' as the 'TexMathsPreamble' property. This bit of text needs to include line-breaks. As long as the extension is used without touching the file document properties everything is fine. As soon as one edits the document properties (e.g. to associate a title to the document) all that depends on the extension is broken.


To reproduce the issue with the texmaths extension:
---------------------------------------------------

1) Install the texmath extension
2) Open a new presentation or drawing
3) click the "curly pi" icon used to enter texmaths equations
4) When the texmaths dialog opens, press the preamble button
5) Note how the default preamble is organized on multiple lines
6) Close the preamble dialog by pressing the 'save' button, to assure that
a custom document property is created
7) Close the texmaths dialog by pressing 'ESC'
8) Open the File->Properties dialog go to the 'Custom Properties' tab. Do not edit anything, just note that there is a TexMathsPreamble custom property
9) Move to the 'Description' tab. Assign a title to the document (e.g. 'foobar') and close the dialog pressing the OK button
10) click again the "curly pi" icon used to enter texmaths equations
11) When the texmaths dialog opens, press the preamble button
12) Note that now the preamble is corrupted, with all the line breaks removed


Relationship to the opendocument file format:
---------------------------------------------

I am not an expert with this, but I believe that custom properties that include text should be 'string' type by the standard and need not to be 'normalizedString'. If this is the case, the text type custom properties should be allowed to contain characters like line breaks, tabs, initial spaces, etc.

If this is the case (please confirm), the current behavior is a non-conformance to the standard.

Note that there is no need to have a GUI allowing line breaks to be entered. But if line-breaks are being entered programmatically, the GUI should not mess with them.


Questions
---------

1) In case I am wrong and the standard forbids the inclusion of line break chars in custom properties, please let me know. In this case, I'll suggest the texmaths author to use base64 encoding to store the preamble.

2) Please let me know if, apart from custom properties, there is any other mechanism that extensions can use to store their own data together with a document. If there is a better mechanism, this can be suggested to the texmaths extension author.

Sorry for the long post, thanks in advance
Comment 1 Joel Madero 2014-03-08 19:15:28 UTC
Setting version to at least 4.1.5 as version field is the oldest version that we can reproduce the problem
Comment 2 Thomas Hackert 2014-04-06 14:04:14 UTC
Hello Sergio, *,
I cannot confirm this bug neither with LO Version: 4.1.5.3 Build-ID: 1c1366bba2ba2b554cd2ca4d87c06da81c05d24 nor with LO Version: 4.2.3.3
Build ID: 6c3586f855673fa6a1576797f575b31ac6fa0ba3 (parallel installed, following the instructions from https://wiki.documentfoundation.org/Installing_in_parallel), both with installed Germanophone lang- as well as helppack under Debian Testing i686, sorry ... :(

What I did:
1. Downloaded and installed http://extensions.libreoffice.org/extension-center/texmaths-1/releases/0.39/texmaths-0-39.oxt
2. Created a Writer (but later I tried it also with Impress) document
3. Followed your instructions from point 1 to point 12 ... ;)

But when I reach your point 12, my preamble is not corrupted at all. It looks the same as the first time.

Which version of the extension did you use, btw.? And would you be so kind to tell us, which OS/architecture you used to find this bug, please?
TIA
Thomas.
Comment 3 sergio.callegari 2014-04-06 14:20:44 UTC
This is because texmaths 0.39 has a workaround for the issue.
It substitutes a rarely used char for the line break.

You can test with texmaths 0.38 or writing a macro that programmatically sets a custom property to a string with a line break.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.