fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / inc / macros / registration.hxx
blob836e09716d3fbc7cc7c62ef45562945a6538d463
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_FRAMEWORK_INC_MACROS_REGISTRATION_HXX
21 #define INCLUDED_FRAMEWORK_INC_MACROS_REGISTRATION_HXX
23 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 //namespace framework{
28 /*_________________________________________________________________________________________________________________
30 macros for registration of services
31 Please use follow public macros only!
33 IFFACTORY( CLASS ) => use it as parameter for COMPONENT_GETFACTORY( IFFACTORIES )
34 COMPONENTGETFACTORY( LIB, IFFACTORIES ) => use it to define exported function LIB_component_getFactory()
36 _________________________________________________________________________________________________________________*/
38 // public
39 // use it as parameter for COMPONENT_GETFACTORY( IFFACTORIES )
41 #define IFFACTORY( CLASS ) \
42 /* If searched name found ... */ \
43 /* You can't add some statements before follow line ... Here can be an ELSE-statement! */ \
44 if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \
45 { \
46 /* ... then create right factory for this service. */ \
47 /* xFactory and xServiceManager are local variables of method which use this macro. */ \
48 xFactory = CLASS::impl_createFactory( xServiceManager ); \
51 // public
52 // define method to instanciate new services
54 #define COMPONENTGETFACTORY( LIB, IFFACTORIES ) \
55 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL LIB##_component_getFactory( const sal_Char* pImplementationName, \
56 void* pServiceManager , \
57 void* /*pRegistryKey*/ ) \
58 { \
59 /* Set default return value for this operation - if it failed. */ \
60 void* pReturn = NULL; \
61 if ( \
62 ( pImplementationName != NULL ) && \
63 ( pServiceManager != NULL ) \
64 ) \
65 { \
66 /* Define variables which are used in following macros. */ \
67 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xFactory; \
68 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager; \
69 xServiceManager = static_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ); \
70 /* These parameter will expand to */ \
71 /* "IF_NAME_CREATECOMPONENTFACTORY(a) */ \
72 /* else */ \
73 /* ... */ \
74 /* else */ \
75 /* IF_NAME_CREATECOMPONENTFACTORY(z)" */ \
76 IFFACTORIES \
77 /* Factory is valid, if service was found. */ \
78 if ( xFactory.is() ) \
79 { \
80 xFactory->acquire(); \
81 pReturn = xFactory.get(); \
82 } \
83 } \
84 /* Return with result of this operation. */ \
85 return pReturn; \
88 //} // namespace framework
90 #endif // INCLUDED_FRAMEWORK_INC_MACROS_REGISTRATION_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */