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