Bug 128273 - FORMATTING Calc changes a number format
Summary: FORMATTING Calc changes a number format
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Number-Format
  Show dependency treegraph
 
Reported: 2019-10-20 11:19 UTC by Fred
Modified: 2023-07-10 10:41 UTC (History)
8 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 Fred 2019-10-20 11:19:34 UTC
Description:
Hello,
I entered this number format description to display phone numbers: 0#" "##" "##" "##" "##
When I reopen my document after saving, the description has changed to: #" "##" "##" "##" "#0
cordially

Steps to Reproduce:
1. enter the description format 0#" "##" "##" "##" "## in a cell
2. save and close the document
3. reopen the calc


Actual Results:
the description format is transformed in #" "##" "##" "##" "#0

Expected Results:
preserved the description


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Julien Nabet 2019-10-20 11:45:08 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 2 m_a_riosv 2019-10-20 15:34:37 UTC
Sorry but what it's the sense of such format, '0' should be followed by zeroes not by #. Well may be looking for a way to get the number aligned to the left, with two numbers before the first space. But I think numbers format can't work in this way
Comment 3 Julien Nabet 2019-10-20 15:48:43 UTC
(In reply to m.a.riosv from comment #2)
> Sorry but what it's the sense of such format, '0' should be followed by
> zeroes not by #. Well may be looking for a way to get the number aligned to
> the left, with two numbers before the first space. But I think numbers
> format can't work in this way

Either the format is correct and reopening the file should display the same or it's incorrect and there should so error message when trying to save the formula, shouldn't it?

Eike: thought you might be interested in this one.
Comment 5 Eike Rathke 2019-10-22 13:24:34 UTC
Meanwhile the bug submitter found out that what he actually needed instead is
" 0 " #" "##" "##" "##" "##

The problem with the reported format is that it is ambiguous regarding the use of 0 and #. While it works in the number formatter when entered, it can't be stored as format description to ODF which results in

    <number:number-style style:name="N121">
      <number:number number:decimal-places="0" loext:min-decimal-places="0" number:min-integer-digits="1">
        <number:embedded-text number:position="8"> </number:embedded-text>
        <number:embedded-text number:position="6"> </number:embedded-text>
        <number:embedded-text number:position="4"> </number:embedded-text>
        <number:embedded-text number:position="2"> </number:embedded-text>
      </number:number>
    </number:number-style>


Whereas
" 0 " #" "##" "##" "##" "##
is stored as

    <number:number-style style:name="N121">
      <number:text> 0  </number:text>
      <number:number number:decimal-places="0" loext:min-decimal-places="0" number:min-integer-digits="0">
        <number:embedded-text number:position="8"> </number:embedded-text>
        <number:embedded-text number:position="6"> </number:embedded-text>
        <number:embedded-text number:position="4"> </number:embedded-text>
        <number:embedded-text number:position="2"> </number:embedded-text>
      </number:number>
    </number:number-style>
Comment 6 Eike Rathke 2019-10-22 13:48:16 UTC
(In reply to Julien Nabet from comment #3)
> Either the format is correct and reopening the file should display the same
> or it's incorrect and there should so error message when trying to save the
> formula, shouldn't it?
The number formatter is file format agnostic and should be.
I'm not sure the original format code with its intention could even be described in ODF syntax.

However, the minimal reproducer could be 0# which when reloaded is just 0 and stored as

    <number:number-style style:name="N121">
      <number:number number:decimal-places="0" loext:min-decimal-places="0" number:min-integer-digits="1"/>
    </number:number-style>

The intention of the format is to prepend a 0 if the number is one digit (except for the 0 case, but I'm not even sure if that is on purpose), but that's basically the same for the format code 00 except for the 0 case where it also displays 00.

Which is stored as

    <number:number-style style:name="N121">
      <number:number number:decimal-places="0" loext:min-decimal-places="0" number:min-integer-digits="2"/>
    </number:number-style>
Comment 7 Julien Nabet 2019-10-23 21:15:15 UTC
(In reply to Eike Rathke from comment #6)
> (In reply to Julien Nabet from comment #3)
> ...
> The number formatter is file format agnostic and should be.
> ...
I don't understand why but you're the Calc expert and I trust you.
Should this one be a WONTFIX then?
Comment 8 Eike Rathke 2019-10-24 16:25:10 UTC
Maybe the 0# format could be stored with a number:min-integer-digits="1" and loext:optional-integer-digits="1" (which would have to be implemented as a new loext namespace extension) or some such, and for
0#" "##" "##" "##" "##
with a similar number:min-integer-digits="1" loext:optional-integer-digits="9".
Not sure, needs investigation I don't have time for currently.
Comment 9 Eike Rathke 2019-10-24 16:39:25 UTC
(In reply to Julien Nabet from comment #7)
> (In reply to Eike Rathke from comment #6)
> > The number formatter is file format agnostic and should be.
> I don't understand why but you're the Calc expert and I trust you.
Because the number formatter does not know anything about the target file format the number format will be stored in, storing to Excel formats for example simply will store the format code. Reading such format code also should not invalidate the format just because it could be stored in a different file format. Also, with the (more empirically determined) syntax of these format codes constructs are possible that can't be stored in all file formats. Then again, some formats are possible that can be stored in ODF but not in OOXML. Hence restricting the number formatter to a subset that all file formats know even if a format code otherwise is syntactically correct would not be a good approach. And furthermore error-prone because the format code syntax is really twisted..
Comment 10 BogdanB 2020-09-20 04:43:51 UTC
I tested with:

0#

" 0 " #" "##" "##" "##" "##

0#" "##" "##" "##" "##

And this numbers remain as entered into the cells.
Am I missing something or something have changed?


Version: 7.0.1.2
Build ID: 7cbcfc562f6eb6708b5ff7d7397325de9e764452
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 11 Hylton Conacher 2021-06-13 12:42:12 UTC
When dealing with large Calc (7.0.6.2 OR 7.1.3) sheets with  many columns , I find this BUG BOTH ANNOYING and TIME CONSUMING. When using spreadsheets  as a data source when writing reports, time and flow of work are disrupted when one has to RE-FORMAT  a range of cells or cell, only to have it revert to its previous #### state a few seconds later, regardless of one of the format changing cells are selected or not.
Comment 12 QA Administrators 2023-06-14 03:12:46 UTC Comment hidden (obsolete)
Comment 13 Rajasekaran Karunanithi 2023-07-06 11:05:31 UTC
In Windows 10(x64), no problem at all.When I reopen the file it  shows 0#" "##" "##" "##" "##.No changes.No producable in Windows 10(x64).

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: d74344f6cae0cf1c12f08249c8f49be1374fb98f
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-IN (en_IN); UI: en-US
Calc: threaded
Comment 14 Buovjaga 2023-07-10 10:41:30 UTC
I repro Format Cell - Numbers - Format Code with

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 81726f5af5fda25f0d92ffc8458d7f24eb16f408
CPU threads: 2; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_FI); UI: en-US
Calc: threaded