2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "sal/config.h"
21 #include "com/sun/star/uno/Exception.hpp"
22 #include "com/sun/star/uno/Reference.hxx"
23 #include "com/sun/star/uno/RuntimeException.hpp"
24 #include "com/sun/star/uno/Sequence.hxx"
25 #include "com/sun/star/uno/XComponentContext.hpp"
26 #include "com/sun/star/uno/XInterface.hpp"
27 #include "cppuhelper/factory.hxx"
28 #include "cppuhelper/implbase1.hxx"
29 #include "cppuhelper/implementationentry.hxx"
30 #include "cppuhelper/weak.hxx"
31 #include "rtl/ustring.h"
32 #include "rtl/ustring.hxx"
33 #include "sal/types.h"
34 #include "uno/environment.h"
35 #include "uno/lbnames.h"
37 #include "test/types/TestException.hpp"
38 #include "test/types/XTest.hpp"
42 class Service
: public cppu::WeakImplHelper1
< test::types::XTest
> {
46 virtual void SAL_CALL
throwException()
47 throw (test::types::TestException
, css::uno::RuntimeException
)
49 throw test::types::TestException(
50 rtl::OUString("test"),
51 static_cast< cppu::OWeakObject
* >(this));
55 Service(Service
&); // not defined
56 void operator =(Service
&); // not defined
63 css::uno::Reference
< css::uno::XInterface
> create(
64 css::uno::Reference
< css::uno::XComponentContext
> const &)
65 SAL_THROW((css::uno::Exception
))
68 return static_cast< cppu::OWeakObject
* >(new Service
);
69 } catch (std::bad_alloc
&) {
70 throw css::uno::RuntimeException(
71 rtl::OUString("std::bad_alloc"),
72 css::uno::Reference
< css::uno::XInterface
>());
76 rtl::OUString
getImplementationName() {
77 return rtl::OUString("test.cpp.cpptest.Component");
80 css::uno::Sequence
< rtl::OUString
> getSupportedServiceNames() {
81 rtl::OUString
s("test.types.CppTest");
82 return css::uno::Sequence
< rtl::OUString
>(&s
, 1);
87 cppu::ImplementationEntry entries
[] = {
88 { CppTest::create
, CppTest::getImplementationName
,
89 CppTest::getSupportedServiceNames
, cppu::createSingleComponentFactory
, 0,
91 { 0, 0, 0, 0, 0, 0 } };
95 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory(
96 char const * implName
, void * serviceManager
, void * registryKey
)
98 return cppu::component_getFactoryHelper(
99 implName
, serviceManager
, registryKey
, entries
);