1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // System - Includes ----------------------------------------------------- 32*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "sdmod.hxx" 36*cdf0e10cSrcweir #include "unomodule.hxx" 37*cdf0e10cSrcweir #include <sfx2/objface.hxx> 38*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 39*cdf0e10cSrcweir #include <sfx2/request.hxx> 40*cdf0e10cSrcweir #include <vos/mutex.hxx> 41*cdf0e10cSrcweir #include <vcl/svapp.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir using namespace ::com::sun::star; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SdUnoModule_getImplementationName() throw( uno::RuntimeException ) 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Draw.DrawingModule" ) ); 48*cdf0e10cSrcweir } 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL SdUnoModule_getSupportedServiceNames() throw( uno::RuntimeException ) 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir uno::Sequence< rtl::OUString > aSeq( 1 ); 53*cdf0e10cSrcweir aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher")); 54*cdf0e10cSrcweir return aSeq; 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SdUnoModule_createInstance( 58*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 61*cdf0e10cSrcweir return uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( new SdUnoModule( rSMgr ) ) ); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // XNotifyingDispatch 65*cdf0e10cSrcweir 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) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir // there is no guarantee, that we are holded alive during this method! 68*cdf0e10cSrcweir // May the outside dispatch container will be updated by a CONTEXT_CHANGED 69*cdf0e10cSrcweir // asynchronous ... 70*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis(static_cast< ::com::sun::star::frame::XNotifyingDispatch* >(this)); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 73*cdf0e10cSrcweir SdDLL::Init(); 74*cdf0e10cSrcweir const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete ); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir sal_Int16 aState = ::com::sun::star::frame::DispatchResultState::DONTKNOW; 77*cdf0e10cSrcweir if ( !pSlot ) 78*cdf0e10cSrcweir aState = ::com::sun::star::frame::DispatchResultState::FAILURE; 79*cdf0e10cSrcweir else 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SD_MOD()->GetPool() ); 82*cdf0e10cSrcweir const SfxPoolItem* pResult = SD_MOD()->ExecuteSlot( aReq ); 83*cdf0e10cSrcweir if ( pResult ) 84*cdf0e10cSrcweir aState = ::com::sun::star::frame::DispatchResultState::SUCCESS; 85*cdf0e10cSrcweir else 86*cdf0e10cSrcweir aState = ::com::sun::star::frame::DispatchResultState::FAILURE; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir if ( xListener.is() ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir xListener->dispatchFinished( 92*cdf0e10cSrcweir ::com::sun::star::frame::DispatchResultEvent( 93*cdf0e10cSrcweir xThis, aState, ::com::sun::star::uno::Any())); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir // XDispatch 97*cdf0e10cSrcweir 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 ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir dispatchWithNotification(aURL, aArgs, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >()); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir 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 ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir 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 ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SdUnoModule::queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir sal_Int32 nCount = seqDescripts.getLength(); 113*cdf0e10cSrcweir SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount ); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; ++i ) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL , 118*cdf0e10cSrcweir seqDescripts[i].FrameName , 119*cdf0e10cSrcweir seqDescripts[i].SearchFlags ); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir return lDispatcher; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // XDispatchProvider 126*cdf0e10cSrcweir REFERENCE< XDISPATCH > SAL_CALL SdUnoModule::queryDispatch( const UNOURL& aURL, const OUSTRING&, sal_Int32 ) throw( RUNTIMEEXCEPTION ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 129*cdf0e10cSrcweir SdDLL::Init(); 130*cdf0e10cSrcweir const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete ); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir REFERENCE< XDISPATCH > xSlot; 133*cdf0e10cSrcweir if ( pSlot ) 134*cdf0e10cSrcweir xSlot = this; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir return xSlot; 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir // XServiceInfo 140*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SdUnoModule::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir return SdUnoModule_getImplementationName(); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir sal_Bool SAL_CALL SdUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(::com::sun::star::uno::RuntimeException) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames(); 148*cdf0e10cSrcweir const UNOOUSTRING* pArray = seqServiceNames.getConstArray(); 149*cdf0e10cSrcweir for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir if ( pArray[nCounter] == sServiceName ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir return sal_True ; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir return sal_False ; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SdUnoModule::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir return SdUnoModule_getSupportedServiceNames(); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164