Created attachment 149780 [details]
A sample with endnotes at the section's end and wrong chapter field
When a chapter is enclosed into a section, *and* the section has endnotes collected at the end of that section, *and* the endnotes flow to a new page, *and* that new page has a header with Chapter field in it, then the Chapter field on that page which is started with a section's endnotes shows wrong chapter information.
Steps to reproduce:
1. Create a new text document.
2. Add a header to the used page style (i.e., "Default Style" in pristine configuration).
3. Add Chapter field to the header, displaying Chapter Name of level 1.
4. In the page body, type "FirstHeading" and apply Heading 1 paragraph style.
5. Add some chapter text.
6. Add a new paragraph with text "SecondHeading" and Heading 1 style.
7. Add second chapter text enough to see that it flows to a next page, and it's clear that the next page's header shows "SecondHeading" in the Chapter field.
8. Select "SecondHeading" and the following chapter, and add a section; in the section properties, make sure to collect endnotes at the end of section.
9. Add some endnotes to the second chapter text (now in section), so that endnotes (also in that section) start to flow to a new page.
Expected: the new page starting with the rest of second chapter's endnotes should have "SecondHeading" in the header.
Actual: that page has "FirstHeading" in the header.
I confirm it with the provided document. I also deleted field in header ad added it again - same result
Version: 188.8.131.52.alpha1+ (x64)
Build ID: e92dcfdc7bd7b237e0bee26ff226a102d9e8e766
CPU threads: 4; OS: Windows 10.0; UI render: GL; VCL: win;
TinderBox: Win-x86_64@42, Branch:master, Time: 2019-05-14_00:00:57
Locale: en-US (de_DE); UI-Language: en-US
*** Bug 127264 has been marked as a duplicate of this bug. ***
The *Heading 1* doesn't need to be enclosed in the section. The structure:
-- start of section
section contents without *Heading n*
-- end of section
also exhibits the bug.
User AJB49 mentions the bug already exists in LO 4.1.6. So, this is a long standing bug.