Bug 166361 - Conditional formatting in LO Calc sometimes corrupt - needs better checks
Summary: Conditional formatting in LO Calc sometimes corrupt - needs better checks
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.0.0.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, dataLoss, regression
Depends on:
Blocks: Conditional-Formatting
  Show dependency treegraph
 
Reported: 2025-04-27 09:22 UTC by Thomas Maeder
Modified: 2025-05-05 02:14 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Original file, looks OK but with some corruption (32.96 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-04-27 09:25 UTC, Thomas Maeder
Details
Screenshot: conditional formatting in sheet "Détails" (260.10 KB, image/png)
2025-04-27 09:30 UTC, Thomas Maeder
Details
Screenshot: conditional formatting corrupt after sheet deletion (104.30 KB, image/png)
2025-04-27 09:35 UTC, Thomas Maeder
Details
3a) Saved file after delete sheet - conditional formatting gone (32.37 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-04-27 09:38 UTC, Thomas Maeder
Details
3a) Conditional formatting gone after sheet deletion & save-open (319.73 KB, image/png)
2025-04-27 09:41 UTC, Thomas Maeder
Details
3b) Corrupt file after duplicating sheet with conditional formatting (56.17 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-04-27 09:46 UTC, Thomas Maeder
Details
3b) Conditional formatting not present in duplicated sheet (378.40 KB, image/png)
2025-04-27 09:50 UTC, Thomas Maeder
Details
Problem confirmed with exemple created from scratch (32.06 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-04-27 15:07 UTC, Thomas Maeder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Maeder 2025-04-27 09:22:06 UTC
Description:
FORMATTING: After heavy use (but no crash), I found that conditional formatting acted strangely on a file.
- Deleting the sheet before the one with conditional formatting changes all conditional formatting cell references to #REF!
- Duplicating the sheet with conditional formatting yields a copy of the cells, but not of the conditional formatting.

Steps to Reproduce:
Doesn't happen systematically ex-nihilo → see attached file with conditional formatting somehow corrupted.
1)Open file "LO conditional formatting corruption.ods".
2)Look at conditional formatting in sheet "Détails" = 2 conditions OK.
3a) Delete first sheet "Liste" → conditional formatting in "Détails" broken
- See screenshots → #REF! in conditional formatting
- Upon saving & opening, conditional formatting has entirely disappeared!
- See 
3b) Duplicate the sheet "Détails" -> no conditional formatting in copy "Détails_2".
- See attachment "LO conditional formatting corruption delete sheet.ods".

Actual Results:
Conditional formatting is:
3a) broken upon prior sheet deletion, then disappears entirely, or
3b) not copied in sheet copy.

Expected Results:
a) Conditional formatting in a sheet should not be broken by deletion of another (unless there is a dependency, which is not the case here).
b) Conditional formatting should be reliably copied when duplicating a sheet.


Reproducible: Always


User Profile Reset: No

Additional Info:
This is not easily reproducible in general, but always in the attached sheet.
Somehow, the conditional formatting info here has some form of subtle corruption → LO Calc needs more robust checks (conditional formatting is in general one of the weak points).

Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 7370d4be9e3cf6031a51beef54ff3bda878e3fac
CPU threads: 8; OS: macOS 12.7.6; UI render: default; VCL: osx
Locale: fr-CH (fr_CH.UTF-8); UI: fr-FR
Calc: threaded
Comment 1 Thomas Maeder 2025-04-27 09:25:46 UTC
Created attachment 200553 [details]
Original file, looks OK but with some corruption

This is the corrupt file. It apparently looks OK in this state, and the conditional formatting is in sheet "Détails" → see next comment.
Comment 2 Thomas Maeder 2025-04-27 09:30:06 UTC
Created attachment 200554 [details]
Screenshot: conditional formatting in sheet "Détails"

Everything still looks fine at this point.
Comment 3 Thomas Maeder 2025-04-27 09:35:27 UTC
Created attachment 200555 [details]
Screenshot: conditional formatting corrupt after sheet deletion

3a) Directly after deletion of sheet "Liste", the conditional formatting in "Détails" is now corrupt, with cell references marked "Ref!".
Comment 4 Thomas Maeder 2025-04-27 09:38:52 UTC
Created attachment 200556 [details]
3a) Saved file after delete sheet - conditional formatting gone

