Bug 147535 - The style filter "Applied styles" should respect conditional formattings
Summary: The style filter "Applied styles" should respect conditional formattings
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.4 all versions
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Sidebar-Styles
  Show dependency treegraph
 
Reported: 2022-02-19 10:57 UTC by Jean-Francois Nifenecker
Modified: 2022-10-07 09:28 UTC (History)
2 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 Jean-Francois Nifenecker 2022-02-19 10:57:46 UTC
Description:
The way cell styles usage detection is reported in the Calc Styles side panel (BTW also by the style .isInUse API property) may lead the user to delete actually useful styles, breaking the spreadsheet look.

Styles side panel -> Cell styles -> Applied styles

In Calc, a cell style is currently reported as used when it is used for itself in any cell formatting.

In fact, a cell style should be reported as used in all of the following situations:
1. when it is actually used per itself in any cell of the spreadsheet (current situation)
2. when it is actually used in a conditional format (the CF being applied or not is of NO importance)
3. and 1. and 2., recursively to their heirs, direct or not.


This means that currently a user might erroneously consider a custom style as not used -- thus removing it -- while the style or a child of his' is actually used in the spreadsheet. 

This would potentially cause havoc to the formatting, since:
-- the cell styles inheritance tree might be unknown to the current user
-- some conditional formattings might not be visible at the time of the (inappropriate) style removal.

Remember that a user is not necessarily the person who originally designed the spreadsheet, hence s-he might overlook such "details".

Side note: in Writer, the paragraphs styles inheritance tree is respected. An unused parent style is listed as Applied whenever one of its heirs is actually used.

Steps to Reproduce:
0. Open a new spreadsheet document.
1. Create a cell style, say "MyParent", descending from Default. 
Set it to whatever you want, say "14pt font.
Make sure to not have any cell with that style applied.
2. Create a cell style "MyChild", descending from MyParent.
Set it to whatever you want, say white font on black background.
Apply this style to cell Sheet0.A1.
3. Create a cell style "MyCF", descending from MyParent.
Set it to whatever you want, say white font on red background.
4. Select Sheet0.B1 and create a conditional format with:
Value = 10 ; style = CF 
Check this by entering 10 in Sheet0.B1.
5. Go to the Styles side panel, cell style, Applied styles. MyParent is not present, while its children MyChild and MyCF are actually used.

Actual Results:
A parent cell style is not considered as used when one of his heirs is actually used.
A cell style is not considered as used when it is used for conditional formatting only.
A parent cell style is not considered as used when one of his heirs is used for conditional formatting only.

Expected Results:
Cell styles should be reported as used when:
-- they are used in some cell formatting
-- they are not used in some cell formatting, but:
   * one of their heirs is actually used for cell formatting.
   * they are used in some conditional formatting only.
   * one of their heirs is actually used for conditional formatting onyl.


Reproducible: Always


User Profile Reset: No



Additional Info:
(none)
Comment 1 Roman Kuznetsov 2022-10-06 18:50:49 UTC
confirm the problem in

Version: 7.3.6.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: kf5 (cairo+xcb)
Locale: ru-RU (ru_RU.UTF-8); UI: ru-RU
Ubuntu package version: 1:7.3.6-0ubuntu0.22.04.1
Calc: threaded

UX-team, please look at it. 
What should show Styles list when the Used styles variant was selected?

Should it to show styles that conditional formatting uses? I think YES
SHould it to show parent styles, if user used only its children? I think NO
Comment 2 Heiko Tietze 2022-10-07 08:35:34 UTC
Yes, Applied Styles should also list the styles from CF whether actually effective or not. Meaning if a CF wants to apply Accent 1 in case of values >1, for example, but no value is currently >1 the style should still be listed as used.
Comment 3 Jean-Francois Nifenecker 2022-10-07 09:28:55 UTC
(In reply to Roman Kuznetsov from comment #1)
> [...]
> SHould it to show parent styles, if user used only its children? I think NO

This would not be consistent with how Writer paragraphs styles are listed as used.

See my first message:
"Side note: in Writer, the paragraphs styles inheritance tree is respected. An unused parent style is listed as Applied whenever one of its heirs is actually used."