Page 1 of 1

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

Posted: Wed Jun 12, 2019 12:22 pm
by BenDev
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...

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

Posted: Thu Jun 13, 2019 12:00 am
by JeJe
Have you tried calling .uno:UseHeaderFooterMenu with the Dispatch Helper?

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

Posted: Thu Jun 13, 2019 10:01 am
by BenDev
@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

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/Framew ... 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

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...

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

Posted: Thu Jun 13, 2019 11:49 am
by JeJe
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

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

Posted: Thu Jun 13, 2019 1:57 pm
by BenDev
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.

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

Posted: Thu Aug 01, 2019 4:24 pm
by Pashahasband
Hi, I have the same task, did you find a solution?

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

Posted: Fri Aug 02, 2019 8:50 am
by Pashahasband
Hi, it turned off through
Reference <XModel> xModelView (xTextDocument, UNO_QUERY);
Reference <XViewSettingsSupplier> xViewSettings (xModelView-> getCurrentController (), UNO_QUERY);
Reference <XPropertySet> propView = xViewSettings-> getViewSettings ();
propView-> setPropertyValue ("UseHeaderFooterMenu", :: Any (sal_Bool (false)));

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

Posted: Fri Aug 02, 2019 2:02 pm
by Pashahasband
We also managed to hide the menu item for the UseHeaderFooterMenu command, but you can also delete the header and footer through their default setting. Do not prompt the menu command in insert "Header and Footer"?

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

Posted: Thu Aug 08, 2019 10:54 am
by BenDev
Pashahasband wrote:Hi, it turned off through
Reference <XModel> xModelView (xTextDocument, UNO_QUERY);
Reference <XViewSettingsSupplier> xViewSettings (xModelView-> getCurrentController (), UNO_QUERY);
Reference <XPropertySet> propView = xViewSettings-> getViewSettings ();
propView-> setPropertyValue ("UseHeaderFooterMenu", :: Any (sal_Bool (false)));

Hello,
Could you be more specific on this code?
Is this used in basic (as basic doesn't accept this syntax), or JavaScript, BeanShell or python?

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

Posted: Thu Aug 08, 2019 10:59 am
by Pashahasband
Hi, I used this in .cpp, but I think you can make an analogy in any other. The main thing is to turn to XViewSettingsSupplier.

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

Posted: Fri Aug 09, 2019 2:10 pm
by hubert lambert
Hi,

With the help of Pashahasband:

Code: Select all

    doc = thiscomponent
    vs = doc.CurrentController.ViewSettings
    vs.UseHeaderFooterMenu = False
Regards.

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

Posted: Mon Aug 19, 2019 2:50 pm
by BenDev
@hubert lambert:Thanks a lot!

Well at first, I thought there would be something that easy, but my researchs brought me somewhere else with very more complex solution point of vue :shock: .

Since I'm working on LibreOffice and OpenOffice, I've found that the documentation was really dispersed and I found a little difficult to get concrete examples apart from the forums...

For example, in this case, here is the documentation I found for the use of the ViewSettings Service:
https://www.openoffice.org/api/docs/com ... tings.html

It doesn't really identify "UseHeaderFooterMenu " as an element or a Properties we can directly set from code.
Not sure that we can get this information from the use of xray or MRI?

So for example, where or how did you get the information of the direct use of UseHeaderFooterMenu as a property of ViewSettings?