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_sw.hxx" 30*cdf0e10cSrcweir // System - Includes ----------------------------------------------------- 31*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchResultState.hpp> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include "swmodule.hxx" 35*cdf0e10cSrcweir #include "swdll.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 SwUnoModule_getImplementationName() throw( uno::RuntimeException ) 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Writer.WriterModule" ) ); 48*cdf0e10cSrcweir } 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL SwUnoModule_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.text.ModuleDispatcher")); 54*cdf0e10cSrcweir return aSeq; 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_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 >( dynamic_cast< frame::XDispatch * >(new SwUnoModule( rSMgr )), uno::UNO_QUERY ); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // XNotifyingDispatch 65*cdf0e10cSrcweir void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener ) throw (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 uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this)); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 73*cdf0e10cSrcweir SwDLL::Init(); 74*cdf0e10cSrcweir const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete ); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir sal_Int16 aState = frame::DispatchResultState::DONTKNOW; 77*cdf0e10cSrcweir if ( !pSlot ) 78*cdf0e10cSrcweir aState = frame::DispatchResultState::FAILURE; 79*cdf0e10cSrcweir else 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SW_MOD()->GetPool() ); 82*cdf0e10cSrcweir const SfxPoolItem* pResult = SW_MOD()->ExecuteSlot( aReq ); 83*cdf0e10cSrcweir if ( pResult ) 84*cdf0e10cSrcweir aState = frame::DispatchResultState::SUCCESS; 85*cdf0e10cSrcweir else 86*cdf0e10cSrcweir aState = frame::DispatchResultState::FAILURE; 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir if ( xListener.is() ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir xListener->dispatchFinished( 92*cdf0e10cSrcweir frame::DispatchResultEvent( 93*cdf0e10cSrcweir xThis, aState, uno::Any())); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // XDispatch 98*cdf0e10cSrcweir void SAL_CALL SwUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw( uno::RuntimeException ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >()); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir void SAL_CALL SwUnoModule::addStatusListener( 104*cdf0e10cSrcweir const uno::Reference< frame::XStatusListener > & /*xControl*/, 105*cdf0e10cSrcweir const util::URL& /*aURL*/) 106*cdf0e10cSrcweir throw( uno::RuntimeException ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir void SAL_CALL SwUnoModule::removeStatusListener( 111*cdf0e10cSrcweir const uno::Reference< frame::XStatusListener > & /*xControl*/, 112*cdf0e10cSrcweir const util::URL& /*aURL*/) throw( uno::RuntimeException ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SwUnoModule::queryDispatches( 117*cdf0e10cSrcweir const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( uno::RuntimeException ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir sal_Int32 nCount = seqDescripts.getLength(); 120*cdf0e10cSrcweir SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir for( sal_Int32 i=0; i<nCount; ++i ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL , 125*cdf0e10cSrcweir seqDescripts[i].FrameName , 126*cdf0e10cSrcweir seqDescripts[i].SearchFlags ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir return lDispatcher; 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // XDispatchProvider 133*cdf0e10cSrcweir REFERENCE< XDISPATCH > SAL_CALL SwUnoModule::queryDispatch( 134*cdf0e10cSrcweir const UNOURL& aURL, const OUSTRING& /*sTargetFrameName*/, 135*cdf0e10cSrcweir sal_Int32 /*eSearchFlags*/ ) throw( uno::RuntimeException ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir REFERENCE< XDISPATCH > xReturn; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 140*cdf0e10cSrcweir SwDLL::Init(); 141*cdf0e10cSrcweir const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete ); 142*cdf0e10cSrcweir if ( pSlot ) 143*cdf0e10cSrcweir xReturn = REFERENCE< XDISPATCH >(static_cast< XDISPATCH* >(this), uno::UNO_QUERY); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir return xReturn; 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // XServiceInfo 149*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SwUnoModule::getImplementationName( ) throw(uno::RuntimeException) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir return SwUnoModule_getImplementationName(); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir sal_Bool SAL_CALL SwUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(uno::RuntimeException) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames(); 157*cdf0e10cSrcweir const UNOOUSTRING* pArray = seqServiceNames.getConstArray(); 158*cdf0e10cSrcweir for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir if ( pArray[nCounter] == sServiceName ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir return sal_True ; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir return sal_False ; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL SwUnoModule::getSupportedServiceNames( ) throw(uno::RuntimeException) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir return SwUnoModule_getSupportedServiceNames(); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173