Writer: header/footer, variables and conditional text

I want to design a “smart” footer to include varying information within a sequence of pages associated with the same page style.

In the main text flow, I insert here and there a field from Variables as type Set variable, Select flag (this is the name of the variable, always the same), Format Standard and value 0 or 1.

The footer is made of three paragraphs:

  • A “common” one with field Show variable flag Standard to echo the present value
  • The second begins with a field from Functions Type Hidden paragraph, Condition flag==0 and text “flag <> 0”
  • The third one is similar to the second but for condition flag==1 and text “flag <> 1”

Since I have View>Filed Names enabled and hidden text/paragraphs visible to debug my test document, I use print view to see the result.

The footer correctly displays the current value of the variable (the last set in the page), however hidden paragraph conditional seems to be computed only once with the value valid at the end of the first page.

My understanding of Writer behaviour is:

  • header/footer are computed first time they are needed and stored in a cache of the page style, i.e. at start of first page (header) and at bottom of first page (footer)
  • “simple” fields are kept as “insertion action”, like put current page number of current value of variable, including for cross-references
  • conditional and hidden text/para/section: the condition is evaluated and related text is inserted; condition is discarded, deemed no longer necessary because “right” text has been selected; consequently this part becomes “static” in the cache and is not recomputed on next pages

Since I can change the value of a variable in the running text, I’d like the header/footer conditional text to remain “dynamic” so that its contents reflects the current value of the variable, not the value it had when the page style was first switched.

Am I missing something? Is this a bug?


Adding a test file: HiddenParaTest.odt


Changed title because issue is specific to header/footer; clarified my understanding of the phenomenon

EDIT 2019-10-09

Filed bug tdf#128041

This must be a bug (but I imagine that fixing it would be a nightmare…).

Conditional paragraphs work fine in running text (respecting the cnanging value of "flag), but page headers and footers remain as when initially generated (i.e. according to the “flag” value at the first page break). This is probably not as intended (i.e. a bug)

@keme - this behaviour (as I describe it in the bug report) is inconsistent: variable fields (such as page number or chapter references) are correctly updated with the running value but the condition for hidden text/para/section is computed only once at generation time and the resulting text/para/section is kept in the cached header or footer.

If it is an implementation decision, it should be explicitly mentioned in the doc as a limitation. Without any caveat, I consider it indeed a bug and I filed the report. Now, when will it be fixed? And as @mikekaganski remarked, it might be a nightmare to fix. I never dug in the code personally.