Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
21 : #include <com/sun/star/frame/DispatchResultState.hpp>
22 :
23 : #include "sddll.hxx"
24 : #include "sdmod.hxx"
25 : #include "unomodule.hxx"
26 : #include <sfx2/objface.hxx>
27 : #include <sfx2/bindings.hxx>
28 : #include <sfx2/request.hxx>
29 : #include <osl/mutex.hxx>
30 : #include <vcl/svapp.hxx>
31 :
32 : using namespace ::com::sun::star;
33 :
34 2 : ::rtl::OUString SAL_CALL SdUnoModule_getImplementationName() throw( uno::RuntimeException )
35 : {
36 2 : return rtl::OUString( "com.sun.star.comp.Draw.DrawingModule" );
37 : }
38 :
39 0 : uno::Sequence< rtl::OUString > SAL_CALL SdUnoModule_getSupportedServiceNames() throw( uno::RuntimeException )
40 : {
41 0 : uno::Sequence< rtl::OUString > aSeq( 1 );
42 0 : aSeq[0] = "com.sun.star.drawing.ModuleDispatcher";
43 0 : return aSeq;
44 : }
45 :
46 0 : uno::Reference< uno::XInterface > SAL_CALL SdUnoModule_createInstance(
47 : const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
48 : {
49 0 : SolarMutexGuard aGuard;
50 0 : return uno::Reference< uno::XInterface >( static_cast< cppu::OWeakObject* >( new SdUnoModule( rSMgr ) ) );
51 : }
52 :
53 : // XNotifyingDispatch
54 0 : 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)
55 : {
56 : // there is no guarantee, that we are holded alive during this method!
57 : // May the outside dispatch container will be updated by a CONTEXT_CHANGED
58 : // asynchronous ...
59 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis(static_cast< ::com::sun::star::frame::XNotifyingDispatch* >(this));
60 :
61 0 : SolarMutexGuard aGuard;
62 0 : SdDLL::Init();
63 0 : const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete );
64 :
65 0 : sal_Int16 aState = ::com::sun::star::frame::DispatchResultState::DONTKNOW;
66 0 : if ( !pSlot )
67 0 : aState = ::com::sun::star::frame::DispatchResultState::FAILURE;
68 : else
69 : {
70 0 : SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SD_MOD()->GetPool() );
71 0 : const SfxPoolItem* pResult = SD_MOD()->ExecuteSlot( aReq );
72 0 : if ( pResult )
73 0 : aState = ::com::sun::star::frame::DispatchResultState::SUCCESS;
74 : else
75 0 : aState = ::com::sun::star::frame::DispatchResultState::FAILURE;
76 : }
77 :
78 0 : if ( xListener.is() )
79 : {
80 0 : xListener->dispatchFinished(
81 : ::com::sun::star::frame::DispatchResultEvent(
82 0 : xThis, aState, ::com::sun::star::uno::Any()));
83 0 : }
84 0 : }
85 : // XDispatch
86 0 : 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 )
87 : {
88 0 : dispatchWithNotification(aURL, aArgs, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >());
89 0 : }
90 :
91 0 : 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 )
92 : {
93 0 : }
94 :
95 0 : 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 )
96 : {
97 0 : }
98 :
99 0 : SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SdUnoModule::queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( ::com::sun::star::uno::RuntimeException )
100 : {
101 0 : sal_Int32 nCount = seqDescripts.getLength();
102 0 : SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount );
103 :
104 0 : for( sal_Int32 i=0; i<nCount; ++i )
105 : {
106 0 : lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL ,
107 0 : seqDescripts[i].FrameName ,
108 0 : seqDescripts[i].SearchFlags );
109 : }
110 :
111 0 : return lDispatcher;
112 : }
113 :
114 : // XDispatchProvider
115 0 : REFERENCE< XDISPATCH > SAL_CALL SdUnoModule::queryDispatch( const UNOURL& aURL, const rtl::OUString&, sal_Int32 ) throw( RUNTIMEEXCEPTION )
116 : {
117 0 : SolarMutexGuard aGuard;
118 0 : SdDLL::Init();
119 0 : const SfxSlot* pSlot = SD_MOD()->GetInterface()->GetSlot( aURL.Complete );
120 :
121 0 : REFERENCE< XDISPATCH > xSlot;
122 0 : if ( pSlot )
123 0 : xSlot = this;
124 :
125 0 : return xSlot;
126 : }
127 :
128 : // XServiceInfo
129 0 : ::rtl::OUString SAL_CALL SdUnoModule::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException)
130 : {
131 0 : return SdUnoModule_getImplementationName();
132 : }
133 :
134 0 : sal_Bool SAL_CALL SdUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(::com::sun::star::uno::RuntimeException)
135 : {
136 0 : UNOSEQUENCE< rtl::OUString > seqServiceNames = getSupportedServiceNames();
137 0 : const rtl::OUString* pArray = seqServiceNames.getConstArray();
138 0 : for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
139 : {
140 0 : if ( pArray[nCounter] == sServiceName )
141 : {
142 0 : return sal_True ;
143 : }
144 : }
145 0 : return sal_False ;
146 : }
147 :
148 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SdUnoModule::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
149 : {
150 0 : return SdUnoModule_getSupportedServiceNames();
151 : }
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|