merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / unoidl / unomodule.cxx
blob4e0f9eae05501a0abfdaa4760810b604b9a83bba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unomodule.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 // System - Includes -----------------------------------------------------
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/frame/DispatchResultState.hpp>
38 #include "sdmod.hxx"
39 #include "unomodule.hxx"
40 #include <sfx2/objface.hxx>
41 #include <sfx2/bindings.hxx>
42 #include <sfx2/request.hxx>
43 #include <vos/mutex.hxx>
44 #include <vcl/svapp.hxx>
46 using namespace ::com::sun::star;
48 ::rtl::OUString SAL_CALL SdUnoModule_getImplementationName() throw( uno::RuntimeException )
50 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Draw.DrawingModule" ) );
53 uno::Sequence< rtl::OUString > SAL_CALL SdUnoModule_getSupportedServiceNames() throw( uno::RuntimeException )
55 uno::Sequence< rtl::OUString > aSeq( 1 );
56 aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ModuleDispatcher"));
57 return aSeq;
60 uno::Reference< uno::XInterface > SAL_CALL SdUnoModule_createInstance(
61 const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
63 ::vos::OGuard aGuard( Application::GetSolarMutex() );
64 return uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( new SdUnoModule( rSMgr ) ) );
67 // XNotifyingDispatch
68 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)
70 // there is no guarantee, that we are holded alive during this method!
71 // May the outside dispatch container will be updated by a CONTEXT_CHANGED
72 // asynchronous ...
73 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis(static_cast< ::com::sun::star::frame::XNotifyingDispatch* >(this));
75 ::vos::OGuard aGuard( Application::GetSolarMutex() );
76 SdDLL::Init();
77 const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete );
79 sal_Int16 aState = ::com::sun::star::frame::DispatchResultState::DONTKNOW;
80 if ( !pSlot )
81 aState = ::com::sun::star::frame::DispatchResultState::FAILURE;
82 else
84 SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SD_MOD()->GetPool() );
85 const SfxPoolItem* pResult = SD_MOD()->ExecuteSlot( aReq );
86 if ( pResult )
87 aState = ::com::sun::star::frame::DispatchResultState::SUCCESS;
88 else
89 aState = ::com::sun::star::frame::DispatchResultState::FAILURE;
92 if ( xListener.is() )
94 xListener->dispatchFinished(
95 ::com::sun::star::frame::DispatchResultEvent(
96 xThis, aState, ::com::sun::star::uno::Any()));
99 // XDispatch
100 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 )
102 dispatchWithNotification(aURL, aArgs, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >());
105 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 )
109 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 )
113 SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SdUnoModule::queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException )
115 sal_Int32 nCount = seqDescripts.getLength();
116 SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount );
118 for( sal_Int32 i=0; i<nCount; ++i )
120 lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL ,
121 seqDescripts[i].FrameName ,
122 seqDescripts[i].SearchFlags );
125 return lDispatcher;
128 // XDispatchProvider
129 REFERENCE< XDISPATCH > SAL_CALL SdUnoModule::queryDispatch( const UNOURL& aURL, const OUSTRING&, sal_Int32 ) throw( RUNTIMEEXCEPTION )
131 ::vos::OGuard aGuard( Application::GetSolarMutex() );
132 SdDLL::Init();
133 const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete );
135 REFERENCE< XDISPATCH > xSlot;
136 if ( pSlot )
137 xSlot = this;
139 return xSlot;
142 // XServiceInfo
143 ::rtl::OUString SAL_CALL SdUnoModule::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException)
145 return SdUnoModule_getImplementationName();
148 sal_Bool SAL_CALL SdUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(::com::sun::star::uno::RuntimeException)
150 UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames();
151 const UNOOUSTRING* pArray = seqServiceNames.getConstArray();
152 for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
154 if ( pArray[nCounter] == sServiceName )
156 return sal_True ;
159 return sal_False ;
162 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SdUnoModule::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
164 return SdUnoModule_getSupportedServiceNames();