OpenOffice.org 2.0 User Interface Controller Internals

The user interface elements are using controllers for each of their elements to bind them to the dynamic state of the application module. It's the responsibility of every user interface controller to call and to display the current state of its bound function.

OOo 2.0 uses the following user interface controllers:

  • Menubar
    • Popup menu controller
    • Generic menu item controller
    • Internal menu controller
  • Toolbar
    • Generic toolbar item controller
    • Specific toolbar item controller
  • Statusbar
    • Specific statusbar item controller

Generic menu item controller

A normal menu item is controlled by a generic menu item controller. A menu bar of an application module uses for about 90% of its menu items generic item controllers. For example the Edit - Undo, Redo and Edit - Cut, Copy and Paste menu items are implemented using generic menu item controllers.

Internal menu controller

An Internal menu controllers is used for special menu items, like the window list (accessible via the Window popup menu). Internal menu controllers are completely responsible for their menu items. Currently there is no special menu controller which is implemented outside the framework library. There exists no UNO API to implement internal menu controllers.

Popup menu controller

A popup menu controller is a special menu controller which is responsible for a whole popup menu inside a menu bar. A popup menu controller must be a UNO service and registered in the configuration controller set, which can be found at org.openoffice.Office.UI.Controller/Registered/PopupMenu. The configuration set associates UNO service names implementing a popup menu controller with a command URL. The command URL is used by our XML based menu bar description. A popup menu controller is created by a popup menu controller factory which uses the configuration set to retrieve the correct service name and to initialize it.


The framework project provides a base class to implement popup menu controller easier. It can be found in framework/inc/helper/popupmenucontrollerbase.hxx. There are several implementations for popup menu controller in framework/source/uielement which uses the base class and can be used as templates.

Toolbar item controller

Toolbar item controllers are responsible for a single toolbar button or toolbar item window (like a combobox, dropdown-box or an edit field).

Generic toolbar item controller

A generic toolbar item controller is used by toolbar implementation for simple toolbar buttons. Normally most items of a toolbar consists of generic toolbar item controllers.

Specific toolbar item controllers

The framework provides a base class which makes it much easier to implement UNO based specific toolbar item controllers. It can be found in svtools/inc/toolboxcontroller.hxx.

The sfx2 based specific toolbar item controllers are registered by calling ToolbarControllerClass::RegisterControl(SlotID, SfxModule* ). The framework implementation uses a special toolbar controller factory to create instances of sfx2 based specific toolbar item controllers. Sfx2 based specific toolbar controllers can use the known base class sfx2/inc/tbxctrl.hxx. It's a special wrapper which converts calls to the its UNO interfaces to the needs of sfx2 based toolbar controllers.

class SFX2_DLLPUBLIC SfxToolBoxControl:
public ::com::sun::star::awt::XDockableWindowListener,
public ::com::sun::star::frame::XSubToolbarController,
public svt::ToolboxController
{
friend class SfxToolbox;
friend class SfxToolBox_Impl;
friend class SfxToolboxCustomizer;
friend class SfxPopupWindow;
friend struct SfxTbxCtrlFactory;

SfxToolBoxControl_Impl* pImpl;

protected:
DECL_LINK( PopupModeEndHdl, void * );
DECL_LINK( ClosePopupWindow, SfxPopupWindow * );

// old SfxToolBoxControl methods
virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
virtual void Select( BOOL bMod1 = FALSE );
virtual void Select( USHORT nModifier );

virtual void DoubleClick();
virtual void Click();
virtual SfxPopupWindowType GetPopupWindowType() const;
virtual SfxPopupWindow* CreatePopupWindow();
virtual SfxPopupWindow* CreatePopupWindowCascading();
virtual Window* CreateItemWindow( Window *pParent );

// Must be called by subclass to set a new popup window instance
void SetPopupWindow( SfxPopupWindow* pWindow );

// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();

// XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );

// XComponent
virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);

// new controller API
// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );

