update dev300-m58
[ooovba.git] / cppu / test / ObjectFactory / CppObject.cxx
blobe46d72fa7cbb1bc2781a57a647bca8ef70e1d968
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: CppObject.cxx,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_cppu.hxx"
34 #include "cppu/EnvDcp.hxx"
35 #include "cppuhelper/implbase1.hxx"
37 #include "com/sun/star/uno/XComponentContext.hpp"
39 #include "CppObject.hxx"
42 using namespace ::com::sun::star;
45 #ifdef LOG_LIFECYCLE
46 #define LOG_LIFECYCLE_CppObject
47 #endif
49 #define LOG_LIFECYCLE_CppObject
50 #ifdef LOG_LIFECYCLE_CppObject
51 # include <iostream>
52 # define LOG_LIFECYCLE_CppObject_emit(x) x
54 #else
55 # define LOG_LIFECYCLE_CppObject_emit(x)
57 #endif
59 CppObject::CppObject(Callee * pCallee) SAL_THROW((uno::RuntimeException))
60 : m_nRef (1),
61 m_pCallee(pCallee)
63 LOG_LIFECYCLE_CppObject_emit(fprintf(stderr, "LIFE: %s -> %p\n", "CppObject::CppObject", this));
66 CppObject::~CppObject() SAL_THROW((uno::RuntimeException))
68 LOG_LIFECYCLE_CppObject_emit(fprintf(stderr, "LIFE: %s -> %p\n", "CppObject::~CppObject", this));
71 void SAL_CALL CppObject::acquire() throw ()
73 m_pCallee(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::acquire")).pData);
75 osl_incrementInterlockedCount(&m_nRef);
78 void SAL_CALL CppObject::release() throw ()
80 m_pCallee(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::release")).pData);
82 if (osl_decrementInterlockedCount(&m_nRef) == 0)
83 delete this;
86 uno::Any SAL_CALL CppObject::queryInterface(uno::Type const & rType ) throw (uno::RuntimeException)
88 m_pCallee(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::queryInterface")).pData);
90 void * bla = this;
92 return uno::Any(&bla, rType);
96 uno::XInterface * CppObject::s_create(Callee * pCallee)
98 return new CppObject(pCallee);
101 void CppObject::s_call(uno::XInterface * pXInterface)
103 uno::Reference<uno::XInterface> tmp;
105 pXInterface->queryInterface(::getCppuType(&tmp));