Bug 162916 - DOCX: ToC created without "Show Page Numbers" in MSO gets numbers in LO
Summary: DOCX: ToC created without "Show Page Numbers" in MSO gets numbers in LO
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:25.2.0
Keywords: bibisected, filter:docx
Depends on:
Blocks: TableofContents-Indexes
  Show dependency treegraph
 
Reported: 2024-09-11 08:30 UTC by Timur
Modified: 2024-09-25 00:45 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
ToC wihtout numbers (17.10 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-09-11 08:30 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timur 2024-09-11 08:30:17 UTC
Created attachment 196379 [details]
ToC wihtout numbers

In MSO, when creating Table of Contents (ToC) there is the option "Show Page Numbers" which is turned on by default. 
If that option is turned off ToC is created without numbers. LO opens it correctly.
But, Update index shows the page numbers. 
Tested with 25.2.
Comment 1 Timur 2024-09-11 08:51:02 UTC Comment hidden (obsolete)
Comment 2 raal 2024-09-11 17:51:45 UTC
Confirm with Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: b418f3d8d332276e6990cf7532a8f66aeb1d2f6c
CPU threads: 4; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US
Calc: threaded
Comment 3 Justin L 2024-09-24 15:18:39 UTC
The bibisect situation is a lot more complex than comment 1 suggests. 

In 4.2 the file loaded with the page numbers showing, until
    commit d6e321f8264188ce8371c060ebeb75b213f0c90f
    Author: Noel Grandin on Fri Oct 18 09:59:22 2013 +0200
        convert sw/source/core/doc/*.cxx from String to OUString

That commit can hardly be called a "fix" for TOC numbering, and was specifically reverted by mstahl in 4.3 as referenced by comment 1. Note that this fix returned the page numbers AT LOAD TIME - so it can hardly be called the regression of this bug report.

The load time numbering was probably eliminated later in 4.3 with
commit 9679e9c23216decb5f9f25f85b04cb3f25211111
Vinaya Mandke <vinaya.mandke@synerzip.com> on Mon Dec 30 16:22 2013
    fdo#69649 Fix for pre-rendered Table Of Contents
    Reviewed on: https://gerrit.libreoffice.org/7207

I suspect that Vinaya's patch just renders the last-seen-view-of-the-field-as-recorded-in-the-document instead of rendering an updated TOC.

In other words I'm sure this has never worked. I expect that LO simply doesn't have the ability to display the TOC without page numbers, making this an enhancement request.

DomainMapper_Impl.cxx's handleToc for \n has "todo: what does the description mean?"

-----

The TOC field can have an \n field-argument "Without field-argument, omits page numbers from the table of contents. Page numbers are omitted from all levels unless a range of entry levels is specified by text in this switch's field-argument. A range is specified as for \l."
Comment 4 Justin L 2024-09-24 19:36:47 UTC
Very interesting - we already export this just fine - since initial import.
ww8atr.cxx StartTOX
    sStr += "\\n "
    + OUString::number( nNoPgStt )
    + "-"
    + OUString::number( nNoPgEnd )
    + " ";

That's because it works for DOC - both import and export (since DOC also writes the same sFieldCmd string).
Comment 5 Commit Notification 2024-09-25 00:06:52 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9112a4a4cc700569f8321b8191abb4238697a404

tdf#162916 writerfilter TOC: import "no page number" flag

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.