android: Update app-specific/MIME type icons
[LibreOffice.git] / desktop / test / deployment / crashextension / crashextension.cxx
blob2e64f3af024b2b6a3c240690f0782869d4923dde
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include <sal/config.h>
12 #include <cassert>
13 #include <cstddef>
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>
33 namespace
35 class Provider : public cppu::WeakImplHelper3<css::lang::XServiceInfo,
36 css::frame::XDispatchProvider, css::frame::XDispatch>
38 public:
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();
52 private:
53 explicit Provider(css::uno::Reference<css::uno::XComponentContext> const& context)
54 : context_(context)
56 assert(context.is());
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)
112 return this;
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)
121 s[i]
122 = queryDispatch(Requests[i].FeatureURL, Requests[i].FrameName, Requests[i].SearchFlags);
124 return s;
127 void Provider::dispatch(css::util::URL const&, css::uno::Sequence<css::beans::PropertyValue> const&)
129 // Crash LibreOffice
130 *((char*)NULL) = 0;
133 cppu::ImplementationEntry const services[]
134 = { { &Provider::static_create, &Provider::static_getImplementationName,
135 &Provider::static_getSupportedServiceNames, &cppu::createSingleComponentFactory, NULL,
136 0 },
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: */