3a) After deleting the sheet "Liste" and seeing corrupt conditional formatting in "Détails", the file is saved as is. After reopening it, the corrupt formatting seems to have entirely disappeared → see next screenshot.
Comment 5 Thomas Maeder 2025-04-27 09:41:54 UTC
Created attachment 200557 [details]
3a) Conditional formatting gone after sheet deletion & save-open

3a) This is how conditional formatting for "Détails" looks after saving and reopening the sheet. To sum up: conditional formatting in "Détails" goes form "apparently OK" to corrupt (after deletion of sheet "Liste") to entirely gone in the saved file.
Comment 6 Thomas Maeder 2025-04-27 09:46:49 UTC
Created attachment 200558 [details]
3b) Corrupt file after duplicating sheet with conditional formatting

3b) We now turn to duplicating the sheet with conditional formatting. This is the result after saving. The copy "Détails_2" of the conditionally-formatted sheet "Détails" looks the same, but has no conditional formatting → see screenshot in next comment.
Comment 7 Thomas Maeder 2025-04-27 09:50:37 UTC
Created attachment 200559 [details]
3b) Conditional formatting not present in duplicated sheet

3b) Immediately after duplication of sheet "Détails", sheet "Détails_2" has no conditional formatting. Saving / quitting LO / reopening shows that the formatting is indeed gone - this is not some display issue.
Comment 8 m_a_riosv 2025-04-27 14:05:20 UTC
a) Reproducible
Version: 25.2.3.1 (X86_64) / LibreOffice Community
Build ID: d8d1af5f77df955194e52baabe19324532ac8e8b
CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-US (es_ES); UI: en-US
Calc: CL threaded
and
Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a6e59a058306f0523f3686a9b084d010bd80e632
CPU threads: 16; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-GB
Calc: CL threaded
Maybe it was already reported, but I can't find it.

The b) looks like a duplicate of https://bugs.documentfoundation.org/show_bug.cgi?id=153506
Comment 9 Thomas Maeder 2025-04-27 15:07:48 UTC
Created attachment 200574 [details]
Problem confirmed with exemple created from scratch

As the original file was very large and had many changes, I tried to reproduce the problem with a much simpler one created from scratch.
This one has two sheets with conditional formatting: CF1 and CF2.
1) Delete CF1.
2) look into conditional formatting of CF2: corrupt!
3) Save the modified file, with CF1 deleted.
4) Re-open it & look into conditional formatting of CF2: gone!

Notes:
- I tried it in safe mode as well. Strangely, the conditional formatting doesn't look exactly the same after deleting CF1 (#REF! is in the range rather than in the formula), but is also corrupt. Upon saving & re-opening, it is also gone.
- If one deletes the second sheet CF2, everything seems fine…
Comment 10 Telesto 2025-04-28 02:20:57 UTC
Also with
Version: 7.2.0.4 / LibreOffice Community
Build ID: 9a9c6381e3f7a62afc1329bd359cc48accb6435b
CPU threads: 8; OS: Mac OS X 10.16; UI render: default; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded

and with
Version: 7.0.0.3
Build ID: 8061b3e9204bef6b321a21033174034a5e2ea88e
CPU threads: 8; OS: Mac OS X 10.16; UI render: default; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 11 Telesto 2025-05-01 10:09:43 UTC
STR
1. Open attachment 200574 [details]
2. Click on E4 in sheet CF2
3. Format -> Conditional formatting -> Manage
4. Notice range A4:A12 (fine)
5. Close dialog
6. Delete sheet CF2
7. Click on E4 in sheet CF2
8. Format -> Conditional formatting -> Manage
9. A4 changed into #REF!
10. Close dialog

Extra addition
15. Save
16. File -> Reload
17. Conditional formatting rule lost (not occurring in 6.0.4.1, so different issue, or consequence of the primary bug)

Alternative extra addition
11. CTRL+Z
12. Click on E4 in sheet CF2
13. Format -> Conditional formatting -> Manage
14. A4 changed into #REF!


Also in
Versie: 6.3.0.4 (x86)
Build ID: 057fc023c990d676a43019934386b85b21a9ee99
CPU-threads: 4; Besturingssysteem: Windows 10.0; UI-render: GL; VCL: win; 
Locale: nl-NL (nl_NL); UI-taal: nl-NL
Calc: CL

