Bug 157618 - FILESAVE: Calc ignores directly formatted text color in .ods files
Summary: FILESAVE: Calc ignores directly formatted text color in .ods files
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.1.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, filter:ods, regression
Depends on:
Blocks: Calc-Cells Automatic-Color
  Show dependency treegraph
 
Reported: 2023-10-05 14:07 UTC by Patrick (volunteer)
Modified: 2024-08-09 03:53 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Screen snapshot of .ods file after saving new spreadsheet and reopening it (746.70 KB, image/png)
2023-10-05 14:10 UTC, Patrick (volunteer)
Details
Screen snapshot of .xlsx file after saving new spreadsheet and reopening it (744.10 KB, image/png)
2023-10-05 14:10 UTC, Patrick (volunteer)
Details
Saved .ods file (8.79 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-10-05 14:10 UTC, Patrick (volunteer)
Details
Saved .xlsx file (5.71 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2023-10-05 14:11 UTC, Patrick (volunteer)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick (volunteer) 2023-10-05 14:07:52 UTC
Description:
Saving to an .ods file appears to corrupt the directly formatted text in a cell. Specifically, if a cell has a style with a dark background color (e.g. red) and the cell is directly formatted with the following, the text will be rendered as white even though the background of the cell is white:

- Text color for the cell is directly formatted to "automatic"
- Background color for the cell is directly formatted to "no fill"

Steps to Reproduce:
1. Open a new Calc spreadsheet
2. Select cell A1 and enter some text
3. Select the Styles > Error menu item. This well change the cell's background color to red and the text color to white.
3. Using the Font Color toolbar button, set the text color to "Automatic" and using the Background Color toolbar button, set the background color to "No Fill".
This will change the cell's background color to transparent and the automatic text color will render as black.
4. Save Calc spreadsheet as an .ods file and then immediately save as an .xlsx.
5. Close Calc spreadsheet.

Actual Results:
When the .ods file is opened, the cell is correctly rendered with a white background but the text is incorrectly rendered as white instead of black.

When the .xlsx file is opened, the cell is correctly rendered with black text on a white background.

Expected Results:
The cell in the .ods file should be rendered like the cell in the .xlsx file with black text on a white background.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Not sure when this bug started occurring but it occurs as far back as LibreOffice 7.5.7.1 but does not occur in OpenOffice 4.1.14 or NeoOffice 2022.7 (i.e. LibreOffice 4.4).

My first guess is that the bug occurs when saving and .ods file since the same bug occurs when opening the .ods file in Microsoft Excel.
Comment 1 Patrick (volunteer) 2023-10-05 14:10:12 UTC
Created attachment 190044 [details]
Screen snapshot of .ods file after saving new spreadsheet and reopening it
Comment 2 Patrick (volunteer) 2023-10-05 14:10:36 UTC
Created attachment 190045 [details]
Screen snapshot of .xlsx file after saving new spreadsheet and reopening it
Comment 3 Patrick (volunteer) 2023-10-05 14:10:58 UTC
Created attachment 190046 [details]
Saved .ods file
Comment 4 Patrick (volunteer) 2023-10-05 14:11:11 UTC
Created attachment 190047 [details]
Saved .xlsx file
Comment 5 Patrick (volunteer) 2023-10-05 22:00:05 UTC
Note for myself: I found that the cell's ATTR_BACKGROUND gets set differently depending on whether you are opening the .ods or the .xlsx files attached to this bug.

Next step: find where ATTR_BACKGROUND is set during loading of the document:


diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 7638652e6857..87383ec29398 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -472,6 +472,10 @@ void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemS
         }
         else
         {
+            // tdf#157618 when opening the .ods file, ATTR_BACKGROUND is set
+            // to the Error style's red background color whereas opening the
+            // .xlsx file, ATTR_BACKGROUND is set to the cell's directly
+            // formatted transparent background color.
             aBackColor = rItemSet.Get(ATTR_BACKGROUND).GetColor();
         }
Comment 6 Heiko Tietze 2023-10-16 13:40:47 UTC Comment hidden (off-topic)
Comment 7 Stéphane Guillou (stragu) 2023-10-19 21:21:45 UTC
Thanks Patrick. Reproduced on Linux with:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: b83f069101f1e6d8aaac09a805f02bbc4c619e7a
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 8 BogdanB 2023-10-20 20:27:15 UTC
The black color is lost also in
Version: 7.1.0.0.alpha0+
Build ID: abcc4eb907661e07ad850ccce7eb06f129da4286
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

I don't have older versions.
Comment 9 Kira Tubo 2023-11-03 03:49:44 UTC
Reproduced in: 

Version: 5.4.0.0.alpha1 (x64)
Build ID: 0b9f9bef65bb21ebb6a64aafad448f7f62dc824a
CPU threads: 6; OS: Windows 6.19; UI render: default; 
Locale: en-US (en_US); Calc: CL

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 676e0527d2f31556eccae314fbb12ce204f02ec7
CPU threads: 6; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

-----------------

NOT reproduced in:

Version 4.0.0.0.beta1 (Build ID: 87906242e87d3ddb2ba9827818f2d1416d80cc7)
Comment 10 Steve271 2024-08-09 03:53:41 UTC
bibisected with linux-41max repo and got the following results:

 7019e8654514116303a57895f660b5f3a39f364f is the first bad commit
commit 7019e8654514116303a57895f660b5f3a39f364f
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Fri Sep 18 10:43:03 2015 +0800

    source-hash-77e21bb36a2cdaaa0f4049dee0d45c5b2325c6e9
    
    commit 77e21bb36a2cdaaa0f4049dee0d45c5b2325c6e9
    Author:     Luke Deller <luke@deller.id.au>
    AuthorDate: Sat Mar 9 01:26:56 2013 +1100
    Commit:     Fridrich Strba <fridrich@documentfoundation.org>
    CommitDate: Mon Mar 11 14:54:57 2013 +0000


	2601: Change definition of "dark" colour for fdo#61993 | https://gerrit.libreoffice.org/c/core/+/2601

I don't know if Luke is still contributing but I'll add Cc anyways