Show field variable in header from first setter on page


I’ve got a simple document with a header in which I show the content of a field variable named ‘guideword’. Then I add some headlines and paragraphs to the body. On each headline I also set the variable ‘guideword’ to the name of the headline itself because I always want to see it in the page header as well.

It seems the displayed value of the variable in the header is always the content set on the page before or from the same page if it was set on the very first paragraph.

Is it possible to always show the value of the variable that was first set on the same page instead of using the value from the page before? Or is there an other possibility regarding headlines or certain paragraphstyles which can be shown in the header when they appear on a page?

In the attachment you can find a simple example of my problem. All I want is to see “p2” in the header of page 3.

In reality the document is much more complex and is generated automatically, so it should not be edited manually. And because it gets generated automatically my first idea was to add the “variable setter” for “p2” to every paragraph before the real “paragraph 2” until the setter for “p1” was reached but then I also would see “p2” in the header of page 2 which would also be wrong.

It would also be possible to write a macro for that which can be executed after generating the document but I hope it can be solved with “normal” tools instead.

If you need more information or clarifications, please ask. Thanks!

This a strange behaviour of the header/footer generation. I have a bit different context (see this question) but the cause is the same.

I fiied a bug report as tdf#128041. A long discussion was needed to convince this is indeed a bug. Log in to bug site to add a comment in order to show other users than me are also affected by the bug. This could help to promote it in the fix (!) queue.

I am not sure my issue is a real bug. I am not working with conditional fields like you do but with simple variables. However I need to see the set value of a variable in the header if it was set on the same page. I do not want to see the value from the page before.

It is indeed the same thing: in my conditions I needed the value of a variable. However, I got the value seen first when the page style was first used to layout the page. Afterwards, when setting another page (after a page break or normal flow to a new page), the value of the variable was never recalculated. The page engine used the value capture on page style initialisation.

I may also have misunderstood your description, in which case your question is akin to the chapter numbering problem. Headers are computed when a new page is created. The state of fields (caution when the field requests a variable value, you may stumble on my bug) is captured as it is for the first paragraph of the page. If a heading change or variable change occurs beyond this first paragraph, it won’t be reported in the header.

The problem does not occur in the footer because the footer is formatted after the last paragraph has been set in the page. Thus, you always have accurate last values for the page.

OK, I took time to open your attached doc (which I didn’t at first, apologies). With my default page margins and default font, your P2 was at top of page 3 and header shows “P2”. I then increased top and bottom margin so that your P2 was not the first paragraph. Header then shows “P1”, as explained in my previous comment, because P1 was the current value when the page started.

You’re also right, you don’t suffer from my bug.

I’m afraid there is no solution. Writer was designed so that the header reflects the state of the first paragraph in the page. The header engine does not peek beyond this first paragraph. This causes subtle problems when referencing sub-chapter numbers. Changing the behaviour would cause even more problems (deferring composing the header would prevent to know how much room is left for text in the page), not speaking of performance.