1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // System - Includes ----------------------------------------------------- 28cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 29cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "sdmod.hxx" 32cdf0e10cSrcweir #include "unomodule.hxx" 33cdf0e10cSrcweir #include <sfx2/objface.hxx> 34cdf0e10cSrcweir #include <sfx2/bindings.hxx> 35cdf0e10cSrcweir #include <sfx2/request.hxx> 36cdf0e10cSrcweir #include <vos/mutex.hxx> 37cdf0e10cSrcweir #include <vcl/svapp.hxx> 38cdf0e10cSrcweir 39cdf0e10cSrcweir using namespace ::com::sun::star; 40cdf0e10cSrcweir 41cdf0e10cSrcweir ::rtl::OUString SAL_CALL SdUnoModule_getImplementationName() throw( uno::RuntimeException ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Draw.DrawingModule" ) ); 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL SdUnoModule_getSupportedServiceNames() throw( uno::RuntimeException ) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSeq( 1 ); 49cdf0e10cSrcweir aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher")); 50cdf0e10cSrcweir return aSeq; 51cdf0e10cSrcweir } 52cdf0e10cSrcweir 53cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SdUnoModule_createInstance( 54cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 57cdf0e10cSrcweir return uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( new SdUnoModule( rSMgr ) ) ); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir // XNotifyingDispatch 61cdf0e10cSrcweir void SAL_CALL SdUnoModule::dispatchWithNotification( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir // there is no guarantee, that we are holded alive during this method! 64cdf0e10cSrcweir // May the outside dispatch container will be updated by a CONTEXT_CHANGED 65cdf0e10cSrcweir // asynchronous ... 66cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis(static_cast< ::com::sun::star::frame::XNotifyingDispatch* >(this)); 67cdf0e10cSrcweir 68cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 69cdf0e10cSrcweir SdDLL::Init(); 70cdf0e10cSrcweir const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir sal_Int16 aState = ::com::sun::star::frame::DispatchResultState::DONTKNOW; 73cdf0e10cSrcweir if ( !pSlot ) 74cdf0e10cSrcweir aState = ::com::sun::star::frame::DispatchResultState::FAILURE; 75cdf0e10cSrcweir else 76cdf0e10cSrcweir { 77cdf0e10cSrcweir SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SD_MOD()->GetPool() ); 78cdf0e10cSrcweir const SfxPoolItem* pResult = SD_MOD()->ExecuteSlot( aReq ); 79cdf0e10cSrcweir if ( pResult ) 80cdf0e10cSrcweir aState = ::com::sun::star::frame::DispatchResultState::SUCCESS; 81cdf0e10cSrcweir else 82cdf0e10cSrcweir aState = ::com::sun::star::frame::DispatchResultState::FAILURE; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir if ( xListener.is() ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir xListener->dispatchFinished( 88cdf0e10cSrcweir ::com::sun::star::frame::DispatchResultEvent( 89cdf0e10cSrcweir xThis, aState, ::com::sun::star::uno::Any())); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir } 92cdf0e10cSrcweir // XDispatch 93cdf0e10cSrcweir void SAL_CALL SdUnoModule::dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw( ::com::sun::star::uno::RuntimeException ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir dispatchWithNotification(aURL, aArgs, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >()); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir void SAL_CALL SdUnoModule::addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > &, const ::com::sun::star::util::URL&) throw( ::com::sun::star::uno::RuntimeException ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir void SAL_CALL SdUnoModule::removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > &, const ::com::sun::star::util::URL&) throw( ::com::sun::star::uno::RuntimeException ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SdUnoModule::queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir sal_Int32 nCount = seqDescripts.getLength(); 109cdf0e10cSrcweir SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; ++i ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL , 114cdf0e10cSrcweir seqDescripts[i].FrameName , 115cdf0e10cSrcweir seqDescripts[i].SearchFlags ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir return lDispatcher; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir // XDispatchProvider 122cdf0e10cSrcweir REFERENCE< XDISPATCH > SAL_CALL SdUnoModule::queryDispatch( const UNOURL& aURL, const OUSTRING&, sal_Int32 ) throw( RUNTIMEEXCEPTION ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 125cdf0e10cSrcweir SdDLL::Init(); 126cdf0e10cSrcweir const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir REFERENCE< XDISPATCH > xSlot; 129cdf0e10cSrcweir if ( pSlot ) 130cdf0e10cSrcweir xSlot = this; 131cdf0e10cSrcweir 132cdf0e10cSrcweir return xSlot; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir // XServiceInfo 136cdf0e10cSrcweir ::rtl::OUString SAL_CALL SdUnoModule::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir return SdUnoModule_getImplementationName(); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir sal_Bool SAL_CALL SdUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(::com::sun::star::uno::RuntimeException) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames(); 144cdf0e10cSrcweir const UNOOUSTRING* pArray = seqServiceNames.getConstArray(); 145cdf0e10cSrcweir for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir if ( pArray[nCounter] == sServiceName ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir return sal_True ; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir } 152cdf0e10cSrcweir return sal_False ; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SdUnoModule::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir return SdUnoModule_getSupportedServiceNames(); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160