// XToolbarController
virtual void SAL_CALL execute( sal_Int16 KeyModifier )
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL click()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL doubleClick()
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow()
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& rParent )
throw (::com::sun::star::uno::RuntimeException);

// XSubToolbarController
virtual ::sal_Bool SAL_CALL opensSubToolbar( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getSubToolbarName( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL updateImage( ) throw (::com::sun::star::uno::RuntimeException);

// XDockableWindowListener
virtual void SAL_CALL startDocking( const ::com::sun::star::awt::DockingEvent& e ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::awt::DockingData SAL_CALL docking( const ::com::sun::star::awt::DockingEvent& e ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL endDocking( const ::com::sun::star::awt::EndDockingEvent& e ) throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL toggleFloatingMode( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL closed( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent& e ) throw (::com::sun::star::uno::RuntimeException);

// helper methods
void createAndPositionSubToolBar( const ::rtl::OUString& rSubToolBarResName );
 ::Size getPersistentFloatingSize( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rSubToolBarResName );

public:
SFX_DECL_TOOLBOX_CONTROL();

SfxToolBoxControl( USHORT nSlotID, USHORT nId, ToolBox& rBox, BOOL bShowStrings = FALSE );
virtual ~SfxToolBoxControl();

ToolBox& GetToolBox() const;
unsigned short GetId() const;
unsigned short GetSlotId() const;

void Dispatch(

const ::rtl::OUString& aCommand,
 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
static void Dispatch(

const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider, const rtl::OUString& rCommand, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );

static SfxItemState GetItemState( const SfxPoolItem* pState );
static SfxToolBoxControl* CreateControl( USHORT nSlotId, USHORT nTbxId, ToolBox *pBox, SfxModule *pMod );
};

 Specific statusbar item controller

The framework library provides a base class in svtools/inc/statusbarcontroller.hxx which makes it simpler to implement a UNO based specific status bar controller.

The sfx2 based specific statusbar item controllers are registered by calling StatusbarControllerClass::RegisterControl(SlotID, SfxModule* ). The framework implementation uses a special statusbar controller factory to create instances of sfx2 based specific statusbar item controllers. Sfx2 based specific statusbar controllers can use the known base class sfx2/inc/stbitem.hxx. It's a special wrapper which converts calls to the its UNO interfaces to the needs of sfx2 based statusbar controllers.

class SFX2_DLLPUBLIC SfxStatusBarControl: public svt::StatusbarController
{
USHORT nSlotId;
USHORT nId;
StatusBar* pBar;

protected:
// new controller API
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();

// XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );

// XComponent
virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);

// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );

// XStatusbarController
virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos,
 ::sal_Int32 nCommand,
 ::sal_Bool bMouseEvent,
const ::com::sun::star::uno::Any& aData )

throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
const ::com::sun::star::awt::Rectangle& rOutputRectangle,
 ::sal_Int32 nItemId,

::sal_Int32 nStyle )

throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);

// Old sfx2 interface
virtual void StateChanged( USHORT nSID, SfxItemState eState,
const SfxPoolItem* pState );
virtual void Click();
virtual void DoubleClick();
virtual void Command( const CommandEvent& rCEvt );
virtual BOOL MouseButtonDown( const MouseEvent & );
virtual BOOL MouseMove( const MouseEvent & );
virtual BOOL MouseButtonUp( const MouseEvent & );
virtual void Paint( const UserDrawEvent &rUDEvt );

static USHORT convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons );

public:
SfxStatusBarControl( USHORT nSlotID, USHORT nId, StatusBar& rBar );
virtual ~SfxStatusBarControl();

USHORT GetSlotId() const { return nSlotId; }
USHORT GetId() const { return nId; }
StatusBar& GetStatusBar() const { return *pBar; }
void CaptureMouse();
void ReleaseMouse();

static SfxStatusBarControl* CreateControl( USHORT nSlotID, USHORT nId, StatusBar *pBar, SfxModule* );
};


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值