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