LibreOffice LibreOffice 4.3 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mapping.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19 #ifndef INCLUDED_UNO_MAPPING_HXX
20 #define INCLUDED_UNO_MAPPING_HXX
21
22 #include <cppu/macros.hxx>
23 #include <rtl/alloc.h>
24 #include <rtl/ustring.hxx>
25 #include <uno/mapping.h>
26 #include <com/sun/star/uno/Type.hxx>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <cppu/unotype.hxx>
29 #include <uno/environment.hxx>
30 #include <uno/lbnames.h>
31
32 typedef struct _typelib_TypeDescription typelib_TypeDescription;
33 typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription;
34 typedef struct _uno_Interface uno_Interface;
35
36 namespace com
37 {
38 namespace sun
39 {
40 namespace star
41 {
42 namespace uno
43 {
44
49 class Mapping
50 {
51 uno_Mapping * _pMapping;
52
53 public:
54 // these are here to force memory de/allocation to sal lib.
56 inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
57 { return ::rtl_allocateMemory( nSize ); }
58 inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
59 { ::rtl_freeMemory( pMem ); }
60 inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
61 { return pMem; }
62 inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
63 {}
65
73 inline Mapping(
74 const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo,
75 const ::rtl::OUString & rAddPurpose = ::rtl::OUString() )
76 SAL_THROW(());
77
84 inline Mapping(
85 uno_Environment * pFrom, uno_Environment * pTo,
86 const ::rtl::OUString & rAddPurpose = ::rtl::OUString() )
87 SAL_THROW(());
88
96 inline Mapping(const Environment & rFrom, const Environment & rTo,
97 const ::rtl::OUString & rAddPurpose = ::rtl::OUString() )
98 SAL_THROW(());
99
104 inline Mapping( uno_Mapping * pMapping = 0 ) SAL_THROW(());
105
110 inline Mapping( const Mapping & rMapping ) SAL_THROW(());
111
114 inline ~Mapping() SAL_THROW(());
115
121 inline Mapping & SAL_CALL operator = ( uno_Mapping * pMapping ) SAL_THROW(());
127 inline Mapping & SAL_CALL operator = ( const Mapping & rMapping ) SAL_THROW(())
128 { return operator = ( rMapping._pMapping ); }
129
134 inline uno_Mapping * SAL_CALL get() const SAL_THROW(())
135 { return _pMapping; }
136
141 inline bool SAL_CALL is() const SAL_THROW(())
142 { return (_pMapping != 0); }
143
146 inline void SAL_CALL clear() SAL_THROW(());
147
154 inline void * SAL_CALL mapInterface( void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const SAL_THROW(());
161 inline void * SAL_CALL mapInterface( void * pInterface, typelib_TypeDescription * pTypeDescr ) const SAL_THROW(())
162 { return mapInterface( pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); }
163
170 inline void * SAL_CALL mapInterface(
171 void * pInterface, const ::com::sun::star::uno::Type & rType ) const SAL_THROW(());
172
179 inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const SAL_THROW(())
180 { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, pTypeDescr ); }
187 inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_TypeDescription * pTypeDescr ) const SAL_THROW(())
188 { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); }
189
196 inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, const ::com::sun::star::uno::Type & rType ) const SAL_THROW(());
197 };
198
199 inline Mapping::Mapping(
200 const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo, const ::rtl::OUString & rAddPurpose )
201 SAL_THROW(())
202 : _pMapping( 0 )
203 {
204 uno_getMappingByName( &_pMapping, rFrom.pData, rTo.pData, rAddPurpose.pData );
205 }
206
207 inline Mapping::Mapping(
208 uno_Environment * pFrom, uno_Environment * pTo, const ::rtl::OUString & rAddPurpose )
209 SAL_THROW(())
210 : _pMapping( 0 )
211 {
212 uno_getMapping( &_pMapping, pFrom, pTo, rAddPurpose.pData );
213 }
214
215 inline Mapping::Mapping(
216 const Environment & rFrom, const Environment & rTo, const ::rtl::OUString & rAddPurpose )
217 SAL_THROW(())
218 : _pMapping(0)
219 {
220 uno_getMapping( &_pMapping, rFrom.get(), rTo.get(), rAddPurpose.pData );
221 }
222
223 inline Mapping::Mapping( uno_Mapping * pMapping ) SAL_THROW(())
224 : _pMapping( pMapping )
225 {
226 if (_pMapping)
227 (*_pMapping->acquire)( _pMapping );
228 }
229
230 inline Mapping::Mapping( const Mapping & rMapping ) SAL_THROW(())
231 : _pMapping( rMapping._pMapping )
232 {
233 if (_pMapping)
234 (*_pMapping->acquire)( _pMapping );
235 }
236
237 inline Mapping::~Mapping() SAL_THROW(())
238 {
239 if (_pMapping)
240 (*_pMapping->release)( _pMapping );
241 }
242
243 inline void Mapping::clear() SAL_THROW(())
244 {
245 if (_pMapping)
246 {
247 (*_pMapping->release)( _pMapping );
248 _pMapping = 0;
249 }
250 }
251
252 inline Mapping & Mapping::operator = ( uno_Mapping * pMapping ) SAL_THROW(())
253 {
254 if (pMapping)
255 (*pMapping->acquire)( pMapping );
256 if (_pMapping)
257 (*_pMapping->release)( _pMapping );
258 _pMapping = pMapping;
259 return *this;
260 }
261
262 inline void Mapping::mapInterface(
263 void ** ppOut, void * pInterface, const ::com::sun::star::uno::Type & rType ) const
264 SAL_THROW(())
265 {
266 typelib_TypeDescription * pTD = 0;
267 TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() );
268 if (pTD)
269 {
270 (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTD );
271 TYPELIB_DANGER_RELEASE( pTD );
272 }
273 }
274
275 inline void * Mapping::mapInterface(
276 void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const
277 SAL_THROW(())
278 {
279 void * pOut = 0;
280 (*_pMapping->mapInterface)( _pMapping, &pOut, pInterface, pTypeDescr );
281 return pOut;
282 }
283
284 inline void * Mapping::mapInterface(
285 void * pInterface, const ::com::sun::star::uno::Type & rType ) const
286 SAL_THROW(())
287 {
288 void * pOut = 0;
289 mapInterface( &pOut, pInterface, rType );
290 return pOut;
291 }
292
305 template< class C >
306 inline bool mapToCpp( Reference< C > * ppRet, uno_Interface * pUnoI ) SAL_THROW(())
307 {
308 Mapping aMapping(
309 ::rtl::OUString( UNO_LB_UNO ),
310 ::rtl::OUString( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) );
311 OSL_ASSERT( aMapping.is() );
312 aMapping.mapInterface(
313 (void **)ppRet, pUnoI, ::cppu::getTypeFavourUnsigned( ppRet ) );
314 return (0 != *ppRet);
315 }
328 template< class C >
329 inline bool mapToUno( uno_Interface ** ppRet, const Reference< C > & x ) SAL_THROW(())
330 {
331 Mapping aMapping(
332 ::rtl::OUString( CPPU_CURRENT_LANGUAGE_BINDING_NAME ),
333 ::rtl::OUString( UNO_LB_UNO ) );
334 OSL_ASSERT( aMapping.is() );
335 aMapping.mapInterface(
336 (void **)ppRet, x.get(), ::cppu::getTypeFavourUnsigned( &x ) );
337 return (0 != *ppRet);
338 }
339
340 }
341 }
342 }
343 }
344
345 #endif
346
347 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_uno_Mapping::release
uno_ReleaseMappingFunc release
Releases mapping.
Definition: mapping.h:72
alloc.h
com::sun::star::uno::Mapping::is
bool is() const SAL_THROW(())
Tests if a mapping is set.
Definition: mapping.hxx:141
com::sun::star::uno::Mapping::~Mapping
~Mapping() SAL_THROW(())
Destructor.
Definition: mapping.hxx:237
mapping.h
com::sun::star::uno::Mapping::Mapping
Mapping(const ::rtl::OUString &rFrom, const ::rtl::OUString &rTo, const ::rtl::OUString &rAddPurpose=::rtl::OUString()) SAL_THROW(())
Holds a mapping from the specified source to the specified destination by environment type names...
Definition: mapping.hxx:199
com::sun::star::uno::Mapping::operator=
Mapping & operator=(uno_Mapping *pMapping) SAL_THROW(())
Sets a given mapping.
Definition: mapping.hxx:252
rtl_allocateMemory
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
uno_getMapping
CPPU_DLLPUBLIC void uno_getMapping(struct _uno_Mapping **ppMapping, struct _uno_Environment *pFrom, struct _uno_Environment *pTo, rtl_uString *pAddPurpose) SAL_THROW_EXTERN_C()
Gets an interface mapping from one environment to another.
com::sun::star::uno::Environment
C++ wrapper for binary C uno_Environment.
Definition: environment.hxx:45
lbnames.h
Reference.hxx
com::sun::star::uno::Mapping::mapInterface
void mapInterface(void **ppOut, void *pInterface, typelib_InterfaceTypeDescription *pTypeDescr) const SAL_THROW(())
Maps an interface from one environment to another.
Definition: mapping.hxx:179
com::sun::star::uno::Mapping::clear
void clear() SAL_THROW(())
Releases a set mapping.
Definition: mapping.hxx:243
com::sun::star::uno::mapToUno
bool mapToUno(uno_Interface **ppRet, const Reference< C > &x) SAL_THROW(())
Deprecated.
Definition: mapping.hxx:329
cppu::getTypeFavourUnsigned
::com::sun::star::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:287
_uno_Environment
The binary specification of an UNO environment.
Definition: environment.h:41
unotype.hxx
com::sun::star::uno::Mapping
C++ wrapper for C uno_Mapping.
Definition: mapping.hxx:49
macros.hxx
_uno_Mapping
This is the binary specification of a mapping.
Definition: mapping.h:64
_typelib_InterfaceTypeDescription
Type description of an interface.
Definition: typedescription.h:370
com::sun::star::uno::Mapping::mapInterface
void * mapInterface(void *pInterface, typelib_InterfaceTypeDescription *pTypeDescr) const SAL_THROW(())
Maps an interface from one environment to another.
Definition: mapping.hxx:275
SAL_THROW
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
_typelib_TypeDescription
Full type description of a type.
Definition: typedescription.h:71
OSL_ASSERT
#define OSL_ASSERT(c)
Definition: diagnose.h:105
com::sun::star::uno::Environment::get
uno_Environment * get() const SAL_THROW(())
Provides UNacquired pointer to the set C environment.
Definition: environment.hxx:115
environment.hxx
_uno_Mapping::acquire
uno_AcquireMappingFunc acquire
Acquires mapping.
Definition: mapping.h:68
Type.hxx
com::sun::star::uno::Mapping::mapInterface
void mapInterface(void **ppOut, void *pInterface, typelib_TypeDescription *pTypeDescr) const SAL_THROW(())
Maps an interface from one environment to another.
Definition: mapping.hxx:187
com::sun::star::uno::Reference
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
com::sun::star::uno::mapToCpp
bool mapToCpp(Reference< C > *ppRet, uno_Interface *pUnoI) SAL_THROW(())
Deprecated.
Definition: mapping.hxx:306
_uno_Interface
The binary C uno interface description.
Definition: dispatcher.h:62
UNO_LB_UNO
#define UNO_LB_UNO
Environment type name for binary C UNO.
Definition: lbnames.h:45
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:82
rtl_freeMemory
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
ustring.hxx
_uno_Mapping::mapInterface
uno_MapInterfaceFunc mapInterface
mapping function
Definition: mapping.h:76
uno_getMappingByName
CPPU_DLLPUBLIC void uno_getMappingByName(struct _uno_Mapping **ppMapping, rtl_uString *pFrom, rtl_uString *pTo, rtl_uString *pAddPurpose) SAL_THROW_EXTERN_C()
Gets an interface mapping from one language environment to another by corresponding environment type ...
com
Definition: types.h:391