Bug 133145 - FILEOPEN DOC: Endnotes not at end of document
Summary: FILEOPEN DOC: Endnotes not at end of document
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: high normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:7.1.0 target:7.0.0.1 target:6.4.6
Keywords: bibisected, bisected, filter:doc, regression
Depends on:
Blocks:
 
Reported: 2020-05-18 10:19 UTC by Karsten Decker
Modified: 2020-06-17 12:01 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file (8.42 KB, application/vnd.oasis.opendocument.text)
2020-05-21 07:58 UTC, Telesto
Details
Proper example file (8.86 KB, application/vnd.oasis.opendocument.text)
2020-06-03 15:46 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Decker 2020-05-18 10:19:19 UTC
Description:
Hi, I wrote a book of about 300 pages containing several pictures and about 50 endnotes. I had saved it as .doc (word format) because I will need to convert it later to epub, mobi and pdf Format. Anyway, after opening it today I first thought all my endnotes were gone, but then I noticed that they are suddenly all over the place on different pages (However, not like foodnotes on the page the anker is placed). Trying to reformat them as Endnotes did not help, even deleting the first one with ctrl x and then inserting a new endnote die not help. However, now Writer  crashed twice while opening the file and saving it. 

Steps to Reproduce:
1.insert endnote
2.right click in endnote and use foodnote/endnote to change
3.delete wrong endnote with ctrl x and insert again as endnote

Actual Results:
When I try to change endnotes or foodnotes using any of the thre steps they are placed on all kind of pages, like foodnotes, but not on the right page and not in order (at least the recreatesd endnote "1" is after endnote 32, then about 5 or 6 lines of Text, then endnote 33 -42document

Expected Results:
Have all endnotes on the last pages in right order


Reproducible: Always


User Profile Reset: No



Additional Info:
In Openoffice 4.1.3 I can open the saved document correctly.
Comment 1 Telesto 2020-05-18 21:52:24 UTC
An example file including steps to reproduce would be nice to have
Comment 2 Dieter 2020-05-20 09:34:10 UTC
(In reply to Telesto from comment #1)
> An example file including steps to reproduce would be nice to have

I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
Comment 3 Telesto 2020-05-21 07:58:31 UTC
Created attachment 161061 [details]
Example file
Comment 4 Telesto 2020-05-21 08:00:36 UTC
STR
1. Open the attached file
2. Save as DOC
3. File reload

Endnote look like footnotes


not in
4.3.7.2
Comment 5 Telesto 2020-05-21 09:24:02 UTC
Bisected to:
tdf#124601 sw: add ContinuousEndnotes layout compat option
Writer has two cases for laying out endnotes: either they are at the end
of the section or are on a separate endnote page at the end of the
document.

Word always puts endnotes as continuous content at the end of the
document, not on a separate page.

Given that this continuous / separate page behavior difference seems to
be not part of the ODF or OOXML file format and neither UI allows to
configure this, the best way to resolve this looks like a new layout
compat option.

At a layout level, the "endnotes at the end of the section" code is
close to what we need, we just need to make sure that:

1) Endnotes are never moved backwards, even if their reference moves
back.

2) When appending an endnote, they should go to the footnote container
on the last page, not close to their reference.

With this, the page number in Word and Writer now match for the bugdoc.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=4814e8caa5f06c4fe438dfd7d7315e4a2410ea18

~/win64-6.4
$ git bisect good f0d625e87e083783f9495e007ea69704ac5f3464 is the first bad commit
commit f0d625e87e083783f9495e007ea69704ac5f3464
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Mon Sep 30 13:51:06 2019 -0700

    source 4814e8caa5f06c4fe438dfd7d7315e4a2410ea18

    source 4814e8caa5f06c4fe438dfd7d7315e4a2410ea18

:040000 040000 5f81ebdc97dc109fef6a70cf719a9b5f46002047 b39bbf45e3d61deb81000b436cb120233c01030e M      instdir
Comment 6 Telesto 2020-05-21 09:25:17 UTC
Adding cc to Miklos Vajna
Comment 7 Miklos Vajna 2020-06-03 15:16:50 UTC
This seems to be working as intended. Word only supports endnotes at the end of the document (continuously, not on a separate page), so we turn on that layout compat flag when opening DOC files. Once you save to a Word format and you reopen the document, Writer will do its best to layout the doc the same way as Word does.

One thing we can do is to add UI for this flag, so if you open your DOC file and you don't like the Word layout, then disabling the ContinuousEndnotes mode is possible via tools -> options -> writer -> compatibility.
Comment 8 Telesto 2020-06-03 15:46:22 UTC
Created attachment 161582 [details]
Proper example file
Comment 9 Telesto 2020-06-03 15:50:15 UTC
(In reply to Miklos Vajna from comment #7)
> This seems to be working as intended. Word only supports endnotes at the end
> of the document (continuously, not on a separate page), so we turn on that
> layout compat flag when opening DOC files. Once you save to a Word format
> and you reopen the document, Writer will do its best to layout the doc the
> same way as Word does.
> 
> One thing we can do is to add UI for this flag, so if you open your DOC file
> and you don't like the Word layout, then disabling the ContinuousEndnotes
> mode is possible via tools -> options -> writer -> compatibility.

Lets add a proper example file.. demonstrating the issue

1. Open ODT 
2. Export to DOC -> File & Reload (file opens wrongly in LibO, but fine fine in Word 2003)
Comment 10 Miklos Vajna 2020-06-04 17:06:19 UTC
I can now reproduce the problem with the above sample.
Comment 11 Commit Notification 2020-06-16 07:03:30 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/35bb0594b2d977312ef06fc5262cc7592bc13d0f

tdf#133145 sw ContinuousEndnotes: fix moving endnotes to a previous page

It will be available in 7.1.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 12 Commit Notification 2020-06-16 11:21:03 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/b67ee7ed04fb081c21205ada72c0843af92de28c

tdf#133145 sw ContinuousEndnotes: fix moving endnotes to a previous page

It will be available in 7.0.0.1.

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 13 Commit Notification 2020-06-17 12:01:16 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/7caa0003b0dc71ed676cc8fa84585c49f8ac5031

tdf#133145 sw ContinuousEndnotes: fix moving endnotes to a previous page

It will be available in 6.4.6.

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.