Apache OpenOffice (AOO) Bugzilla – Issue 75809
API functionality loss (menu items disabling)
Last modified: 2013-02-24 21:10:03 UTC
I have failed to determine which subcomponent I had to choose correctly... How to reproduce bug (I think it is bug): 1. Start Writer; 2. Add this macro to Standard basic library: sub tweakMenu() on error goto ErrH dim xMenu as object xMenu = ThisComponent.getCurrentController.getFrame.LayoutManager.getElement("private:resource/menubar/menubar").XMenuBar xMenu.enableItem(xMenu.getItemId(1), false) xMenu.enableItem(xMenu.getItemId(2), false) exit sub ErrH: msgbox error end sub 3. To run macro you can create toolbar button or use other available methods; 4. Run macro and observe main menu items become grey (color of inactivity); 5. Select these "inactive" menu items or any other main menu items; 6. Watch as "inactive" items become active. In OOO 2.0.3 all worked as it should, only in OOO 2.1 I detected such behaviour. OS: Windows 2000, service pack 5.0
sher1, please provide the file with the macro - after copying and pasting I can't get it to do anything with top-level menu (I have set it to run via hot-key). Tested with 2.2RC2 on WinXP. Thanks.
I've added .odt file which contains macro Standard.Module1.tweakMenu. 1. Start Writer; 2. Open this file (with option "enable macros"); 3. Select menu item "Tools->Macros->Run Macro..."; 4. In the dialog find and select the macro and click button "Run"; 5. You should observe behaviour mentioned previously. Tested with 2.2RC2 on Win2K SP5.0.
Created attachment 44008 [details] File with
Addition to previous attachment: Desired file with macro.
cd->sher1: WARNING: The XMenuBar property at the ui element "menubar" is not documented in the IDL description and an implementation detail. You are not allowed to use it to make any changes!! Ignoring this warning can lead to crashes and inconsistent menu item states. Your example cannot work as the state of the OpenOffice.org menu bar is highly dynamic. The state "enabled/disabled" you have changed by your code will be overwritten by the application module. If you want to disable a function you should use the "Disable commands feature" which is described in detail in the Developer's Guide, see chapter 4.7.4 Disable Commands.
cd, I have tried with OO 2.0.4 on Suse 10.2 and macro disabled menu items. It does not with 2.2, so behavior has changed.
jsc -> cd: can you please comment and then fix or close the issue
.
cd: Using the XMenu/XMenuBar interfaces on the OpenOffice.org menu bar is not allowed and will not be supported. May be it can work for some people, but using this API is strongly discouraged and can lead to crashes! cd: Therefore I set this issue to closed now.