Framework/Tutorial/Statusbar Controller

From Apache OpenOffice Wiki
< Framework
Revision as of 08:48, 19 February 2007 by Cd (Talk | contribs)

Jump to: navigation, search

This tutorial will give you a detailed overview of the OpenOffice.org status bar and how to create a status bar conbtroller. Everybody is invited to participate. May be someone wants to translate the extension to a different language (e.g. Java or Python) or wants to have more information about a specific topic. You can set a link to this page, if you think that this page adds valuable information. The outcome of this tutorial will be a language selection status bar controller where you can set the document

The reader of this tutorial should have the following programming skills


The OpenOffice.org status bar

The OpenOffice.org status bar is controlled by the frame based layout manager. Every frame contains a layout manager that controls the user interfaces elements (e.g. menu bar, status bar, toolbars). The layout manager identifies every user interface element via a unique url. The status bar can be addressed by the following url: private:resource/statusbar/statusbar. The status bar is always located at the bottom side of a frame. It's also responsible to show the progress bar during loading of a document.

OpenOffice2UserInterfaceElements.png

The status bar consists of several status bar controller which each controls a different aspect. For example the default OpenOffice.org Writer status bar contains nine different controllers you can see on the following illustration.

Write statusbar.JPG

General abstract of the status bar controller concept

Status bar controller architecture

A status bar controller is responsible for a single aspect that should be accessible via status bar. It must be implemented via UNO using the status bar controller service. This service is called com.sun.star.frame.StatusbarController. The OpenOffice.org status bar implementation uses the different interfaces of the service for creation, initialization, destruction and communication. The following snippet shows the UNO IDL description of the central com.sun.star.frame.StatusbarController service:

[cpp] //=============================================================================

module com {  module sun {  module star {  module frame {

//============================================================================= /** is an abstract service for a component which offers a more complex user

   interface to users within a status bar.
   A generic status bar function is represented as a text field which has 
   provides status information to the user. A status bar controller can be 
   added to a status bar and provide information or functions with a more 
   sophisticated user interface.
   A typical example for a status bar controller is the zoom level chooser 
   within the statusbar. It provides an option to change the zoom level of 
   an application.
   see com::sun::star::frame::XDispatchProvider
   see com::sun::star::frame::XStatusbarController
   since OOo 2.0.0
*/

service StatusbarController {

   //-------------------------------------------------------------------------
   /** with this interface a component can receive events if a feature has 
       changed.
       The toolbar controller implementation should register itself as a 
       listener when its com::sun::star::util::XUpdatable interface has 
       been called.
    */
   interface com::sun::star::frame::XStatusListener;
   /** used to initialize a component with required arguments.
       A toolbar controller needs at least three additional arguments 
       provided as com::sun::star::beans::PropertyValue:
       Frame
       com::sun::star::frame::XFrame instance to which the toolbar 
       controller belongs.
       
       CommandURL
       a string which specifies the command a statusbar controller is bound.
       ServiceManager
       a com::sun::star::lang::XMultiServiceFactory instance which can 
       be used to create additional UNO services.
   */
   interface com::sun::star::lang::XInitialization;
   /** used to notify an implementation that it needs to add its listener or 
       remove and add them again.
       A status bar controller instance is ready for use after this call has 
       been made the first time. The status bar implementation guarentees that 
       the controller's item window has been added to the status bar and its 
       reference is held by it.
   */
   interface com::sun::star::util::XUpdatable;
   //-------------------------------------------------------------------------
   /** used to notify changed features and requests for additional user 
       interface items.
       Mostly used by a status bar implementation to forward information to 
       and request services from a status bar controller component. This 
       interface must be useable after 
       com::sun::star::lang::XInitialitation::initialize has been called.  
       The behavior of the interface is undefined if the controller component 
       hasn't been initialized.
    */
   interface com::sun::star::frame::XStatusbarController;

};

}; }; }; };

Configuration

The language selection status bar controller

This chapter describes how to create a language selection status bar controller. It uses the previous described concepts and descriptions to implement it.

A status bar controller skeleton

The lanuage selection part

Personal tools