Bug 144599 - Page count before an endnote marker shows wrong number of pages
Summary: Page count before an endnote marker shows wrong number of pages
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Footnote-Endnote Fields-Page-Count
  Show dependency treegraph
 
Reported: 2021-09-19 01:16 UTC by John
Modified: 2023-01-03 10:22 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
test file (11.61 KB, application/vnd.oasis.opendocument.text)
2021-09-19 20:00 UTC, John
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John 2021-09-19 01:16:47 UTC
Description:
Start Writer and create a new document from the default template.

Insert a page count field (Insert > Field > Page Count).

Notice the field shows 1.

Below this field, type "foo" followed by an endnote (Insert > Footnote and Endnote > Endnote).

Type some text for the endnote itself (for example, "bar").

Return to your "foo". Notice that you have 2 pages now, but the page count field above "foo" still shows 1.

Below "foo", insert another page count field. Notice it shows 2.

So in other words here is what you will end up

```
1
foo<superscript i>
2
```

This is bad. Both counters should update automatically.

Press F9 to update all fields. Now you have 

```
2
foo<superscript i>
2
```

You may think pressing F9 resolves the issue partly, but actually it doesn't. For example, save this document and close it. Then open it again. Bam! You have

```
1
foo<superscript i>
2
```

again.

----------------------------

The real life case:

I have a template for technical writing with the following protected section in the very beginning of the first page:

```
document title:
<here is the field for title>

page count:
<here is the field for page count>

aggigned template:
<here is the field for assigned template>
```

Each time I open a document with endnotes, the page count field shows me the wrong number of pages.

Steps to Reproduce:
see above

Actual Results:
see above

Expected Results:
see above


Reproducible: Always


User Profile Reset: No



Additional Info:
see above
Comment 1 [REDACTED] 2021-09-19 16:26:33 UTC
Confirmed on LibO 7.2.0.4 https://gerrit.libreoffice.org/gitweb?p=core.git;a=log;h=ce769e3009755dcf0082844e386f5dca4c8ecb2f in Ubuntu Linux 20. The page count field updates automatically when you add pages in the "normal" area, but not when you add an endnotes section. You have to do Tools - Update - Fields (or F9) to force the page count to update in some other way. Once updated, it will automatically update when you add so many endnotes that the text wraps to a second endnotes page. 

I'm not sure if this would count as a bug. I don't know how much auto-updating for such cases would cost in terms of time spent checking if the page count needs to be updated. Not auto-updating the ToC makes sense to me - it'd probably mean that Writer would have to check at virtually every new paragraph whether it's a paragraph that has to be added to the ToC. But it's definitely something that may give some users a headache. Do we want that?
Comment 2 John 2021-09-19 18:45:48 UTC
> I'm not sure if this would count as a bug. [...]

The main problem is that even if you update a field by pressing F9 and save your document, the field will revert to its un-updated state once you open the document again.

There is no such an issue with ToC. Once you updated it, you can safely close the document and open it again. Updating ToC is boring at times, but it works reliably and predictabely.

In case of page count the issue is different and is much worse.
Comment 3 [REDACTED] 2021-09-19 19:48:24 UTC Comment hidden (obsolete)
Comment 4 John 2021-09-19 20:00:00 UTC
Created attachment 175126 [details]
test file
Comment 5 John 2021-09-19 20:03:13 UTC
(In reply to Peter Roelofsen from comment #3)

No, I save it as ODT.

I have just attached a test file. I hope with the test file it will be easier to understand what I mean.
Comment 6 ajlittoz 2021-09-20 07:31:16 UTC
Confirmed with 7.1.6.2 under Fedora Linux 34

When I reopen the test file (.odt) the first page count is wrong, the second one is correct.

I wouldn't mind manually updating the fields (as I usually do) as long as the restored values (when opening the file) are consistent.
Comment 7 John 2021-09-25 21:00:05 UTC Comment hidden (obsolete)
Comment 8 Timur 2022-06-10 13:45:54 UTC
That Page Count doesn't update on insert doesn't seem like a bug. It would be resource intensive.  
But that Page Count opens wrong after F9 and save and close, seems like a bug.
Comment 9 Stéphane Guillou (stragu) 2023-01-03 10:22:57 UTC
Repro in recent master build:

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: ef3b7b7118c854d8ca67cc2249b6c08ddc1885eb
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded