[Solved] Make header/footer read-only

Java, C++, C#, Delphi... - Using the UNO bridges
Locked
Samuel
Posts: 9
Joined: Fri Mar 21, 2025 8:51 am

[Solved] Make header/footer read-only

Post by Samuel »

[Solved] Hi i am able to create header/footer through java but i am not able to make it read-only. Is there any method or libraries for the same?
Last edited by robleyd on Tue Mar 25, 2025 4:26 am, edited 3 times in total.
OpenOffice 4.1.15 on Windows11
User avatar
Hagar Delest
Moderator
Posts: 33350
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Is there anyway to make the header/footer read-only?

Post by Hagar Delest »

Not that I know of, directly.
Not tested: you can try to insert a section in the header/footer and protect it.

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the button if your issue has been fixed.
LibreOffice 25.2 on Linux Mint Debian Edition (LMDE Faye) and 24.8 portable on Windows 11.
User avatar
keme
Volunteer
Posts: 3775
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Is there anyway to make the header/footer read-only?

Post by keme »

Another untested strategy, if Hagar's suggestion does not help you:
It may be possible to protect the entire document, but have an inserted section which is editable.

I don't know how to do either programmatically, though. Hopefully you'll find out.
JeJe
Volunteer
Posts: 3064
Joined: Wed Mar 09, 2016 2:40 pm

Re: Is there anyway to make the header/footer read-only?

Post by JeJe »

With a mousehandler and keyhandler you can intercept mouse and key presses and prevent their action eg by testing to see if the text has the ImplementationName SwXHeadFootText.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Lupp
Volunteer
Posts: 3693
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Is there anyway to make the header/footer read-only?

Post by Lupp »

There is a different approach. See attached example. I made it with LibO 25.2.1. In AOO menu paths and setting dialogs are different, but you will easily find what you need.
aoo112635_ProtectHeaderFooter.odt
(12.81 KiB) Downloaded 45 times
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Samuel
Posts: 9
Joined: Fri Mar 21, 2025 8:51 am

Re: Is there anyway to make the header/footer read-only?

Post by Samuel »

ThankYou guys for the replies, was able to make it read only by adding the header/footer in a text section and used isProtected property to protect it and prevent editing.
OpenOffice 4.1.15 on Windows11
JeJe
Volunteer
Posts: 3064
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Is there anyway to make the header/footer read-only?

Post by JeJe »

As a cosmetic enhancement you could add, on each page, a form controls label anchored to the page, with blank text so it is invisible (so long as the form controls design mode is off). Using the label to cover from the bottom of the header to the top of the page and extending it to the page edges you can stop clicking in the header to edit it.

Edit: and also, if you wanted, the blank label is a method of adding a tooltip for where it covers.
Attachments
stop clicking in heading.odt
(9.19 KiB) Downloaded 17 times
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Locked