Bug 95239 - Wrong ToC in Navigator and PDF when using frames
Summary: Wrong ToC in Navigator and PDF when using frames
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: László Németh
URL:
Whiteboard: target:25.2.0
Keywords:
Depends on:
Blocks: Navigator PDF-Export Frame
  Show dependency treegraph
 
Reported: 2015-10-21 23:01 UTC by Joaquim Pedro França Simão
Modified: 2024-11-06 17:02 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
ODT file with headings and wrong ToC in Navigator (15.72 KB, application/vnd.oasis.opendocument.text)
2015-10-21 23:01 UTC, Joaquim Pedro França Simão
Details
PDF created from example ODT, with wrong bookmark structure (21.25 KB, application/pdf)
2015-10-21 23:02 UTC, Joaquim Pedro França Simão
Details
how TOC appears for the ODT test file (6.13 KB, image/png)
2023-02-09 16:34 UTC, sdc.blanco
Details
APA Style test document with inline headings in text frames (19.93 KB, application/vnd.oasis.opendocument.text-flat-xml)
2024-11-06 16:54 UTC, László Németh
Details
Generated PDF from the APA Style test document with Heading 4 and Heading 5 in text frames (40.49 KB, application/pdf)
2024-11-06 16:55 UTC, László Németh
Details
Bad PDF outline before the fix for the APA Style test document (30.45 KB, application/pdf)
2024-11-06 16:58 UTC, László Németh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joaquim Pedro França Simão 2015-10-21 23:01:42 UTC
Created attachment 119857 [details]
ODT file with headings and wrong ToC in Navigator

If I set some headings inside a frame, the ordering on Navigator window is wrong, including on PDF export, but a generated Table of Contents (ToC) in Writer is correct.

Expected behaviour:
The ToC entries in the Navigator window and the PDF bookmarks on the exported document are with the correct heading tree structure.

Current behaviour:
LO puts all sub-headings inside the last top-heading.

Steps to reproduce:
- create new writer document;
- insert a Frame
- insert some text inside the newly created frame, assign "Heading 1" style;
- outsite the frame, insert some text and assign "Heading 2" style;
- insert another paragraph, assign "Text Body" style;
- insert another frame and repeat the previous steps.

- export as PDF, make sure that the "Export Bookmarks" option ("General" Tab, section "General") is active;
- the resulting PDF has all the "Heading 2" entries under the last "Heading 1" inserted.

See the attached odt and the exported PDF.
Comment 1 Joaquim Pedro França Simão 2015-10-21 23:02:29 UTC
Created attachment 119858 [details]
PDF created from example ODT, with wrong bookmark structure
Comment 2 Buovjaga 2015-10-24 15:49:24 UTC
Confirmed.

Win 7 Pro 64-bit, Version: 5.0.2.2 (x64)
Build ID: 37b43f919e4de5eeaca9b9755ed688758a8251fe
Locale: fi-FI (fi_FI)

LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
Comment 3 QA Administrators 2016-11-08 11:20:23 UTC Comment hidden (obsolete)
Comment 4 Mike 2018-08-03 04:51:33 UTC
Confirmed

Version: 6.1.0.2 (x64)
Build-ID: b3972dcf1284967612d5ee04fea9d15bcf0cc106
CPU-Threads: 4; BS: Windows 10.0; UI-Render: Standard; 
Gebietsschema: de-DE (de_DE); Calc: group threaded
Comment 5 QA Administrators 2021-01-30 04:17:41 UTC Comment hidden (obsolete)
Comment 6 Joaquim Pedro França Simão 2021-02-03 23:47:18 UTC
Still exists in latest Version: 7.1.0.3 (x64) / LibreOffice Community
Build ID: f6099ecf3d29644b5008cc8f48f42f4a40986e4c
CPU threads: 12; OS: Windows 10.0 Build 19042; UI render: Skia/Vulkan; VCL: win
Locale: pt-BR (pt_BR); UI: pt-BR
Calc: CL


And reproduced in BrOffice 3.3.0 OOO330m19 (Build:6) tag libreoffice-3.3.0.4
Comment 7 QA Administrators 2023-02-04 03:20:04 UTC Comment hidden (obsolete)
Comment 8 sdc.blanco 2023-02-09 16:34:00 UTC
Created attachment 185268 [details]
how TOC appears for the ODT test file

I believe the Navigator part of the issue was fixed with bug 143569.

I did not test the PDF part.  Bug 143569 also mentions a PDF problem. If that issue still remains, then maybe this bug summary can be adjusted to highlight the PDF issue.

Also....

(In reply to Joaquim Pedro França Simão from comment #0)
> but a generated Table of Contents (ToC) in Writer is correct.
I have attached a screenshot of what happens when I make a TOC using the file in When I opened attachment 119857 [details] in LO 7.2.7.2 and 7.6.0.0.alpha0+.

It does not look right to me.  The Outline Level 1 headings (in the Frames) appear after the Outline Level 2 headings.
Comment 9 Commit Notification 2024-11-06 16:47:12 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3056c75db5b2a8a945621349fea9ee1183872989

tdf#95239 sw: fix wrong order of PDF ToC, if headings put in text frames

It will be available in 25.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 10 László Németh 2024-11-06 16:47:35 UTC
Full commit description:

tdf#95239 sw: fix wrong order of PDF ToC, if headings put in text frames

PDF outlines (called also as PDF bookmarks or ToC) contained headings in
the wrong order if they were placed in a text frame:

Heading 2 (frame) ... 2
Heading 3 (frame) ... 2
Heading 1 ........... 1

Now PDF export didn't list text frame headings only at the start of the
ToC, but in their correct position and hierarchy, based on the page
and vertical position of the headings:

Heading 1 ................ 1
  Heading 2 (frame) ...... 2
     Heading 3 (frame) ... 2

This is useful for the recently implemented inline headings, where
e.g. APA Style Heading 4 and Heading 5 are there in text frames
anchored as characters, see tdf#48459.

Extend PDFium test environment for bookmarks, and add tdf#131728 DOCX
and an APA Style .fodt unit tests.

Note: if the higher headings are only in text frames, but not the
lower ones, only the order corrected, but not the full hierarchy, yet.

This is a follow-up to commit d87cf67f8f3346a1e380383917a3a4552fd9248e
"tdf#131728 sw inline heading: fix missing/broken DOCX export",
commit a1dcbd1d1ce6071d48bb5df26d7839aeb21b75a8
"tdf#48459 sw inline heading: add Inline Heading frame style" and
commit 49765a9e7be41d4908729ff7d838755276b244cb
"tdf#48459 tdf#131728 sw inline heading: new frame style: fix DOCX
export".
Comment 11 László Németh 2024-11-06 16:52:11 UTC
@Joaquim Pedro França Simão and all: thanks for the bug report and feedback!

The order of the headings are fixed with this commit. The remaining issue is the incomplete hierarchy, where the higher headings are there in text frames, not the lower ones. Please, file a new bug for it, if that is really needed.
Comment 12 László Németh 2024-11-06 16:54:07 UTC
Created attachment 197449 [details]
APA Style test document with inline headings in text frames
Comment 13 László Németh 2024-11-06 16:55:51 UTC
Created attachment 197450 [details]
Generated PDF from the APA Style test document with Heading 4 and Heading 5  in text frames

See Bug 48459 and Bug 131728 for more details about inline heading support and interoperability.
Comment 14 László Németh 2024-11-06 16:58:16 UTC
Created attachment 197451 [details]
Bad PDF outline before the fix for the APA Style test document