1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
21 #include <com/sun/star/frame/DispatchResultState.hpp>
22 #include <cppuhelper/supportsservice.hxx>
27 #include "unomodule.hxx"
28 #include <sfx2/objface.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/request.hxx>
31 #include <vcl/svapp.hxx>
33 using namespace ::com::sun::star
;
36 void SAL_CALL
SdUnoModule::dispatchWithNotification( const util::URL
& aURL
, const uno::Sequence
< beans::PropertyValue
>& aArgs
, const uno::Reference
< frame::XDispatchResultListener
>& xListener
)
38 // there is no guarantee, that we are holded alive during this method!
39 // May the outside dispatch container will be updated by a CONTEXT_CHANGED
41 uno::Reference
< uno::XInterface
> xThis(static_cast< frame::XNotifyingDispatch
* >(this));
43 SolarMutexGuard aGuard
;
45 const SfxSlot
* pSlot
= SD_MOD()->GetInterface()->GetSlot( aURL
.Complete
);
47 sal_Int16 aState
= frame::DispatchResultState::DONTKNOW
;
49 aState
= frame::DispatchResultState::FAILURE
;
52 SfxRequest
aReq( pSlot
, aArgs
, SfxCallMode::SYNCHRON
, SD_MOD()->GetPool() );
53 const SfxPoolItem
* pResult
= SD_MOD()->ExecuteSlot( aReq
);
55 aState
= frame::DispatchResultState::SUCCESS
;
57 aState
= frame::DispatchResultState::FAILURE
;
62 xListener
->dispatchFinished(
63 frame::DispatchResultEvent(
64 xThis
, aState
, uno::Any()));
68 void SAL_CALL
SdUnoModule::dispatch( const util::URL
& aURL
, const uno::Sequence
< beans::PropertyValue
>& aArgs
)
70 dispatchWithNotification(aURL
, aArgs
, uno::Reference
< frame::XDispatchResultListener
>());
73 void SAL_CALL
SdUnoModule::addStatusListener(const uno::Reference
< frame::XStatusListener
> &, const util::URL
&)
77 void SAL_CALL
SdUnoModule::removeStatusListener(const uno::Reference
< frame::XStatusListener
> &, const util::URL
&)
81 uno::Sequence
< uno::Reference
< frame::XDispatch
> > SAL_CALL
SdUnoModule::queryDispatches( const uno::Sequence
< frame::DispatchDescriptor
>& seqDescripts
)
83 sal_Int32 nCount
= seqDescripts
.getLength();
84 uno::Sequence
< uno::Reference
< frame::XDispatch
> > lDispatcher( nCount
);
86 for( sal_Int32 i
=0; i
<nCount
; ++i
)
88 lDispatcher
[i
] = queryDispatch( seqDescripts
[i
].FeatureURL
,
89 seqDescripts
[i
].FrameName
,
90 seqDescripts
[i
].SearchFlags
);
97 uno::Reference
< frame::XDispatch
> SAL_CALL
SdUnoModule::queryDispatch( const util::URL
& aURL
, const OUString
&, sal_Int32
)
99 SolarMutexGuard aGuard
;
101 const SfxSlot
* pSlot
= SD_MOD()->GetInterface()->GetSlot( aURL
.Complete
);
103 uno::Reference
< frame::XDispatch
> xSlot
;
111 OUString SAL_CALL
SdUnoModule::getImplementationName( )
113 return OUString( "com.sun.star.comp.Draw.DrawingModule" );
116 sal_Bool SAL_CALL
SdUnoModule::supportsService( const OUString
& sServiceName
)
118 return cppu::supportsService(this, sServiceName
);
121 uno::Sequence
< OUString
> SAL_CALL
SdUnoModule::getSupportedServiceNames( )
123 uno::Sequence
<OUString
> aSeq
{ "com.sun.star.drawing.ModuleDispatcher" };
128 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
129 com_sun_star_comp_Draw_DrawingModule_get_implementation(css::uno::XComponentContext
* ,
130 css::uno::Sequence
<css::uno::Any
> const &)
132 SolarMutexGuard aGuard
;
134 return cppu::acquire(new SdUnoModule
);
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */