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 #include <map>
57 
58 namespace framework
59 {
60 
61 class FrameworkStatusBar;
62 class StatusBarManager : public ::com::sun::star::frame::XFrameActionListener         ,
63                          public ::com::sun::star::lang::XComponent                    ,
64                          public ::com::sun::star::lang::XTypeProvider                 ,
65                          public ::com::sun::star::ui::XUIConfigurationListener,
66 					     public ThreadHelpBase		                                  ,
67 					     public ::cppu::OWeakObject
68 {
69     friend class FrameworkStatusBar;
70 
71     public:
72         StatusBarManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServicveManager,
73                           const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
74                           const rtl::OUString& rResourceName,
75                           StatusBar* pStatusBar );
76         virtual ~StatusBarManager();
77 
78         //  XInterface, XTypeProvider, XServiceInfo
79         FWK_DECLARE_XINTERFACE
80         FWK_DECLARE_XTYPEPROVIDER
81 
82         StatusBar* GetStatusBar() const;
83 
84         // XFrameActionListener
85 		virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException );
86 
87         // XEventListener
88 		virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
89 
90         // XUIConfigurationListener
91         virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
92         virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
93         virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
94 
95         // XComponent
96         void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
97         void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
98         void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
99 
100         void FillStatusBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarData );
101 
102     protected:
103         void StateChanged( StateChangedType nType );
104 	    void DataChanged( const DataChangedEvent& rDCEvt );
105 	    void UserDraw( const UserDrawEvent& rUDEvt );
106         void Command( const CommandEvent& rEvt );
107         void MouseMove( const MouseEvent& rMEvt );
108         void MouseButtonDown( const MouseEvent& rMEvt );
109         void MouseButtonUp( const MouseEvent& rMEvt );
110         DECL_LINK( Click, StatusBar* );
111         DECL_LINK( DoubleClick, StatusBar* );
112 
113         void RemoveControllers();
114         rtl::OUString RetrieveLabelFromCommand( const rtl::OUString& aCmdURL );
115         void CreateControllers();
116         void UpdateControllers();
117         void AddFrameActionListener();
118         void MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL ::com::sun::star::frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&));
119 
120     protected:
121         typedef std::map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > StatusBarControllerMap;
122 
123         sal_Bool                                                                                        m_bDisposed : 1,
124                                                                                                         m_bFrameActionRegistered : 1,
125                                                                                                         m_bUpdateControllers : 1;
126         sal_Bool                                                                                        m_bModuleIdentified;
127         StatusBar*                                                                                      m_pStatusBar;
128         rtl::OUString                                                                                   m_aModuleIdentifier;
129         rtl::OUString                                                                                   m_aResourceName;
130         com::sun::star::uno::Reference< com::sun::star::frame::XFrame >                                 m_xFrame;
131         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >                        m_xUICommandLabels;
132         StatusBarControllerMap                                                                          m_aControllerMap;
133         ::cppu::OMultiTypeInterfaceContainerHelper                                                      m_aListenerContainer;   /// container for ALL Listener
134         ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >                  m_xServiceManager;
135         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration >  m_xStatusbarControllerRegistration;
136 };
137 
138 }
139 
140 #endif // __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_
141