1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <uielement/statusbarmanager.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir //	my own includes
35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36*cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
37*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
38*cdf0e10cSrcweir #include <framework/sfxhelperfunctions.hxx>
39*cdf0e10cSrcweir #include <macros/generic.hxx>
40*cdf0e10cSrcweir #include <macros/xinterface.hxx>
41*cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
42*cdf0e10cSrcweir #include <stdtypes.h>
43*cdf0e10cSrcweir #include "services.h"
44*cdf0e10cSrcweir #include "general.h"
45*cdf0e10cSrcweir #include "properties.h"
46*cdf0e10cSrcweir #include <helper/mischelper.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49*cdf0e10cSrcweir //	interface includes
50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/ui/ItemStyle.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/ui/ItemType.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/awt/Command.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
62*cdf0e10cSrcweir //	other includes
63*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
66*cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
67*cdf0e10cSrcweir #endif
68*cdf0e10cSrcweir #include <svtools/statusbarcontroller.hxx>
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #include <vcl/status.hxx>
71*cdf0e10cSrcweir #include <vcl/svapp.hxx>
72*cdf0e10cSrcweir #include <rtl/logfile.hxx>
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir using namespace ::com::sun::star;
75*cdf0e10cSrcweir #ifndef css
76*cdf0e10cSrcweir #define css ::com::sun::star
77*cdf0e10cSrcweir #endif
78*cdf0e10cSrcweir #ifndef css_ui
79*cdf0e10cSrcweir #define css_ui ::com::sun::star::ui
80*cdf0e10cSrcweir #endif
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir const sal_Int32  HELPID_PREFIX_LENGTH    = 7;
83*cdf0e10cSrcweir static const char*      HELPID_PREFIX           = "helpid:";
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir // Property names of a menu/menu item ItemDescriptor
86*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_COMMANDURL[]  = "CommandURL";
87*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_HELPURL[]     = "HelpURL";
88*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_OFFSET[]      = "Offset";
89*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_STYLE[]       = "Style";
90*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_WIDTH[]       = "Width";
91*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_TYPE[]        = "Type";
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir namespace framework
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir static sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle )
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir     sal_uInt16 nItemBits( 0 );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     if (( nStyle & css_ui::ItemStyle::ALIGN_RIGHT ) == css_ui::ItemStyle::ALIGN_RIGHT )
101*cdf0e10cSrcweir         nItemBits |= SIB_RIGHT;
102*cdf0e10cSrcweir     else if ( nStyle & css_ui::ItemStyle::ALIGN_LEFT )
103*cdf0e10cSrcweir         nItemBits |= SIB_LEFT;
104*cdf0e10cSrcweir     else
105*cdf0e10cSrcweir         nItemBits |= SIB_CENTER;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     if (( nStyle & css_ui::ItemStyle::DRAW_FLAT ) == css_ui::ItemStyle::DRAW_FLAT )
108*cdf0e10cSrcweir         nItemBits |= SIB_FLAT;
109*cdf0e10cSrcweir     else if ( nStyle & css_ui::ItemStyle::DRAW_OUT3D )
110*cdf0e10cSrcweir         nItemBits |= SIB_OUT;
111*cdf0e10cSrcweir     else
112*cdf0e10cSrcweir         nItemBits |= SIB_IN;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     if (( nStyle & css_ui::ItemStyle::AUTO_SIZE ) == css_ui::ItemStyle::AUTO_SIZE )
115*cdf0e10cSrcweir         nItemBits |= SIB_AUTOSIZE;
116*cdf0e10cSrcweir     if ( nStyle & css_ui::ItemStyle::OWNER_DRAW )
117*cdf0e10cSrcweir         nItemBits |= SIB_USERDRAW;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     return nItemBits;
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir //*****************************************************************************************************************
123*cdf0e10cSrcweir //	XInterface, XTypeProvider, XServiceInfo
124*cdf0e10cSrcweir //*****************************************************************************************************************
125*cdf0e10cSrcweir DEFINE_XINTERFACE_5                     (   StatusBarManager                                                        ,
126*cdf0e10cSrcweir                                             ::cppu::OWeakObject                                                     ,
127*cdf0e10cSrcweir                                             DIRECT_INTERFACE( lang::XTypeProvider                                   ),
128*cdf0e10cSrcweir                                             DIRECT_INTERFACE( lang::XComponent                                      ),
129*cdf0e10cSrcweir 											DIRECT_INTERFACE( frame::XFrameActionListener                           ),
130*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::ui::XUIConfigurationListener                    ),
131*cdf0e10cSrcweir 											DERIVED_INTERFACE( lang::XEventListener, frame::XFrameActionListener    )
132*cdf0e10cSrcweir 										)
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_5                  (   StatusBarManager                    ,
135*cdf0e10cSrcweir                                             lang::XTypeProvider		            ,
136*cdf0e10cSrcweir                                             lang::XComponent                    ,
137*cdf0e10cSrcweir                                             css::ui::XUIConfigurationListener  ,
138*cdf0e10cSrcweir 											frame::XFrameActionListener         ,
139*cdf0e10cSrcweir 											lang::XEventListener
140*cdf0e10cSrcweir 										)
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir StatusBarManager::StatusBarManager(
143*cdf0e10cSrcweir     const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
144*cdf0e10cSrcweir     const uno::Reference< frame::XFrame >& rFrame,
145*cdf0e10cSrcweir     const rtl::OUString& rResourceName,
146*cdf0e10cSrcweir     StatusBar* pStatusBar ) :
147*cdf0e10cSrcweir     ThreadHelpBase( &Application::GetSolarMutex() ),
148*cdf0e10cSrcweir     OWeakObject(),
149*cdf0e10cSrcweir     m_bDisposed( sal_False ),
150*cdf0e10cSrcweir     m_bFrameActionRegistered( sal_False ),
151*cdf0e10cSrcweir     m_bUpdateControllers( sal_False ),
152*cdf0e10cSrcweir     m_bModuleIdentified( sal_False ),
153*cdf0e10cSrcweir     m_pStatusBar( pStatusBar ),
154*cdf0e10cSrcweir     m_aResourceName( rResourceName ),
155*cdf0e10cSrcweir     m_xFrame( rFrame ),
156*cdf0e10cSrcweir     m_aListenerContainer( m_aLock.getShareableOslMutex() ),
157*cdf0e10cSrcweir     m_xServiceManager( rServiceManager )
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StatusBarManager" );
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     if ( m_xServiceManager.is() )
162*cdf0e10cSrcweir         m_xStatusbarControllerRegistration = uno::Reference< css::frame::XUIControllerRegistration >(
163*cdf0e10cSrcweir                                                     m_xServiceManager->createInstance( SERVICENAME_STATUSBARCONTROLLERFACTORY ),
164*cdf0e10cSrcweir                                                     uno::UNO_QUERY );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     m_pStatusBar->SetClickHdl( LINK( this, StatusBarManager, Click ) );
167*cdf0e10cSrcweir     m_pStatusBar->SetDoubleClickHdl( LINK( this, StatusBarManager, DoubleClick ) );
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir StatusBarManager::~StatusBarManager()
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir StatusBar* StatusBarManager::GetStatusBar() const
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::GetStatusBar" );
177*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
178*cdf0e10cSrcweir     return m_pStatusBar;
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir void StatusBarManager::frameAction( const frame::FrameActionEvent& Action )
182*cdf0e10cSrcweir throw ( uno::RuntimeException )
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::frameAction" );
185*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
186*cdf0e10cSrcweir     if ( Action.Action == frame::FrameAction_CONTEXT_CHANGED )
187*cdf0e10cSrcweir         UpdateControllers();
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir void SAL_CALL StatusBarManager::disposing( const lang::EventObject& Source ) throw ( uno::RuntimeException )
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::disposing" );
193*cdf0e10cSrcweir     {
194*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
195*cdf0e10cSrcweir         if ( m_bDisposed )
196*cdf0e10cSrcweir             return;
197*cdf0e10cSrcweir     }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     RemoveControllers();
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	{
202*cdf0e10cSrcweir 	    ResetableGuard aGuard( m_aLock );
203*cdf0e10cSrcweir         if ( Source.Source == uno::Reference< uno::XInterface >( m_xFrame, uno::UNO_QUERY ))
204*cdf0e10cSrcweir             m_xFrame.clear();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         m_xServiceManager.clear();
207*cdf0e10cSrcweir     }
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir // XComponent
211*cdf0e10cSrcweir void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException )
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::dispose" );
214*cdf0e10cSrcweir     uno::Reference< lang::XComponent > xThis(
215*cdf0e10cSrcweir         static_cast< OWeakObject* >(this), uno::UNO_QUERY );
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     lang::EventObject aEvent( xThis );
218*cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     {
221*cdf0e10cSrcweir 	    ResetableGuard aGuard( m_aLock );
222*cdf0e10cSrcweir         if ( !m_bDisposed )
223*cdf0e10cSrcweir         {
224*cdf0e10cSrcweir             RemoveControllers();
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir             delete m_pStatusBar;
227*cdf0e10cSrcweir             m_pStatusBar = 0;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir             if ( m_bFrameActionRegistered && m_xFrame.is() )
230*cdf0e10cSrcweir             {
231*cdf0e10cSrcweir                 try
232*cdf0e10cSrcweir                 {
233*cdf0e10cSrcweir                     m_xFrame->removeFrameActionListener( uno::Reference< frame::XFrameActionListener >(
234*cdf0e10cSrcweir                                                             static_cast< ::cppu::OWeakObject *>( this ),
235*cdf0e10cSrcweir                                                             uno::UNO_QUERY ));
236*cdf0e10cSrcweir                 }
237*cdf0e10cSrcweir                 catch ( uno::Exception& )
238*cdf0e10cSrcweir                 {
239*cdf0e10cSrcweir                 }
240*cdf0e10cSrcweir             }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir             m_xFrame.clear();
243*cdf0e10cSrcweir             m_xServiceManager.clear();
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir             m_bDisposed = sal_True;
246*cdf0e10cSrcweir         }
247*cdf0e10cSrcweir     }
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir void SAL_CALL StatusBarManager::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::addEventListener" );
253*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
256*cdf0e10cSrcweir     if ( m_bDisposed )
257*cdf0e10cSrcweir         throw lang::DisposedException();
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType(
260*cdf0e10cSrcweir         ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener );
261*cdf0e10cSrcweir }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir void SAL_CALL StatusBarManager::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) throw( uno::RuntimeException )
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::removeEventListener" );
266*cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType(
267*cdf0e10cSrcweir         ( const uno::Reference< lang::XEventListener >* ) NULL ), xListener );
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir // XUIConfigurationListener
271*cdf0e10cSrcweir void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" );
274*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
277*cdf0e10cSrcweir     if ( m_bDisposed )
278*cdf0e10cSrcweir         return;
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" );
284*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
287*cdf0e10cSrcweir     if ( m_bDisposed )
288*cdf0e10cSrcweir         return;
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" );
294*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
297*cdf0e10cSrcweir     if ( m_bDisposed )
298*cdf0e10cSrcweir         return;
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir void StatusBarManager::UpdateControllers()
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UpdateControllers" );
304*cdf0e10cSrcweir     if ( !m_bUpdateControllers )
305*cdf0e10cSrcweir     {
306*cdf0e10cSrcweir         m_bUpdateControllers = sal_True;
307*cdf0e10cSrcweir         const sal_uInt32 nCount = m_aControllerVector.size();
308*cdf0e10cSrcweir         for ( sal_uInt32 n = 0; n < nCount; n++ )
309*cdf0e10cSrcweir         {
310*cdf0e10cSrcweir             try
311*cdf0e10cSrcweir             {
312*cdf0e10cSrcweir                 uno::Reference< util::XUpdatable > xUpdatable( m_aControllerVector[n], uno::UNO_QUERY );
313*cdf0e10cSrcweir                 if ( xUpdatable.is() )
314*cdf0e10cSrcweir                     xUpdatable->update();
315*cdf0e10cSrcweir             }
316*cdf0e10cSrcweir             catch ( uno::Exception& )
317*cdf0e10cSrcweir             {
318*cdf0e10cSrcweir             }
319*cdf0e10cSrcweir         }
320*cdf0e10cSrcweir     }
321*cdf0e10cSrcweir     m_bUpdateControllers = sal_False;
322*cdf0e10cSrcweir }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir void StatusBarManager::RemoveControllers()
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::RemoveControllers" );
327*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir     if ( m_bDisposed )
330*cdf0e10cSrcweir         return;
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir     const sal_uInt32 nCount = m_aControllerVector.size();
333*cdf0e10cSrcweir     for ( sal_uInt32 n = 0; n < nCount; n++ )
334*cdf0e10cSrcweir     {
335*cdf0e10cSrcweir         try
336*cdf0e10cSrcweir         {
337*cdf0e10cSrcweir             uno::Reference< lang::XComponent > xComponent(
338*cdf0e10cSrcweir                 m_aControllerVector[n], uno::UNO_QUERY );
339*cdf0e10cSrcweir             if ( xComponent.is() )
340*cdf0e10cSrcweir                 xComponent->dispose();
341*cdf0e10cSrcweir         }
342*cdf0e10cSrcweir         catch ( uno::Exception& )
343*cdf0e10cSrcweir         {
344*cdf0e10cSrcweir         }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir         m_aControllerVector[n].clear();
347*cdf0e10cSrcweir     }
348*cdf0e10cSrcweir }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir rtl::OUString StatusBarManager::RetrieveLabelFromCommand( const rtl::OUString& aCmdURL )
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir     return framework::RetrieveLabelFromCommand(aCmdURL,m_xServiceManager,m_xUICommandLabels,m_xFrame,m_aModuleIdentifier,m_bModuleIdentified,"Name");
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir void StatusBarManager::CreateControllers()
356*cdf0e10cSrcweir {
357*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" );
358*cdf0e10cSrcweir     uno::Reference< lang::XMultiComponentFactory > xStatusbarControllerFactory( m_xStatusbarControllerRegistration, uno::UNO_QUERY );
359*cdf0e10cSrcweir     uno::Reference< uno::XComponentContext > xComponentContext;
360*cdf0e10cSrcweir     uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY );
361*cdf0e10cSrcweir     uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar );
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir     if ( xProps.is() )
364*cdf0e10cSrcweir         xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext;
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < m_pStatusBar->GetItemCount(); i++ )
367*cdf0e10cSrcweir     {
368*cdf0e10cSrcweir         sal_uInt16 nId = m_pStatusBar->GetItemId( i );
369*cdf0e10cSrcweir         if ( nId == 0 )
370*cdf0e10cSrcweir             continue;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir         rtl::OUString                            aCommandURL( m_pStatusBar->GetItemCommand( nId ));
373*cdf0e10cSrcweir         sal_Bool                                 bInit( sal_True );
374*cdf0e10cSrcweir         uno::Reference< frame::XStatusListener > xController;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir         svt::StatusbarController* pController( 0 );
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir         if ( m_xStatusbarControllerRegistration.is() &&
379*cdf0e10cSrcweir              m_xStatusbarControllerRegistration->hasController( aCommandURL, m_aModuleIdentifier ))
380*cdf0e10cSrcweir         {
381*cdf0e10cSrcweir             if ( xStatusbarControllerFactory.is() )
382*cdf0e10cSrcweir             {
383*cdf0e10cSrcweir                 uno::Sequence< uno::Any > aSeq( 5 );
384*cdf0e10cSrcweir                 beans::PropertyValue aPropValue;
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" ));
387*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( m_aModuleIdentifier );
388*cdf0e10cSrcweir                 aSeq[0] = uno::makeAny( aPropValue );
389*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
390*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( m_xFrame );
391*cdf0e10cSrcweir                 aSeq[1] = uno::makeAny( aPropValue );
392*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
393*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( m_xServiceManager );
394*cdf0e10cSrcweir                 aSeq[2] = uno::makeAny( aPropValue );
395*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
396*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( xStatusbarWindow );
397*cdf0e10cSrcweir                 aSeq[3] = uno::makeAny( aPropValue );
398*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
399*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( nId );
400*cdf0e10cSrcweir                 aSeq[4] = uno::makeAny( aPropValue );
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir                 xController = uno::Reference< frame::XStatusListener >(
403*cdf0e10cSrcweir                                 xStatusbarControllerFactory->createInstanceWithArgumentsAndContext(
404*cdf0e10cSrcweir                                     aCommandURL, aSeq, xComponentContext ),
405*cdf0e10cSrcweir                                 uno::UNO_QUERY );
406*cdf0e10cSrcweir                 bInit = sal_False; // Initialization is done through the factory service
407*cdf0e10cSrcweir             }
408*cdf0e10cSrcweir         }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir         if ( !xController.is() )
411*cdf0e10cSrcweir         {
412*cdf0e10cSrcweir             pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL );
413*cdf0e10cSrcweir             if ( !pController )
414*cdf0e10cSrcweir                 pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId );
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir             if ( pController )
417*cdf0e10cSrcweir                 xController = uno::Reference< frame::XStatusListener >(
418*cdf0e10cSrcweir                                 static_cast< ::cppu::OWeakObject *>( pController ),
419*cdf0e10cSrcweir                                 uno::UNO_QUERY );
420*cdf0e10cSrcweir         }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir         m_aControllerVector.push_back( xController );
423*cdf0e10cSrcweir         uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY );
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir         if ( xInit.is() )
426*cdf0e10cSrcweir         {
427*cdf0e10cSrcweir             if ( bInit )
428*cdf0e10cSrcweir             {
429*cdf0e10cSrcweir                 beans::PropertyValue aPropValue;
430*cdf0e10cSrcweir                 uno::Sequence< uno::Any > aArgs( 5 );
431*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
432*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( m_xFrame );
433*cdf0e10cSrcweir                 aArgs[0] = uno::makeAny( aPropValue );
434*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandURL" ));
435*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( aCommandURL );
436*cdf0e10cSrcweir                 aArgs[1] = uno::makeAny( aPropValue );
437*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
438*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( m_xServiceManager );
439*cdf0e10cSrcweir                 aArgs[2] = uno::makeAny( aPropValue );
440*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
441*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( xStatusbarWindow );
442*cdf0e10cSrcweir                 aArgs[3] = uno::makeAny( aPropValue );
443*cdf0e10cSrcweir                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
444*cdf0e10cSrcweir                 aPropValue.Value    = uno::makeAny( nId );
445*cdf0e10cSrcweir                 aArgs[4] = uno::makeAny( aPropValue );
446*cdf0e10cSrcweir                 xInit->initialize( aArgs );
447*cdf0e10cSrcweir             }
448*cdf0e10cSrcweir         }
449*cdf0e10cSrcweir     }
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir     AddFrameActionListener();
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir void StatusBarManager::AddFrameActionListener()
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::AddFrameActionListener" );
457*cdf0e10cSrcweir     if ( !m_bFrameActionRegistered && m_xFrame.is() )
458*cdf0e10cSrcweir     {
459*cdf0e10cSrcweir         m_bFrameActionRegistered = sal_True;
460*cdf0e10cSrcweir         m_xFrame->addFrameActionListener( uno::Reference< frame::XFrameActionListener >(
461*cdf0e10cSrcweir             static_cast< ::cppu::OWeakObject *>( this ), uno::UNO_QUERY ));
462*cdf0e10cSrcweir     }
463*cdf0e10cSrcweir }
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAccess >& rItemContainer )
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::StatusBarManager::FillStatusbar" );
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir     if ( m_bDisposed || !m_pStatusBar )
472*cdf0e10cSrcweir         return;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     sal_uInt16         nId( 1 );
475*cdf0e10cSrcweir     rtl::OUString  aHelpIdPrefix( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ));
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir     RemoveControllers();
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir     // reset and fill command map
480*cdf0e10cSrcweir     m_pStatusBar->Clear();
481*cdf0e10cSrcweir     m_aControllerVector.clear();
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir     for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
484*cdf0e10cSrcweir     {
485*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::FillStatusBar" );
486*cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue >   aProp;
487*cdf0e10cSrcweir         rtl::OUString                           aCommandURL;
488*cdf0e10cSrcweir         rtl::OUString                           aHelpURL;
489*cdf0e10cSrcweir         sal_Int16                               nOffset( 0 );
490*cdf0e10cSrcweir         sal_Int16                               nStyle( 0 );
491*cdf0e10cSrcweir         sal_Int16                               nWidth( 0 );
492*cdf0e10cSrcweir         sal_uInt16                              nType( css_ui::ItemType::DEFAULT );
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir         try
495*cdf0e10cSrcweir         {
496*cdf0e10cSrcweir             if ( rItemContainer->getByIndex( n ) >>= aProp )
497*cdf0e10cSrcweir             {
498*cdf0e10cSrcweir                 for ( int i = 0; i < aProp.getLength(); i++ )
499*cdf0e10cSrcweir                 {
500*cdf0e10cSrcweir                     if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
501*cdf0e10cSrcweir                     {
502*cdf0e10cSrcweir                         aProp[i].Value >>= aCommandURL;
503*cdf0e10cSrcweir                     }
504*cdf0e10cSrcweir                     else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
505*cdf0e10cSrcweir                     {
506*cdf0e10cSrcweir                         aProp[i].Value >>= aHelpURL;
507*cdf0e10cSrcweir                     }
508*cdf0e10cSrcweir                     else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
509*cdf0e10cSrcweir                     {
510*cdf0e10cSrcweir                         aProp[i].Value >>= nStyle;
511*cdf0e10cSrcweir                     }
512*cdf0e10cSrcweir                     else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
513*cdf0e10cSrcweir                     {
514*cdf0e10cSrcweir                         aProp[i].Value >>= nType;
515*cdf0e10cSrcweir                     }
516*cdf0e10cSrcweir                     else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH ))
517*cdf0e10cSrcweir                     {
518*cdf0e10cSrcweir                         aProp[i].Value >>= nWidth;
519*cdf0e10cSrcweir                     }
520*cdf0e10cSrcweir                     else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_OFFSET ))
521*cdf0e10cSrcweir                     {
522*cdf0e10cSrcweir                         aProp[i].Value >>= nOffset;
523*cdf0e10cSrcweir                     }
524*cdf0e10cSrcweir                 }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir                 if (( nType == ::com::sun::star::ui::ItemType::DEFAULT ) && ( aCommandURL.getLength() > 0 ))
527*cdf0e10cSrcweir                 {
528*cdf0e10cSrcweir                     rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
529*cdf0e10cSrcweir                     sal_uInt16        nItemBits( impl_convertItemStyleToItemBits( nStyle ));
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir                     m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset );
532*cdf0e10cSrcweir                     m_pStatusBar->SetItemCommand( nId, aCommandURL );
533*cdf0e10cSrcweir                     m_pStatusBar->SetAccessibleName( nId, aString );
534*cdf0e10cSrcweir                     ++nId;
535*cdf0e10cSrcweir                 }
536*cdf0e10cSrcweir             }
537*cdf0e10cSrcweir         }
538*cdf0e10cSrcweir         catch ( ::com::sun::star::lang::IndexOutOfBoundsException& )
539*cdf0e10cSrcweir         {
540*cdf0e10cSrcweir             break;
541*cdf0e10cSrcweir         }
542*cdf0e10cSrcweir     }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir     // Create controllers
545*cdf0e10cSrcweir     CreateControllers();
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir     // Notify controllers that they are now correctly initialized and can start listening
548*cdf0e10cSrcweir     UpdateControllers();
549*cdf0e10cSrcweir }
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir void StatusBarManager::StateChanged( StateChangedType )
552*cdf0e10cSrcweir {
553*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::StateChanged" );
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir void StatusBarManager::DataChanged( const DataChangedEvent& rDCEvt )
557*cdf0e10cSrcweir {
558*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::DataChanged" );
559*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir     if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS	        ) ||
562*cdf0e10cSrcweir          ( rDCEvt.GetType() == DATACHANGED_FONTS            ) ||
563*cdf0e10cSrcweir 		 ( rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION ) ||
564*cdf0e10cSrcweir 		 ( rDCEvt.GetType() == DATACHANGED_DISPLAY	        ))	&&
565*cdf0e10cSrcweir          ( rDCEvt.GetFlags() & SETTINGS_STYLE		        ))
566*cdf0e10cSrcweir     {
567*cdf0e10cSrcweir         css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
568*cdf0e10cSrcweir         css::uno::Reference< css::beans::XPropertySet > xPropSet( m_xFrame, css::uno::UNO_QUERY );
569*cdf0e10cSrcweir         if ( xPropSet.is() )
570*cdf0e10cSrcweir             xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))) >>= xLayoutManager;
571*cdf0e10cSrcweir         if ( xLayoutManager.is() )
572*cdf0e10cSrcweir         {
573*cdf0e10cSrcweir             aGuard.unlock();
574*cdf0e10cSrcweir             xLayoutManager->doLayout();
575*cdf0e10cSrcweir         }
576*cdf0e10cSrcweir     }
577*cdf0e10cSrcweir }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt )
580*cdf0e10cSrcweir {
581*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" );
582*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir     if ( m_bDisposed )
585*cdf0e10cSrcweir         return;
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir     sal_uInt16 nId( rUDEvt.GetItemId() );
588*cdf0e10cSrcweir     if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
589*cdf0e10cSrcweir     {
590*cdf0e10cSrcweir         uno::Reference< frame::XStatusbarController > xController(
591*cdf0e10cSrcweir             m_aControllerVector[nId-1], uno::UNO_QUERY );
592*cdf0e10cSrcweir         if ( xController.is() && rUDEvt.GetDevice() )
593*cdf0e10cSrcweir         {
594*cdf0e10cSrcweir             uno::Reference< awt::XGraphics > xGraphics =
595*cdf0e10cSrcweir                 rUDEvt.GetDevice()->CreateUnoGraphics();
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir             awt::Rectangle aRect( rUDEvt.GetRect().Left(),
598*cdf0e10cSrcweir                                   rUDEvt.GetRect().Top(),
599*cdf0e10cSrcweir                                   rUDEvt.GetRect().GetWidth(),
600*cdf0e10cSrcweir                                   rUDEvt.GetRect().GetHeight() );
601*cdf0e10cSrcweir             aGuard.unlock();
602*cdf0e10cSrcweir             xController->paint( xGraphics, aRect, rUDEvt.GetItemId(), rUDEvt.GetStyle() );
603*cdf0e10cSrcweir         }
604*cdf0e10cSrcweir     }
605*cdf0e10cSrcweir }
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir void StatusBarManager::Command( const CommandEvent& rEvt )
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" );
610*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir     if ( m_bDisposed )
613*cdf0e10cSrcweir         return;
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir     if ( rEvt.GetCommand() == COMMAND_CONTEXTMENU )
616*cdf0e10cSrcweir     {
617*cdf0e10cSrcweir         sal_uInt16 nId = m_pStatusBar->GetItemId( rEvt.GetMousePosPixel() );
618*cdf0e10cSrcweir         if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
619*cdf0e10cSrcweir         {
620*cdf0e10cSrcweir             uno::Reference< frame::XStatusbarController > xController(
621*cdf0e10cSrcweir                 m_aControllerVector[nId-1], uno::UNO_QUERY );
622*cdf0e10cSrcweir             if ( xController.is() )
623*cdf0e10cSrcweir             {
624*cdf0e10cSrcweir                 awt::Point aPos;
625*cdf0e10cSrcweir                 aPos.X = rEvt.GetMousePosPixel().X();
626*cdf0e10cSrcweir                 aPos.Y = rEvt.GetMousePosPixel().Y();
627*cdf0e10cSrcweir                 xController->command( aPos, awt::Command::CONTEXTMENU, sal_True, uno::Any() );
628*cdf0e10cSrcweir             }
629*cdf0e10cSrcweir         }
630*cdf0e10cSrcweir     }
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir void StatusBarManager::MouseMove( const MouseEvent& rMEvt )
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" );
636*cdf0e10cSrcweir     MouseButton(rMEvt,&frame::XStatusbarController::mouseMove);
637*cdf0e10cSrcweir }
638*cdf0e10cSrcweir void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&))
639*cdf0e10cSrcweir {
640*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" );
641*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir     if ( !m_bDisposed )
644*cdf0e10cSrcweir     {
645*cdf0e10cSrcweir         sal_uInt16 nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() );
646*cdf0e10cSrcweir         if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
647*cdf0e10cSrcweir         {
648*cdf0e10cSrcweir             uno::Reference< frame::XStatusbarController > xController(
649*cdf0e10cSrcweir                 m_aControllerVector[nId-1], uno::UNO_QUERY );
650*cdf0e10cSrcweir             if ( xController.is() )
651*cdf0e10cSrcweir             {
652*cdf0e10cSrcweir                 ::com::sun::star::awt::MouseEvent aMouseEvent;
653*cdf0e10cSrcweir                 aMouseEvent.Buttons = rMEvt.GetButtons();
654*cdf0e10cSrcweir                 aMouseEvent.X = rMEvt.GetPosPixel().X();
655*cdf0e10cSrcweir                 aMouseEvent.Y = rMEvt.GetPosPixel().Y();
656*cdf0e10cSrcweir                 aMouseEvent.ClickCount = rMEvt.GetClicks();
657*cdf0e10cSrcweir                 (xController.get()->*_pMethod)( aMouseEvent);
658*cdf0e10cSrcweir             }
659*cdf0e10cSrcweir         } // if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
660*cdf0e10cSrcweir     }
661*cdf0e10cSrcweir }
662*cdf0e10cSrcweir void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt )
663*cdf0e10cSrcweir {
664*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" );
665*cdf0e10cSrcweir     MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonDown);
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir void StatusBarManager::MouseButtonUp( const MouseEvent& rMEvt )
669*cdf0e10cSrcweir {
670*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonUp" );
671*cdf0e10cSrcweir     MouseButton(rMEvt,&frame::XStatusbarController::mouseButtonUp);
672*cdf0e10cSrcweir }
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir IMPL_LINK( StatusBarManager, Click, StatusBar*, EMPTYARG )
675*cdf0e10cSrcweir {
676*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir     if ( m_bDisposed )
679*cdf0e10cSrcweir         return 1;
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir     sal_uInt16 nId = m_pStatusBar->GetCurItemId();
682*cdf0e10cSrcweir     if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
683*cdf0e10cSrcweir     {
684*cdf0e10cSrcweir         uno::Reference< frame::XStatusbarController > xController(
685*cdf0e10cSrcweir             m_aControllerVector[nId-1], uno::UNO_QUERY );
686*cdf0e10cSrcweir         if ( xController.is() )
687*cdf0e10cSrcweir             xController->click();
688*cdf0e10cSrcweir     }
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir     return 1;
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir IMPL_LINK( StatusBarManager, DoubleClick, StatusBar*, EMPTYARG )
694*cdf0e10cSrcweir {
695*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir     if ( m_bDisposed )
698*cdf0e10cSrcweir         return 1;
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir     sal_uInt16 nId = m_pStatusBar->GetCurItemId();
701*cdf0e10cSrcweir     if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
702*cdf0e10cSrcweir     {
703*cdf0e10cSrcweir         uno::Reference< frame::XStatusbarController > xController(
704*cdf0e10cSrcweir             m_aControllerVector[nId-1], uno::UNO_QUERY );
705*cdf0e10cSrcweir         if ( xController.is() )
706*cdf0e10cSrcweir             xController->doubleClick();
707*cdf0e10cSrcweir     }
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir     return 1;
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir }
713