bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / sfxuno.hxx
blob13f8006f733af9de97c3bca2c200e80e94a8b3fd
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_SFX2_SFXUNO_HXX
21 #define INCLUDED_SFX2_SFXUNO_HXX
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <com/sun/star/uno/Exception.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/util/URL.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30 #include <com/sun/star/lang/XTypeProvider.hpp>
31 #include <com/sun/star/beans/NamedValue.hpp>
33 #include <com/sun/star/uno/Type.h>
34 #include <com/sun/star/uno/Any.h>
35 #include <com/sun/star/uno/Reference.h>
36 #include <com/sun/star/uno/Sequence.hxx>
37 #include <cppuhelper/typeprovider.hxx>
38 #include <cppuhelper/queryinterface.hxx>
39 #include <cppuhelper/factory.hxx>
41 #include <osl/mutex.hxx>
42 #include <rtl/ustring.hxx>
45 inline sal_Bool operator==( const css::util::URL& aURL1, const css::util::URL& aURL2 )
47 return aURL1.Complete == aURL2.Complete;
50 class SfxAllItemSet ;
51 class SfxItemSet ;
52 class SfxSlot ;
54 SFX2_DLLPUBLIC void TransformParameters( sal_uInt16 nSlotId ,
55 const css::uno::Sequence< css::beans::PropertyValue >& seqArgs ,
56 SfxAllItemSet& aSet ,
57 const SfxSlot* pSlot = 0 );
59 SFX2_DLLPUBLIC void TransformItems( sal_uInt16 nSlotId ,
60 const SfxItemSet& aSet ,
61 css::uno::Sequence< css::beans::PropertyValue >& seqArgs ,
62 const SfxSlot* pSlot = 0 );
64 bool GetEncryptionData_Impl( const SfxItemSet* pSet, css::uno::Sequence< css::beans::NamedValue >& aEncryptionData );
66 typedef sal_Int32 FrameSearchFlags;
68 //________________________________________________________________________________________________________________________
69 // macros for declaration and definition of uno-services
70 //________________________________________________________________________________________________________________________
72 //************************************************************************************************************************
73 // declaration of XInterface::queryInterface()
74 // XInterface::aquire()
75 // XInterface::release()
76 // XTypeProvider::getTypes()
77 // XTypeProvider::getImplementationId()
78 // XServiceInfo::getImplementationName()
79 // XServiceInfo::supportsService()
80 // XServiceInfo::getSupportedServiceNames()
81 // static xxx::impl_getStaticSupportedServiceNames()
82 // static xxx::impl_getStaticImplementationName()
83 // static xxx::impl_createInstance()
84 //************************************************************************************************************************
85 #define SFX_DECL_XSERVICEINFO_NOFACTORY \
86 /* XServiceInfo */ \
87 virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException ); \
88 virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException ); \
89 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException ); \
91 /* Helper for XServiceInfo */ \
92 static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); \
93 static OUString impl_getStaticImplementationName(); \
95 /* Helper for registry */ \
96 static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception );
98 //************************************************************************************************************************
99 // declaration of XInterface::queryInterface()
100 // XInterface::aquire()
101 // XInterface::release()
102 // XTypeProvider::getTypes()
103 // XTypeProvider::getImplementationId()
104 // XServiceInfo::getImplementationName()
105 // XServiceInfo::supportsService()
106 // XServiceInfo::getSupportedServiceNames()
107 // static xxx::impl_getStaticSupportedServiceNames()
108 // static xxx::impl_getStaticImplementationName()
109 // static xxx::impl_createInstance()
110 // static xxx::impl_createFactory()
111 //************************************************************************************************************************
112 #define SFX_DECL_XSERVICEINFO \
113 SFX_DECL_XSERVICEINFO_NOFACTORY \
114 static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
116 //************************************************************************************************************************
117 // implementation of XServiceInfo::getImplementationName()
118 // XServiceInfo::supportsService()
119 // XServiceInfo::getSupportedServiceNames()
120 // static xxx::impl_getStaticSupportedServiceNames()
121 // static xxx::impl_getStaticImplementationName()
122 // static xxx::impl_createInstance()
123 //************************************************************************************************************************
124 #define SFX_IMPL_XSERVICEINFO( IMPLCLASS, IMPLSERVICENAME, IMPLNAME ) \
126 /* XServiceInfo */ \
127 OUString SAL_CALL IMPLCLASS::getImplementationName() throw( css::uno::RuntimeException ) \
129 return impl_getStaticImplementationName(); \
132 /* XServiceInfo */ \
133 sal_Bool SAL_CALL IMPLCLASS::supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException ) \
135 css::uno::Sequence< OUString > seqServiceNames = getSupportedServiceNames(); \
136 const OUString* pArray = seqServiceNames.getConstArray(); \
137 for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) \
139 if ( pArray[nCounter] == sServiceName ) \
141 return sal_True ; \
144 return sal_False ; \
147 /* XServiceInfo */ \
148 css::uno::Sequence< OUString > SAL_CALL IMPLCLASS::getSupportedServiceNames() throw( css::uno::RuntimeException ) \
150 return impl_getStaticSupportedServiceNames(); \
153 /* Helper for XServiceInfo */ \
154 css::uno::Sequence< OUString > IMPLCLASS::impl_getStaticSupportedServiceNames() \
156 css::uno::Sequence< OUString > seqServiceNames( 1 ); \
157 seqServiceNames.getArray() [0] = OUString::createFromAscii( IMPLSERVICENAME ); \
158 return seqServiceNames ; \
161 /* Helper for XServiceInfo */ \
162 OUString IMPLCLASS::impl_getStaticImplementationName() \
164 return OUString::createFromAscii( IMPLNAME ); \
167 /* Helper for registry */ \
168 css::uno::Reference< css::uno::XInterface > SAL_CALL IMPLCLASS::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception ) \
170 return css::uno::Reference< css::uno::XInterface >( *new IMPLCLASS( xServiceManager ) ); \
173 //************************************************************************************************************************
174 // implementation of XServiceInfo::getImplementationName()
175 // XServiceInfo::supportsService()
176 // XServiceInfo::getSupportedServiceNames()
177 // static xxx::impl_getStaticSupportedServiceNames()
178 // static xxx::impl_getStaticImplementationName()
179 // static xxx::impl_createInstance()
180 //************************************************************************************************************************
181 #define SFX_IMPL_XSERVICEINFO_CTX( IMPLCLASS, IMPLSERVICENAME, IMPLNAME ) \
183 /* XServiceInfo */ \
184 OUString SAL_CALL IMPLCLASS::getImplementationName() throw( css::uno::RuntimeException ) \
186 return impl_getStaticImplementationName(); \
189 /* XServiceInfo */ \
190 sal_Bool SAL_CALL IMPLCLASS::supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException ) \
192 css::uno::Sequence< OUString > seqServiceNames = getSupportedServiceNames(); \
193 const OUString* pArray = seqServiceNames.getConstArray(); \
194 for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) \
196 if ( pArray[nCounter] == sServiceName ) \
198 return sal_True ; \
201 return sal_False ; \
204 /* XServiceInfo */ \
205 css::uno::Sequence< OUString > SAL_CALL IMPLCLASS::getSupportedServiceNames() throw( css::uno::RuntimeException ) \
207 return impl_getStaticSupportedServiceNames(); \
210 /* Helper for XServiceInfo */ \
211 css::uno::Sequence< OUString > IMPLCLASS::impl_getStaticSupportedServiceNames() \
213 css::uno::Sequence< OUString > seqServiceNames( 1 ); \
214 seqServiceNames.getArray() [0] = OUString::createFromAscii( IMPLSERVICENAME ); \
215 return seqServiceNames ; \
218 /* Helper for XServiceInfo */ \
219 OUString IMPLCLASS::impl_getStaticImplementationName() \
221 return OUString::createFromAscii( IMPLNAME ); \
224 /* Helper for registry */ \
225 css::uno::Reference< css::uno::XInterface > SAL_CALL IMPLCLASS::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception ) \
227 return css::uno::Reference< css::uno::XInterface >( *new IMPLCLASS( comphelper::getComponentContext(xServiceManager) ) ); \
230 //************************************************************************************************************************
231 // definition of createFactory() for MultiServices
232 //************************************************************************************************************************
233 #define SFX_IMPL_SINGLEFACTORY( IMPLCLASS ) \
235 css::uno::Reference< css::lang::XSingleServiceFactory > IMPLCLASS::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) \
237 css::uno::Reference< css::lang::XSingleServiceFactory > xReturn ( \
238 cppu::createSingleFactory( xServiceManager , \
239 IMPLCLASS::impl_getStaticImplementationName() , \
240 IMPLCLASS::impl_createInstance , \
241 IMPLCLASS::impl_getStaticSupportedServiceNames() ) \
242 ); \
243 return xReturn ; \
246 //************************************************************************************************************************
247 // definition of createFactory() for OneInstance-Services
248 //************************************************************************************************************************
249 #define SFX_IMPL_ONEINSTANCEFACTORY( IMPLCLASS ) \
251 css::uno::Reference< css::lang::XSingleServiceFactory > IMPLCLASS::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) \
253 css::uno::Reference< css::lang::XSingleServiceFactory > xReturn( \
254 cppu::createOneInstanceFactory( xServiceManager , \
255 IMPLCLASS::impl_getStaticImplementationName() , \
256 IMPLCLASS::impl_createInstance , \
257 IMPLCLASS::impl_getStaticSupportedServiceNames() ) \
258 ); \
259 return xReturn ; \
262 //************************************************************************************************************************
263 // definition for "extern c sfx_component_getFactory()"
264 //************************************************************************************************************************
265 #define CREATEFACTORY(CLASS) \
267 /* Create right factory ... */ \
268 xFactory = CLASS::impl_createFactory( xServiceManager );
270 //************************************************************************************************************************
271 // definition for "extern c sfx_component_getFactory()"
272 //************************************************************************************************************************
273 #define IF_NAME_CREATECOMPONENTFACTORY(CLASS) \
275 if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \
277 CREATEFACTORY ( CLASS ) \
280 #endif // INCLUDED_SFX2_SFXUNO_HXX
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */