Bug 82802 - conditional style with no conditions is displayed as un-conditional style after reloading document
Summary: conditional style with no conditions is displayed as un-conditional style aft...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: All All
: low minor
Assignee: Justin L
URL:
Whiteboard: BSA target:7.2.0 target:7.1.0.2 targe...
Keywords:
: 137166 (view as bug list)
Depends on:
Blocks: Writer-Styles-Paragraph
  Show dependency treegraph
 
Reported: 2014-08-19 08:02 UTC by Marcell Nemes
Modified: 2022-05-04 09:10 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
screenshot of conditional style setting (87.46 KB, image/png)
2014-08-19 13:10 UTC, sophie
Details
Conditional formatting made by AOO 4.1.2 (9.26 KB, application/vnd.oasis.opendocument.text)
2017-05-05 22:58 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcell Nemes 2014-08-19 08:02:42 UTC
Problem description:

I have created a custom conditional style, to test its behaviour. After saving the document and reopening it, the style lost its conditional attribute, and it became a regular style.

Steps to reproduce:

1. create a new style
2. under the 'Condition' tab check 'Conditional Style'
3. write a paragraph and use the custom style
4. save the document
5. reopen it

Current behavior:

The conditional style reverts to normal style.

Expected behavior:

The style should keep its conditional attribute.

Operating System: other
Version: 4.3.0.4 release
Comment 1 Marcell Nemes 2014-08-19 08:12:44 UTC
Update:

The error occurs when at the time of saving the document, there are no styles applied to the custom style. 'Conditional Style' is still checked though.
Comment 2 sophie 2014-08-19 13:10:01 UTC
Created attachment 104887 [details]
screenshot of conditional style setting

