Bug 157200 - table of content with duplicate entries
Summary: table of content with duplicate entries
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha1+
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
Depends on:
Blocks: TableofContents-Indexes
  Show dependency treegraph
 
Reported: 2023-09-12 07:47 UTC by SusanneMohn
Modified: 2023-10-13 04:02 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Document with table of content with custom styles (3.01 MB, application/vnd.oasis.opendocument.text)
2023-09-12 07:49 UTC, SusanneMohn
Details
Example file after setting category to Abb. and updating the ToF in German UI (53.55 KB, image/png)
2023-09-14 23:50 UTC, Gabor Kelemen (allotropia)
Details
Similar example for simple TOC (13.16 KB, application/vnd.oasis.opendocument.text)
2023-09-15 11:45 UTC, Gabor Kelemen (allotropia)
Details
The second example file in Writer (72.29 KB, image/png)
2023-09-15 11:48 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description SusanneMohn 2023-09-12 07:47:20 UTC
new fetaure in LO 7.6.: Table of Figures can be generated more flexibly based on a paragraph style, not only by categories or object names. tdf#153090 (Michael Stahl, allotropia) 
Result: In the List of Figures, the entries formatted with the custom style AbbRot are duplicated.
Comment 1 SusanneMohn 2023-09-12 07:49:40 UTC
Created attachment 189508 [details]
Document with table of content with custom styles
Comment 2 Stéphane Guillou (stragu) 2023-09-12 12:41:40 UTC
Thank you, Susanne.
Checking with linux-64-7.6 bibisect repo, this started at 2178d1ef764ec3e4cf0e8096392f1a4789fc8a64 which points to:

commit 90e1698dab3d286c10136719aa85fee2f56ad9fd
author	Michael Stahl Mon Jan 23 16:38:03 2023 +0100
committer	Michael Stahl Tue Jan 24 13:39:23 2023 +0000
tdf#153090 xmloff: ODF import/export of source style on ToX
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146013

Updating the index before this commit removes the two duplicate entries, which makes sense as using additional paragraph styles was not available then.

So to be clear: the duplicated entries are expected, as the default table of figures relies on the captions' "number range" fields, and the "new additional paragraph style" feature relies on the style of the paragraph.
If you needs an index based on only styles, you can use the index type "user-defined".
Let me know if I'm missing something. (I'm only really exploring the feature now :) )

However, testing the feature made me hit this regression:
0. Right-click > update the index: Illustration references remain
1. Open the dialog to edit the Table of Figures, but don't change any setting in the dialog
2. Click OK

Result: entries based on caption fields are removed. That's because, since 6.3, opening the dialog resets the type to Figure (instead of keeping Illustration).

Still current with recent master build:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: cea165a3ebdb5f2a2b172004ff1b3848f303d78a
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

So I'll close this report as "not a bug", and report the other issue separately if not already reported.
Do you know when this example file was created / with which version of LO?
Comment 3 Stéphane Guillou (stragu) 2023-09-14 13:16:01 UTC
(In reply to Stéphane Guillou (stragu) from comment #2)

> So I'll close this report as "not a bug", and report the other issue
> separately if not already reported.
> Do you know when this example file was created / with which version of LO?

I've reported it as bug 157223 and it has already been fixed by Caolán :)
Let us know if there are further issues or if I missed the point above.
Cheers!
Comment 4 Gabor Kelemen (allotropia) 2023-09-14 23:48:45 UTC
Hm, I believe there is merit in the report.

This new feature was inspired from Word, and there it works a bit differently than in Writer: 
It is possible to select a caption category and a custom style (although their UI is kinda counter-intuitive in this area, and selecting a custom style instantly resets the category setting to none - but it can be set again).

See attachment 184747 [details] from bug 153090 about this: the ToF is made from two settings: the category "ábra" (figure) and the custom style _CustomImageCaption. The small house images description has both these conditions true, but only one entry is added in the ToF, even after updating it in Word. Which makes sense, it's only one paragraph in the document body.

However in Writer it's also easy to reproduce the entry duplication with attachment 184745 [details] : 
- Set the LO UI to German
- Open the attachment 184745 [details]
- Edit the ToF, set the Kategorie to Abb.
- OK the dialog -> ToF is updated, the first two entries are duplicated.
(the same happens in Hungarian UI and selecting the ábra Category - this duplicates the third entry)

I think it would make sense to not duplicate ToF entries even if they match two criteria.

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: beaea2e992912b4747d790070b26371f557b1f57
CPU threads: 15; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: de-DE
Calc: threaded

Note that it's possible to set up a simple TOC with similarly duplicated entries that have both an outline level set and their para style is also assigned to a TOC level. That is also nonsense to show and does not match what Word does, which only shows one entry even if a paragraph matches multiple conditions.
Comment 5 Gabor Kelemen (allotropia) 2023-09-14 23:50:25 UTC
Created attachment 189583 [details]
Example file after setting category to Abb. and updating the ToF in German UI
Comment 6 Stéphane Guillou (stragu) 2023-09-15 09:50:27 UTC
Thanks Gabor.

It's true that following your steps, then opening the resulting DOCX in Office.com and updating the ToF removes the duplicates.

(I also tested saving Susanne's attachment 189508 [details] as DOCX, opening on Office.com and updating the ToF, it results in no duplicates but images included inline. Something else to have a look at.)

Michael, what do you think?
Comment 7 Gabor Kelemen (allotropia) 2023-09-15 11:45:40 UTC
Created attachment 189606 [details]
Similar example for simple TOC

Here is another example, the Hello World paragraph has Outline level set (by me), and also added as additional style as level 3. TOC shows it twice.
Comment 8 Gabor Kelemen (allotropia) 2023-09-15 11:48:19 UTC
Created attachment 189607 [details]
The second example file in Writer