How to get #pages in a chapter (e.g. #pages using a Page Style)?

I have a document with several "chapter"s. Each “chapter” uses its own Page Style, with it’s own footer, and restarts page numbering at 1 on the first page (specified in the manual Break which switches to the next chapter’s Page Style).

How can I put the total number of pages in the current chapter in the footer (e.g.“Page 1 of 17” where there are 17 pages in the current chapter)?

Note that Insert->Field->Page Count (or Insert->Field->Statistics… Pages/AsPageStyle) inserts the total number of pages in the whole document, not the number of pages which use the current Page Style.

Right now there is no way of doing that automatically. A workaround is to define a variable and cross reference it in the footer, to then manually redefine it at the beginning of each chapter assigning to that variable the number of pages of that chapter. See this article for a detailed explanation of this workaround: Writer: An Extreme Example of “Variables” Use

See my answer in question Writer: Section page count in footer?

It provides a fully automatic solution without the need of manually setting a variable.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!