Bug 97837 - FORMATTING: General Replaces User Defined Format When Workbook is Saved, Close and Reopened
Summary: FORMATTING: General Replaces User Defined Format When Workbook is Saved, Clo...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Laurent Balland
URL:
Whiteboard: target:5.3.0 target:5.2.0.1 target:5....
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-13 14:03 UTC by kiaora-paora
Modified: 2016-08-19 00:17 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kiaora-paora 2016-02-13 14:03:18 UTC
User defined custom formats may be re-arranged (normalised) by LibreOffice.
For example: {{{General "Strike"}}} is rearranged as {{{General" Strike"}}}.

You may have to save, close and reopen the workbook to see this but, yes,
the space has moved from the left to the right of the adjacent quote.

Over time, I've got the hang of this and now experience few surprises.

However there is one unwelcome one.

I know the @ symbol has special significance and must be quoted, for example:
{{{"@ "General}}}.  Does what it should and survives save/close/reopen.

I do not know that the / symbol has any special significance but I quote it
anyway:  {{{"/ "General}}}.  This does what it should but does not survive
save/close/reopen.  When the workbook is reopened, the format has been changed
to just {{{General}}}.

I don't want {{{"@ "General}}}: it's just the simplest example I can think of.

I want {{{"/ "#,##0.00}}} but that too is re-arranged to just  {{{General}}}.

Actually, I want {{{[>0]"/ "#,##0.00;[<0]"/ -"#,##0.00;0}}} but this gets
rearranged to {{{[>0]General;[<0]"/ -"#,##0.00;0}}}.

This looks to me like unintended behaviour rather than aping the behaviour
of other spreadsheets.

This behaviour is present in 5.1.0.  It was first noticed in 3.5.7, which I
still use on a daily basis.  I've checked 3.3.0 and the behaviour is there
also so I guess it was inherited from OOo.
Comment 1 Buovjaga 2016-02-16 12:29:22 UTC
I put {{{Yleinen "Strike"}}}
And it changed to

"{{{"Yleinen" Strike}}}"

after reload.

Win 7 Pro 64-bit Version: 5.2.0.0.alpha0+
Build ID: a6f876d45bd4e41a7143594a6cb11b6893a0f620
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-02-11_00:07:38
Locale: fi-FI (fi_FI)
Comment 2 Laurent Balland 2016-05-02 10:12:50 UTC
The exact string "/ " is not correctly IMPORTED. 
It is correctly saved in XML code, check export to fods file: format
"/ "General
is saved as
  <number:number-style style:name="N111">
   <number:text>/ </number:text>
   <number:number number:min-integer-digits="1"/>
   <number:text/>
  </number:number-style>

But during import, something goes wrong. It makes format unread and replaced by General, whatever the format was. 
 
No problem if string is longer or if space is replaced by another character. String "/" works well also.
Comment 3 Laurent Balland 2016-05-10 12:17:03 UTC
(In reply to Laurent BP from comment #2)
> String "/" works well also.
This assertion is wrong.

All strings limited to " ", "-", "/", ".", ",", ":", "\'" and same strings with a second character set as " "
are not quoted during import. See:
http://opengrok.libreoffice.org/xref/core/xmloff/source/style/xmlnumfi.cxx#lcl_EnquoteIfNecessary

Then parser reads it as date, time, decimal or thousand delimiter, which fails to recognize the number format and set it as General format. See
http://opengrok.libreoffice.org/xref/core/xmloff/source/style/xmlnumfi.cxx#1708

I see two possibilities:
- during parsing, store an alternative string with ALL text in quote; then if number format recognition fails, test with this alternative string
- during export, store an attribute in <text> field, which identifies it as quoted text, to make difference with text used as delimiter. Right now, both quoted text and delimiter text is stored in the same way.
Comment 4 Commit Notification 2016-06-16 07:43:33 UTC
Laurent Balland-Poirier committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=bd4ef2734b60d2188874178f173c9163ced09ce7

tdf#97837 Detect delimiter only for date, time, currency

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2016-06-16 08:16:22 UTC
Laurent Balland-Poirier committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0330e8cd0ce65c62e61d4b5af5dc1aab3b0db697&h=libreoffice-5-2

tdf#97837 Detect delimiter only for date, time, currency

It will be available in 5.2.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Wolfgang Jäger 2016-06-16 09:32:10 UTC
See also bug#99996 .
Comment 7 Wolfgang Jäger 2016-06-16 09:36:46 UTC
(In reply to Wolfgang Jäger from comment #6)
> See also bug#99996 .

This comment is concerning my Comment #3 to bug#99996 . I could not yet test the bugfix in 5.2 (Beta2) with this respect.
Comment 8 Buovjaga 2016-06-16 10:21:07 UTC
(In reply to Wolfgang Jäger from comment #7)
> (In reply to Wolfgang Jäger from comment #6)
> > See also bug#99996 .
> 
> This comment is concerning my Comment #3 to bug#99996 . I could not yet test
> the bugfix in 5.2 (Beta2) with this respect.

The bug fix will be in 5.2 RC1 as mentioned in comment 5
Comment 9 Commit Notification 2016-06-29 18:23:53 UTC
Laurent Balland-Poirier committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b3bba0b8452d1e5798bd01f09a642718bcecf30f

tdf#97837 Add qa unit test

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2016-08-10 16:45:54 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4d993ae8f267e35f7c030861a92226c940bb46cc

XML number format: do not enquote space followed by minus, tdf#97837 follow-up

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2016-08-16 20:03:28 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3a3cd19df142dddeb74bee6a7a38ba8419cd86be&h=libreoffice-5-2

XML number format: do not enquote space followed by minus, tdf#97837 follow-up

It will be available in 5.2.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2016-08-19 00:17:02 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-5-2-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=96a8c73a44ff26e60b90fe59461af880a0c7c025&h=libreoffice-5-2-1

XML number format: do not enquote space followed by minus, tdf#97837 follow-up

It will be available in 5.2.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.