lijian wrote:

> Hi all,
> 
> I know that with some special conditions, some menus will be disabled and 
> turn grey.
> But when I select any anchor object, text frame for example, all the 
> textshell related menus
> such as insert-bookmark/footnot/symbols... will be disabled.
> 
> Could anybody give me help on this problem ? I wonder how this is achieved.

This is the SFX "shell" feature.

All commands in toolbars, menus etc. are called "Slots" in sfx2. An
object that is able to execute commands or give status information about
it (enabled/disabled or on/off etc.) is called a "Shell". Each View
managed by sfx2 has an object called "Dispatcher" that maintains a stack
of Shell objects. The Dispatcher has a partner called "Bindings" that is
a contact object for UI controls where they can register to get a
handler for the slot they represent. The Bindings object uses its
Dispatcher to find such handlers, ask them for status information or to
execute a command.

When the Dispatchcer searches a shell that supports a particular slot,
it goes through its stack of shells and takes the first one that
declares itself able to handle this slot. By pushing and popping
different shells on or from the stack, the application can create
different UI contexts that automatically enable or disable slots
(commands) depending on the selection.

As an example, when Writer is in text editing mode, the stack looks as
follows:

TextShell
ViewShell
ViewFrame
ObjectShell
Module
Application

So each time sfx looks for a "slot server" it first will check the
TextShell, then the ViewShell etc.

When now a graphic is selected, the TextShell is popped from the stack
and a GraphicShell is pushed, making the stack look

GraphicShell
ViewShell
ViewFrame
ObjectShell
Module
Application

So suddenly all slots only handled by a TextShell won't be found on the
stack and in that case the Bindings object will send a "Disabled" status
to its registered controls. OTOH, new slots are being found now and the
related controls now will switch to an "enabled" state.

You can read more about that here:

http://wiki.services.openoffice.org/wiki/Framework/Article/Implementation_of_the_Dispatch_API_In_SFX2

Best regards,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "nospamfor...@gmx.de".
I use it for the OOo lists and only rarely read other mails sent to it.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@sw.openoffice.org
For additional commands, e-mail: dev-h...@sw.openoffice.org

Reply via email to