Manipulating menus at runtime

View: New views
3 Messages — Rating Filter:   Alert me  

Manipulating menus at runtime

by Laurent Godard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all

I wrote an extension and now wants to enable/disable menu entries
dynamically at runtime both for my extension and legacy menu entries

Is there a way and could someone point me in the right direction
Any codesnippet in any language or some keywords and basic steps are
welcommed

Thanks in advance

Laurent



--
Laurent Godard <lgodard@...> - Ingénierie OpenOffice.org -
http://www.indesko.com
Nuxeo Enterprise Content Management >> http://www.nuxeo.com -
http://www.nuxeo.org
Livre "Programmation OpenOffice.org", Eyrolles 2004-2006

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Manipulating menus at runtime

by Laurent Godard-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi again

I answer myself as i found ;)

digging into the SDK, i found
ooo_sdk/examples/DevelopersGuide/OfficeDev/DisableCommands
and the java code is totally understandable

I had to adapt to my extension, but globaly, here is the code at the end
of this mail.
No need to restart

so thanks to carsten driesner for its code in the SDK

one thing i have to now find is the name of the Legacy menu entries. Is
it the .uno: names ?

Thanks again

Laurent

'-------------------------

sub test
   conf =
getConfigSetting("/org.openoffice.Office.Commands/Execute/Disabled" ,true)
   elem = conf.createInstanceWithArguments(array())
 
elem.setPropertyValue("Command","vnd.sun.star.script:Myextension.Module.action?language=Basic&location=application")
       
        conf.insertByName("action",elem)
        conf.commitChanges()
end sub

'--------------------------

function getConfigSetting(target as string, forUpdate as boolean)

        dim aParams(0) As new com.sun.star.beans.PropertyValue

        if forUpdate then
                service = "com.sun.star.configuration.ConfigurationUpdateAccess"
        else
                service = "com.sun.star.configuration.ConfigurationAccess"
        endif
       
        aConfigProvider = createUnoService(
"com.sun.star.configuration.ConfigurationProvider" )
        aParams(0).Name = "nodepath"
        aParams(0).Value = target
        aSettings = aConfigProvider.createInstanceWithArguments(service,
aParams() )
       
        getConfigSetting = aSettings

end function


--
Laurent Godard <lgodard@...> - Ingénierie OpenOffice.org -
http://www.indesko.com
Nuxeo Enterprise Content Management >> http://www.nuxeo.com -
http://www.nuxeo.org
Livre "Programmation OpenOffice.org", Eyrolles 2004-2006

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Parent Message unknown Re: Manipulating menus at runtime

by Carsten Driesner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Laurent Godard wrote:

> Hi again
>
> I answer myself as i found ;)
>
> digging into the SDK, i found
> ooo_sdk/examples/DevelopersGuide/OfficeDev/DisableCommands
> and the java code is totally understandable
>
> I had to adapt to my extension, but globaly, here is the code at the end
> of this mail.
> No need to restart
>
> so thanks to carsten driesner for its code in the SDK
>
> one thing i have to now find is the name of the Legacy menu entries. Is
> it the .uno: names ?

Hi Laurent,

I want to give you some more information about how you can achieve your
goal. Currently your solution with DisableCommands at runtime works for
menus only and this is just an implementation detail. There are no plans
to change the implementation for the OpenOffice.org menus so you are
safe for the next future. Be careful, this solution won't work if you
want to disable toolbar items! It looks like that many people need an
easy solution to disable entries at runtime. I think we should think
about an enhancement that DisableCommands works for every user interface
element. May be you can write me a "Request for enhancement".
A generic solution would be to use a dispatch interceptor which adds
your implementation into the dispatch chain. There you can manipulate
the state of commands as you like. You can find more information in the
Developer's Guide.
Most menu entries uses the .uno: scheme. A list of command URLs for menu
entries can be found here:
http://wiki.services.openoffice.org/wiki/Framework/Article/OpenOffice.org_2.x_Commands

Regards,
Carsten

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

LightInTheBox - Buy quality products at wholesale price!