Bug 137166 - Conditional paragraph style not saved
Summary: Conditional paragraph style not saved
Status: RESOLVED DUPLICATE of bug 82802
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0.1.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected
Depends on:
Blocks:
 
Reported: 2020-09-30 17:28 UTC by Jean-Marc Bourguet
Modified: 2020-12-07 14:35 UTC (History)
6 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-Marc Bourguet 2020-09-30 17:28:22 UTC
Description:
When I save a document which has conditional paragraph styles, they should be present when I open the document.

Steps to Reproduce:
1. Open a new document with the default template
2. Set a conditional paragraph style for the paragraph style "Corps de Texte" (sorry, I'm using the french version and it doesn't allow me to switch to English for the UI) mapping the context "1er niveau de numérotation" to the style "Numérotation 1".
3. Save the file.
4. Leave Writer.
5. Launch Writer and reload the file.


Actual Results:
The conditional paragraph style has disappeared.

Expected Results:
The conditional style should still be present. (If the issue is that the file format .odt doesn't allow to represent conditional style, there should be a warning somewhere stating which format should be used to save it correctly).


Reproducible: Always


User Profile Reset: No



Additional Info:
I've reproduced the issue on both Windows with LibreOffice 7.0.1.2 and on Linux with LibreOffice in an up to date Ubuntu 20.04 (6.4.X if I'm not mistaken).
Comment 1 Dieter 2020-10-01 06:02:30 UTC
I can't confirm it with

Version: 7.0.1.2 (x64)
Build ID: 7cbcfc562f6eb6708b5ff7d7397325de9e764452
CPU threads: 4; OS: Windows 10.0 Build 19041; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: threaded
Comment 2 Jean-Marc Bourguet 2020-10-01 15:36:23 UTC
@Dieter, did you try with the default style "Text Body" which is presented in the french version as "Corps de texte"? If I create a new paragraph style, I can save and reload the conditional paragraph style, if I try to set conditional paragraph information for "Text Body", I can't.
Comment 3 Dieter 2020-10-01 16:14:45 UTC
(In reply to Jean-Marc Bourguet from comment #2)
> @Dieter, did you try with the default style "Text Body"

Yes.
Comment 4 Xisco Faulí 2020-11-11 15:03:43 UTC
Thank you for reporting the bug. To be certain the reported issue is not related to corruption in the user profile, could you please reset your Libreoffice profile ( https://wiki.documentfoundation.org/UserProfile ) and re-test?

I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' if the issue is still present
Comment 5 Jean-Marc Bourguet 2020-11-12 20:33:53 UTC
(In reply to Xisco Faulí from comment #4)
> Thank you for reporting the bug. To be certain the reported issue is not
> related to corruption in the user profile, could you please reset your
> Libreoffice profile ( https://wiki.documentfoundation.org/UserProfile ) and
> re-test?
> 
> I have set the bug's status to 'NEEDINFO'. Please change it back to
> 'UNCONFIRMED' if the issue is still present

I can confirm that I still reproduce the issue with the profile reset.

Yours
Comment 6 Justin L 2020-12-03 08:36:45 UTC
Conditional styles in Writer is new to me.
I found it when editing the paragraph style - a Condition tab is there (already since at least LO 3.5!).

If, with a new/clean user profile, I open LibreOffice and set the paragraph style filter to only show "Conditional" styles, I already see Text Body. When I modify that paragraph style, the checkbox for "Conditional Style" is checked, but disabled. (And that seems true for any style that enables "conditional styles".)

As OP says - in there you have to map a Context with a style - and then press "Apply" to create the mapping.  (What effect it has I don't know because I couldn't see any change in my document under those contexts...)

So - in the end I confirm what OP says. The mapping is still there in a new style that I create, but in "Text Body", any mapping is lost. (I notice that no other built-in styles have the option to set a conditional style.)

It worked up until LO 5.2. Unfortunately, I don't yet have the per-commit bibisect for 5.2, so the problem started in the range https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=125cdf3404e60cf78f2a5547e9a06ce994df5c8e..7041701edc6274eaa9df4dae970452131f76e433

Not yet calling this a regression, because I don't know if TextBody should be allowed to have a conditional state.
Comment 7 Justin L 2020-12-03 09:54:42 UTC
Conditional styles have been there since 2000 - initial import.

For some reason, text body really is supposed to be conditional.
bool IsConditionalByPoolId(sal_uInt16 nId)
{
    // TODO: why is this style conditional?
    // If it is changed to no longer be conditional, then a style "Text Body"
    // will be imported without its conditions from ODF.
    return RES_POOLCOLL_TEXT == nId;
}

Since this has been broken since 2015 with no complaints except people who get confused, should we just get rid of this exception to the rule completely?

*** This bug has been marked as a duplicate of bug 82802 ***
Comment 8 Regina Henschel 2020-12-03 12:19:37 UTC
(In reply to Justin L from comment #7)
> Conditional styles have been there since 2000 - initial import.
> 
> For some reason, text body really is supposed to be conditional.

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 9 Justin L 2020-12-03 13:03:11 UTC
(In reply to Regina Henschel from comment #8)
> Therefore, any styles you derive from it can be used as conditional styles.
That sounds like meaningless drivel to me.  If I create a new style "derived" from the default style, I also have a condition tab available. Obsolete information?
Comment 10 Regina Henschel 2020-12-03 14:45:43 UTC
The intention is to have a predefined style as conditional style, even if the condition is empty. So you can define an own conditional style, which fits in nicely into the "Text Body" hierarchy. That makes it easier for users.

And I don't know, in which way conditional style is used in macros.

So the information is not obsolete, but the feature has to be repaired.
Comment 11 Justin L 2020-12-07 07:58:06 UTC
(In reply to Justin L from comment #6)
> I don't yet have the per-commit bibisect for 5.2.
I finally got this downloaded although it needs two OSes to run it. The bad section only works on 20.04, and 16.04 can use that bad part that 20.04 runs.

Anyway, the first bad result appears to be from Bjoern Michaelsen on 13:15:27
commit aef1e2dde5e53ba8416a393bbe155ef0c18511a7
move SwXStyle entirely into compilation unit
Comment 12 Justin L 2020-12-07 14:35:15 UTC
This commit is entirely beyond my comprehension. My guess is it has to do with ICoreParagraphStyle - which appears to have been forgotten to be added to SwXPageStyle?

ICoreParagraphStyle as removed by commit da870b35dd0cf8b7a987530e896b3e044f444908
Author: Noel Grandin on Mon Sep 26 13:01:42 2016 +0200
    remove unused ICoreParagraphStyle

It was added back in with commit a5b4cb3f836c991d0647f55e1ef4920ce6115eac
Author: Troy Rollo on Tue Jun 6 17:41:33 2017 +1000
    tdf#103091 conditional style conditions not saved

Yet despite the incomprehensibility of this all, I might have the solution. It looks like the only problem is that Troy added the requirement for xNewStyle.
Using GetStyle() instead solves the problem.