Template based style management - page styles not really inheriting, .odt from .ott

Writer 25.2.7.latest

Document editorial method used
Style-based document formatting, however only paragraphs, characters and pages.
Template-based style management and maintenance.

Problem encountered
For some page style its definition deviates template versus document.
Next style attribute of objective page style in template is different than same page style in document.
Neither menu Styles > Load Styles from Template… nor Reloading whole document helps to fix.

DeepWiKi Devin points to following line in source code

cit.:

The issue is in the base LoadStyles implementation where page style follow relationships are incorrectly copied. When loading styles from a template, the code calls GetParent() instead of
GetFollow() objcont.cxx:431-435 :

if(pFound[i].pSource->HasFollowSupport())  
    pFound[i].pDest->SetFollow(pFound[i].pSource->GetParent()); // BUG: Should be GetFollow()

This causes page styles to lose their “Next style” relationship when loaded from templates.

Is it really the reason of problem myself observes?

I want to manage my styles (paragraph, character, page) in template to avoid manual management.
Myself not lucky on finding matching topic here on AskLO, nor in bugs.documentfoundation.org.

Short test of the link: ‘document template to document’ completed with passed >>> Test-wise one paragraph style got a slight modification; template modification stored to disk; document Reload detects template modification yet subsequent examination of paragraph modified in template reveals presence of modification in document.

EDIT
Whaala, conducted test of template-document link helped to have desired state: page style in focus is in-sync template versus document; problem healed.

I wish page style inheritance be working document template to document so I don’t need to apply in end-effect costly workarounds with success not guaranteed. In template the paragraph style determines page style - it does that by means of page break as paragraph style attribute. In document the page first paragraph uses that paragraph style. Any idea if found mistake in LoadStyles method is true root cause of problem observed?

Manual loading page styles from template to document did not help.
Also document reload did not although in general the link between document and template works fine.

Next problem is that while recent test mentioned in question did heal the problem (unclear is the persistence of this effect) the sidebar, the tab Page Styles indicates Default Page Style although the page very first paragraph uses paragraph style where the page break attribute links to custom page style. I learned that only paragraph (either per direct formatting or via use of a style) or manual page break can determine which page style is used. Page has no manual break but page style setting in paragraph style (page first paragraph) is not effective (according to side bar, the page styles tab).
Only when i set the desired page style by means of paragraph direct formatting (page’s first paragraph) the desired page style is effectively used (indications in side bar page styles tab as well as in the page header/footer markers). What’s going on?
003.odt (12.2 KB)

It is not a matter of inheritance.
<br<You want to start your document with non default page style. This can be done only by adding a manual page break.

  1. put the cursor to the very beginning of your text
  2. hit Enter to create an empty paragraph at top; go into this empty paragraph
  3. style it Body Text (to eliminate Appendix MstA styling)
  4. Insert>More Breaks>Manual Break to force Appendix page style

Check now that all your pages in the sample have switched to Appendix. You can delete the starting empty paragraph and its page break.


Why does it work and your sample does not work?

The very first paragraph in a document is “special”. If its paragraph style contains a forced page break, this break is ineffective because Writer knows it is already at start of page. Consequently a manual break must be explicitly inserted to change the page style. When you remove it, Writer does not revert to Default Page Style because it notices that Appendix MstA requests the same page style.


Quite weird, but that’s the current implementation.

Alternatively, you could apply Appendix page style manually on the first page. But this is direct formatting and I don’t know how “persistent” it remains (EDIT: this remark is intended to draw your attention on the hazards related to DF; a sophisticated document should contain as few DF as possible to avoid issues when editing).


When you suspect a problem between a template and a file, attach both so that we can check the problem is or not in the template.

Thanks for input. That’s interesting because other .odt’s with regular chapters present results equal to my expectation - yet I can’t see manual page break be opening those documents.
Nor the style inspector nor Styles sidebar spothlight indicate paragraph direct formatting; yet style modification conducted in template for a test gets transported properly to linked document. I don’t remember to have applied your trick once.

According to sources I used so far direct formatting features high persistence however it has also its shadow sides.

Thanks for workaround proposal. Test done. It sufficed to conduct steps 1 to 3, subsequently to remove blank paragraph added in course of this workaround. You may mean the persistence of this form is unclear.