Menus
Calc’s menus are organized in the xml file located in sc/uiconfig/scalc/menubar/menubar.xml. This file stores the hierarchy of the menu items and their corresponding dispatch command names. Each command name is prefixed with .uno: followed by a camel-cased command name that typically looks like this: .uno:InsertCell or .uno:ScenarioManager. When the user selects a menu item, the associated command gets dispatched.
These commands are associated with their menu strings in another xml file located in officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu, which gives the default menu string for en-US locale. Strings for other locales are given in the localize.sdf file located in the same directory as CalcCommands.xcu. For menus that are shared across all applications, such as Save As or Print, officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu has their command names.
When a command is dispatched by selecting a menu in Calc, it first goes to the framework code and eventually finds its way back into Calc’s core implementation code if the command is specific to Calc. But inside Calc’s core, the old slot ID mechanism is still used to handle events. The mapping is done in the sc/sdi/*.sdi files, where each dispatch command name is mapped to a preprocessed numerical slot ID that looks like FID_INS_CELL or SID_SCENARIOS.
Status Bar
Left double-click event
VCL’s StatusBar class, which is a child class of Window, initially intercepts mouse inputs, and its methods Click and DoubleClick get called for single- and double-click events, respectively. This StatusBar class has two handler member objects of type Link for each click type. The Link class (located in svtools module) simply calls a function whose pointer is stored within, which in the case of single- or double-click event is the Click or DoubleClick method of class StatusBarManager in the framework module, respectively. These methods then obtain an instance of the appropriate status bar controller of type css::frame::XStatusbarController and calls its method click or doubleClick depending upon the click type. The XStatusbarController interface is implemented by the ::svt::StatusbarController class in the svtools module, and there is one instance of this class for every status pane that handles double-click events. Interestingly, this class does not implement the click method (it’s an empty method), which essentially means that a single mouse click event on a status bar pane never triggers any event if that pane is designed to handle double-click events. The only page that handles single-click events is the selection mode status pane, but that pane is associated with a different class that implements css::frame::XStatusbarController (more on this later).
Once double-clicked, the statusbar controller instance calls execute to dispatch a command to the active application for it to handle. What command gets dispatched is specific to each pane; in Calc, the status bar contains 8 status panes, and the commands they dispatch upon double-click are, from left to right, .uno:StatusDocPos, .uno:StatusPageStyle, .uno:Zoom, .uno:InsertMode, .uno:StatusSelectionMode (this gets fired by single-click as mentioned earlier), .uno:ModifiedStatus, .uno:Signature, and the rightmost status pane dispatches .uno:Size command.
Single click event on selection mode status pane
As mentioned earlier, the selection mode status pane (one that toggles between ADD, EXT and STD) handles single-click events, but no double-click ones. The code path for this event handling is identical to that of double-click events described earlier, up to the point where it reaches the Click method of framework::StatusBarManager. There, it retrieves an instance of class SfxStatusBarControl which itself is a child class of svt::StatusbarController (hence exports the XStatusbarController interface). SfxStatusBarControl overwrites the virtual method click which gets called from the StatusBarManager, and that method calls the Click (virtual) method of SvxSelectionModeControl – a further child class of SfxStatusBarControl. This method then builds the command and finally calls the execute method of the super class svt::StatusbarController to dispatch the command to the application.
After the command gets dispatched
After the dispatch method of css::frame::XDispatch interface gets called to dispatch the command, it eventually makes its way into the application code.
First, the code path moves to SfxOfficeDispatch in sfx2 module which implements the XDispatch interface. It checks whether or not a controller item – an instance of class SfxControllerItem – exists. If it does, it calls the dispatch method of that controller item instance, which jumps to SfxDispatchController_Impl’s dispatch method.
After a couple more calls in the sfx2 module, it eventually reaches the execution method of one of Calc’s shell class instances. What command gets dispatched to what method of what class is described in another section. In short, the following associations exist:
.uno:StatusDocPosand.uno:StatusSelectionModego to ScCellShell::Execute.uno:StatusPageStyleand.uno:Zoomgo to ScTabViewShell::Execute
Right click event
When a status pane is right-clicked, FrameworkStatusBar::Command gets called, which then calls the method of the same name of class StatusBarManager. Both classes are in the framework module. (to be continued)
Image Button with Color Updater
Some image buttons on the toolbars have a horizontal strip whose color gets updated. One such example is the background color button. In Calc, for example, when the cell cursor moves to a cell with a different background color, it updates the color of the button strip with that of the new cell. Here is how it works.
First, when the cell cursor position changes, Calc calls ScTabView::CursorPosChanged which ultimately calls InvalidateAttribs of the same class. This method tells the SfxBindings instance to invalidate a whole bunch of attributes so that the framework can update changed attributes if needed. The background color attribute is among those who get invalidated via its ID SID_BACKGROUND_COLOR. This eventually puts an update request on the background color in queue.
When the time comes to update the color, it calls Calc’s ScFormatShell::GetAttrState to retrieve the background color of the current cell. This color information is stored as an instance of class Color from the tools module, which is then put into the SfxItemSet instance as SfxPoolItem by wrapping it inside SvxColorItem class. Eventually, the path reaches ToolboxButtonColorUpdater::Update method that takes care of updating the color of the button strip in the associated image button.
