xref: /aoo41x/main/cppu/inc/com/sun/star/uno/genfunc.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_
28 #define _COM_SUN_STAR_UNO_GENFUNC_HXX_
29 
30 #include <com/sun/star/uno/genfunc.h>
31 #include <com/sun/star/uno/Any.hxx>
32 
33 
34 namespace com
35 {
36 namespace sun
37 {
38 namespace star
39 {
40 namespace uno
41 {
42 
43 //==================================================================================================
44 inline void SAL_CALL cpp_acquire( void * pCppI )
45 	SAL_THROW( () )
46 {
47 	reinterpret_cast< XInterface * >( pCppI )->acquire();
48 }
49 //==================================================================================================
50 inline void SAL_CALL cpp_release( void * pCppI )
51 	SAL_THROW( () )
52 {
53 	reinterpret_cast< XInterface * >( pCppI )->release();
54 }
55 //==================================================================================================
56 inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType )
57 	SAL_THROW( () )
58 {
59 	if (pCppI)
60 	{
61 #ifndef EXCEPTIONS_OFF
62 		try
63 		{
64 #endif
65 			Any aRet( reinterpret_cast< XInterface * >( pCppI )->queryInterface(
66 				* reinterpret_cast< const Type * >( &pType ) ) );
67 			if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
68 			{
69 				XInterface * pRet = reinterpret_cast< XInterface * >( aRet.pReserved );
70 				aRet.pReserved = 0;
71 				return pRet;
72 			}
73 #ifndef EXCEPTIONS_OFF
74 		}
75 		catch (RuntimeException &)
76 		{
77 		}
78 #endif
79 	}
80 	return 0;
81 }
82 
83 }
84 }
85 }
86 }
87 
88 #endif
89