15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55900e8ecSAndrew Rist  * distributed with this work for additional information
65900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
105900e8ecSAndrew Rist  *
115900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist  *
135900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist  * software distributed under the License is distributed on an
155900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
175900e8ecSAndrew Rist  * specific language governing permissions and limitations
185900e8ecSAndrew Rist  * under the License.
195900e8ecSAndrew Rist  *
205900e8ecSAndrew Rist  *************************************************************/
215900e8ecSAndrew Rist 
225900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <svtools/statusbarcontroller.hxx>
27cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
29cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
32cdf0e10cSrcweir #include <vos/mutex.hxx>
33cdf0e10cSrcweir #include <vcl/svapp.hxx>
34cdf0e10cSrcweir #include <vcl/window.hxx>
35cdf0e10cSrcweir #include <vcl/status.hxx>
36cdf0e10cSrcweir #include <svtools/imgdef.hxx>
37cdf0e10cSrcweir #include <svtools/miscopt.hxx>
380c02d14eSAriel Constenla-Haile #include <toolkit/helper/vclunohelper.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace ::cppu;
41cdf0e10cSrcweir using namespace ::com::sun::star::awt;
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir using namespace ::com::sun::star::util;
44cdf0e10cSrcweir using namespace ::com::sun::star::beans;
45cdf0e10cSrcweir using namespace ::com::sun::star::lang;
46cdf0e10cSrcweir using namespace ::com::sun::star::frame;
47cdf0e10cSrcweir using namespace ::com::sun::star::frame;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace svt
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 
StatusbarController(const Reference<XMultiServiceFactory> & rServiceManager,const Reference<XFrame> & xFrame,const::rtl::OUString & aCommandURL,unsigned short nID)52cdf0e10cSrcweir StatusbarController::StatusbarController(
53cdf0e10cSrcweir     const Reference< XMultiServiceFactory >& rServiceManager,
54cdf0e10cSrcweir     const Reference< XFrame >& xFrame,
55cdf0e10cSrcweir     const ::rtl::OUString& aCommandURL,
56cdf0e10cSrcweir     unsigned short nID ) :
57cdf0e10cSrcweir     OWeakObject()
58cdf0e10cSrcweir     ,   m_bInitialized( sal_False )
59cdf0e10cSrcweir     ,   m_bDisposed( sal_False )
60cdf0e10cSrcweir     ,   m_nID( nID )
61cdf0e10cSrcweir     ,   m_xFrame( xFrame )
62cdf0e10cSrcweir     ,   m_xServiceManager( rServiceManager )
63cdf0e10cSrcweir     ,   m_aCommandURL( aCommandURL )
64cdf0e10cSrcweir     ,   m_aListenerContainer( m_aMutex )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
StatusbarController()68cdf0e10cSrcweir StatusbarController::StatusbarController() :
69cdf0e10cSrcweir     OWeakObject()
70cdf0e10cSrcweir     ,   m_bInitialized( sal_False )
71cdf0e10cSrcweir     ,   m_bDisposed( sal_False )
72cdf0e10cSrcweir     ,   m_nID( 0 )
73cdf0e10cSrcweir     ,   m_aListenerContainer( m_aMutex )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
~StatusbarController()77cdf0e10cSrcweir StatusbarController::~StatusbarController()
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
getFrameInterface() const81cdf0e10cSrcweir Reference< XFrame > StatusbarController::getFrameInterface() const
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
84cdf0e10cSrcweir     return m_xFrame;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
getServiceManager() const87cdf0e10cSrcweir Reference< XMultiServiceFactory > StatusbarController::getServiceManager() const
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
90cdf0e10cSrcweir     return m_xServiceManager;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
getLayoutManager() const93cdf0e10cSrcweir Reference< XLayoutManager > StatusbarController::getLayoutManager() const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
96cdf0e10cSrcweir     Reference< XLayoutManager > xLayoutManager;
97cdf0e10cSrcweir     Reference< XPropertySet > xPropSet( m_xFrame, UNO_QUERY );
98cdf0e10cSrcweir     if ( xPropSet.is() )
99cdf0e10cSrcweir     {
100cdf0e10cSrcweir         try
101cdf0e10cSrcweir         {
102cdf0e10cSrcweir             Any a;
103cdf0e10cSrcweir             a = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
104cdf0e10cSrcweir             a >>= xLayoutManager;
105cdf0e10cSrcweir         }
106cdf0e10cSrcweir         catch ( Exception& )
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir         }
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     return xLayoutManager;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
getURLTransformer() const114cdf0e10cSrcweir Reference< XURLTransformer > StatusbarController::getURLTransformer() const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
117cdf0e10cSrcweir     if ( !m_xURLTransformer.is() && m_xServiceManager.is() )
118cdf0e10cSrcweir     {
119cdf0e10cSrcweir         m_xURLTransformer = Reference< XURLTransformer >(
120cdf0e10cSrcweir                                 m_xServiceManager->createInstance(
121cdf0e10cSrcweir                                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))),
122cdf0e10cSrcweir                                 UNO_QUERY );
123cdf0e10cSrcweir     }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     return m_xURLTransformer;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir // XInterface
queryInterface(const Type & rType)129cdf0e10cSrcweir Any SAL_CALL StatusbarController::queryInterface( const Type& rType )
130cdf0e10cSrcweir throw ( RuntimeException )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	Any a = ::cppu::queryInterface(
133cdf0e10cSrcweir 				rType ,
134cdf0e10cSrcweir 				static_cast< XStatusbarController* >( this ),
135cdf0e10cSrcweir 				static_cast< XStatusListener* >( this ),
136cdf0e10cSrcweir 				static_cast< XEventListener* >( this ),
137cdf0e10cSrcweir 				static_cast< XInitialization* >( this ),
138cdf0e10cSrcweir                 static_cast< XComponent* >( this ),
139cdf0e10cSrcweir                 static_cast< XUpdatable* >( this ));
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	if ( a.hasValue() )
142cdf0e10cSrcweir 		return a;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	return OWeakObject::queryInterface( rType );
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
acquire()147cdf0e10cSrcweir void SAL_CALL StatusbarController::acquire() throw ()
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     OWeakObject::acquire();
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
release()152cdf0e10cSrcweir void SAL_CALL StatusbarController::release() throw ()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     OWeakObject::release();
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
initialize(const Sequence<Any> & aArguments)157cdf0e10cSrcweir void SAL_CALL StatusbarController::initialize( const Sequence< Any >& aArguments )
158cdf0e10cSrcweir throw ( Exception, RuntimeException )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     bool bInitialized( true );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     {
163cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir         if ( m_bDisposed )
166cdf0e10cSrcweir             throw DisposedException();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         bInitialized = m_bInitialized;
169cdf0e10cSrcweir     }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     if ( !bInitialized )
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
174cdf0e10cSrcweir         m_bInitialized = sal_True;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         PropertyValue aPropValue;
177cdf0e10cSrcweir         for ( int i = 0; i < aArguments.getLength(); i++ )
178cdf0e10cSrcweir         {
179cdf0e10cSrcweir             if ( aArguments[i] >>= aPropValue )
180cdf0e10cSrcweir             {
1810c02d14eSAriel Constenla-Haile                 if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Frame" )))
182cdf0e10cSrcweir                     aPropValue.Value >>= m_xFrame;
1830c02d14eSAriel Constenla-Haile                 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CommandURL" )))
184cdf0e10cSrcweir                     aPropValue.Value >>= m_aCommandURL;
1850c02d14eSAriel Constenla-Haile                 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ServiceManager" )))
186cdf0e10cSrcweir                     aPropValue.Value >>= m_xServiceManager;
1870c02d14eSAriel Constenla-Haile                 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ParentWindow" )))
188cdf0e10cSrcweir                     aPropValue.Value >>= m_xParentWindow;
1890c02d14eSAriel Constenla-Haile 				else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Identifier" )))
190cdf0e10cSrcweir 					aPropValue.Value >>= m_nID;
1910c02d14eSAriel Constenla-Haile                 else if ( aPropValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StatusbarItem" )))
1920c02d14eSAriel Constenla-Haile                     aPropValue.Value >>= m_xStatusbarItem;
193cdf0e10cSrcweir             }
194cdf0e10cSrcweir         }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         if ( m_aCommandURL.getLength() )
197cdf0e10cSrcweir             m_aListenerMap.insert( URLToDispatchMap::value_type( m_aCommandURL, Reference< XDispatch >() ));
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
update()201cdf0e10cSrcweir void SAL_CALL StatusbarController::update()
202cdf0e10cSrcweir throw ( RuntimeException )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
206cdf0e10cSrcweir         if ( m_bDisposed )
207cdf0e10cSrcweir             throw DisposedException();
208cdf0e10cSrcweir     }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     // Bind all registered listeners to their dispatch objects
211cdf0e10cSrcweir     bindListener();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir // XComponent
dispose()215cdf0e10cSrcweir void SAL_CALL StatusbarController::dispose()
216cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
217cdf0e10cSrcweir {
218cdf0e10cSrcweir     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
222cdf0e10cSrcweir         if ( m_bDisposed )
223cdf0e10cSrcweir             throw DisposedException();
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     com::sun::star::lang::EventObject aEvent( xThis );
227cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
230cdf0e10cSrcweir     Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
231cdf0e10cSrcweir     Reference< XURLTransformer > xURLTransformer = getURLTransformer();
232cdf0e10cSrcweir     URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
233cdf0e10cSrcweir     com::sun::star::util::URL aTargetURL;
234cdf0e10cSrcweir     while ( pIter != m_aListenerMap.end() )
235cdf0e10cSrcweir     {
236cdf0e10cSrcweir         try
237cdf0e10cSrcweir         {
238cdf0e10cSrcweir             Reference< XDispatch > xDispatch( pIter->second );
239cdf0e10cSrcweir             aTargetURL.Complete = pIter->first;
240cdf0e10cSrcweir             xURLTransformer->parseStrict( aTargetURL );
241cdf0e10cSrcweir 
242cdf0e10cSrcweir             if ( xDispatch.is() && xStatusListener.is() )
243cdf0e10cSrcweir                 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir         catch ( Exception& )
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir         }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         ++pIter;
250cdf0e10cSrcweir     }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     // clear hash map
253cdf0e10cSrcweir     m_aListenerMap.clear();
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     // release references
256cdf0e10cSrcweir     m_xURLTransformer.clear();
257cdf0e10cSrcweir     m_xServiceManager.clear();
258cdf0e10cSrcweir     m_xFrame.clear();
259cdf0e10cSrcweir     m_xParentWindow.clear();
2600c02d14eSAriel Constenla-Haile     m_xStatusbarItem.clear();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     m_bDisposed = sal_True;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
addEventListener(const Reference<XEventListener> & xListener)265cdf0e10cSrcweir void SAL_CALL StatusbarController::addEventListener( const Reference< XEventListener >& xListener )
266cdf0e10cSrcweir throw ( RuntimeException )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
removeEventListener(const Reference<XEventListener> & aListener)271cdf0e10cSrcweir void SAL_CALL StatusbarController::removeEventListener( const Reference< XEventListener >& aListener )
272cdf0e10cSrcweir throw ( RuntimeException )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), aListener );
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // XEventListener
disposing(const EventObject & Source)278cdf0e10cSrcweir void SAL_CALL StatusbarController::disposing( const EventObject& Source )
279cdf0e10cSrcweir throw ( RuntimeException )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     if ( m_bDisposed )
284cdf0e10cSrcweir         return;
285cdf0e10cSrcweir 
2860c02d14eSAriel Constenla-Haile     Reference< XFrame > xFrame( Source.Source, UNO_QUERY );
2870c02d14eSAriel Constenla-Haile     if ( xFrame.is() )
2880c02d14eSAriel Constenla-Haile     {
2890c02d14eSAriel Constenla-Haile         if ( xFrame == m_xFrame )
2900c02d14eSAriel Constenla-Haile             m_xFrame.clear();
2910c02d14eSAriel Constenla-Haile         return;
2920c02d14eSAriel Constenla-Haile     }
2930c02d14eSAriel Constenla-Haile 
2940c02d14eSAriel Constenla-Haile     Reference< XDispatch > xDispatch( Source.Source, UNO_QUERY );
2950c02d14eSAriel Constenla-Haile     if ( !xDispatch.is() )
2960c02d14eSAriel Constenla-Haile         return;
2970c02d14eSAriel Constenla-Haile 
298cdf0e10cSrcweir     URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
299cdf0e10cSrcweir     while ( pIter != m_aListenerMap.end() )
300cdf0e10cSrcweir     {
301cdf0e10cSrcweir         // Compare references and release dispatch references if they are equal.
3020c02d14eSAriel Constenla-Haile         if ( xDispatch == pIter->second )
303cdf0e10cSrcweir             pIter->second.clear();
304cdf0e10cSrcweir         pIter++;
305cdf0e10cSrcweir     }
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir // XStatusListener
statusChanged(const FeatureStateEvent & Event)309cdf0e10cSrcweir void SAL_CALL StatusbarController::statusChanged( const FeatureStateEvent& Event )
310cdf0e10cSrcweir throw ( RuntimeException )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     if ( m_bDisposed )
315cdf0e10cSrcweir         return;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir     Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
318cdf0e10cSrcweir     if ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR && m_nID != 0 )
319cdf0e10cSrcweir     {
320cdf0e10cSrcweir         rtl::OUString aStrValue;
321cdf0e10cSrcweir         StatusBar*    pStatusBar = (StatusBar *)pWindow;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir         if ( Event.State >>= aStrValue )
324cdf0e10cSrcweir             pStatusBar->SetItemText( m_nID, aStrValue );
325cdf0e10cSrcweir         else if ( !Event.State.hasValue() )
326cdf0e10cSrcweir             pStatusBar->SetItemText( m_nID, String() );
327cdf0e10cSrcweir     }
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir // XStatusbarController
mouseButtonDown(const::com::sun::star::awt::MouseEvent &)331cdf0e10cSrcweir ::sal_Bool SAL_CALL StatusbarController::mouseButtonDown(
332cdf0e10cSrcweir     const ::com::sun::star::awt::MouseEvent& )
333cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir     return sal_False;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
mouseMove(const::com::sun::star::awt::MouseEvent &)338cdf0e10cSrcweir ::sal_Bool SAL_CALL StatusbarController::mouseMove(
339cdf0e10cSrcweir     const ::com::sun::star::awt::MouseEvent& )
340cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     return sal_False;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
mouseButtonUp(const::com::sun::star::awt::MouseEvent &)345cdf0e10cSrcweir ::sal_Bool SAL_CALL StatusbarController::mouseButtonUp(
346cdf0e10cSrcweir     const ::com::sun::star::awt::MouseEvent& )
347cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir     return sal_False;
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
command(const::com::sun::star::awt::Point &,::sal_Int32,::sal_Bool,const::com::sun::star::uno::Any &)352cdf0e10cSrcweir void SAL_CALL StatusbarController::command(
353cdf0e10cSrcweir     const ::com::sun::star::awt::Point&,
354cdf0e10cSrcweir     ::sal_Int32,
355cdf0e10cSrcweir     ::sal_Bool,
356cdf0e10cSrcweir     const ::com::sun::star::uno::Any& )
357cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
paint(const::com::sun::star::uno::Reference<::com::sun::star::awt::XGraphics> &,const::com::sun::star::awt::Rectangle &,::sal_Int32)361cdf0e10cSrcweir void SAL_CALL StatusbarController::paint(
362cdf0e10cSrcweir     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >&,
363cdf0e10cSrcweir     const ::com::sun::star::awt::Rectangle&,
364cdf0e10cSrcweir     ::sal_Int32 )
365cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
click(const::com::sun::star::awt::Point &)3690c02d14eSAriel Constenla-Haile void SAL_CALL StatusbarController::click( const ::com::sun::star::awt::Point& )
370cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
371cdf0e10cSrcweir {
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
doubleClick(const::com::sun::star::awt::Point &)3740c02d14eSAriel Constenla-Haile void SAL_CALL StatusbarController::doubleClick( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     if ( m_bDisposed )
379cdf0e10cSrcweir         return;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     Sequence< PropertyValue > aArgs;
382cdf0e10cSrcweir     execute( aArgs );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
addStatusListener(const rtl::OUString & aCommandURL)385cdf0e10cSrcweir void StatusbarController::addStatusListener( const rtl::OUString& aCommandURL )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir     Reference< XDispatch >       xDispatch;
388cdf0e10cSrcweir     Reference< XStatusListener > xStatusListener;
389cdf0e10cSrcweir     com::sun::star::util::URL    aTargetURL;
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
393cdf0e10cSrcweir         URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
394cdf0e10cSrcweir 
395cdf0e10cSrcweir         // Already in the list of status listener. Do nothing.
396cdf0e10cSrcweir         if ( pIter != m_aListenerMap.end() )
397cdf0e10cSrcweir             return;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir         // Check if we are already initialized. Implementation starts adding itself as status listener when
400*509df7cbSJohn Bampton         // initialize is called.
401cdf0e10cSrcweir         if ( !m_bInitialized )
402cdf0e10cSrcweir         {
403cdf0e10cSrcweir             // Put into the hash_map of status listener. Will be activated when initialized is called
404cdf0e10cSrcweir             m_aListenerMap.insert( URLToDispatchMap::value_type( aCommandURL, Reference< XDispatch >() ));
405cdf0e10cSrcweir             return;
406cdf0e10cSrcweir         }
407cdf0e10cSrcweir         else
408cdf0e10cSrcweir         {
409*509df7cbSJohn Bampton             // Add status listener directly as initialize has already been called.
410cdf0e10cSrcweir             Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
411cdf0e10cSrcweir             if ( m_xServiceManager.is() && xDispatchProvider.is() )
412cdf0e10cSrcweir             {
413cdf0e10cSrcweir                 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
414cdf0e10cSrcweir                 aTargetURL.Complete = aCommandURL;
415cdf0e10cSrcweir                 xURLTransformer->parseStrict( aTargetURL );
416cdf0e10cSrcweir                 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
417cdf0e10cSrcweir 
418cdf0e10cSrcweir                 xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
419cdf0e10cSrcweir                 URLToDispatchMap::iterator aIter = m_aListenerMap.find( aCommandURL );
420cdf0e10cSrcweir                 if ( aIter != m_aListenerMap.end() )
421cdf0e10cSrcweir                 {
422cdf0e10cSrcweir                     Reference< XDispatch > xOldDispatch( aIter->second );
423cdf0e10cSrcweir                     aIter->second = xDispatch;
424cdf0e10cSrcweir 
425cdf0e10cSrcweir                     try
426cdf0e10cSrcweir                     {
427cdf0e10cSrcweir                         if ( xOldDispatch.is() )
428cdf0e10cSrcweir                             xOldDispatch->removeStatusListener( xStatusListener, aTargetURL );
429cdf0e10cSrcweir                     }
430cdf0e10cSrcweir                     catch ( Exception& )
431cdf0e10cSrcweir                     {
432cdf0e10cSrcweir                     }
433cdf0e10cSrcweir                 }
434cdf0e10cSrcweir                 else
435cdf0e10cSrcweir                     m_aListenerMap.insert( URLToDispatchMap::value_type( aCommandURL, xDispatch ));
436cdf0e10cSrcweir             }
437cdf0e10cSrcweir         }
438cdf0e10cSrcweir     }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     // Call without locked mutex as we are called back from dispatch implementation
441cdf0e10cSrcweir     try
442cdf0e10cSrcweir     {
443cdf0e10cSrcweir         if ( xDispatch.is() )
444cdf0e10cSrcweir             xDispatch->addStatusListener( xStatusListener, aTargetURL );
445cdf0e10cSrcweir     }
446cdf0e10cSrcweir     catch ( Exception& )
447cdf0e10cSrcweir     {
448cdf0e10cSrcweir     }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
removeStatusListener(const rtl::OUString & aCommandURL)451cdf0e10cSrcweir void StatusbarController::removeStatusListener( const rtl::OUString& aCommandURL )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir     URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
456cdf0e10cSrcweir     if ( pIter != m_aListenerMap.end() )
457cdf0e10cSrcweir     {
458cdf0e10cSrcweir         Reference< XDispatch > xDispatch( pIter->second );
459cdf0e10cSrcweir         Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
460cdf0e10cSrcweir         m_aListenerMap.erase( pIter );
461cdf0e10cSrcweir 
462cdf0e10cSrcweir         try
463cdf0e10cSrcweir         {
464cdf0e10cSrcweir             Reference< XURLTransformer > xURLTransformer = getURLTransformer();
465cdf0e10cSrcweir             com::sun::star::util::URL aTargetURL;
466cdf0e10cSrcweir             aTargetURL.Complete = aCommandURL;
467cdf0e10cSrcweir             xURLTransformer->parseStrict( aTargetURL );
468cdf0e10cSrcweir 
469cdf0e10cSrcweir             if ( xDispatch.is() && xStatusListener.is() )
470cdf0e10cSrcweir                 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
471cdf0e10cSrcweir         }
472cdf0e10cSrcweir         catch ( Exception& )
473cdf0e10cSrcweir         {
474cdf0e10cSrcweir         }
475cdf0e10cSrcweir     }
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
bindListener()478cdf0e10cSrcweir void StatusbarController::bindListener()
479cdf0e10cSrcweir {
480cdf0e10cSrcweir     std::vector< Listener > aDispatchVector;
481cdf0e10cSrcweir     Reference< XStatusListener > xStatusListener;
482cdf0e10cSrcweir 
483cdf0e10cSrcweir     {
484cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
485cdf0e10cSrcweir 
486cdf0e10cSrcweir         if ( !m_bInitialized )
487cdf0e10cSrcweir             return;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir         // Collect all registered command URL's and store them temporary
490cdf0e10cSrcweir         Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
491cdf0e10cSrcweir         if ( m_xServiceManager.is() && xDispatchProvider.is() )
492cdf0e10cSrcweir         {
493cdf0e10cSrcweir             xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
494cdf0e10cSrcweir             URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
495cdf0e10cSrcweir             while ( pIter != m_aListenerMap.end() )
496cdf0e10cSrcweir             {
497cdf0e10cSrcweir                 Reference< XURLTransformer > xURLTransformer = getURLTransformer();
498cdf0e10cSrcweir                 com::sun::star::util::URL aTargetURL;
499cdf0e10cSrcweir                 aTargetURL.Complete = pIter->first;
500cdf0e10cSrcweir                 xURLTransformer->parseStrict( aTargetURL );
501cdf0e10cSrcweir 
502cdf0e10cSrcweir                 Reference< XDispatch > xDispatch( pIter->second );
503cdf0e10cSrcweir                 if ( xDispatch.is() )
504cdf0e10cSrcweir                 {
505cdf0e10cSrcweir                     // We already have a dispatch object => we have to requery.
506cdf0e10cSrcweir                     // Release old dispatch object and remove it as listener
507cdf0e10cSrcweir                     try
508cdf0e10cSrcweir                     {
509cdf0e10cSrcweir                         xDispatch->removeStatusListener( xStatusListener, aTargetURL );
510cdf0e10cSrcweir                     }
511cdf0e10cSrcweir                     catch ( Exception& )
512cdf0e10cSrcweir                     {
513cdf0e10cSrcweir                     }
514cdf0e10cSrcweir                 }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir                 pIter->second.clear();
517cdf0e10cSrcweir                 xDispatch.clear();
518cdf0e10cSrcweir 
519cdf0e10cSrcweir                 // Query for dispatch object. Old dispatch will be released with this, too.
520cdf0e10cSrcweir                 try
521cdf0e10cSrcweir                 {
522cdf0e10cSrcweir                     xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
523cdf0e10cSrcweir                 }
524cdf0e10cSrcweir                 catch ( Exception& )
525cdf0e10cSrcweir                 {
526cdf0e10cSrcweir                 }
527cdf0e10cSrcweir                 pIter->second = xDispatch;
528cdf0e10cSrcweir 
529cdf0e10cSrcweir                 Listener aListener( aTargetURL, xDispatch );
530cdf0e10cSrcweir                 aDispatchVector.push_back( aListener );
531cdf0e10cSrcweir                 ++pIter;
532cdf0e10cSrcweir             }
533cdf0e10cSrcweir         }
534cdf0e10cSrcweir     }
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     // Call without locked mutex as we are called back from dispatch implementation
5370c02d14eSAriel Constenla-Haile     if ( !xStatusListener.is() )
5380c02d14eSAriel Constenla-Haile         return;
5390c02d14eSAriel Constenla-Haile 
5400c02d14eSAriel Constenla-Haile     for ( sal_uInt32 i = 0; i < aDispatchVector.size(); i++ )
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         try
543cdf0e10cSrcweir         {
5440c02d14eSAriel Constenla-Haile             Listener& rListener = aDispatchVector[i];
5450c02d14eSAriel Constenla-Haile             if ( rListener.xDispatch.is() )
5460c02d14eSAriel Constenla-Haile                 rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL );
5470c02d14eSAriel Constenla-Haile             else if ( rListener.aURL.Complete == m_aCommandURL )
548cdf0e10cSrcweir             {
5490c02d14eSAriel Constenla-Haile                 // Send status changed for the main URL, if we cannot get a valid dispatch object.
5500c02d14eSAriel Constenla-Haile                 // UI disables the button. Catch exception as we release our mutex, it is possible
5510c02d14eSAriel Constenla-Haile                 // that someone else already disposed this instance!
5520c02d14eSAriel Constenla-Haile                 FeatureStateEvent aFeatureStateEvent;
5530c02d14eSAriel Constenla-Haile                 aFeatureStateEvent.IsEnabled = sal_False;
5540c02d14eSAriel Constenla-Haile                 aFeatureStateEvent.FeatureURL = rListener.aURL;
5550c02d14eSAriel Constenla-Haile                 aFeatureStateEvent.State = Any();
5560c02d14eSAriel Constenla-Haile                 xStatusListener->statusChanged( aFeatureStateEvent );
557cdf0e10cSrcweir             }
558cdf0e10cSrcweir         }
5590c02d14eSAriel Constenla-Haile         catch ( ... ){}
560cdf0e10cSrcweir     }
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
unbindListener()563cdf0e10cSrcweir void StatusbarController::unbindListener()
564cdf0e10cSrcweir {
565cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     if ( !m_bInitialized )
568cdf0e10cSrcweir         return;
569cdf0e10cSrcweir 
5700c02d14eSAriel Constenla-Haile     Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
5710c02d14eSAriel Constenla-Haile     URLToDispatchMap::iterator pIter = m_aListenerMap.begin();
5720c02d14eSAriel Constenla-Haile     while ( pIter != m_aListenerMap.end() )
573cdf0e10cSrcweir     {
5740c02d14eSAriel Constenla-Haile         Reference< XURLTransformer > xURLTransformer = getURLTransformer();
5750c02d14eSAriel Constenla-Haile         com::sun::star::util::URL aTargetURL;
5760c02d14eSAriel Constenla-Haile         aTargetURL.Complete = pIter->first;
5770c02d14eSAriel Constenla-Haile         xURLTransformer->parseStrict( aTargetURL );
578cdf0e10cSrcweir 
5790c02d14eSAriel Constenla-Haile         Reference< XDispatch > xDispatch( pIter->second );
5800c02d14eSAriel Constenla-Haile         if ( xDispatch.is() )
5810c02d14eSAriel Constenla-Haile         {
5820c02d14eSAriel Constenla-Haile             // We already have a dispatch object => we have to requery.
5830c02d14eSAriel Constenla-Haile             // Release old dispatch object and remove it as listener
5840c02d14eSAriel Constenla-Haile             try
5850c02d14eSAriel Constenla-Haile             {
5860c02d14eSAriel Constenla-Haile                 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
5870c02d14eSAriel Constenla-Haile             }
5880c02d14eSAriel Constenla-Haile             catch ( Exception& )
589cdf0e10cSrcweir             {
590cdf0e10cSrcweir             }
591cdf0e10cSrcweir         }
5920c02d14eSAriel Constenla-Haile         pIter->second.clear();
5930c02d14eSAriel Constenla-Haile         ++pIter;
594cdf0e10cSrcweir     }
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
isBound() const597cdf0e10cSrcweir sal_Bool StatusbarController::isBound() const
598cdf0e10cSrcweir {
599cdf0e10cSrcweir     vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     if ( !m_bInitialized )
602cdf0e10cSrcweir         return sal_False;
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     URLToDispatchMap::const_iterator pIter = m_aListenerMap.find( m_aCommandURL );
605cdf0e10cSrcweir     if ( pIter != m_aListenerMap.end() )
606cdf0e10cSrcweir         return ( pIter->second.is() );
607cdf0e10cSrcweir 
608cdf0e10cSrcweir     return sal_False;
609cdf0e10cSrcweir }
610cdf0e10cSrcweir 
updateStatus()611cdf0e10cSrcweir void StatusbarController::updateStatus()
612cdf0e10cSrcweir {
613cdf0e10cSrcweir     bindListener();
614cdf0e10cSrcweir }
615cdf0e10cSrcweir 
updateStatus(const rtl::OUString aCommandURL)616cdf0e10cSrcweir void StatusbarController::updateStatus( const rtl::OUString aCommandURL )
617cdf0e10cSrcweir {
618cdf0e10cSrcweir     Reference< XDispatch > xDispatch;
619cdf0e10cSrcweir     Reference< XStatusListener > xStatusListener;
620cdf0e10cSrcweir     com::sun::star::util::URL aTargetURL;
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     {
623cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
624cdf0e10cSrcweir 
625cdf0e10cSrcweir         if ( !m_bInitialized )
626cdf0e10cSrcweir             return;
627cdf0e10cSrcweir 
628cdf0e10cSrcweir         // Try to find a dispatch object for the requested command URL
629cdf0e10cSrcweir         Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
630cdf0e10cSrcweir         xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY );
631cdf0e10cSrcweir         if ( m_xServiceManager.is() && xDispatchProvider.is() )
632cdf0e10cSrcweir         {
633cdf0e10cSrcweir             Reference< XURLTransformer > xURLTransformer = getURLTransformer();
634cdf0e10cSrcweir             aTargetURL.Complete = aCommandURL;
635cdf0e10cSrcweir             xURLTransformer->parseStrict( aTargetURL );
636cdf0e10cSrcweir             xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 );
637cdf0e10cSrcweir         }
638cdf0e10cSrcweir     }
639cdf0e10cSrcweir 
640cdf0e10cSrcweir     if ( xDispatch.is() && xStatusListener.is() )
641cdf0e10cSrcweir     {
642cdf0e10cSrcweir         // Catch exception as we release our mutex, it is possible that someone else
643cdf0e10cSrcweir         // has already disposed this instance!
644cdf0e10cSrcweir         // Add/remove status listener to get a update status information from the
645cdf0e10cSrcweir         // requested command.
646cdf0e10cSrcweir         try
647cdf0e10cSrcweir         {
648cdf0e10cSrcweir             xDispatch->addStatusListener( xStatusListener, aTargetURL );
649cdf0e10cSrcweir             xDispatch->removeStatusListener( xStatusListener, aTargetURL );
650cdf0e10cSrcweir         }
651cdf0e10cSrcweir         catch ( Exception& )
652cdf0e10cSrcweir         {
653cdf0e10cSrcweir         }
654cdf0e10cSrcweir     }
655cdf0e10cSrcweir }
656cdf0e10cSrcweir 
getControlRect() const657cdf0e10cSrcweir ::Rectangle StatusbarController::getControlRect() const
658cdf0e10cSrcweir {
659cdf0e10cSrcweir     ::Rectangle aRect;
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     {
662cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir         if ( m_bDisposed )
665cdf0e10cSrcweir             throw DisposedException();
666cdf0e10cSrcweir 
667cdf0e10cSrcweir         if ( m_xParentWindow.is() )
668cdf0e10cSrcweir         {
669cdf0e10cSrcweir             StatusBar* pStatusBar = dynamic_cast< StatusBar* >( VCLUnoHelper::GetWindow( m_xParentWindow ));
670cdf0e10cSrcweir             if ( pStatusBar && pStatusBar->GetType() == WINDOW_STATUSBAR )
671cdf0e10cSrcweir                 aRect = pStatusBar->GetItemRect( m_nID );
672cdf0e10cSrcweir         }
673cdf0e10cSrcweir     }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir     return aRect;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
execute(const::com::sun::star::uno::Sequence<::com::sun::star::beans::PropertyValue> & aArgs)678cdf0e10cSrcweir void StatusbarController::execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir     Reference< XDispatch >       xDispatch;
681cdf0e10cSrcweir     Reference< XURLTransformer > xURLTransformer;
682cdf0e10cSrcweir     rtl::OUString                aCommandURL;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
686cdf0e10cSrcweir 
687cdf0e10cSrcweir         if ( m_bDisposed )
688cdf0e10cSrcweir             throw DisposedException();
689cdf0e10cSrcweir 
690cdf0e10cSrcweir         if ( m_bInitialized &&
691cdf0e10cSrcweir              m_xFrame.is() &&
692cdf0e10cSrcweir              m_xServiceManager.is() &&
693cdf0e10cSrcweir              m_aCommandURL.getLength() )
694cdf0e10cSrcweir         {
695cdf0e10cSrcweir             xURLTransformer = getURLTransformer();
696cdf0e10cSrcweir             aCommandURL = m_aCommandURL;
697cdf0e10cSrcweir             URLToDispatchMap::iterator pIter = m_aListenerMap.find( m_aCommandURL );
698cdf0e10cSrcweir             if ( pIter != m_aListenerMap.end() )
699cdf0e10cSrcweir                 xDispatch = pIter->second;
700cdf0e10cSrcweir         }
701cdf0e10cSrcweir     }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     if ( xDispatch.is() && xURLTransformer.is() )
704cdf0e10cSrcweir     {
705cdf0e10cSrcweir         try
706cdf0e10cSrcweir         {
707cdf0e10cSrcweir             com::sun::star::util::URL aTargetURL;
708cdf0e10cSrcweir 
709cdf0e10cSrcweir             aTargetURL.Complete = aCommandURL;
710cdf0e10cSrcweir             xURLTransformer->parseStrict( aTargetURL );
711cdf0e10cSrcweir             xDispatch->dispatch( aTargetURL, aArgs );
712cdf0e10cSrcweir         }
713cdf0e10cSrcweir         catch ( DisposedException& )
714cdf0e10cSrcweir         {
715cdf0e10cSrcweir         }
716cdf0e10cSrcweir     }
717cdf0e10cSrcweir }
718cdf0e10cSrcweir 
execute(const rtl::OUString & aCommandURL,const Sequence<::com::sun::star::beans::PropertyValue> & aArgs)719cdf0e10cSrcweir void StatusbarController::execute(
720cdf0e10cSrcweir     const rtl::OUString& aCommandURL,
721cdf0e10cSrcweir     const Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir     Reference< XDispatch >      xDispatch;
724cdf0e10cSrcweir     com::sun::star::util::URL   aTargetURL;
725cdf0e10cSrcweir 
726cdf0e10cSrcweir     {
727cdf0e10cSrcweir         vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
728cdf0e10cSrcweir 
729cdf0e10cSrcweir         if ( m_bDisposed )
730cdf0e10cSrcweir             throw DisposedException();
731cdf0e10cSrcweir 
732cdf0e10cSrcweir         if ( m_bInitialized &&
733cdf0e10cSrcweir              m_xFrame.is() &&
734cdf0e10cSrcweir              m_xServiceManager.is() &&
735cdf0e10cSrcweir              m_aCommandURL.getLength() )
736cdf0e10cSrcweir         {
737cdf0e10cSrcweir             Reference< XURLTransformer > xURLTransformer( getURLTransformer() );
738cdf0e10cSrcweir             aTargetURL.Complete = aCommandURL;
739cdf0e10cSrcweir             xURLTransformer->parseStrict( aTargetURL );
740cdf0e10cSrcweir 
741cdf0e10cSrcweir             URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
742cdf0e10cSrcweir             if ( pIter != m_aListenerMap.end() )
743cdf0e10cSrcweir                 xDispatch = pIter->second;
744cdf0e10cSrcweir             else
745cdf0e10cSrcweir             {
746cdf0e10cSrcweir                 Reference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider(
747cdf0e10cSrcweir                     m_xFrame->getController(), UNO_QUERY );
748cdf0e10cSrcweir                 if ( xDispatchProvider.is() )
749cdf0e10cSrcweir                     xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
750cdf0e10cSrcweir             }
751cdf0e10cSrcweir         }
752cdf0e10cSrcweir     }
753cdf0e10cSrcweir 
754cdf0e10cSrcweir     if ( xDispatch.is() )
755cdf0e10cSrcweir     {
756cdf0e10cSrcweir         try
757cdf0e10cSrcweir         {
758cdf0e10cSrcweir             xDispatch->dispatch( aTargetURL, aArgs );
759cdf0e10cSrcweir         }
760cdf0e10cSrcweir         catch ( DisposedException& )
761cdf0e10cSrcweir         {
762cdf0e10cSrcweir         }
763cdf0e10cSrcweir     }
764cdf0e10cSrcweir }
765cdf0e10cSrcweir 
766cdf0e10cSrcweir } // svt
767