and in
Version: 6.1.6.3
Build ID: 5896ab1714085361c45cf540f76f60673dd96a72
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: nl-NL (nl_NL); Calc: CL

and in
Versie: 6.0.4.1
Build ID: a63363f6506b8bdc5222481ce79ef33b2d13c741
CPU-threads: 4; Besturingssysteem: Windows 10.0; UI-render: GL; 
Locale: nl-NL (nl_NL); Calc: CL

fine in 
Version: 5.4.0.3
Build ID: 7556cbc6811c9d992f4064ab9287069087d7f62c
CPU threads: 4; OS: Windows 6.2; UI render: default; 
Locale: nl-NL (nl_NL); Calc: CL
Comment 12 Saburo 2025-05-05 02:14:41 UTC
1. Open attachment 200574 [details]
2. Delete sheet CF1
3. Conditional formatting is preserved. Or The background color disappears. (It will return if you save the file and reload it.)

Version: 4.2.0.0.alpha0+
author	Kohei Yoshida
commit 8eb6de29009d009b8fa61fa8bb0e3bc60c7bfdf9
Make this guy unused, and remove it.
Change-Id: Ib4a2f195b3ff1d291b0ffe99c27b1d3e807252d5

3. The background color disappears.
Conditional formatting is present or absent when reloading the file after saving it

Version: 4.3.0.0.alpha1+
author	Kohei Yoshida
commit 146f6e7e68ea56f79b72047b97bd9fba66db499d
fdo#76710: Adjust sheet position of conditional format entries.
When inserting or deleting sheets.

3. The background color disappears.
When I try to edit conditional formatting again by pressing OK, the program crashes.

Version: 5.0.0.0.alpha1+
author	Henry Castro
commit 2b5915da481990fd6ea272104215d82b6fbf5dbb
tdf#60573 Conditional formatting does not allow scrolling
If you need to apply conditional formatting to a cell not shown presently
on your screen you cannot scroll to the position you would like to use.

Change-Id: I18549316d2c725ce032a65cffb969bed21b771c3
Reviewed-on: https://gerrit.libreoffice.org/14258

3. The background color disappears.
When checking in the conditional formatting manager, the range becomes #REF
Version: 6.0.0.0.alpha0+
author	Eike Rathke
commit 62ee21cb463d80a28c4c41a488f85e07abafbc69
Fix export test crash of ooo95715-1.xls
Negative sheet number injected by
sc::FormulaLogger::GroupScope::addRefMessage() wans't handled by lcl_Format()

	#9  0x00007f292172c322 in ScGroupTokenConverter::convert (this=0x7ffc5b1940d0, rCode=..., rScope=...)
		at /build/libo/dev/sc/source/core/data/grouptokenconverter.cxx:140
	#8  0x00007f29224c54d8 in sc::FormulaLogger::GroupScope::addRefMessage (this=0x7ffc5b193ff0, rCellPos=...,
		rRefPos=..., nLen=111, rArray=...) at /build/libo/dev/sc/source/core/tool/formulalogger.cxx:147
	#7  0x00007f292181c071 in ScRange::Format (this=0x7ffc5b193dc0, nFlags=-32760, pDoc=0x4b1db70, rDetails=...,
		bFullAddressNotation=false) at /build/libo/dev/sc/source/core/tool/address.cxx:2211
	#6  0x00007f292181b9a9 in ScAddress::Format (this=0x7ffc5b193dc0, nFlags=-32760, pDoc=0x4b1db70, rDetails=...)
		at /build/libo/dev/sc/source/core/tool/address.cxx:2111
	#5  0x00007f292181ecf5 in lcl_Format<rtl::OUStringBuffer> (r="", nTab=-1, nRow=75, nCol=0, nFlags=-30968,
		pDoc=0x4b1db70, rDetails=...) at /build/libo/dev/sc/source/core/tool/address.cxx:2018
	#4  0x00007f29214471fb in rtl::OUString::operator[] (this=0x7ffc5b193c00, index=0)
		at /build/libo/dev/include/rtl/ustring.hxx:668

Change-Id: I68ecfb11574644e9e5670431789ee42d37d27523

***
By the way, if you insert a column between columns C and D on sheet CF1,
the conditional formatting will also change,
but on sheet CF2, the named range will change but the reference range of the conditional formatting will not change.