Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / ucbhelper / macros.hxx
blob09dca56d575044389a867d3fb52e23298e244add
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 #ifndef INCLUDED_UCBHELPER_MACROS_HXX
21 #define INCLUDED_UCBHELPER_MACROS_HXX
23 #include <sal/types.h>
24 #include <cppuhelper/queryinterface.hxx>
25 #include <cppuhelper/factory.hxx>
26 #include <cppuhelper/weakref.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <cppuhelper/typeprovider.hxx>
30 #include <osl/mutex.hxx>
31 #include <ucbhelper/getcomponentcontext.hxx>
34 #define CPPU_TYPE( T ) cppu::UnoType<T>::get()
35 #define CPPU_TYPE_REF( T ) CPPU_TYPE( T )
37 // XTypeProvider impl. internals
40 #define XTYPEPROVIDER_COMMON_IMPL( Class ) \
41 css::uno::Sequence< sal_Int8 > SAL_CALL \
42 Class::getImplementationId() \
43 { \
44 return css::uno::Sequence<sal_Int8>(); \
47 #define GETTYPES_IMPL_START( Class ) \
48 css::uno::Sequence< css::uno::Type > SAL_CALL \
49 Class::getTypes() \
50 { \
51 static cppu::OTypeCollection* pCollection = nullptr; \
52 if ( !pCollection ) \
53 { \
54 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); \
55 if ( !pCollection ) \
56 { \
57 static cppu::OTypeCollection collection(
59 #define GETTYPES_IMPL_END \
60 ); \
61 pCollection = &collection; \
62 } \
63 } \
64 return (*pCollection).getTypes(); \
68 // XTypeProvider impl.
71 // 2 interfaces supported
72 #define XTYPEPROVIDER_IMPL_2( Class, I1,I2 ) \
73 XTYPEPROVIDER_COMMON_IMPL( Class ) \
74 GETTYPES_IMPL_START( Class ) \
75 CPPU_TYPE_REF( I1 ), \
76 CPPU_TYPE_REF( I2 ) \
77 GETTYPES_IMPL_END
79 // 3 interfaces supported
80 #define XTYPEPROVIDER_IMPL_3( Class, I1,I2,I3 ) \
81 XTYPEPROVIDER_COMMON_IMPL( Class ) \
82 GETTYPES_IMPL_START( Class ) \
83 CPPU_TYPE_REF( I1 ), \
84 CPPU_TYPE_REF( I2 ), \
85 CPPU_TYPE_REF( I3 ) \
86 GETTYPES_IMPL_END
88 // 4 interfaces supported
89 #define XTYPEPROVIDER_IMPL_4( Class, I1,I2,I3,I4 ) \
90 XTYPEPROVIDER_COMMON_IMPL( Class ) \
91 GETTYPES_IMPL_START( Class ) \
92 CPPU_TYPE_REF( I1 ), \
93 CPPU_TYPE_REF( I2 ), \
94 CPPU_TYPE_REF( I3 ), \
95 CPPU_TYPE_REF( I4 ) \
96 GETTYPES_IMPL_END
98 // 5 interfaces supported
99 #define XTYPEPROVIDER_IMPL_5( Class, I1,I2,I3,I4,I5 ) \
100 XTYPEPROVIDER_COMMON_IMPL( Class ) \
101 GETTYPES_IMPL_START( Class ) \
102 CPPU_TYPE_REF( I1 ), \
103 CPPU_TYPE_REF( I2 ), \
104 CPPU_TYPE_REF( I3 ), \
105 CPPU_TYPE_REF( I4 ), \
106 CPPU_TYPE_REF( I5 ) \
107 GETTYPES_IMPL_END
109 // 9 interfaces supported
110 #define XTYPEPROVIDER_IMPL_9( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9 ) \
111 XTYPEPROVIDER_COMMON_IMPL( Class ) \
112 GETTYPES_IMPL_START( Class ) \
113 CPPU_TYPE_REF( I1 ), \
114 CPPU_TYPE_REF( I2 ), \
115 CPPU_TYPE_REF( I3 ), \
116 CPPU_TYPE_REF( I4 ), \
117 CPPU_TYPE_REF( I5 ), \
118 CPPU_TYPE_REF( I6 ), \
119 CPPU_TYPE_REF( I7 ), \
120 CPPU_TYPE_REF( I8 ), \
121 CPPU_TYPE_REF( I9 ) \
122 GETTYPES_IMPL_END
124 // 10 interfaces supported
125 #define XTYPEPROVIDER_IMPL_10( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10 ) \
126 XTYPEPROVIDER_COMMON_IMPL( Class ) \
127 GETTYPES_IMPL_START( Class ) \
128 CPPU_TYPE_REF( I1 ), \
129 CPPU_TYPE_REF( I2 ), \
130 CPPU_TYPE_REF( I3 ), \
131 CPPU_TYPE_REF( I4 ), \
132 CPPU_TYPE_REF( I5 ), \
133 CPPU_TYPE_REF( I6 ), \
134 CPPU_TYPE_REF( I7 ), \
135 CPPU_TYPE_REF( I8 ), \
136 CPPU_TYPE_REF( I9 ), \
137 CPPU_TYPE_REF( I10 ) \
138 GETTYPES_IMPL_END
140 // 11 interfaces supported
141 #define XTYPEPROVIDER_IMPL_11( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11 ) \
142 XTYPEPROVIDER_COMMON_IMPL( Class ) \
143 GETTYPES_IMPL_START( Class ) \
144 CPPU_TYPE_REF( I1 ), \
145 CPPU_TYPE_REF( I2 ), \
146 CPPU_TYPE_REF( I3 ), \
147 CPPU_TYPE_REF( I4 ), \
148 CPPU_TYPE_REF( I5 ), \
149 CPPU_TYPE_REF( I6 ), \
150 CPPU_TYPE_REF( I7 ), \
151 CPPU_TYPE_REF( I8 ), \
152 CPPU_TYPE_REF( I9 ), \
153 CPPU_TYPE_REF( I10 ), \
154 CPPU_TYPE_REF( I11 ) \
155 GETTYPES_IMPL_END
157 // XServiceInfo impl. internals
160 #define XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \
161 OUString SAL_CALL Class::getImplementationName() \
163 return getImplementationName_Static(); \
166 OUString Class::getImplementationName_Static() \
168 return ImplName; \
171 sal_Bool SAL_CALL \
172 Class::supportsService( const OUString& ServiceName ) \
174 return cppu::supportsService( this, ServiceName ); \
177 css::uno::Sequence< OUString > SAL_CALL \
178 Class::getSupportedServiceNames() \
180 return getSupportedServiceNames_Static(); \
183 // XServiceInfo impl.
186 #define ONE_INSTANCE_SERVICE_FACTORY_IMPL( Class ) \
187 css::uno::Reference< css::lang::XSingleServiceFactory > \
188 Class::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ) \
190 return css::uno::Reference< \
191 css::lang::XSingleServiceFactory >( \
192 cppu::createOneInstanceFactory( \
193 rxServiceMgr, \
194 Class::getImplementationName_Static(), \
195 Class##_CreateInstance, \
196 Class::getSupportedServiceNames_Static() ) ); \
199 // Service without service factory.
201 // 1 service name
202 #define XSERVICEINFO_NOFACTORY_IMPL_1( Class, ImplName, Service1 ) \
203 XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \
205 css::uno::Sequence< OUString > \
206 Class::getSupportedServiceNames_Static() \
208 return { Service1 }; \
211 #endif /* ! INCLUDED_UCBHELPER_MACROS_HXX */
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */