Bug 114363 - TOC: Index update causes entries to duplicate if ToC created from Outline and Additional heading styles (in a specific document)
Summary: TOC: Index update causes entries to duplicate if ToC created from Outline and...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: DOCX-TableofContents
  Show dependency treegraph
 
Reported: 2017-12-09 12:53 UTC by Jens Troeger
Modified: 2023-12-28 22:38 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Update ToC to see duplication. (37.59 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-12-09 12:53 UTC, Jens Troeger
Details
Left before, right after ToC update. (66.34 KB, image/jpeg)
2017-12-09 12:54 UTC, Jens Troeger
Details
DOCX updated in MSO (23.59 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-24 13:23 UTC, Timur
Details
DOCX when updated in MSO - screenshot (48.38 KB, image/jpeg)
2019-11-25 06:53 UTC, Timur
Details
The original example file in Word and Writer (163.95 KB, image/png)
2021-08-02 10:20 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Troeger 2017-12-09 12:53:19 UTC
Created attachment 138328 [details]
Update ToC to see duplication.

Updating the ToC index object, either calling update() through UNO or right-clicking on the ToC in the UI causes the top-level entries to duplicate.

See attached document and screen shot, see also https://forum.openoffice.org/en/forum/viewtopic.php?t=91448#p433507
Comment 1 Jens Troeger 2017-12-09 12:54:28 UTC
Created attachment 138329 [details]
Left before, right after ToC update.
Comment 2 Jens Troeger 2017-12-09 12:59:02 UTC
Also happens on 5.4.3.2 and 6.0.0 beta, both Mac and Linux.
Comment 3 MM 2017-12-09 13:08:40 UTC
Confirmed with 

Version: 5.1.6.2
Build ID: 07ac168c60a517dba0f0d7bc7540f5afa45f0909
CPU Threads: 2; OS Version: Linux 4.4; UI Render: default; 
Locale: en-US (en_US.UTF-8); Calc: single

and

Version: 6.1.0.0.alpha0+
Build ID: 1d8cb97fea57b81a1ab151b88c2180e646bd401b
CPU threads: 2; OS: Linux 4.4; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-12-07_01:51:53
Locale: en-US (en_US.UTF-8); Calc: threaded

Not only you'll get a double index, but you can't undo it.
Comment 4 Telesto 2017-12-10 11:12:18 UTC
Showing duplicates on file open
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

and
Versie: 4.2.0.4 
Build ID: 05dceb5d363845f2cf968344d7adab8dcfb2ba71

Showing duplicates after updating the TOC in
Version: 4.3.0.4
Build ID: 62ad5818884a2fc2e5780dd45466868d41009ec
Comment 5 Wolfgang Jäger 2017-12-10 23:53:26 UTC
(Just reporting some experiments.)
The example file is provided as .docx. The issue persists if the document is first saved as .odt and then reloaded. Creating the TOC anew in the reloaded document works without a problem and the new TOC does not show the issue. 
With LibO V5.4.3.2 x64 on Win 10. 
Same with V6.0.0.0beta1 x64 on Win 10.
Comment 6 Wolfgang Jäger 2017-12-11 00:19:55 UTC
AOO 4.1.3 does not show the issue.
Comment 7 Timur 2017-12-25 10:09:28 UTC
Happens only if ToC created both from Outline and Additional heading styles.
So, looks like user error to me and not a bug. 
Turn of either of them and you'll get what you want.
Comment 8 Jens Troeger 2017-12-25 19:10:25 UTC
These are customer documents. Could somebody please elaborate on what went wrong and how to go about the issue? I don't quite follow @Timur's explanation.
Comment 9 Timur 2017-12-26 11:32:17 UTC
ToC right-click, Edit. 
Turn off Outline OR Additional styles, depending what you want. 
What you ask is for ask.libreoffice.org and not for bug report.
Comment 10 Timur 2017-12-26 11:40:06 UTC
(In reply to Wolfgang Jäger from comment #6)
> AOO 4.1.3 does not show the issue.

Interesting, that must've been changed because this behavior is from OO.
We might say this is a bug and this should not duplicate if the same, like AOO. 
But I'm not in favor of that approach. 
I'd like to have it displayed exactly as checked. 
Those who set it up should know what they're doing.
Comment 11 Timur 2017-12-26 11:47:42 UTC
Note: saving this docx shows Bug 112539.
Comment 12 Jens Troeger 2017-12-29 04:53:39 UTC
I disagree.

Considering that the document is a DOCX Word native format I take it that Word is the reference and defines the baseline behavior. When I update the ToC in Word, entries are _not_ duplicated. It seems that AOO does not have this problem either.

Clearly there is a regression between Word and LO.

So instead of expecting LO users to tweak the document's settings after it's loaded (see this comment: https://bugs.documentfoundation.org/show_bug.cgi?id=114363#c9), I think LO should handle this like the baseline reference: without duplicating entries and without expecting the user to tweak anything.
Comment 13 Timur 2017-12-29 07:47:52 UTC
Please don't set wrong status yourself. Reopened is where fix doesn't work. 
This one is not confirmed, not only a behavior but a possible fix. You may wait for a dev or UX to confirm, but cannot do it yourself.
Comment 14 Dieter 2017-12-29 16:46:47 UTC
(In reply to Timur from comment #7)
> Happens only if ToC created both from Outline and Additional heading styles.
> So, looks like user error to me and not a bug. 
> Turn of either of them and you'll get what you want.

I disagree. If I create a document and create ToC both from Outline and form Heading Style there is no dubication
Comment 15 Dieter 2017-12-29 16:51:41 UTC
I can also (In reply to MM from comment #3)
> Confirmed with 
> 
> Version: 5.1.6.2
> 
> and
> 
> Version: 6.1.0.0.alpha0+

> 
> Not only you'll get a double index, but you can't undo it.

I can also confirm it but only wth that specific document from the original bug report => Set to NEW
Comment 16 Jens Troeger 2018-03-16 10:56:34 UTC Comment hidden (no-value)
Comment 17 QA Administrators 2019-03-17 03:51:42 UTC Comment hidden (obsolete)
Comment 18 Dieter 2019-03-17 12:38:49 UTC
Still reproducible in

Version: 6.3.0.0.alpha0+ (x64)
Build ID: 91cdf22b88a4f7bec243c8fb187627e766d3294c
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2019-03-08_00:38:10
Locale: en-US (de_DE); UI-Language: en-US
Calc: threaded
Comment 19 Jens Troeger 2019-03-24 12:56:46 UTC
Still reproducible in LibreOffice 6.2.1.2 7bcb35dc3024a62dea0caee87020152d1ee96e71.
Comment 20 Timur 2019-11-24 13:23:27 UTC
Created attachment 156074 [details]
DOCX updated in MSO

I opened DOCX in MSO 2013 in Windows and after an update to ToC there was an error.
I added another ToC before that one.
Here is updated DOCX.

When I open this new DOCX in LO, I get proper first new ToC without doubled content. Update ToC doesn't spoil it (except ToC title itself).
I see an error for previous ToC from original DOCX. It can be updated in LO and then it doubles chapter titles.

This is NotOutBug.
Comment 21 Jens Troeger 2019-11-24 21:09:47 UTC
So… your solution to this is have people open a DOCX file in Words, resave it, so they can open it in LO?

I have plenty of Word documents that _do_ show duplicate ToC when I open them in LO and they are just fine in Word. And as such I argue that this is indeed a LO bug.
Comment 22 Aron Budea 2019-11-25 05:19:51 UTC
(In reply to Timur from comment #20)
> I opened DOCX in MSO 2013 in Windows and after an update to ToC there was an
> error.
What kind of error did you get? I'm not seeing any errors when updating the ToC in Word 2013.

(In reply to Jens Troeger from comment #21)
> So… your solution to this is have people open a DOCX file in Words, resave
> it, so they can open it in LO?
> 
> I have plenty of Word documents that _do_ show duplicate ToC when I open
> them in LO and they are just fine in Word. And as such I argue that this is
> indeed a LO bug.
If there's indeed an error when updating the originally attached sample's ToC in Word (I haven't encountered one myself), having a clean sample would be helpful.
Comment 23 Jens Troeger 2019-11-25 05:31:40 UTC
> If there's indeed an error when updating the originally attached sample's ToC in Word (I haven't encountered one myself), having a clean sample would be helpful.

Download the original attachment, open it in LO, right-click on the generated ToC and update it. All entries will duplicate. That is the bug, as these entries should _not_ duplicate.
Comment 24 Timur 2019-11-25 06:53:04 UTC
Created attachment 156085 [details]
DOCX when updated in MSO - screenshot

(In reply to Aron Budea from comment #22)
> (In reply to Timur from comment #20)
> > I opened DOCX in MSO 2013 in Windows and after an update to ToC there was an
> > error.
> What kind of error did you get? I'm not seeing any errors when updating the
> ToC in Word 2013.
I updated the entire ToC, not just numbers and got some message, but ToC looks wrong, same as when opened in LO. Attached.

(In reply to Jens Troeger from comment #23)
> Download the original attachment, open it in LO, ...
Sorry, no. File must be a proper one. If it makes trouble in MSO, it cannot be a reference for LO. And it happens in other bugs also, that it's different in different MSO versions or that it's wrong there. 

I don't know how the original was created but there's a problem.
Please see .DOCX I uploaded with both ToC and test those in LO.
Comment 25 Timur 2019-11-25 06:59:10 UTC
Note: I wrote "MSO 2013 in Windows" and I noticed that Jens' is "Microsoft Macintosh Word 15". I don't have more recent MSO, but we cannot chase MS differences.
Comment 26 Aron Budea 2019-11-25 07:06:39 UTC
(In reply to Timur from comment #24)
> I updated the entire ToC, not just numbers and got some message, but ToC
> looks wrong, same as when opened in LO. Attached.
I did the same in the original sample, in Word 2013, and the ToC stays as it is.

I also get the ToC back in your sample, if I update the second ToC that says "No table of contents entries found". Probably some Word strangeness is at work (locale-based, perhaps?), but I'd say the original sample is valid. Let's reopen the bug report.
Comment 27 Jens Troeger 2019-11-25 07:11:34 UTC
> Sorry, no. File must be a proper one. If it makes trouble in MSO, it cannot be a reference for LO. […] I don't know how the original was created but there's a problem.

It _is_ a proper DOCX file straight out of Word two years ago when I opened the bug.

Today I tried it again using Word 16.16.15, and it works just fine and as expected. It does not work with LO 6.3.2.2 (i.e. ToC duplicates when I update it).
Comment 28 Stanislaus J. Pinasthika 2021-05-19 11:18:45 UTC
Still reproducable
Version: 7.1.0.3 / LibreOffice Community
Build ID: f6099ecf3d29644b5008cc8f48f42f4a40986e4c
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: kf5
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

same case, same format.
Comment 29 NISZ LibreOffice Team 2021-08-02 10:20:14 UTC
Created attachment 174025 [details]
The original example file in Word and Writer

The document and its TOC are formatted in a way that updating the TOC in Word results in an empty TOC. The incorrect import of such settings results in too many entries.

As highlighted in this image:
- The setting Outline (Vázlatszintek on the left) is turned OFF in Word, but imported as turned ON in Writer.
- In the TOC-Settings dialog of Word only Heading 2 and Heading 3 are enabled as additional styles to be included into the TOC. (the document has no paragraph formatted with these, so updating in Word will result in an empty TOC)
In Writer the Assign Styles dialog shows Heading 1 is enabled on first level (should be disabled) and Heading 2 and Heading 3 are disabled (should be enabled and assigned to 2nd and 3rd TOC levels).

Manually changing these to match Word settings and updating the TOC results in an empty TOC, just like in Word.

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 7c38362dbe1922c9825dffb463072030948d406b
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: CL
Comment 30 QA Administrators 2023-08-03 03:05:20 UTC Comment hidden (obsolete)
Comment 31 IronRod3 2023-12-28 22:38:15 UTC
[Runnning v7.6.4.1 (X86_64) on Fedora 39 Cinnamon]

I can confirm that this issue still exists.

NOTE: In my case, I had several DOCX with existing indexes which I have brought over (moving from Windows to Linux) and opened in LibreWriter.  Upon right-clicking the index and selecting "Update Index" it duplicated every entry as all of my index entries are Header 1.

Given the earlier descriptions on this bug I doubt the fact these are imported contribute to the issue but wanted it to be known.