[LibreOffice] [Writer] Get/Set state of a Check-SubMenu

Creating a macro - Writing a Script - Using the API

[LibreOffice] [Writer] Get/Set state of a Check-SubMenu

Postby BenDev » Wed Jun 12, 2019 12:22 pm

Hi,

I'm trying to find a way to check the state of a check sub-Menu and to force the state of this sub-menu to Off if needed depending to the actual state.

The concerned Sub-Menu is this one (see the attached image) :
"Main Menu" / "Insertion" / "Header and Footer" / "Use Header/Footer Menu"

The equivalent path with commandURL is:
"private:resource/menubar/menubar" / ".uno:InsertMenu" / ".uno:InsertHeaderFooterMenu" / ".uno:UseHeaderFooterMenu"

I'm able to reach the check Sub-Menu from its properties (see the debug console log on attached image).
So I thought I could check the state of the Sub-Menu and then Set it to Off if needed.
Sadly, the state checked/unchecked of the Sub-Menu seems to be not accessible from those properties...

So I wonder how should I do this, as for now I'm not able to retrieve this sub-menu as a awt-XMenu Object, and so be able to manage some of its properties...
Attachments
CheckSubMenuProperties.png
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [LibreOffice] [Writer] Get/Set state of a Check-SubMenu

Postby JeJe » Thu Jun 13, 2019 12:00 am

Have you tried calling .uno:UseHeaderFooterMenu with the Dispatch Helper?
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 519
Joined: Wed Mar 09, 2016 2:40 pm

Re: [LibreOffice] [Writer] Get/Set state of a Check-SubMenu

Postby BenDev » Thu Jun 13, 2019 10:01 am

@Jeje:

Thanks for your proposition.
I had already found this as a solution to simulate a click on the concerned Sub-Menu:

Code: Select all   Expand viewCollapse view
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
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.
In my case I need to set it to Off.

I've been searching for an argument that I could add for the executeDispatch to specify that the option should be turned to off.
But as oBasic documentation is a real labyrinth that turn sometimes to a real headache, I found the Command URL's page ( https://wiki.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands ), but nothing about the parameters that are needed for the ones that require parameters...

So I tried some attemps by my own in case of luck like:

Code: Select all   Expand viewCollapse view
dim argsAttempt(0) as new com.sun.star.beans.PropertyValue
argsAttempt(0).Name = "Activation"
argsAttempt(0).Value = false
dispatcher.executeDispatch(document, ".uno:UseHeaderFooterMenu", "", 0, argsAttempt())


But it's not appropriate properies...
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm

Re: [LibreOffice] [Writer] Get/Set state of a Check-SubMenu

Postby JeJe » Thu Jun 13, 2019 11:49 am

Its a new feature that's not in my version of LO. Here's a page about it:

https://bugs.documentfoundation.org/sho ... ?id=118621
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 519
Joined: Wed Mar 09, 2016 2:40 pm

Re: [LibreOffice] [Writer] Get/Set state of a Check-SubMenu

Postby BenDev » Thu Jun 13, 2019 1:57 pm

I saw this , yeah.
The Option to disable floating header/footer menu is available since 6.2.0.

My need is to force it to be at Off state.
Because I need the user not to be able to delete the header.
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 38
Joined: Sat May 18, 2019 3:32 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests