1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_ 29 #define __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_ 30 31 //_________________________________________________________________________________________________________________ 32 // my own includes 33 //_________________________________________________________________________________________________________________ 34 35 #include <threadhelp/threadhelpbase.hxx> 36 #include <macros/generic.hxx> 37 #include <macros/xinterface.hxx> 38 #include <macros/xtypeprovider.hxx> 39 #include <stdtypes.h> 40 41 //_________________________________________________________________________________________________________________ 42 // interface includes 43 //_________________________________________________________________________________________________________________ 44 #include <com/sun/star/frame/XFrame.hpp> 45 #include <com/sun/star/frame/XStatusListener.hpp> 46 #include <com/sun/star/frame/XStatusbarController.hpp> 47 #include <com/sun/star/frame/XUIControllerRegistration.hpp> 48 #include <com/sun/star/ui/XUIConfiguration.hpp> 49 #include <com/sun/star/frame/XModuleManager.hpp> 50 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 51 #include <com/sun/star/container/XNameAccess.hpp> 52 53 //_________________________________________________________________________________________________________________ 54 // other includes 55 //_________________________________________________________________________________________________________________ 56 #include <rtl/ustring.hxx> 57 #include <cppuhelper/weak.hxx> 58 #include <cppuhelper/interfacecontainer.hxx> 59 #include <vcl/status.hxx> 60 61 namespace framework 62 { 63 64 class FrameworkStatusBar; 65 class StatusBarManager : public ::com::sun::star::frame::XFrameActionListener , 66 public ::com::sun::star::lang::XComponent , 67 public ::com::sun::star::lang::XTypeProvider , 68 public ::com::sun::star::ui::XUIConfigurationListener, 69 public ThreadHelpBase , 70 public ::cppu::OWeakObject 71 { 72 friend class FrameworkStatusBar; 73 74 public: 75 StatusBarManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServicveManager, 76 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, 77 const rtl::OUString& rResourceName, 78 StatusBar* pStatusBar ); 79 virtual ~StatusBarManager(); 80 81 // XInterface, XTypeProvider, XServiceInfo 82 FWK_DECLARE_XINTERFACE 83 FWK_DECLARE_XTYPEPROVIDER 84 85 StatusBar* GetStatusBar() const; 86 87 // XFrameActionListener 88 virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException ); 89 90 // XEventListener 91 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 92 93 // XUIConfigurationListener 94 virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 95 virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 96 virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 97 98 // XComponent 99 void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException ); 100 void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); 101 void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); 102 103 void FillStatusBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarData ); 104 105 protected: 106 void StateChanged( StateChangedType nType ); 107 void DataChanged( const DataChangedEvent& rDCEvt ); 108 void UserDraw( const UserDrawEvent& rUDEvt ); 109 void Command( const CommandEvent& rEvt ); 110 void MouseMove( const MouseEvent& rMEvt ); 111 void MouseButtonDown( const MouseEvent& rMEvt ); 112 void MouseButtonUp( const MouseEvent& rMEvt ); 113 DECL_LINK( Click, StatusBar* ); 114 DECL_LINK( DoubleClick, StatusBar* ); 115 116 void RemoveControllers(); 117 rtl::OUString RetrieveLabelFromCommand( const rtl::OUString& aCmdURL ); 118 void CreateControllers(); 119 void UpdateControllers(); 120 void AddFrameActionListener(); 121 void MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL ::com::sun::star::frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&)); 122 123 protected: 124 typedef std::vector< ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > StatusBarControllerVector; 125 126 sal_Bool m_bDisposed : 1, 127 m_bFrameActionRegistered : 1, 128 m_bUpdateControllers : 1; 129 sal_Bool m_bModuleIdentified; 130 StatusBar* m_pStatusBar; 131 rtl::OUString m_aModuleIdentifier; 132 rtl::OUString m_aResourceName; 133 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > m_xFrame; 134 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_xUICommandLabels; 135 StatusBarControllerVector m_aControllerVector; 136 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener 137 ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 138 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration > m_xStatusbarControllerRegistration; 139 }; 140 141 } 142 143 #endif // __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_ 144