Bug 136194 - FILEOPEN Chapter numbering in a DOTX import is wrong in version 7.0, was OK in 6.4
Summary: FILEOPEN Chapter numbering in a DOTX import is wrong in version 7.0, was OK i...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on: 141966
Blocks: DOCX-Bullet-Number-Outline-Lists
  Show dependency treegraph
 
Reported: 2020-08-27 16:13 UTC by enyc
Modified: 2021-09-29 09:36 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
FMT Template dotx document template, which triggers the failure. (82.70 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.template)
2020-08-27 16:14 UTC, enyc
Details
FMT Template as exported to PDF with automatic blank pages in LO 7.0.1 (146.43 KB, application/pdf)
2020-08-27 16:15 UTC, enyc
Details
FMT Template as exported to PDF from WinWord-2010, which seems to render correctly. (400.93 KB, application/pdf)
2020-08-27 16:15 UTC, enyc
Details
136194_minimal.docx (25.10 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-04-23 11:37 UTC, Justin L
Details
136194_FMT2.docx: short version with only a minimized appendix. (25.34 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-05-15 07:31 UTC, Justin L
Details
The minimal docx in Word, Writer 7.1 and 7.3alpha (92.42 KB, image/png)
2021-07-12 12:29 UTC, NISZ LibreOffice Team
Details
The original attachment 164761 in Word and Writer nightly (115.74 KB, image/png)
2021-07-12 12:33 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description enyc 2020-08-27 16:13:24 UTC
Description:
Importing   FMT-3-S-Thesis-Template-v1.0.dotx  in LibreOffice 7.0 series now cuts out the entire content pages (all Chapters and also Bibliography).

This is potentially related to #128260 , or may be a separate, new issue.


Steps to Reproduce:
1. Get  https://ec2.sheer.us/~enyc/noidx/FMT-3-S-Thesis-Template-v1.0.dotx
     (or, the same attachment which will be attached to this bug).

2. Open in Libreoffice 7.x

3. Notice the Chapters listed on page xiii and xiv

4. Notice page xxi continues straight to page 1 with all the chapters and bibliography completely missing!.


Actual Results:

This failure is shown in:
https://ec2.sheer.us/~enyc/noidx/FMT-3-S-Thesis-Template-v1.0_LO-7.0.1.pdf


Expected Results:
Compared to correct output:-
https://ec2.sheer.us/~enyc/noidx/FMT-3-S-Thesis-Template-v1.0_WinWord-2010.pdf


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
This is potentially related to #128260 , or may be a separate, new issue.
Comment 1 enyc 2020-08-27 16:14:24 UTC
Created attachment 164761 [details]
FMT Template dotx document template, which triggers the failure.
Comment 2 enyc 2020-08-27 16:15:17 UTC
Created attachment 164762 [details]
FMT Template as exported to PDF with automatic blank pages in LO 7.0.1
Comment 3 enyc 2020-08-27 16:15:58 UTC
Created attachment 164763 [details]
FMT Template as exported to PDF from WinWord-2010, which seems to render correctly.
Comment 4 enyc 2020-08-27 20:12:04 UTC
Happens on at least 2 different LO 7.0 builds, further confirmed.
Comment 5 Telesto 2020-08-28 07:42:30 UTC
The idea is to wait for conformation before setting to new. Reverting to unconfirmed
Comment 6 enyc 2020-09-01 09:09:56 UTC
To be clear opening  FMT-3-S-Thesis-Template-v1.0.dotx  --

Page 23 of 47  should start with heading  "Chapter 1".

Faulty case is:   Page 23 of 47 starts  "Appendix A"  instead.

Also, to be clear, the ToC (Table of Contents) is 'correct' and updating this index, although making document self-consistent, is simply removing reference to the ''vanished'' contents.
Comment 7 Mike Kaganski 2020-09-01 09:33:39 UTC
(In reply to enyc from comment #6)
> opening  FMT-3-S-Thesis-Template-v1.0.dotx  --
> 
> Page 23 of 47  should start with heading  "Chapter 1".
> 
> Faulty case is:   Page 23 of 47 starts  "Appendix A"  instead.

Repro with Version: 7.0.1.2 (x64)
Build ID: 7cbcfc562f6eb6708b5ff7d7397325de9e764452
CPU threads: 12; OS: Windows 10.0 Build 19041; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: threaded

I suspect a rebression from a fix to tdf#76817.
Comment 8 enyc 2020-09-01 11:49:45 UTC
Further Correction -- the content isn't actually missing but actually the chapter headings are mispositioned, becoming Appenixes, I believe!.  Bug Title was corrected accordingly.

"Vanished contents" is a misnomer/mistake in the original report above, but nonetheless check and confirmation above is valid.

Thankyou to Mike Kaganski for pointing out mistakes in process and so-on!.
Comment 9 Aron Budea 2020-09-05 23:51:45 UTC
(In reply to Mike Kaganski from comment #7)
> I suspect a rebression from a fix to tdf#76817.

Good guess, it is a regression from that, bibisected to the following commit using repo bibisect-linux-64-7.1. Adding CC: to László Németh.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=2128d59ab91da853652305390d56b3287bcb67b1
author		László Németh <nemeth@numbertext.org>	2020-06-12 11:11:16 +0200
committer	László Németh <nemeth@numbertext.org>	2020-06-12 17:42:00 +0200

tdf#76817: DOCX import: fix chapter numbering
Comment 10 Justin L 2021-01-27 09:30:26 UTC
repro 7.2+
Comment 11 Justin L 2021-04-23 11:37:09 UTC
Created attachment 171368 [details]
136194_minimal.docx
Comment 12 Justin L 2021-04-23 13:19:29 UTC
In style "Heading 1"'s numbering id 16, which is abstract #10, there is nothing that indicates "Appendix x".

However, Heading 7 (which inherits from Heading 1) seems to take over Chapter Numbering level 1 (which is normally occupied by Heading 1).

Since Heading 1 is not part of Chapter numbering, it should not be treated specially.
Comment 13 Justin L 2021-04-24 04:57:40 UTC
This should have been reverted 6 months ago - as soon as it was reported.  (And it shouldn't have been backported anywhere either.)
Comment 14 Justin L 2021-04-26 19:07:19 UTC
136194_minimal.docx shows we import outline/chapter numbering completely incorrectly in writerfilter. We have band-aids(plasters) everywhere, partially covering a gaping wound.

When dealing with Heading 1 style, we get:
warn:legacy.osl:4046753:4046753:sw/source/core/txtnode/ndtxt.cxx:3887: <HandleModifyAtTextNode()> - text node with outline style, but its paragraph style is not assigned to outline style.
warn:legacy.osl:4046753:4046753:sw/source/core/doc/fmtcol.cxx:601: <SwTextFormatColl::GetAssignedOutlineStyleLevel()> - misuse of method

But how to fix?  Somehow Chapter Numbering should NEVER be set UNLESS we are confident that LibreOffice saved the docx.

I think this would be: the numId == 1, and it is never used in direct formatting, and only used in styles where outlineLevel == listLevel (although examples show that listLevel seems to be optional :-()
It should be irrelevant what the name of the paragraph style is.
(.doc format already does outlineLevel == listLevel)

Crude bandaid patch found at http://gerrit.libreoffice.org/c/core/+/114681
Comment 15 Justin L 2021-05-15 07:24:21 UTC
A better patch is now at https://gerrit.libreoffice.org/c/core/+/115614 which is part of the series of patches for bug 141966.

[I'm confused. The first time I opened the document after that patch series, I saw Appendix A, Appendix B, Appendix C, and finally Appendix D.  When I started to look into it, I have now only seen Appendix A, A.1, A.1.1, and B - like it should be.]

So, it should be fixed in LO 7.3 if all of the patches are accepted. (Delaying the patches and being extremely cautious since numbering is regression-prone.
Comment 16 Justin L 2021-05-15 07:31:36 UTC
Created attachment 172018 [details]
136194_FMT2.docx: short version with only a minimized appendix.
Comment 17 NISZ LibreOffice Team 2021-07-12 12:29:36 UTC
Created attachment 173506 [details]
The minimal docx in Word, Writer 7.1 and 7.3alpha

Minimized attachment 171368 [details] looks good now on open in:

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 0fc020fb73c86a20608e8dff12af607e60327379
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: CL

Not yet in bibisect-win64-7.3 from two weeks ago so can't pinpoint the exact change yet.
Comment 18 NISZ LibreOffice Team 2021-07-12 12:33:00 UTC
Created attachment 173507 [details]
The original attachment 164761 [details] in Word and Writer nightly

The original also looks good. Except for the 
1.2	[Sample Heading 2] 
breaking to a new page in Word but not in Writer - but this is a separate issue.
Comment 19 NISZ LibreOffice Team 2021-07-20 14:46:13 UTC
(In reply to NISZ LibreOffice Team from comment #17)
> Created attachment 173506 [details]
> The minimal docx in Word, Writer 7.1 and 7.3alpha
> 
> Minimized attachment 171368 [details] looks good now on open in:
> 
> Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
> Build ID: 0fc020fb73c86a20608e8dff12af607e60327379
> CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL:
> win
> Locale: hu-HU (hu_HU); UI: hu-HU
> Calc: CL
> 
> Not yet in bibisect-win64-7.3 from two weeks ago so can't pinpoint the exact
> change yet.

Fixed by 
https://git.libreoffice.org/core/+/3e09e0784ad7669d3e0a7655f5e604a2387b1b5d

tdf#141966 writerfilter CN: fix chapter number identification
Comment 20 NISZ LibreOffice Team 2021-08-05 11:54:39 UTC
Verified in: 

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: ad1b12686da88bea57582df10fa85268ada209b8
CPU threads: 4; OS: Windows 10.0 Build 17134; UI render: default; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: threaded