001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037 #include "precompiled_sw.hxx"
038
039
040 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
041 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
042 #endif
043
044 #ifndef _COM_SUN_STAR_FRAME_DISPATCHRESULTSTATE_HPP_
045 #include <com/sun/star/frame/DispatchResultState.hpp>
046 #endif
047
048 #include "swmodule.hxx"
049 #include "swdll.hxx"
050 #include "unomodule.hxx"
051 #include <sfx2/objface.hxx>
052 #include <sfx2/bindings.hxx>
053 #include <sfx2/request.hxx>
054
055 #ifndef _VOS_MUTEX_HXX_
056 #include <vos/mutex.hxx>
057 #endif
058 #ifndef _SV_SVAPP_HXX
059 #include <vcl/svapp.hxx>
060 #endif
061
062 using namespace ::com::sun::star;
063
064 ::rtl::OUString SAL_CALL SwUnoModule_getImplementationName() throw( uno::RuntimeException )
065 {
066 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Writer.WriterModule" ) );
067 }
068
069 uno::Sequence< rtl::OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw( uno::RuntimeException )
070 {
071 uno::Sequence< rtl::OUString > aSeq( 1 );
072 aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.ModuleDispatcher"));
073 return aSeq;
074 }
075
076 uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance(
077 const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
078 {
079 ::vos::OGuard aGuard( Application::GetSolarMutex() );
080 return uno::Reference< uno::XInterface >( dynamic_cast< frame::XDispatch * >(new SwUnoModule( rSMgr )), uno::UNO_QUERY );
081 }
082
083
084 void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener ) throw (uno::RuntimeException)
085 {
086
087
088
089 uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this));
090
091 ::vos::OGuard aGuard( Application::GetSolarMutex() );
092 SwDLL::Init();
093 const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
094
095 sal_Int16 aState = frame::DispatchResultState::DONTKNOW;
096 if ( !pSlot )
097 aState = frame::DispatchResultState::FAILURE;
098 else
099 {
100 SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SW_MOD()->GetPool() );
101 const SfxPoolItem* pResult = SW_MOD()->ExecuteSlot( aReq );
102 if ( pResult )
103 aState = frame::DispatchResultState::SUCCESS;
104 else
105 aState = frame::DispatchResultState::FAILURE;
106 }
107
108 if ( xListener.is() )
109 {
110 xListener->dispatchFinished(
111 frame::DispatchResultEvent(
112 xThis, aState, uno::Any()));
113 }
114 }
115
116
117 void SAL_CALL SwUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw( uno::RuntimeException )
118 {
119 dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >());
120 }
121
122 void SAL_CALL SwUnoModule::addStatusListener(
123 const uno::Reference< frame::XStatusListener > & ,
124 const util::URL& )
125 throw( uno::RuntimeException )
126 {
127 }
128
129 void SAL_CALL SwUnoModule::removeStatusListener(
130 const uno::Reference< frame::XStatusListener > & ,
131 const util::URL& ) throw( uno::RuntimeException )
132 {
133 }
134
135 SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SwUnoModule::queryDispatches(
136 const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( uno::RuntimeException )
137 {
138 sal_Int32 nCount = seqDescripts.getLength();
139 SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount );
140
141 for( sal_Int32 i=0; i<nCount; ++i )
142 {
143 lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL ,
144 seqDescripts[i].FrameName ,
145 seqDescripts[i].SearchFlags );
146 }
147
148 return lDispatcher;
149 }
150
151
152 REFERENCE< XDISPATCH > SAL_CALL SwUnoModule::queryDispatch(
153 const UNOURL& aURL, const OUSTRING& ,
154 sal_Int32 ) throw( uno::RuntimeException )
155 {
156 REFERENCE< XDISPATCH > xReturn;
157
158 ::vos::OGuard aGuard( Application::GetSolarMutex() );
159 SwDLL::Init();
160 const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
161 if ( pSlot )
162 xReturn = REFERENCE< XDISPATCH >(static_cast< XDISPATCH* >(this), uno::UNO_QUERY);
163
164 return xReturn;
165 }
166
167
168 ::rtl::OUString SAL_CALL SwUnoModule::getImplementationName( ) throw(uno::RuntimeException)
169 {
170 return SwUnoModule_getImplementationName();
171 }
172
173 sal_Bool SAL_CALL SwUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(uno::RuntimeException)
174 {
175 UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames();
176 const UNOOUSTRING* pArray = seqServiceNames.getConstArray();
177 for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
178 {
179 if ( pArray[nCounter] == sServiceName )
180 {
181 return sal_True ;
182 }
183 }
184 return sal_False ;
185 }
186
187 uno::Sequence< ::rtl::OUString > SAL_CALL SwUnoModule::getSupportedServiceNames( ) throw(uno::RuntimeException)
188 {
189 return SwUnoModule_getSupportedServiceNames();
190 }
191