Header locked Within but cannot lock Header itself

Hi, I’m facing an issue on managing user restriction for action on a document.
This issue seems to be specific to LibreOffice as it’s about a pop-up menu on the header that apparently only exists on LibreOffice.
I’ve found topics on the pop-up menu on the forum, but in most cases it was about the pros and cons of this element. Not really matching the question related to my context.

About the context:
I’ve got a custom Header that is injected into a header section that is locked by password to avoid any user modification (or deletion).
It works well on that point when it’s about the section as the section is in “Read-only mode”.

The problem is that in LibreOffice, when the user select the header area, a pop-up menu is displayed (see attached image).
This menu allows the user to modify the header, and more problematical in my case to directly delete it!

So the user can easily delete the entire header whereas he’s not allowed to modify what’s inside.
I didn’t find for now any way to make this pop-up menu not displaying or to desactivate the sub-menu it contents to be sure that the user won’t do anything on the header (it’s kind the same for the footer by the way…)

Thanks in advance for any clue or solution for this issue…

Starting with version 6.2, it’s possible to disable that menu on Insert → Header and Footer → Use header/Footer menu.

Thanks for this answer…but this option is not related to the document but to the LO user configuration. So if the document is deployed on many computers, the option could be already set to On or off.

A check on a recorded macro way to switch the option on or off gives:

rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:UseHeaderFooterMenu", "", 0, Array()

But it’s a one way action that doesn’t check if the option is already set to On or Off.
So now I need to check for some code to do this in clean way.

No one else for any clue on this?