Oliver Brinzing schrieb:
Hi,
i have a problem with a XDispatchProviderInterceptor and menu entries
Scenario:
If a user changes to a sheet named "Tabelle2" i register a
XDispatchProviderInterceptor.
Now all GUI elements with URL "macro:///InterceptorDemo" should be
disabled.
I added entries for "OfficeMenuBar", "OfficeToolBar" and "OfficeHelp"
using a Addons.xcu.
Everything works fine so far. Changing to the sheet "Tabelle2" disables
the elements.
Changing to another sheet, enables the elements.
But if i remove the "OfficeToolBar" entry from the Addons.xcu, the menu
entries will
stay *disabled*, even if i change to another sheet ...
What i noticed:
- registering the interceptor does not call menu URL's
they are called only if one opens the menue ... only "OfficeToolBar"
are called at this time.
- opening a menu will call "com.sun.star.frame.XDispatch.addStatusListener"
**and** "com.sun.star.frame.XDispatch.removeStatusListener" ...
this does not happen for "OfficeToolBar" elements...
public void addStatusListener(XStatusListener xControl, URL aURL) {
aListenerHelper.addListener(xFrame, xControl, aURL.Complete);
aListenerHelper.notify(xFrame, aURL, false);
}
public void removeStatusListener(XStatusListener xControl, URL aURL) {
// why is removeStatusListener called for menu entries on open ???
if (interceptor.isDispatchRegistered() == true)
return;
aListenerHelper.notify(xFrame, aURL, true);
aListenerHelper.removeListener(xFrame, xControl, aURL.Complete);
}
any hints are welcome ;-)
i can provide a ready to run example ...
Hi Oliver,
What you have found is an optimization for the menu implementation.
Status updates are not very cheap and the current states of the menu
entries are not visible to the user. The menu contains about 300 entries
and can have a significant performance impact for status updates.
Therefore we decided to retrieve the status on demand, means when the
menu gets opened by the user. The menu implementation uses add- and
removeStatusListener for every menu item to retrieve the status and
updates the state. This optimization is not possible for toolbars as
they are visible all the time. I don't think that this optimization can
have a negative impact on a correct implementation. It's just an
implementation detail. The status is retrieved on demand and not updated
whenever a state changed.
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]