Bug 146404 - Number Format Code: Not all color codes are saved
Summary: Number Format Code: Not all color codes are saved
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: filter:odf, filter:ods, filter:xls, filter:xlsx
: 153812 (view as bug list)
Depends on:
Blocks: Number-Format Save
  Show dependency treegraph
 
Reported: 2021-12-24 13:07 UTC by mmueller
Modified: 2023-03-19 10:54 UTC (History)
4 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 mmueller 2021-12-24 13:07:26 UTC
1  Description

When using special color codes in number format codes, e.g.
  COLOR23¹
that aren't 1 of the 8 documented² color codes, i.e.
  CYAN, GREEN, BLACK, BLUE, MAGENTA, RED, WHITE, YELLOW
the application will correctly display the color, but after saving and reloading the document, the color code will no longer be part of the number format, and no color will be displayed.


2  Steps to reproduce

2.1  Enter "-1234" into a cell.
2.2  Open cell formatting for that cell, and change the number format to
       [COLOR23]0.0
2.3  The number in the cell will now appear green-ish.
2.4  Save the document. Close the document. Re-open the document.
2.5  The number in the cell will appear with the default font color. (NOT green-ish) If you open the cell formatting, you will see the color code vanished from the number format code.


3  Is this a bug?

While it is documented that there are only 8 number format code colors², the application still reacts to input such as COLOR23. This indicates to the user that this is an undocumented feature. The loss of these settings after reloading the document is highly unintuitive. So either:
  a) (Documentation okay, Application bug)
     The bug is that the application allows undocumented color codes.
  b) (Documentation bug, Application bug)
     The documentation forgot to mention the COLOR{NN} codes and the application doesn't properly save them.
     


4  System parameters

Operating system: Gentoo

Package manager: Portage

Package: app-office/libreoffice 7.1.7.2
- Note: Compiled from source, as opposed to the app-office/libreoffice-bin package.

Portage flags:
- USE: bluetooth branding cups dbus gtk mariadb -accessibility -base -clang -coinmp -custom-cflags -debug -eds -firebird -googledrive -gstreamer -java -kde -ldap -odk -pdfimport -postgres -test -vulkan
- ELIBC: -FreeBSD
- LIBREOFFICE_EXTENSIONS: -nlpsolver -scripting-beanshell -scripting-javascript -wiki-publisher
- PYTHON_SINGLE_TARGET: "python3_9 -python3_8 -python3_10


5  Footnotes

¹  COLOR23 is a valid Excel number format code color.
²  https://help.libreoffice.org/7.2/en-US/text/shared/01/05020301.html#hd_id3155994
Comment 1 zcrhonek 2021-12-30 09:14:26 UTC
Format code [COLOR23]0.0  started to work after the commit:
 9a1315f5e88002032f40b184fb5b08cb4d6c0a20 is the first bad commit
commit 9a1315f5e88002032f40b184fb5b08cb4d6c0a20
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Fri Sep 18 11:01:57 2015 +0800

    source-hash-fa72fc3eddbfabb82193452a4ba993b11d1584da
    
    commit fa72fc3eddbfabb82193452a4ba993b11d1584da
    Author:     Eike Rathke <erack@redhat.com>
    AuthorDate: Fri Apr 19 00:47:57 2013 +0200
    Commit:     Eike Rathke <erack@redhat.com>
    CommitDate: Fri Apr 19 00:50:11 2013 +0200
    
        OUString::startsWith() is not equivalent to String::Match()
    
        String::Match() wasn't quite right at that place either, but..

But save and reload never worked.
Adding CC to Eike.
Comment 2 m_a_riosv 2023-02-25 02:30:37 UTC
*** Bug 153812 has been marked as a duplicate of this bug. ***
Comment 3 Laurent Balland 2023-02-26 11:35:30 UTC
"[COLORxx]" format code is 
- is correctly imported from XLSX
- not preserved in XLSX format on export.
- not preserved in ODS format on export (as it is not defined in ODF)

TEXT function does not render color of text (neither with [RED]) and cannot be used as a workaround.

Tested with Version: 7.4.5.1 (x64) / LibreOffice Community
Build ID: 9c0871452b3918c1019dde9bfac75448afc4b57f
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: fr-FR
Calc: threaded
and XL 2016

XL use a localized name for "COLOR" (Couleur in French for instance)
Comment 4 Eike Rathke 2023-02-28 15:48:47 UTC
(In reply to Laurent Balland from comment #3)
> - not preserved in ODS format on export (as it is not defined in ODF)
Yes it is:

    <number:number-style style:name="N117">
      <style:text-properties fo:color="#00a933"/>
      <number:number number:decimal-places="1" number:min-decimal-places="1" number:min-integer-digits="1"/>
    </number:number-style>

But it's not mapped back (if that would be possible at all i.e. in the current colour palette) to [COLOR23] when reading nor does the format code allow for something like [00a933]. Only the 10 predefined [BLACK], [BLUE], ... colour values are mapped.

Code pointers:
https://opengrok.libreoffice.org/xref/core/xmloff/source/style/xmlnumfi.cxx?r=46b7fd59#208
https://opengrok.libreoffice.org/xref/core/xmloff/source/style/xmlnumfi.cxx?r=46b7fd59#2082