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 #ifndef __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_
23 #define __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_
24 
25 #include <threadhelp/threadhelpbase.hxx>
26 #include <macros/generic.hxx>
27 #include <macros/xinterface.hxx>
28 #include <macros/xtypeprovider.hxx>
29 #include <stdtypes.h>
30 
31 #include <com/sun/star/frame/XFrame.hpp>
32 #include <com/sun/star/frame/XStatusbarController.hpp>
33 #include <com/sun/star/frame/XUIControllerFactory.hpp>
34 #include <com/sun/star/ui/XUIConfiguration.hpp>
35 #include <com/sun/star/frame/XModuleManager.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 
39 #include <rtl/ustring.hxx>
40 #include <cppuhelper/weak.hxx>
41 #include <cppuhelper/interfacecontainer.hxx>
42 #include <vcl/status.hxx>
43 #include <map>
44 
45 namespace framework
46 {
47 
48 class FrameworkStatusBar;
49 class StatusBarManager : public ::com::sun::star::frame::XFrameActionListener         ,
50                          public ::com::sun::star::lang::XComponent                    ,
51                          public ::com::sun::star::lang::XTypeProvider                 ,
52                          public ::com::sun::star::ui::XUIConfigurationListener,
53 					     public ThreadHelpBase		                                  ,
54 					     public ::cppu::OWeakObject
55 {
56     friend class FrameworkStatusBar;
57 
58     public:
59         StatusBarManager( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServicveManager,
60                           const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
61                           const rtl::OUString& rResourceName,
62                           StatusBar* pStatusBar );
63         virtual ~StatusBarManager();
64 
65         //  XInterface, XTypeProvider, XServiceInfo
66         FWK_DECLARE_XINTERFACE
67         FWK_DECLARE_XTYPEPROVIDER
68 
69         StatusBar* GetStatusBar() const;
70 
71         // XFrameActionListener
72 		virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException );
73 
74         // XEventListener
75 		virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
76 
77         // XUIConfigurationListener
78         virtual void SAL_CALL elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
79         virtual void SAL_CALL elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
80         virtual void SAL_CALL elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
81 
82         // XComponent
83         void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
84         void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
85         void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
86 
87         void FillStatusBar( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusBarData );
88 
89     protected:
90         void StateChanged( StateChangedType nType );
91 	    void DataChanged( const DataChangedEvent& rDCEvt );
92 	    void UserDraw( const UserDrawEvent& rUDEvt );
93         void Command( const CommandEvent& rEvt );
94         void MouseMove( const MouseEvent& rMEvt );
95         void MouseButtonDown( const MouseEvent& rMEvt );
96         void MouseButtonUp( const MouseEvent& rMEvt );
97         DECL_LINK( Click, StatusBar* );
98         DECL_LINK( DoubleClick, StatusBar* );
99 
100         void RemoveControllers();
101         rtl::OUString RetrieveLabelFromCommand( const rtl::OUString& aCmdURL );
102         void CreateControllers();
103         void UpdateControllers();
104         void AddFrameActionListener();
105         void MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL ::com::sun::star::frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&));
106 
107     protected:
108         typedef std::map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusbarController > > StatusBarControllerMap;
109 
110         sal_Bool                                                                                        m_bDisposed : 1,
111                                                                                                         m_bFrameActionRegistered : 1,
112                                                                                                         m_bUpdateControllers : 1;
113         sal_Bool                                                                                        m_bModuleIdentified;
114         StatusBar*                                                                                      m_pStatusBar;
115         rtl::OUString                                                                                   m_aModuleIdentifier;
116         rtl::OUString                                                                                   m_aResourceName;
117         com::sun::star::uno::Reference< com::sun::star::frame::XFrame >                                 m_xFrame;
118         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >                        m_xUICommandLabels;
119         StatusBarControllerMap                                                                          m_aControllerMap;
120         ::cppu::OMultiTypeInterfaceContainerHelper                                                      m_aListenerContainer;   /// container for ALL Listener
121         ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >                  m_xServiceManager;
122         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerFactory >  m_xStatusbarControllerFactory;
123 };
124 
125 }
126 
127 #endif // __FRAMEWORK_UIELEMENT_STATUSBARMANAGER_HXX_
128