Bug 158962 - Assigning a different list style to nested list removes its indentation (see comment 6)
Summary: Assigning a different list style to nested list removes its indentation (see ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Writer-Styles-List
  Show dependency treegraph
 
Reported: 2024-01-01 19:32 UTC by bintoro
Modified: 2024-02-17 12:53 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case (48.82 KB, application/vnd.oasis.opendocument.text-flat-xml)
2024-01-01 19:32 UTC, bintoro
Details
Reference document (47.02 KB, application/vnd.oasis.opendocument.text-flat-xml)
2024-01-22 10:22 UTC, bintoro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bintoro 2024-01-01 19:32:13 UTC
Created attachment 191688 [details]
Test case

The attached demonstration contains three variations of the same two-level list:

(a) Same list style throughout

    • Main level, item 1
    • Main level, item 2
        • Nested list, item 1
        • Nested list, item 2
    • Main level, item 3

(b) Different list style applied to nested list

    • Main level, item 1
    • Main level, item 2
        – Nested list, item 1
        – Nested list, item 2
    • Main level, item 3

(c) A single multi-paragraph item, different list style applied to nested list

    • Main level, item 1, paragraph 1
      Main level, item 1, paragraph 2
        – Nested list, item 1
        – Nested list, item 2
      Main level, item 1, paragraph 3

These look fine in the editor, but the latter two have an incorrect underlying structure.


*** Expected results ***

Note: Style attributes omitted for clarity.

(a)

    <text:list>
        <text:list-item>
            <text:p>Main level, item 1</text:p>
        </text:list-item>
        <text:list-item>
            <text:p>Main level, item 2</text:p>
            <text:list>
                <text:list-item>
                    <text:p>Nested list, item 1</text:p>
                </text:list-item>
                <text:list-item>
                    <text:p>Nested list, item 2</text:p>
                </text:list-item>
            </text:list>
        </text:list-item>
        <text:list-item>
            <text:p>Main level, item 3</text:p>
        </text:list-item>
    </text:list>

(b)

    The same as (a)

(c)

    <text:list>
        <text:list-item>
            <text:p>Main level, item 1, paragraph 1</text:p>
            <text:p>Main level, item 1, paragraph 2</text:p>
            <text:list>
                <text:list-item>
                    <text:p>Nested list, item 1</text:p>
                </text:list-item>
                <text:list-item>
                    <text:p>Nested list, item 2</text:p>
                </text:list-item>
            </text:list>
            <text:p>Main level, item 1, paragraph 3</text:p>
        </text:list-item>
    </text:list>


*** Actual results ***

(a)

    As expected.

(b)

    <text:list xml:id="...">
        <text:list-item>
            <text:p>Main level, item 1</text:p>
        </text:list-item>
        <text:list-item>
            <text:p>Main level, item 2</text:p>
        </text:list-item>
    </text:list>
    <text:list>
        <text:list-item>
            <text:list>
                <text:list-item>
                    <text:p>Nested list, item 1</text:p>
                </text:list-item>
                <text:list-item>
                    <text:p>Nested list, item 2</text:p>
                </text:list-item>
            </text:list>
        </text:list-item>
    </text:list>
    <text:list text:continue-list="...">
        <text:list-item>
            <text:p>Main level, item 3</text:p>
        </text:list-item>
    </text:list>

Applying a list style to the nested list has caused it to be removed from the main list and placed into its own top-level list.

Instead of one, we now have three consecutive top-level lists containing respectively
– the first item and the first paragraph of the second item
– the nested list, which is supposed to be part of the second item
– the third item.

(c)

    <text:list xml:id="...">
        <text:list-item>
            <text:p>Main level, item 1, paragraph 1</text:p>
            <text:p>Main level, item 1, paragraph 2</text:p>
        </text:list-item>
    </text:list>
    <text:list>
        <text:list-item>
            <text:list>
                <text:list-item>
                    <text:p>Nested list, item 1</text:p>
                </text:list-item>
                <text:list-item>
                    <text:p>Nested list, item 2</text:p>
                </text:list-item>
            </text:list>
        </text:list-item>
    </text:list>
    <text:list text:continue-list="...">
        <text:list-header>
            <text:p>Main level, item 1, paragraph 3</text:p>
        </text:list-header>
    </text:list>

In addition to the result in (b), paragraph 3 is marked up as `list-header` instead of `list-item` to indicate the lack of a bullet.

When exported as HTML, the standalone sublist in cases (b) and (c) results in invalid markup:

    <ul>
        <ul>
            <li><p>Nested list, item 1</p></li>
            <li><p>Nested list, item 2</p></li>
        </ul>
    </ul>
Comment 1 Dieter 2024-01-14 20:16:10 UTC
Not sure, if I've anderstood everything, but you have two different lists in part (b) and so I don't agree with the expectation, that (b) should be the same as (a). If you use style inspector, you can easily see the different numbers of the lists.
Comment 2 bintoro 2024-01-14 20:55:09 UTC
(In reply to Dieter from comment #1)
> Not sure, if I've anderstood everything, but you have two different lists in
> part (b)

That’s the issue I’m reporting. Applying a bullet style to a nested list causes the nested list to be detached from its parent and moved into a top-level list of its own, whereas I would expect it to stay where it is.
Comment 3 Dieter 2024-01-14 21:00:36 UTC
(In reply to bintoro from comment #2)
> That’s the issue I’m reporting. Applying a bullet style to a nested list
> causes the nested list to be detached from its parent and moved into a
> top-level list of its own, whereas I would expect it to stay where it is.

But you selected a different list style and therefore it's a new list. AFAIK it's not possible to have one list with different bullets at the same level (and I can't remember, that I've seen such a list), if this was your aim.
Comment 4 bintoro 2024-01-14 22:20:05 UTC
(In reply to Dieter from comment #3)
> But you selected a different list style and therefore it’s a new list.

Yes, that’s how it seems to work. But should it be that way? You can switch paragraph styles in the middle of a list, so why can’t you reformat a bullet?

In ODF, the style of a list is specified in the `text:style-name` attribute of the `text:list` element. Nested lists are allowed to have their own style attribute, but for some reason LibreOffice doesn’t support that.

There’s nothing to indicate to the user that they are doing it wrong by applying multiple list styles. Even the Writer guide says that it doesn’t make any difference if you configure a single list style to handle all levels or use a separate list style for each. But if the behaviour I’m reporting is expected, then clearly you shouldn’t be doing the latter because it breaks the list structure.

> it’s not possible to have one list with different bullets at the same level

I’m not trying to use two different bullets at the same level. I’m trying to format a nested list.
Comment 5 bintoro 2024-01-20 21:38:06 UTC
>> it’s not possible to have one list with different bullets at the same level
> 
> I’m not trying to use two different bullets at the same level. I’m trying to
> format a nested list.

Actually, I take that back. I mistook Dieter’s comment to mean switching the bullet style between _consecutive items_.

But the ability to have different bullets at a particular level _in different branches_ of the list structure is indeed what I want.

For example:

    * Main item 1
      1. Subitem
      2. Subitem
    * Main item 2
      - Middle item
        1. Subitem
        2. Subitem

Currently, the only way to achieve this kind of thing is by creating two adjacent lists: one for each main branch. Each would have its own list style. But in a list-heavy document, that gets unwieldy very fast, as every single “bullet X at level Y” edit results in a new permutation that must be expressed as a distinct list style.

The list functionality quite clearly seems to be built on the assumption that users will mainly format lists with the same bullet symbol throughout all levels. But professionally typeset documents are not formatted like that.

I think that the list style implementation is trying to do too many things at once, which makes it complicated and inflexible. There should be a way to apply list formatting similarly to direct formatting, i.e., without the formatting taking over the structure as well.

All I need is 
– one list style where I specify the indents for each level
– the ability to choose a bullet/numbering symbol as I create the actual list.
Comment 6 bintoro 2024-01-22 10:05:34 UTC
I have some more information. It seems that Writer already has the capability to represent styles on sub-lists.

If I edit an ODT file manually and assign a style to a sub-list, the document opens up without error and is displayed as intended. What’s more, if I edit the document in Writer and re-save it, the correct markup is preserved. I can even edit the list and the markup still doesn’t get mangled.

This suggests that the document representation and rendering parts support styles on sub-lists just fine and that this is purely a matter of the editor doing the wrong thing.

So, let’s make this bug more actionable.

User scenario:

1. The user is typing a list whose list style is X.
2. Upon starting a new list item, the user increases the list level, thereby creating a sub-list.
3. The user then applies a list style Y to the sub-list (either by directly applying Y or by applying a paragraph style that is linked to Y).

Expected results:

Style Y is applied to the sub-list. As explained above, simply setting the relevant attribute on the object representing the sub-list is likely already possible.

Actual results:

A new top-level list with the style Y is created.

ODF spec:

5.3.1: “Every list, including sub-lists, may have a list style which is applied to its list items and sub-lists. A list style specified for a sub-list overrides the list style specified for the list in which the sub-list is contained.”

19.880.22: “The `text:style-name` attribute specifies the name of a list style that is applied to a list.”
Comment 7 bintoro 2024-01-22 10:22:53 UTC
Created attachment 192095 [details]
Reference document

This document has been edited manually to have a list style on the nested list that differs from that of the enclosing list.

The Style Inspector indicates that the list structure has the same List ID throughout.

This is the desired outcome when applying a list style to a sub-list.

It seems that, as long as you don’t apply any new list styles, you can freely edit the list in Writer, and the structure and styling will remain correct in the saved file.
Comment 8 Buovjaga 2024-02-14 14:56:58 UTC
I reproduce, already in oldest of 3.5.0.

Arch Linux 64-bit, X11
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: fb35c64d5b7bb3c6763d09af613d9c79c657f7a9
CPU threads: 8; OS: Linux 6.7; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 14 February 2024
Comment 9 bintoro 2024-02-17 10:56:50 UTC
@Buovjaga:

I’m not sure about the reworded summary. Removing a list’s indentation is one thing; a workaround would be simply to re-indent. But the bug at hand is about something different: Writer terminates the current list and starts a new one. For that, there is no workaround.

Also, if a list style is applied directly instead of via a paragraph style, the apparent indentation level isn’t even reset. Writer creates a new list and automatically adds empty levels to it in order to preserve the current position. So, things appear to work just fine and you seem to be able to format the sublist independently. But in actuality the structure is turned into the one described in the initial comment.
Comment 10 Buovjaga 2024-02-17 12:53:32 UTC
(In reply to bintoro from comment #9)
> @Buovjaga:
> 
> I’m not sure about the reworded summary. Removing a list’s indentation is
> one thing; a workaround would be simply to re-indent. But the bug at hand is
> about something different: Writer terminates the current list and starts a
> new one. For that, there is no workaround.
> 
> Also, if a list style is applied directly instead of via a paragraph style,
> the apparent indentation level isn’t even reset. Writer creates a new list
> and automatically adds empty levels to it in order to preserve the current
> position. So, things appear to work just fine and you seem to be able to
> format the sublist independently. But in actuality the structure is turned
> into the one described in the initial comment.

Ok, then feel free to tweak the summary.