Hi, I do not reproduce, even after saving and the style not applied in the document, the conditional style is still set, see the screenshot attached. 
I'm using 4.3.0.4 Ubuntu 14.04 x64. Sophie
Comment 3 Marcell Nemes 2014-08-19 13:19:38 UTC
(In reply to comment #2)
> Created attachment 104887 [details]
> screenshot of conditional style setting
> 
> Hi, I do not reproduce, even after saving and the style not applied in the
> document, the conditional style is still set, see the screenshot attached. 
> I'm using 4.3.0.4 Ubuntu 14.04 x64. Sophie

As I see, you're modifying the predefined style called 'Text Body' in english. I haven't encountered any problems with that. I created a new style, and set it as conditional.
Also, I meant the error was when there were no styles applied to any context inside the settings of the style, not wether it was used in the document.
Comment 4 sophie 2014-08-20 13:56:12 UTC
Hi Marcell, in my tests yesterday it works even with a custom style, but I applied the condition inside the dialog box. 
Now I understand what you said, in fact, if you do not apply a condition during the creation of the style, it's not possible to modify it after saving the document because the conditional possibility is lost. 
On one hand I find it normal that if you don't apply a condition, the conditional style doesn't exist, on the other hand, the possibility to modify it once created should be offered.
Set it as New - Sophie
Comment 5 Marcell Nemes 2014-08-20 17:12:06 UTC
Hi Sophie!
Yes, it's a bit confusing, that you can only modify it if it was saved with at least one style applied to the conditional style. Even if you create it with some styles applied, and removing them later causes the unability to modify. I can imagine some scenarios when this occurs, like you make up your mind with some formatting, and have it closed when there are no styles applied at the moment.
Styles should be able to be designed as conditional styles even after creating them. As I see this wouldn't cause any problem, because the conditional ones are still modifiable later, so why couldn't the normal ones be. More so, if you have the conditional style checked, it should mean that it's meant to be a conditional style, even if it has no styles applied to it.
/This time I tried it with LO version 4.2.4.2 under Ubuntu 14.04 LTS./
Marcell
Comment 6 QA Administrators 2015-09-04 02:47:54 UTC Comment hidden (obsolete)
Comment 7 QA Administrators 2016-09-20 10:28:56 UTC Comment hidden (obsolete)
Comment 8 Regina Henschel 2017-05-05 22:50:46 UTC
I see the problem even the condition is set immediately and works while first working on the document. After save and reload the condition is gone.

To reproduce:
Define a style "Red" from Default, that has a red font color.
Define a style "Blue" from Default, that has a blue font color.
Start defining a style "ConditionCaller" from Default. Go to tab Condition and mark "Conditional Style". Apply the style "Red" to the condition "Table Header" and the style "Blue" to "Table". OK
Insert a table e.g. 2 columns and 4 rows with table header and some dummy text.
Mark the whole table and apply your newly defined style "ConditionCaller".
Notice that the text in the first row of the table becomes red and in the other cells blue.
Save the document.
Reload.
Notice that the colors are lost.

If you look into the file, you will see, that there are no <style:map> elements, which would be needed for a conditional style.

This happens too, if you the set the conditions in the style "Text body".

I have used Version: 5.2.6.2
Build ID: a3100ed2409ebf1c212f5048fbe377c281438fdc
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
Locale: de-DE (de_DE); Calc: group
Comment 9 Regina Henschel 2017-05-05 22:58:20 UTC
Created attachment 133098 [details]
Conditional formatting made by AOO 4.1.2

Open attached file. Conditions are lost on opening too.
Comment 10 Regina Henschel 2017-05-05 23:22:05 UTC
In the meantime conditional formatting is broken totally, see bug 103091.
Comment 11 Troy Rollo 2017-06-05 06:26:13 UTC
*** Bug 103091 has been marked as a duplicate of this bug. ***
Comment 12 Troy Rollo 2017-06-05 06:28:26 UTC
There is currently no code in the master branch for saving or restoring paragraph style conditions.
Comment 13 Michael Stahl (allotropia) 2017-06-15 20:11:11 UTC
there is no practical difference between a style that isn't conditional,
and a conditional style with no conditions.

as far as i can see there is no way to differentiate those
2 possibilities in an ODF document either; both cases
don't have any style:map element below style:style.

basically if anything this is an UI problem, we could just remove
this checkbox from the dialog without any loss of functionality.
Comment 14 Kaue 2018-10-23 20:58:56 UTC
(In reply to Regina Henschel from comment #8)
> I see the problem even the condition is set immediately and works while
> first working on the document. After save and reload the condition is gone.
> 
> To reproduce:
> Define a style "Red" from Default, that has a red font color.
> Define a style "Blue" from Default, that has a blue font color.
> Start defining a style "ConditionCaller" from Default. Go to tab Condition
> and mark "Conditional Style". Apply the style "Red" to the condition "Table
> Header" and the style "Blue" to "Table". OK
> Insert a table e.g. 2 columns and 4 rows with table header and some dummy
> text.
> Mark the whole table and apply your newly defined style "ConditionCaller".
> Notice that the text in the first row of the table becomes red and in the
> other cells blue.
> Save the document.
> Reload.
> Notice that the colors are lost.
> 
> If you look into the file, you will see, that there are no <style:map>
> elements, which would be needed for a conditional style.
> 
> This happens too, if you the set the conditions in the style "Text body".
> 
> I have used Version: 5.2.6.2
> Build ID: a3100ed2409ebf1c212f5048fbe377c281438fdc
> CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
> Locale: de-DE (de_DE); Calc: group

The procedure described now works, but conditions set in the "Text body" style are still not working (they disappear after reloading the document) on 6.1.1.2 (x64, Windows 10).
Comment 15 QA Administrators 2019-10-24 02:40:55 UTC Comment hidden (obsolete)
Comment 16 Xisco Faulí 2020-03-09 13:28:07 UTC
Please add keyword 'needsUXEval' and CC 'libreoffice-ux-advise@lists.freedesktop.org' if input from UX is needed.
Comment 17 Justin L 2020-12-03 09:54:42 UTC
*** Bug 137166 has been marked as a duplicate of this bug. ***
Comment 18 Regina Henschel 2020-12-03 12:22:30 UTC
The built-in style "Text Body" is supposed to be a conditional style, even if currently no condition is set.

See https://help.libreoffice.org/7.2/en-US/text/swriter/01/05130100.html?DbPAR=WRITER#bm_id3154656

<quote>
Tip Icon

The "Text Body" Style was created as a conditional style. Therefore, any styles you derive from it can be used as conditional styles.
</quote>
Comment 19 Justin L 2020-12-03 13:11:37 UTC
Here is a code sample for disabling that pointless checkbox. It still needs a glade-person to fully remove it from the UI.
http://gerrit.libreoffice.org/c/core/+/107162 tdf#82802 sw page-style UI: remove pointless makeConditional CB
Comment 20 Heiko Tietze 2020-12-04 08:46:58 UTC
(In reply to Justin L from comment #19)
> It still needs a glade-person...

/done
Comment 21 Justin L 2020-12-07 14:34:18 UTC
Proposed fix for Text Body: http://gerrit.libreoffice.org/c/core/+/10735
Comment 22 Commit Notification 2020-12-14 09:32:02 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1f066313218449cac494a887eb209311efbaa405

tdf#82802 sw page-style UI: remove pointless makeConditional CB

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 23 Commit Notification 2020-12-19 19:56:27 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4b5aaa9edfd58ec8f73de127410656f884f944d7

tdf#82802 sw conditional style conditions not saved for TextBody

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 24 Commit Notification 2020-12-19 21:49:58 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/64b3727adb12601d9a4010ec9160a8958d2ee878

tdf#82802 sw conditional style conditions not saved for TextBody

It will be available in 7.1.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 25 Commit Notification 2020-12-19 22:28:28 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/9d6fcca559d8dbfd77448b7aed9835c1fcae93f3

tdf#82802 sw conditional style conditions not saved for TextBody

It will be available in 7.0.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 26 Mike Kaganski 2022-05-04 08:40:48 UTC
(In reply to Commit Notification from comment #22)
> Justin Luth committed a patch related to this issue.
> tdf#82802 sw page-style UI: remove pointless makeConditional CB

Oh, this regressed. Now you can't enable the styles filter in the bottom right.
Will file a bug.
Comment 27 Mike Kaganski 2022-05-04 08:54:57 UTC
By the way, this seems to settle to "any condition set makes the style conditional; all conditions unset makes it not conditional at any point".

Note that the documentation still states [1]:

> Once defined, you cannot change the conditional properties of a conditional style.

That seemed to be partially wrong even before the changes here (one obviously could add/remove mappings between specific contexts and styles for already defined conditional styles, and also the whole issue here was the ability to change a conditional style into non-conditional just by modifying its mapping); but note how the *checkbox* itself (removed in commit mentioned in comment 22) got disabled once the style was created; and how the Condition tab disappeared completely in non-conditional styles.

So now the question is: why do we limit the Condition tab to only appear when the style is either newly created, or already has conditions? It is clearly possible to change this dynamically - why not show it at all times, allowing one to make any style conditional at any moment - and drop the issue that started this bug report?

(Needs an own bug report; dumping it here in case I forget it all.)

[1] https://help.libreoffice.org/latest/en-US/text/swriter/01/05130100.html?DbPAR=WRITER