Issue 75809 - API functionality loss (menu items disabling)
Summary: API functionality loss (menu items disabling)
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows 2000
: P3 Trivial
Target Milestone: ---
Assignee: carsten.driesner
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-28 09:18 UTC by sher1
Modified: 2013-02-24 21:10 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
File with (7.50 KB, text/plain)
2007-03-29 08:30 UTC, sher1
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description sher1 2007-03-28 09:18:57 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
Comment 1 kpalagin 2007-03-29 04:54:08 UTC
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.
Comment 2 sher1 2007-03-29 08:29:31 UTC
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.
Comment 3 sher1 2007-03-29 08:30:32 UTC
Created attachment 44008 [details]
File with
Comment 4 sher1 2007-03-29 08:31:52 UTC
Addition to previous attachment:

Desired file with macro.
Comment 5 carsten.driesner 2007-03-29 13:31:18 UTC
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.
Comment 6 kpalagin 2007-03-29 13:49:25 UTC
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.
Comment 7 jsc 2007-04-27 12:33:06 UTC
jsc -> cd: can you please comment and then fix or close the issue
Comment 8 jsc 2007-04-27 12:35:05 UTC
.
Comment 9 carsten.driesner 2007-04-27 15:00:06 UTC
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.