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 10cdf0e10cSrcweir * 115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 205900e8ecSAndrew Rist *************************************************************/ 215900e8ecSAndrew Rist 225900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svtools.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // my own includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir #include "svtools/popupmenucontrollerbase.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34cdf0e10cSrcweir // interface includes 35cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp> 37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 38cdf0e10cSrcweir #include <com/sun/star/awt/MenuItemStyle.hpp> 39cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 40cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 41cdf0e10cSrcweir 42cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 43cdf0e10cSrcweir // includes of other projects 44cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 45cdf0e10cSrcweir 46cdf0e10cSrcweir #ifndef _VCL_MENU_HXX_ 47cdf0e10cSrcweir #include <vcl/menu.hxx> 48cdf0e10cSrcweir #endif 49cdf0e10cSrcweir #include <vcl/svapp.hxx> 50cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 51cdf0e10cSrcweir #include <rtl/logfile.hxx> 52cdf0e10cSrcweir #include <vos/mutex.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 55cdf0e10cSrcweir // Defines 56cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 57cdf0e10cSrcweir // 58cdf0e10cSrcweir 59cdf0e10cSrcweir using ::rtl::OUString; 60cdf0e10cSrcweir 61cdf0e10cSrcweir using namespace com::sun::star; 62cdf0e10cSrcweir using namespace com::sun::star::uno; 63cdf0e10cSrcweir using namespace com::sun::star::lang; 64cdf0e10cSrcweir using namespace com::sun::star::frame; 65cdf0e10cSrcweir using namespace com::sun::star::beans; 66cdf0e10cSrcweir using namespace com::sun::star::util; 67cdf0e10cSrcweir 68cdf0e10cSrcweir namespace svt 69cdf0e10cSrcweir { 70cdf0e10cSrcweir 71cdf0e10cSrcweir struct PopupMenuControllerBaseDispatchInfo 72cdf0e10cSrcweir { 73cdf0e10cSrcweir Reference< XDispatch > mxDispatch; 74cdf0e10cSrcweir const URL maURL; 75cdf0e10cSrcweir const Sequence< PropertyValue > maArgs; 76cdf0e10cSrcweir 77cdf0e10cSrcweir PopupMenuControllerBaseDispatchInfo( const Reference< XDispatch >& xDispatch, const URL& rURL, const Sequence< PropertyValue >& rArgs ) 78cdf0e10cSrcweir : mxDispatch( xDispatch ), maURL( rURL ), maArgs( rArgs ) {} 79cdf0e10cSrcweir }; 80cdf0e10cSrcweir 81cdf0e10cSrcweir PopupMenuControllerBase::PopupMenuControllerBase( const Reference< XMultiServiceFactory >& xServiceManager ) : 82cdf0e10cSrcweir ::comphelper::OBaseMutex(), 83cdf0e10cSrcweir PopupMenuControllerBaseType(m_aMutex), 84cdf0e10cSrcweir m_bInitialized( false ), 85cdf0e10cSrcweir m_xServiceManager( xServiceManager ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir if ( m_xServiceManager.is() ) 88cdf0e10cSrcweir m_xURLTransformer.set( m_xServiceManager->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer"))),UNO_QUERY ); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir PopupMenuControllerBase::~PopupMenuControllerBase() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir // protected function 96cdf0e10cSrcweir void PopupMenuControllerBase::throwIfDisposed() throw ( RuntimeException ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose) 99cdf0e10cSrcweir throw com::sun::star::lang::DisposedException(); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir // protected function 103cdf0e10cSrcweir void PopupMenuControllerBase::resetPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir if ( rPopupMenu.is() && rPopupMenu->getItemCount() > 0 ) 106cdf0e10cSrcweir { 107*d026be40SAriel Constenla-Haile rPopupMenu->clear(); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::disposing() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir // Reset our members and set disposed flag 114cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 115cdf0e10cSrcweir m_xFrame.clear(); 116cdf0e10cSrcweir m_xDispatch.clear(); 117cdf0e10cSrcweir m_xPopupMenu.clear(); 118cdf0e10cSrcweir m_xServiceManager.clear(); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir // XServiceInfo 122cdf0e10cSrcweir 123cdf0e10cSrcweir sal_Bool SAL_CALL PopupMenuControllerBase::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir const Sequence< rtl::OUString > aSNL( getSupportedServiceNames() ); 126cdf0e10cSrcweir const rtl::OUString * pArray = aSNL.getConstArray(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) 129cdf0e10cSrcweir if( pArray[i] == ServiceName ) 130cdf0e10cSrcweir return true; 131cdf0e10cSrcweir 132cdf0e10cSrcweir return false; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir // XEventListener 136cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::disposing( const EventObject& ) throw ( RuntimeException ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 139cdf0e10cSrcweir m_xFrame.clear(); 140cdf0e10cSrcweir m_xDispatch.clear(); 141cdf0e10cSrcweir m_xPopupMenu.clear(); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir // XMenuListener 145*d026be40SAriel Constenla-Haile void SAL_CALL PopupMenuControllerBase::itemHighlighted( const awt::MenuEvent& ) throw (RuntimeException) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir void PopupMenuControllerBase::impl_select(const Reference< XDispatch >& _xDispatch,const URL& aURL) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir Sequence<PropertyValue> aArgs; 152cdf0e10cSrcweir OSL_ENSURE(_xDispatch.is(),"PopupMenuControllerBase::impl_select: No dispatch"); 153cdf0e10cSrcweir if ( _xDispatch.is() ) 154cdf0e10cSrcweir _xDispatch->dispatch( aURL, aArgs ); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157*d026be40SAriel Constenla-Haile void SAL_CALL PopupMenuControllerBase::itemSelected( const awt::MenuEvent& rEvent ) throw (RuntimeException) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir throwIfDisposed(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 162cdf0e10cSrcweir 163*d026be40SAriel Constenla-Haile if( m_xPopupMenu.is() ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir Sequence<PropertyValue> aArgs; 166*d026be40SAriel Constenla-Haile dispatchCommand( m_xPopupMenu->getCommand( rEvent.MenuId ), aArgs ); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir void PopupMenuControllerBase::dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs ) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir throwIfDisposed(); 175cdf0e10cSrcweir 176cdf0e10cSrcweir try 177cdf0e10cSrcweir { 178cdf0e10cSrcweir Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY_THROW ); 179cdf0e10cSrcweir URL aURL; 180cdf0e10cSrcweir aURL.Complete = sCommandURL; 181cdf0e10cSrcweir m_xURLTransformer->parseStrict( aURL ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, OUString(), 0 ), UNO_QUERY_THROW ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir Application::PostUserEvent( STATIC_LINK(0, PopupMenuControllerBase, ExecuteHdl_Impl), new PopupMenuControllerBaseDispatchInfo( xDispatch, aURL, rArgs ) ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir } 188cdf0e10cSrcweir catch( Exception& ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir IMPL_STATIC_LINK_NOINSTANCE( PopupMenuControllerBase, ExecuteHdl_Impl, PopupMenuControllerBaseDispatchInfo*, pDispatchInfo ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir pDispatchInfo->mxDispatch->dispatch( pDispatchInfo->maURL, pDispatchInfo->maArgs ); 197cdf0e10cSrcweir delete pDispatchInfo; 198cdf0e10cSrcweir return 0; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201*d026be40SAriel Constenla-Haile void SAL_CALL PopupMenuControllerBase::itemActivated( const awt::MenuEvent& ) throw (RuntimeException) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205*d026be40SAriel Constenla-Haile void SAL_CALL PopupMenuControllerBase::itemDeactivated( const awt::MenuEvent& ) throw (RuntimeException) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir osl::ClearableMutexGuard aLock( m_aMutex ); 212cdf0e10cSrcweir throwIfDisposed(); 213cdf0e10cSrcweir aLock.clear(); 214cdf0e10cSrcweir 215cdf0e10cSrcweir updateCommand( m_aCommandURL ); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::updateCommand( const rtl::OUString& rCommandURL ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir osl::ClearableMutexGuard aLock( m_aMutex ); 221cdf0e10cSrcweir Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); 222cdf0e10cSrcweir Reference< XDispatch > xDispatch( m_xDispatch ); 223cdf0e10cSrcweir URL aTargetURL; 224cdf0e10cSrcweir aTargetURL.Complete = rCommandURL; 225cdf0e10cSrcweir m_xURLTransformer->parseStrict( aTargetURL ); 226cdf0e10cSrcweir aLock.clear(); 227cdf0e10cSrcweir 228cdf0e10cSrcweir // Add/remove status listener to get a status update once 229cdf0e10cSrcweir if ( xDispatch.is() ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir xDispatch->addStatusListener( xStatusListener, aTargetURL ); 232cdf0e10cSrcweir xDispatch->removeStatusListener( xStatusListener, aTargetURL ); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir 237cdf0e10cSrcweir // XDispatchProvider 238cdf0e10cSrcweir Reference< XDispatch > SAL_CALL 239cdf0e10cSrcweir PopupMenuControllerBase::queryDispatch( 240cdf0e10cSrcweir const URL& /*aURL*/, 241cdf0e10cSrcweir const rtl::OUString& /*sTarget*/, 242cdf0e10cSrcweir sal_Int32 /*nFlags*/ ) 243cdf0e10cSrcweir throw( RuntimeException ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir // must be implemented by subclass 246cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 247cdf0e10cSrcweir throwIfDisposed(); 248cdf0e10cSrcweir 249cdf0e10cSrcweir return Reference< XDispatch >(); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispatches( const Sequence< DispatchDescriptor >& lDescriptor ) throw( RuntimeException ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir // Create return list - which must have same size then the given descriptor 255cdf0e10cSrcweir // It's not allowed to pack it! 256cdf0e10cSrcweir osl::ClearableMutexGuard aLock( m_aMutex ); 257cdf0e10cSrcweir throwIfDisposed(); 258cdf0e10cSrcweir aLock.clear(); 259cdf0e10cSrcweir 260cdf0e10cSrcweir sal_Int32 nCount = lDescriptor.getLength(); 261cdf0e10cSrcweir uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir // Step over all descriptors and try to get any dispatcher for it. 264cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; ++i ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir lDispatcher[i] = queryDispatch( lDescriptor[i].FeatureURL , 267cdf0e10cSrcweir lDescriptor[i].FrameName , 268cdf0e10cSrcweir lDescriptor[i].SearchFlags ); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir return lDispatcher; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir // XDispatch 275cdf0e10cSrcweir void SAL_CALL 276cdf0e10cSrcweir PopupMenuControllerBase::dispatch( 277cdf0e10cSrcweir const URL& /*aURL*/, 278cdf0e10cSrcweir const Sequence< PropertyValue >& /*seqProperties*/ ) 279cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir // must be implemented by subclass 282cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 283cdf0e10cSrcweir throwIfDisposed(); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir void SAL_CALL 287cdf0e10cSrcweir PopupMenuControllerBase::addStatusListener( 288cdf0e10cSrcweir const Reference< XStatusListener >& xControl, 289cdf0e10cSrcweir const URL& aURL ) 290cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir osl::ResettableMutexGuard aLock( m_aMutex ); 293cdf0e10cSrcweir throwIfDisposed(); 294cdf0e10cSrcweir aLock.clear(); 295cdf0e10cSrcweir 296cdf0e10cSrcweir bool bStatusUpdate( false ); 297cdf0e10cSrcweir rBHelper.addListener( ::getCppuType( &xControl ), xControl ); 298cdf0e10cSrcweir 299cdf0e10cSrcweir aLock.reset(); 300cdf0e10cSrcweir if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) 301cdf0e10cSrcweir bStatusUpdate = true; 302cdf0e10cSrcweir aLock.clear(); 303cdf0e10cSrcweir 304cdf0e10cSrcweir if ( bStatusUpdate ) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir // Dummy update for popup menu controllers 307cdf0e10cSrcweir FeatureStateEvent aEvent; 308cdf0e10cSrcweir aEvent.FeatureURL = aURL; 309cdf0e10cSrcweir aEvent.IsEnabled = sal_True; 310cdf0e10cSrcweir aEvent.Requery = sal_False; 311cdf0e10cSrcweir aEvent.State = Any(); 312cdf0e10cSrcweir xControl->statusChanged( aEvent ); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::removeStatusListener( 317cdf0e10cSrcweir const Reference< XStatusListener >& xControl, 318cdf0e10cSrcweir const URL& /*aURL*/ ) 319cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir rBHelper.removeListener( ::getCppuType( &xControl ), xControl ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir ::rtl::OUString PopupMenuControllerBase::determineBaseURL( const ::rtl::OUString& aURL ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir // Just use the main part of the URL for popup menu controllers 327cdf0e10cSrcweir sal_Int32 nQueryPart( 0 ); 328cdf0e10cSrcweir sal_Int32 nSchemePart( 0 ); 329cdf0e10cSrcweir rtl::OUString aMainURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.popup:" )); 330cdf0e10cSrcweir 331cdf0e10cSrcweir nSchemePart = aURL.indexOf( ':' ); 332cdf0e10cSrcweir if (( nSchemePart > 0 ) && 333cdf0e10cSrcweir ( aURL.getLength() > ( nSchemePart+1 ))) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir nQueryPart = aURL.indexOf( '?', nSchemePart ); 336cdf0e10cSrcweir if ( nQueryPart > 0 ) 337cdf0e10cSrcweir aMainURL += aURL.copy( nSchemePart, nQueryPart-nSchemePart ); 338cdf0e10cSrcweir else if ( nQueryPart == -1 ) 339cdf0e10cSrcweir aMainURL += aURL.copy( nSchemePart+1 ); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir return aMainURL; 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir // XInitialization 346cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 349cdf0e10cSrcweir 350cdf0e10cSrcweir sal_Bool bInitalized( m_bInitialized ); 351cdf0e10cSrcweir if ( !bInitalized ) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir PropertyValue aPropValue; 354cdf0e10cSrcweir rtl::OUString aCommandURL; 355cdf0e10cSrcweir Reference< XFrame > xFrame; 356cdf0e10cSrcweir 357cdf0e10cSrcweir for ( int i = 0; i < aArguments.getLength(); i++ ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir if ( aArguments[i] >>= aPropValue ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir if ( aPropValue.Name.equalsAscii( "Frame" )) 362cdf0e10cSrcweir aPropValue.Value >>= xFrame; 363cdf0e10cSrcweir else if ( aPropValue.Name.equalsAscii( "CommandURL" )) 364cdf0e10cSrcweir aPropValue.Value >>= aCommandURL; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir if ( xFrame.is() && aCommandURL.getLength() ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir m_xFrame = xFrame; 371cdf0e10cSrcweir m_aCommandURL = aCommandURL; 372cdf0e10cSrcweir m_aBaseURL = determineBaseURL( aCommandURL ); 373cdf0e10cSrcweir m_bInitialized = true; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir } 376cdf0e10cSrcweir } 377cdf0e10cSrcweir // XPopupMenuController 378cdf0e10cSrcweir void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir osl::MutexGuard aLock( m_aMutex ); 381cdf0e10cSrcweir throwIfDisposed(); 382cdf0e10cSrcweir 383cdf0e10cSrcweir if ( m_xFrame.is() && !m_xPopupMenu.is() ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir // Create popup menu on demand 386cdf0e10cSrcweir vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); 387cdf0e10cSrcweir 388cdf0e10cSrcweir m_xPopupMenu = xPopupMenu; 389cdf0e10cSrcweir m_xPopupMenu->addMenuListener( Reference< awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); 390cdf0e10cSrcweir 391cdf0e10cSrcweir Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); 392cdf0e10cSrcweir 393cdf0e10cSrcweir URL aTargetURL; 394cdf0e10cSrcweir aTargetURL.Complete = m_aCommandURL; 395cdf0e10cSrcweir m_xURLTransformer->parseStrict( aTargetURL ); 396cdf0e10cSrcweir m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); 397cdf0e10cSrcweir 398cdf0e10cSrcweir impl_setPopupMenu(); 399cdf0e10cSrcweir 400cdf0e10cSrcweir updatePopupMenu(); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir } 403cdf0e10cSrcweir void PopupMenuControllerBase::impl_setPopupMenu() 404cdf0e10cSrcweir { 405cdf0e10cSrcweir } 406cdf0e10cSrcweir } 407