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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svtools.hxx"
26 #include <svtools/statusbarcontroller.hxx>
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/frame/XDispatchProvider.hpp>
30 #include <com/sun/star/lang/DisposedException.hpp>
31 #include <com/sun/star/frame/XLayoutManager.hpp>
32 #include <vos/mutex.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/window.hxx>
35 #include <vcl/status.hxx>
36 #include <svtools/imgdef.hxx>
37 #include <svtools/miscopt.hxx>
38 #include <toolkit/helper/vclunohelper.hxx>
39
40 using namespace ::cppu;
41 using namespace ::com::sun::star::awt;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::util;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::frame;
47 using namespace ::com::sun::star::frame;
48
49 namespace svt
50 {
51
StatusbarController(const Reference<XMultiServiceFactory> & rServiceManager,const Reference<XFrame> & xFrame,const::rtl::OUString & aCommandURL,unsigned short nID)52 StatusbarController::StatusbarController(
53 const Reference< XMultiServiceFactory >& rServiceManager,
54 const Reference< XFrame >& xFrame,
55 const ::rtl::OUString& aCommandURL,
56 unsigned short nID ) :
57 OWeakObject()
58 , m_bInitialized( sal_False )
59 , m_bDisposed( sal_False )
60 , m_nID( nID )
61 , m_xFrame( xFrame )
62 , m_xServiceManager( rServiceManager )
63 , m_aCommandURL( aCommandURL )
64 , m_aListenerContainer( m_aMutex )
65 {
66 }
67
StatusbarController()68 StatusbarController::StatusbarController() :
69 OWeakObject()
70 , m_bInitialized( sal_False )
71 , m_bDisposed( sal_False )
72 , m_nID( 0 )
73 , m_aListenerContainer( m_aMutex )
74 {
75 }
76
~StatusbarController()77 StatusbarController::~StatusbarController()
78 {
79 }
80
getFrameInterface() const81 Reference< XFrame > StatusbarController::getFrameInterface() const
82 {
83 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
84 return m_xFrame;
85 }
86
getServiceManager() const87 Reference< XMultiServiceFactory > StatusbarController::getServiceManager() const
88 {
89 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
90 return m_xServiceManager;
91 }
92
getLayoutManager() const93 Reference< XLayoutManager > StatusbarController::getLayoutManager() const
94 {
95 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
96 Reference< XLayoutManager > xLayoutManager;
97 Reference< XPropertySet > xPropSet( m_xFrame, UNO_QUERY );
98 if ( xPropSet.is() )
99 {
100 try
101 {
102 Any a;
103 a = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
104 a >>= xLayoutManager;
105 }
106 catch ( Exception& )
107 {
108 }
109 }
110
111 return xLayoutManager;
112 }
113
getURLTransformer() const114 Reference< XURLTransformer > StatusbarController::getURLTransformer() const
115 {
116 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
117 if ( !m_xURLTransformer.is() && m_xServiceManager.is() )
118 {
119 m_xURLTransformer = Reference< XURLTransformer >(
120 m_xServiceManager->createInstance(
121 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))),
122 UNO_QUERY );
123 }
124
125 return m_xURLTransformer;
126 }
127
128 // XInterface
queryInterface(const Type & rType)129 Any SAL_CALL StatusbarController::queryInterface( const Type& rType )
130 {
131 Any a = ::cppu::queryInterface(
132 rType ,
133 static_cast< XStatusbarController* >( this ),
134 static_cast< XStatusListener* >( this ),
135 static_cast< XEventListener* >( this ),
136 static_cast< XInitialization* >( this ),
137 static_cast< XComponent* >( this ),
138 static_cast< XUpdatable* >( this ));
139
140 if ( a.hasValue() )
141 return a;
142
143 return OWeakObject::queryInterface( rType );
144 }
145
acquire()146 void SAL_CALL StatusbarController::acquire() throw ()
147 {
148 OWeakObject::acquire();
149 }
150
release()151 void SAL_CALL StatusbarController::release() throw ()
152 {
153 OWeakObject::release();
154 }
155
initialize(const Sequence<Any> & aArguments)156 void SAL_CALL StatusbarController::initialize( const Sequence< Any >& aArguments )
157 {
158 bool bInitialized( true );
159
160 {
161 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
162
163 if ( m_bDisposed )
164 throw DisposedException();
165
166 bInitialized = m_bInitialized;
167 }
168
169 if ( !bInitialized )
170 {
171 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
172 m_bInitialized = sal_True;
173
174 PropertyValue aPropValue;
175 for ( int i = 0; i < aArguments.getLength(); i++ )
176 {
177 if ( aArguments[i] >>= aPropValue )
178 {
179 if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Frame" )))
180 aPropValue.Value >>= m_xFrame;
181 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CommandURL" )))
182 aPropValue.Value >>= m_aCommandURL;
183 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ServiceManager" )))
184 aPropValue.Value >>= m_xServiceManager;
185 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ParentWindow" )))
186 aPropValue.Value >>= m_xParentWindow;
187 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Identifier" )))
188 aPropValue.Value >>= m_nID;
189 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StatusbarItem" )))
190 aPropValue.Value >>= m_xStatusbarItem;
191 }
192 }
193
194 if ( m_aCommandURL.getLength() )
195 m_aListenerMap.insert( URLToDispatchMap::value_type( m_aCommandURL, Reference< XDispatch >() ));
196 }
197 }
198
update()199 void SAL_CALL StatusbarController::update()
200 {
201 {
202 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
203 if ( m_bDisposed )
204 throw DisposedException();
205 }
206
207 // Bind all registered listeners to their dispatch objects
208 bindListener();
209 }
210
211 // XComponent
dispose()212 void SAL_CALL StatusbarController::dispose()
213 {
214 Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
215
216 {
217 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
218 if ( m_bDisposed )
219 throw DisposedException();
220 }
221
222 com::sun::star::lang::EventObject aEvent( xThis );
223 m_aListenerContainer.disposeAndClear( aEvent );
224
225 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
226 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
227 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
228 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
229 com::sun::star::util::URL aTargetURL;
230 while ( pIter != m_aListenerMap.end() )
231 {
232 try
233 {
234 Reference< XDispatch > xDispatch( pIter->second );
235 aTargetURL.Complete = pIter->first;
236 xURLTransformer->parseStrict( aTargetURL );
237
238 if ( xDispatch.is() && xStatusListener.is() )
239 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
240 }
241 catch ( Exception& )
242 {
243 }
244
245 ++pIter;
246 }
247
248 // clear hash map
249 m_aListenerMap.clear();
250
251 // release references
252 m_xURLTransformer.clear();
253 m_xServiceManager.clear();
254 m_xFrame.clear();
255 m_xParentWindow.clear();
256 m_xStatusbarItem.clear();
257
258 m_bDisposed = sal_True;
259 }
260
addEventListener(const Reference<XEventListener> & xListener)261 void SAL_CALL StatusbarController::addEventListener( const Reference< XEventListener >& xListener )
262 {
263 m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
264 }
265
removeEventListener(const Reference<XEventListener> & aListener)266 void SAL_CALL StatusbarController::removeEventListener( const Reference< XEventListener >& aListener )
267 {
268 m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), aListener );
269 }
270
271 // XEventListener
disposing(const EventObject & Source)272 void SAL_CALL StatusbarController::disposing( const EventObject& Source )
273 {
274 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
275
276 if ( m_bDisposed )
277 return;
278
279 Reference< XFrame > xFrame( Source.Source, UNO_QUERY );
280 if ( xFrame.is() )
281 {
282 if ( xFrame == m_xFrame )
283 m_xFrame.clear();
284 return;
285 }
286
287 Reference< XDispatch > xDispatch( Source.Source, UNO_QUERY );
288 if ( !xDispatch.is() )
289 return;
290
291 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
292 while ( pIter != m_aListenerMap.end() )
293 {
294 // Compare references and release dispatch references if they are equal.
295 if ( xDispatch == pIter->second )
296 pIter->second.clear();
297 pIter++;
298 }
299 }
300
301 // XStatusListener
statusChanged(const FeatureStateEvent & Event)302 void SAL_CALL StatusbarController::statusChanged( const FeatureStateEvent& Event )
303 {
304 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
305
306 if ( m_bDisposed )
307 return;
308
309 Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
310 if ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR && m_nID != 0 )
311 {
312 rtl::OUString aStrValue;
313 StatusBar* pStatusBar = (StatusBar *)pWindow;
314
315 if ( Event.State >>= aStrValue )
316 pStatusBar->SetItemText( m_nID, aStrValue );
317 else if ( !Event.State.hasValue() )
318 pStatusBar->SetItemText( m_nID, String() );
319 }
320 }
321
322 // XStatusbarController
mouseButtonDown(const::com::sun::star::awt::MouseEvent &)323 ::sal_Bool SAL_CALL StatusbarController::mouseButtonDown(
324 const ::com::sun::star::awt::MouseEvent& )
325 {
326 return sal_False;
327 }
328
mouseMove(const::com::sun::star::awt::MouseEvent &)329 ::sal_Bool SAL_CALL StatusbarController::mouseMove(
330 const ::com::sun::star::awt::MouseEvent& )
331 {
332 return sal_False;
333 }
334
mouseButtonUp(const::com::sun::star::awt::MouseEvent &)335 ::sal_Bool SAL_CALL StatusbarController::mouseButtonUp(
336 const ::com::sun::star::awt::MouseEvent& )
337 {
338 return sal_False;
339 }
340
command(const::com::sun::star::awt::Point &,::sal_Int32,::sal_Bool,const::com::sun::star::uno::Any &)341 void SAL_CALL StatusbarController::command(
342 const ::com::sun::star::awt::Point&,
343 ::sal_Int32,
344 ::sal_Bool,
345 const ::com::sun::star::uno::Any& )
346 {
347 }
348
paint(const::com::sun::star::uno::Reference<::com::sun::star::awt::XGraphics> &,const::com::sun::star::awt::Rectangle &,::sal_Int32)349 void SAL_CALL StatusbarController::paint(
350 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >&,
351 const ::com::sun::star::awt::Rectangle&,
352 ::sal_Int32 )
353 {
354 }
355
click(const::com::sun::star::awt::Point &)356 void SAL_CALL StatusbarController::click( const ::com::sun::star::awt::Point& )
357 {
358 }
359
doubleClick(const::com::sun::star::awt::Point &)360 void SAL_CALL StatusbarController::doubleClick( const ::com::sun::star::awt::Point& )
361 {
362 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
363
364 if ( m_bDisposed )
365 return;
366
367 Sequence< PropertyValue > aArgs;
368 execute( aArgs );
369 }
370
addStatusListener(const rtl::OUString & aCommandURL)371 void StatusbarController::addStatusListener( const rtl::OUString& aCommandURL )
372 {
373 Reference< XDispatch > xDispatch;
374 Reference< XStatusListener > xStatusListener;
375 com::sun::star::util::URL aTargetURL;
376
377 {
378 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
379 URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
380
381 // Already in the list of status listener. Do nothing.
382 if ( pIter != m_aListenerMap.end() )
383 return;
384
385 // Check if we are already initialized. Implementation starts adding itself as status listener when
386 // initialize is called.
387 if ( !m_bInitialized )
388 {
389 // Put into the hash_map of status listener. Will be activated when initialized is called
390 m_aListenerMap.insert( URLToDispatchMap::value_type( aCommandURL, Reference< XDispatch >() ));
391 return;
392 }
393 else
394 {
395 // Add status listener directly as initialize has already been called.
396 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
397 if ( m_xServiceManager.is() && xDispatchProvider.is() )
398 {
399 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
400 aTargetURL.Complete = aCommandURL;
401 xURLTransformer->parseStrict( aTargetURL );
402 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
403
404 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
405 URLToDispatchMap::iterator aIter = m_aListenerMap.find( aCommandURL );
406 if ( aIter != m_aListenerMap.end() )
407 {
408 Reference< XDispatch > xOldDispatch( aIter->second );
409 aIter->second = xDispatch;
410
411 try
412 {
413 if ( xOldDispatch.is() )
414 xOldDispatch->removeStatusListener( xStatusListener, aTargetURL );
415 }
416 catch ( Exception& )
417 {
418 }
419 }
420 else
421 m_aListenerMap.insert( URLToDispatchMap::value_type( aCommandURL, xDispatch ));
422 }
423 }
424 }
425
426 // Call without locked mutex as we are called back from dispatch implementation
427 try
428 {
429 if ( xDispatch.is() )
430 xDispatch->addStatusListener( xStatusListener, aTargetURL );
431 }
432 catch ( Exception& )
433 {
434 }
435 }
436
removeStatusListener(const rtl::OUString & aCommandURL)437 void StatusbarController::removeStatusListener( const rtl::OUString& aCommandURL )
438 {
439 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
440
441 URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
442 if ( pIter != m_aListenerMap.end() )
443 {
444 Reference< XDispatch > xDispatch( pIter->second );
445 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
446 m_aListenerMap.erase( pIter );
447
448 try
449 {
450 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
451 com::sun::star::util::URL aTargetURL;
452 aTargetURL.Complete = aCommandURL;
453 xURLTransformer->parseStrict( aTargetURL );
454
455 if ( xDispatch.is() && xStatusListener.is() )
456 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
457 }
458 catch ( Exception& )
459 {
460 }
461 }
462 }
463
bindListener()464 void StatusbarController::bindListener()
465 {
466 std::vector< Listener > aDispatchVector;
467 Reference< XStatusListener > xStatusListener;
468
469 {
470 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
471
472 if ( !m_bInitialized )
473 return;
474
475 // Collect all registered command URL's and store them temporary
476 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
477 if ( m_xServiceManager.is() && xDispatchProvider.is() )
478 {
479 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
480 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
481 while ( pIter != m_aListenerMap.end() )
482 {
483 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
484 com::sun::star::util::URL aTargetURL;
485 aTargetURL.Complete = pIter->first;
486 xURLTransformer->parseStrict( aTargetURL );
487
488 Reference< XDispatch > xDispatch( pIter->second );
489 if ( xDispatch.is() )
490 {
491 // We already have a dispatch object => we have to requery.
492 // Release old dispatch object and remove it as listener
493 try
494 {
495 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
496 }
497 catch ( Exception& )
498 {
499 }
500 }
501
502 pIter->second.clear();
503 xDispatch.clear();
504
505 // Query for dispatch object. Old dispatch will be released with this, too.
506 try
507 {
508 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
509 }
510 catch ( Exception& )
511 {
512 }
513 pIter->second = xDispatch;
514
515 Listener aListener( aTargetURL, xDispatch );
516 aDispatchVector.push_back( aListener );
517 ++pIter;
518 }
519 }
520 }
521
522 // Call without locked mutex as we are called back from dispatch implementation
523 if ( !xStatusListener.is() )
524 return;
525
526 for ( sal_uInt32 i = 0; i < aDispatchVector.size(); i++ )
527 {
528 try
529 {
530 Listener& rListener = aDispatchVector[i];
531 if ( rListener.xDispatch.is() )
532 rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL );
533 else if ( rListener.aURL.Complete == m_aCommandURL )
534 {
535 // Send status changed for the main URL, if we cannot get a valid dispatch object.
536 // UI disables the button. Catch exception as we release our mutex, it is possible
537 // that someone else already disposed this instance!
538 FeatureStateEvent aFeatureStateEvent;
539 aFeatureStateEvent.IsEnabled = sal_False;
540 aFeatureStateEvent.FeatureURL = rListener.aURL;
541 aFeatureStateEvent.State = Any();
542 xStatusListener->statusChanged( aFeatureStateEvent );
543 }
544 }
545 catch ( ... ){}
546 }
547 }
548
unbindListener()549 void StatusbarController::unbindListener()
550 {
551 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
552
553 if ( !m_bInitialized )
554 return;
555
556 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
557 URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
558 while ( pIter != m_aListenerMap.end() )
559 {
560 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
561 com::sun::star::util::URL aTargetURL;
562 aTargetURL.Complete = pIter->first;
563 xURLTransformer->parseStrict( aTargetURL );
564
565 Reference< XDispatch > xDispatch( pIter->second );
566 if ( xDispatch.is() )
567 {
568 // We already have a dispatch object => we have to requery.
569 // Release old dispatch object and remove it as listener
570 try
571 {
572 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
573 }
574 catch ( Exception& )
575 {
576 }
577 }
578 pIter->second.clear();
579 ++pIter;
580 }
581 }
582
isBound() const583 sal_Bool StatusbarController::isBound() const
584 {
585 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
586
587 if ( !m_bInitialized )
588 return sal_False;
589
590 URLToDispatchMap::const_iterator pIter = m_aListenerMap.find( m_aCommandURL );
591 if ( pIter != m_aListenerMap.end() )
592 return ( pIter->second.is() );
593
594 return sal_False;
595 }
596
updateStatus()597 void StatusbarController::updateStatus()
598 {
599 bindListener();
600 }
601
updateStatus(const rtl::OUString aCommandURL)602 void StatusbarController::updateStatus( const rtl::OUString aCommandURL )
603 {
604 Reference< XDispatch > xDispatch;
605 Reference< XStatusListener > xStatusListener;
606 com::sun::star::util::URL aTargetURL;
607
608 {
609 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
610
611 if ( !m_bInitialized )
612 return;
613
614 // Try to find a dispatch object for the requested command URL
615 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
616 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
617 if ( m_xServiceManager.is() && xDispatchProvider.is() )
618 {
619 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
620 aTargetURL.Complete = aCommandURL;
621 xURLTransformer->parseStrict( aTargetURL );
622 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 );
623 }
624 }
625
626 if ( xDispatch.is() && xStatusListener.is() )
627 {
628 // Catch exception as we release our mutex, it is possible that someone else
629 // has already disposed this instance!
630 // Add/remove status listener to get a update status information from the
631 // requested command.
632 try
633 {
634 xDispatch->addStatusListener( xStatusListener, aTargetURL );
635 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
636 }
637 catch ( Exception& )
638 {
639 }
640 }
641 }
642
getControlRect() const643 ::Rectangle StatusbarController::getControlRect() const
644 {
645 ::Rectangle aRect;
646
647 {
648 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
649
650 if ( m_bDisposed )
651 throw DisposedException();
652
653 if ( m_xParentWindow.is() )
654 {
655 StatusBar* pStatusBar = dynamic_cast< StatusBar* >( VCLUnoHelper::GetWindow( m_xParentWindow ));
656 if ( pStatusBar && pStatusBar->GetType() == WINDOW_STATUSBAR )
657 aRect = pStatusBar->GetItemRect( m_nID );
658 }
659 }
660
661 return aRect;
662 }
663
execute(const::com::sun::star::uno::Sequence<::com::sun::star::beans::PropertyValue> & aArgs)664 void StatusbarController::execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
665 {
666 Reference< XDispatch > xDispatch;
667 Reference< XURLTransformer > xURLTransformer;
668 rtl::OUString aCommandURL;
669
670 {
671 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
672
673 if ( m_bDisposed )
674 throw DisposedException();
675
676 if ( m_bInitialized &&
677 m_xFrame.is() &&
678 m_xServiceManager.is() &&
679 m_aCommandURL.getLength() )
680 {
681 xURLTransformer = getURLTransformer();
682 aCommandURL = m_aCommandURL;
683 URLToDispatchMap::iterator pIter = m_aListenerMap.find( m_aCommandURL );
684 if ( pIter != m_aListenerMap.end() )
685 xDispatch = pIter->second;
686 }
687 }
688
689 if ( xDispatch.is() && xURLTransformer.is() )
690 {
691 try
692 {
693 com::sun::star::util::URL aTargetURL;
694
695 aTargetURL.Complete = aCommandURL;
696 xURLTransformer->parseStrict( aTargetURL );
697 xDispatch->dispatch( aTargetURL, aArgs );
698 }
699 catch ( DisposedException& )
700 {
701 }
702 }
703 }
704
execute(const rtl::OUString & aCommandURL,const Sequence<::com::sun::star::beans::PropertyValue> & aArgs)705 void StatusbarController::execute(
706 const rtl::OUString& aCommandURL,
707 const Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
708 {
709 Reference< XDispatch > xDispatch;
710 com::sun::star::util::URL aTargetURL;
711
712 {
713 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
714
715 if ( m_bDisposed )
716 throw DisposedException();
717
718 if ( m_bInitialized &&
719 m_xFrame.is() &&
720 m_xServiceManager.is() &&
721 m_aCommandURL.getLength() )
722 {
723 Reference< XURLTransformer > xURLTransformer( getURLTransformer() );
724 aTargetURL.Complete = aCommandURL;
725 xURLTransformer->parseStrict( aTargetURL );
726
727 URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
728 if ( pIter != m_aListenerMap.end() )
729 xDispatch = pIter->second;
730 else
731 {
732 Reference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider(
733 m_xFrame->getController(), UNO_QUERY );
734 if ( xDispatchProvider.is() )
735 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
736 }
737 }
738 }
739
740 if ( xDispatch.is() )
741 {
742 try
743 {
744 xDispatch->dispatch( aTargetURL, aArgs );
745 }
746 catch ( DisposedException& )
747 {
748 }
749 }
750 }
751
752 } // svt
753