merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / inc / ServiceMacros.hxx
blob1cb552767aaa41ba9c5c09cada21a6c11ef832d5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ServiceMacros.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _APPHELPER_SERVICEMACROS_HXX
31 #define _APPHELPER_SERVICEMACROS_HXX
34 to use these macros the supported services and the implementation name needs to be static
35 especially you need to implement (declaration is contained in macro already):
37 static com::sun::star::uno::Sequence< rtl::OUString >
38 Class::getSupportedServiceNames_Static();
41 //=========================================================================
43 // XServiceInfo decl
45 //=========================================================================
46 namespace apphelper
49 #define APPHELPER_XSERVICEINFO_DECL() \
50 virtual ::rtl::OUString SAL_CALL \
51 getImplementationName() \
52 throw( ::com::sun::star::uno::RuntimeException ); \
53 virtual sal_Bool SAL_CALL \
54 supportsService( const ::rtl::OUString& ServiceName ) \
55 throw( ::com::sun::star::uno::RuntimeException ); \
56 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL \
57 getSupportedServiceNames() \
58 throw( ::com::sun::star::uno::RuntimeException ); \
60 static ::rtl::OUString getImplementationName_Static(); \
61 static ::com::sun::star::uno::Sequence< ::rtl::OUString > \
62 getSupportedServiceNames_Static();
64 //=========================================================================
66 // XServiceInfo impl
68 //=========================================================================
70 #define APPHELPER_XSERVICEINFO_IMPL( Class, ImplName ) \
71 ::rtl::OUString SAL_CALL Class::getImplementationName() \
72 throw( ::com::sun::star::uno::RuntimeException ) \
73 { \
74 return getImplementationName_Static(); \
75 } \
77 ::rtl::OUString Class::getImplementationName_Static() \
78 { \
79 return ImplName; \
80 } \
82 sal_Bool SAL_CALL \
83 Class::supportsService( const ::rtl::OUString& ServiceName ) \
84 throw( ::com::sun::star::uno::RuntimeException ) \
85 { \
86 ::com::sun::star::uno::Sequence< ::rtl::OUString > aSNL = \
87 getSupportedServiceNames(); \
88 const ::rtl::OUString* pArray = aSNL.getArray(); \
89 for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) \
90 { \
91 if( pArray[ i ] == ServiceName ) \
92 return sal_True; \
93 } \
95 return sal_False; \
96 } \
98 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL \
99 Class::getSupportedServiceNames() \
100 throw( ::com::sun::star::uno::RuntimeException ) \
102 return getSupportedServiceNames_Static(); \
105 //=========================================================================
107 // Service factory helper decl+impl
109 //to use this macro you need to provide a constructor:
110 //class( Reference< XComponentContext > const & xContext )
111 //and implement OWeakObject
112 //=========================================================================
114 #define APPHELPER_SERVICE_FACTORY_HELPER(Class) \
115 static ::com::sun::star::uno::Reference< \
116 ::com::sun::star::uno::XInterface > SAL_CALL \
117 create( ::com::sun::star::uno::Reference< \
118 ::com::sun::star::uno::XComponentContext > const & xContext) \
119 throw(::com::sun::star::uno::Exception) \
121 return (::cppu::OWeakObject *)new Class( xContext ); \
124 /** This macro contains the default implementation for getImplementationId().
125 Note, that you have to include the header necessary for rtl_createUuid.
126 Insert the following into your file:
128 <code>
129 #include <rtl/uuid.h>
130 </code>
132 @param Class the Class-Name for which getImplementationId() should be
133 implemented
135 #define APPHELPER_GETIMPLEMENTATIONID_IMPL(Class) \
136 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL Class::getImplementationId() \
137 throw (::com::sun::star::uno::RuntimeException) \
139 static ::com::sun::star::uno::Sequence< sal_Int8 > aId; \
140 if( aId.getLength() == 0 ) \
142 aId.realloc( 16 ); \
143 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); \
145 return aId; \
148 }//end namespace apphelper
149 #endif