Better, Faster, Freer

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: i386 ]
Version: HEAD ]

001 /*************************************************************************
002  *
003  *  OpenOffice.org - a multi-platform office productivity suite
004  *
005  *  $RCSfile: unomodule.cxx,v $
006  *
007  *  $Revision: 1.7 $
008  *
009  *  last change: $Author: hr $ $Date: 2007/09/27 12:43:28 $
010  *
011  *  The Contents of this file are made available subject to
012  *  the terms of GNU Lesser General Public License Version 2.1.
013  *
014  *
015  *    GNU Lesser General Public License Version 2.1
016  *    =============================================
017  *    Copyright 2005 by Sun Microsystems, Inc.
018  *    901 San Antonio Road, Palo Alto, CA 94303, USA
019  *
020  *    This library is free software; you can redistribute it and/or
021  *    modify it under the terms of the GNU Lesser General Public
022  *    License version 2.1, as published by the Free Software Foundation.
023  *
024  *    This library is distributed in the hope that it will be useful,
025  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
026  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
027  *    Lesser General Public License for more details.
028  *
029  *    You should have received a copy of the GNU Lesser General Public
030  *    License along with this library; if not, write to the Free Software
031  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
032  *    MA  02111-1307  USA
033  *
034  ************************************************************************/
035 
036 // MARKER(update_precomp.py): autogen include statement, do not remove
037 #include "precompiled_sw.hxx"
038 // System - Includes -----------------------------------------------------
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     // XNotifyingDispatch
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     // there is no guarantee, that we are holded alive during this method!
087     // May the outside dispatch container will be updated by a CONTEXT_CHANGED
088     // asynchronous ...
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     // XDispatch
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 > & /*xControl*/,
124     const util::URL& /*aURL*/)
125     throw( uno::RuntimeException )
126 {
127 }
128 
129 void SAL_CALL SwUnoModule::removeStatusListener(
130     const uno::Reference< frame::XStatusListener > & /*xControl*/,
131     const util::URL& /*aURL*/) 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 // XDispatchProvider
152 REFERENCE< XDISPATCH > SAL_CALL SwUnoModule::queryDispatch(
153     const UNOURL& aURL, const OUSTRING& /*sTargetFrameName*/,
154     sal_Int32 /*eSearchFlags*/    ) 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 // XServiceInfo
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 

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!