1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <sal/config.h>
15 #include <com/sun/star/beans/PropertyValue.hpp>
16 #include <com/sun/star/frame/DispatchDescriptor.hpp>
17 #include <com/sun/star/frame/XDispatch.hpp>
18 #include <com/sun/star/frame/XDispatchProvider.hpp>
19 #include <com/sun/star/frame/XStatusListener.hpp>
20 #include <com/sun/star/lang/XServiceInfo.hpp>
21 #include <com/sun/star/uno/DeploymentException.hpp>
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/util/URL.hpp>
27 #include <cppuhelper/implbase3.hxx>
28 #include <cppuhelper/implementationentry.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <rtl/ustring.hxx>
31 #include <uno/lbnames.h>
35 class Provider
: public cppu::WeakImplHelper3
<css::lang::XServiceInfo
,
36 css::frame::XDispatchProvider
, css::frame::XDispatch
>
39 Provider(const Provider
&) = delete;
40 const Provider
& operator=(const Provider
&) = delete;
42 static css::uno::Reference
<css::uno::XInterface
>
43 SAL_CALL
static_create(css::uno::Reference
<css::uno::XComponentContext
> const& xContext
)
45 return static_cast<cppu::OWeakObject
*>(new Provider(xContext
));
48 static rtl::OUString SAL_CALL
static_getImplementationName();
50 static css::uno::Sequence
<rtl::OUString
> SAL_CALL
static_getSupportedServiceNames();
53 explicit Provider(css::uno::Reference
<css::uno::XComponentContext
> const& context
)
59 virtual ~Provider() {}
61 virtual rtl::OUString SAL_CALL
getImplementationName() override
63 return static_getImplementationName();
66 virtual sal_Bool SAL_CALL
supportsService(rtl::OUString
const& ServiceName
) override
68 return cppu::supportsService(this, ServiceName
);
71 virtual css::uno::Sequence
<rtl::OUString
> SAL_CALL
getSupportedServiceNames() override
73 return static_getSupportedServiceNames();
76 virtual css::uno::Reference
<css::frame::XDispatch
>
77 SAL_CALL
queryDispatch(css::util::URL
const&, rtl::OUString
const&, sal_Int32
) override
;
79 virtual css::uno::Sequence
<css::uno::Reference
<css::frame::XDispatch
>> SAL_CALL
80 queryDispatches(css::uno::Sequence
<css::frame::DispatchDescriptor
> const& Requests
) override
;
82 virtual void SAL_CALL
dispatch(css::util::URL
const&,
83 css::uno::Sequence
<css::beans::PropertyValue
> const&) override
;
85 virtual void SAL_CALL
addStatusListener(css::uno::Reference
<css::frame::XStatusListener
> const&,
86 css::util::URL
const&) override
90 virtual void SAL_CALL
removeStatusListener(
91 css::uno::Reference
<css::frame::XStatusListener
> const&, css::util::URL
const&) override
95 css::uno::Reference
<css::uno::XComponentContext
> context_
;
98 rtl::OUString
Provider::static_getImplementationName()
100 return rtl::OUString("org.libreoffice.test.desktop.deployment.crashextension.impl");
103 css::uno::Sequence
<rtl::OUString
> Provider::static_getSupportedServiceNames()
105 rtl::OUString
name("org.libreoffice.test.desktop.deployment.crashextension");
106 return css::uno::Sequence
<rtl::OUString
>(&name
, 1);
109 css::uno::Reference
<css::frame::XDispatch
> Provider::queryDispatch(css::util::URL
const&,
110 rtl::OUString
const&, sal_Int32
)
115 css::uno::Sequence
<css::uno::Reference
<css::frame::XDispatch
>>
116 Provider::queryDispatches(css::uno::Sequence
<css::frame::DispatchDescriptor
> const& Requests
)
118 css::uno::Sequence
<css::uno::Reference
<css::frame::XDispatch
>> s(Requests
.getLength());
119 for (sal_Int32 i
= 0; i
< s
.getLength(); ++i
)
122 = queryDispatch(Requests
[i
].FeatureURL
, Requests
[i
].FrameName
, Requests
[i
].SearchFlags
);
127 void Provider::dispatch(css::util::URL
const&, css::uno::Sequence
<css::beans::PropertyValue
> const&)
133 cppu::ImplementationEntry
const services
[]
134 = { { &Provider::static_create
, &Provider::static_getImplementationName
,
135 &Provider::static_getSupportedServiceNames
, &cppu::createSingleComponentFactory
, NULL
,
137 { NULL
, NULL
, NULL
, NULL
, NULL
, 0 } };
140 extern "C" SAL_DLLPUBLIC_EXPORT
void*
141 component_getFactory(char const* pImplName
, void* pServiceManager
, void* pRegistryKey
)
143 return cppu::component_getFactoryHelper(pImplName
, pServiceManager
, pRegistryKey
, services
);
146 extern "C" SAL_DLLPUBLIC_EXPORT
void
147 component_getImplementationEnvironment(char const** ppEnvTypeName
, uno_Environment
**)
149 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */