Bug 170670 - FORMATTING Calc mangles single "-" in number format code after file is closed and then re-opened
Summary: FORMATTING Calc mangles single "-" in number format code after file is closed...
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.2.0.3 release
Hardware: All All
: medium normal
Assignee: Laurent Balland
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Number-Format
  Show dependency treegraph
 
Reported: 2026-02-08 19:46 UTC by Jonathan Casiot
Modified: 2026-02-10 21:58 UTC (History)
1 user (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 Jonathan Casiot 2026-02-08 19:46:39 UTC
I have the following number format code defined for a cell:

[>0]#,##0_);[<0](#,##0);"-"_)

This works as expected and when the cell has a zero value a single "-" is displayed followed by the space for a right-hand parenthesis.

However when the file is closed and then re-opened the number format code has been replaced with the following:

[>0]#,##0_);[<0](#,##0);- "_)"

which obviously does not give the desired format for a zero value.

Strangely when this number format code is used:

[>0]#,##0_);[<0](#,##0);"--"_)

no such mangling occurs when the file is closed and re-opened.
Comment 1 ady 2026-02-08 21:58:20 UTC
Repro in LO Dev 26.8 (2026-02-07).

I do believe that Calc modifying the format in the way described in comment 0 is unexpected.

I am not completely sure which should be an adequate format in order to obtain the desired result for "zero" values (instead of Calc modifying the custom format to something different).

I have not tested positive neither negative values, for 2 reasons:
_ these formats are not modified by Calc in unexpected ways; and,
_ using comma as either group separator or decimal separator does not affect the current behavior on the format for "zero" values.

In the meantime, a workaround (to what the OP is looking for, with the format as expressed on comment 0 ) can be:

 "[>0]#,##0_);[<0](#,##0);-#_)" (without the initial and final quotation marks)

IOW, change '"-"_)' to '-#_)' (without the single nor double quotation marks).
Comment 2 Laurent Balland 2026-02-09 16:13:56 UTC
If space is NOT the thousand separator (like for en-US), the format
"-"_)
is wrongly exported in ODF as
<number:text>- _)</number:text>
which is correctly rendered as 
"- _)"

If space IS the thousand separator (like for fr-FR), the format
"-"_)
is almost* correctly exported in ODF as
<number:text loext:blank-width-char=")1">- </number:text>
which is wrongly rendered as 
"- _)"

* I have no idea what '1' figures out
Comment 3 Laurent Balland 2026-02-09 16:46:13 UTC
This regression was introduced in LibO 24.2 branch while resolving tdf#152724
Comment 4 Laurent Balland 2026-02-09 17:06:11 UTC
(In reply to Laurent Balland from comment #2)
> * I have no idea what '1' figures out
'1' is the position in the string, starting at 0.
See: https://github.com/LibreOffice/core/commit/74d9da037cac01c5abd768a99b2f948553fbf144