[Attention: Libreoffice programmers] how can I incorporate a new code for Fields?

I have posted two threads:
(1)How To, in footer, insert formula, like NextPage = Page Number +1

and
(2) How to create and change a page style in a final document?

But I am yet to replicate how Mr. Samyn accomplished the task in the document! The matter is covered in How To, in footer, insert formula, like NextPage = Page Number +1. I would definitely need some guidance for changing the styles in a ready document.

I have mentioned the issue in detail there. If I write a legal booklet or an legal article, I need to write at the beginning of the pages: continued from Page "Previous Page"and at the bottom of the pages : Continued on Page Number "Next Page" , the ones within “” means Fields that are under Insert menu.

This serves the work generally for all pages except First Page (The field is null, as Previous Page is undefined] and End Page [the field is null, Next Page is undefined].

So please help me with building a Field Object, with codes, with if-then–elseif to acheive this objective: Like when the Previous Page is undefined The entire Header would be “null” and when the Next Page field is undefined, the entire footer would be “null”.

How can I do this? Please help me, I implore you.

https://wiki.documentfoundation.org/Development/GetInvolved

Could you afford a little elaboration please?