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/frame/DispatchResultState.hpp>
21 #include <cppuhelper/supportsservice.hxx>
25 #include "unomodule.hxx"
26 #include <sfx2/objface.hxx>
27 #include <sfx2/bindings.hxx>
28 #include <sfx2/request.hxx>
29 #include <vcl/svapp.hxx>
31 using namespace ::com::sun::star
;
34 void SAL_CALL
SdUnoModule::dispatchWithNotification( const util::URL
& aURL
, const uno::Sequence
< beans::PropertyValue
>& aArgs
, const uno::Reference
< frame::XDispatchResultListener
>& xListener
)
36 // there is no guarantee, that we are holded alive during this method!
37 // May the outside dispatch container will be updated by a CONTEXT_CHANGED
39 uno::Reference
< uno::XInterface
> xThis(static_cast< frame::XNotifyingDispatch
* >(this));
41 SolarMutexGuard aGuard
;
43 SdModule
* mod
= SdModule::get();
44 const SfxSlot
* pSlot
= mod
->GetInterface()->GetSlot( aURL
.Complete
);
46 sal_Int16 aState
= frame::DispatchResultState::DONTKNOW
;
48 aState
= frame::DispatchResultState::FAILURE
;
51 SfxRequest
aReq( pSlot
, aArgs
, SfxCallMode::SYNCHRON
, mod
->GetPool() );
52 const SfxPoolItemHolder
aResult(mod
->ExecuteSlot(aReq
));
54 aState
= frame::DispatchResultState::SUCCESS
;
56 aState
= frame::DispatchResultState::FAILURE
;
61 xListener
->dispatchFinished(
62 frame::DispatchResultEvent(
63 xThis
, aState
, uno::Any()));
67 void SAL_CALL
SdUnoModule::dispatch( const util::URL
& aURL
, const uno::Sequence
< beans::PropertyValue
>& aArgs
)
69 dispatchWithNotification(aURL
, aArgs
, uno::Reference
< frame::XDispatchResultListener
>());
72 void SAL_CALL
SdUnoModule::addStatusListener(const uno::Reference
< frame::XStatusListener
> &, const util::URL
&)
76 void SAL_CALL
SdUnoModule::removeStatusListener(const uno::Reference
< frame::XStatusListener
> &, const util::URL
&)
80 uno::Sequence
< uno::Reference
< frame::XDispatch
> > SAL_CALL
SdUnoModule::queryDispatches( const uno::Sequence
< frame::DispatchDescriptor
>& seqDescripts
)
82 sal_Int32 nCount
= seqDescripts
.getLength();
83 uno::Sequence
< uno::Reference
< frame::XDispatch
> > lDispatcher( nCount
);
85 std::transform(seqDescripts
.begin(), seqDescripts
.end(), lDispatcher
.getArray(),
86 [this](const frame::DispatchDescriptor
& rDescr
) -> uno::Reference
<frame::XDispatch
> {
87 return queryDispatch(rDescr
.FeatureURL
, rDescr
.FrameName
, rDescr
.SearchFlags
); });
93 uno::Reference
< frame::XDispatch
> SAL_CALL
SdUnoModule::queryDispatch( const util::URL
& aURL
, const OUString
&, sal_Int32
)
95 SolarMutexGuard aGuard
;
97 const SfxSlot
* pSlot
= SdModule::get()->GetInterface()->GetSlot(aURL
.Complete
);
99 uno::Reference
< frame::XDispatch
> xSlot
;
107 OUString SAL_CALL
SdUnoModule::getImplementationName( )
109 return u
"com.sun.star.comp.Draw.DrawingModule"_ustr
;
112 sal_Bool SAL_CALL
SdUnoModule::supportsService( const OUString
& sServiceName
)
114 return cppu::supportsService(this, sServiceName
);
117 uno::Sequence
< OUString
> SAL_CALL
SdUnoModule::getSupportedServiceNames( )
119 return { u
"com.sun.star.drawing.ModuleDispatcher"_ustr
};
123 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
124 com_sun_star_comp_Draw_DrawingModule_get_implementation(css::uno::XComponentContext
* ,
125 css::uno::Sequence
<css::uno::Any
> const &)
127 SolarMutexGuard aGuard
;
129 return cppu::acquire(new SdUnoModule
);
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */