1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_ 25 #define __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_ 26 27 //_________________________________________________________________________________________________________________ 28 // my own includes 29 //_________________________________________________________________________________________________________________ 30 31 #include <threadhelp/threadhelpbase.hxx> 32 #include <macros/generic.hxx> 33 #include <macros/xinterface.hxx> 34 #include <macros/xtypeprovider.hxx> 35 #include <stdtypes.h> 36 37 //_________________________________________________________________________________________________________________ 38 // interface includes 39 //_________________________________________________________________________________________________________________ 40 #include <com/sun/star/frame/XFrame.hpp> 41 #include <com/sun/star/frame/XStatusListener.hpp> 42 #include <com/sun/star/frame/XStatusbarController.hpp> 43 #include <com/sun/star/frame/XUIControllerRegistration.hpp> 44 #include <com/sun/star/ui/XUIConfiguration.hpp> 45 #include <com/sun/star/frame/XModuleManager.hpp> 46 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 47 #include <com/sun/star/container/XNameAccess.hpp> 48 49 //_________________________________________________________________________________________________________________ 50 // other includes 51 //_________________________________________________________________________________________________________________ 52 #include <rtl/ustring.hxx> 53 #include <cppuhelper/weak.hxx> 54 #include <cppuhelper/interfacecontainer.hxx> 55 #include <vcl/status.hxx> 56 57 namespace framework 58 { 59 60 class FrameworkStatusBar; 61 class StatusBarManager : public ::com::sun::star::frame::XFrameActionListener , 62 public ::com::sun::star::lang::XComponent , 63 public ::com::sun::star::lang::XTypeProvider , 64 public ::com::sun::star::ui::XUIConfigurationListener, 65 public ThreadHelpBase , 66 public ::cppu::OWeakObject 67 { 68 friend class FrameworkStatusBar; 69 70 public: 71 StatusBarManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServicveManager, 72 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, 73 const rtl::OUString& rResourceName, 74 StatusBar* pStatusBar ); 75 virtual ~StatusBarManager(); 76 77 // XInterface, XTypeProvider, XServiceInfo 78 FWK_DECLARE_XINTERFACE 79 FWK_DECLARE_XTYPEPROVIDER 80 81 StatusBar* GetStatusBar() const; 82 83 // XFrameActionListener 84 virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException ); 85 86 // XEventListener 87 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 88 89 // XUIConfigurationListener 90 virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 91 virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 92 virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 93 94 // XComponent 95 void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException ); 96 void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); 97 void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ); 98 99 void FillStatusBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarData ); 100 101 protected: 102 void StateChanged( StateChangedType nType ); 103 void DataChanged( const DataChangedEvent& rDCEvt ); 104 void UserDraw( const UserDrawEvent& rUDEvt ); 105 void Command( const CommandEvent& rEvt ); 106 void MouseMove( const MouseEvent& rMEvt ); 107 void MouseButtonDown( const MouseEvent& rMEvt ); 108 void MouseButtonUp( const MouseEvent& rMEvt ); 109 DECL_LINK( Click, StatusBar* ); 110 DECL_LINK( DoubleClick, StatusBar* ); 111 112 void RemoveControllers(); 113 rtl::OUString RetrieveLabelFromCommand( const rtl::OUString& aCmdURL ); 114 void CreateControllers(); 115 void UpdateControllers(); 116 void AddFrameActionListener(); 117 void MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL ::com::sun::star::frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&)); 118 119 protected: 120 typedef std::vector< ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > StatusBarControllerVector; 121 122 sal_Bool m_bDisposed : 1, 123 m_bFrameActionRegistered : 1, 124 m_bUpdateControllers : 1; 125 sal_Bool m_bModuleIdentified; 126 StatusBar* m_pStatusBar; 127 rtl::OUString m_aModuleIdentifier; 128 rtl::OUString m_aResourceName; 129 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > m_xFrame; 130 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_xUICommandLabels; 131 StatusBarControllerVector m_aControllerVector; 132 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener 133 ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 134 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration > m_xStatusbarControllerRegistration; 135 }; 136 137 } 138 139 #endif // __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_ 140