2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* $RCSfile: apitools.cxx,v $
|
|
|
|
* $Revision: 1.11 $
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 12:48:02 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 05:50:56 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
#ifndef _DBASHARED_APITOOLS_HXX_
|
|
|
|
#include "apitools.hxx"
|
|
|
|
#endif
|
2000-10-27 06:34:13 +00:00
|
|
|
#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
|
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 15:18:56 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#endif
|
2004-10-22 08:03:03 +00:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
2000-09-18 15:18:56 +00:00
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
2005-09-23 11:14:03 +00:00
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace cppu;
|
|
|
|
using namespace osl;
|
|
|
|
using namespace dbaccess;
|
|
|
|
|
|
|
|
//==================================================================================
|
|
|
|
//= various helper functions
|
|
|
|
//==================================================================================
|
|
|
|
//============================================================
|
|
|
|
//= OSubComponent
|
|
|
|
//============================================================
|
2005-09-23 11:14:03 +00:00
|
|
|
DBG_NAME(OSubComponent)
|
2000-09-18 15:18:56 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
OSubComponent::OSubComponent(Mutex& _rMutex, const Reference< XInterface > & xParent)
|
|
|
|
:OComponentHelper(_rMutex)
|
|
|
|
,m_xParent(xParent)
|
|
|
|
{
|
2005-09-23 11:14:03 +00:00
|
|
|
DBG_CTOR(OSubComponent,NULL);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2004-10-22 08:03:03 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OSubComponent::~OSubComponent()
|
|
|
|
{
|
|
|
|
m_xParent = NULL;
|
2005-09-23 11:14:03 +00:00
|
|
|
|
|
|
|
DBG_DTOR(OSubComponent,NULL);
|
2004-10-22 08:03:03 +00:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// com::sun::star::lang::XTypeProvider
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Sequence< Type > OSubComponent::getTypes() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OTypeCollection aTypes(::getCppuType( (const Reference< XComponent > *)0 ),
|
|
|
|
::getCppuType( (const Reference< XTypeProvider > *)0 ),
|
|
|
|
::getCppuType( (const Reference< XWeak > *)0 ));
|
|
|
|
|
|
|
|
return aTypes.getTypes();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XInterface
|
|
|
|
//--------------------------------------------------------------------------
|
2001-10-30 10:50:53 +00:00
|
|
|
void OSubComponent::acquire() throw ( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
OComponentHelper::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
2001-10-30 10:50:53 +00:00
|
|
|
void OSubComponent::release() throw ( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
Reference< XInterface > x( xDelegator );
|
|
|
|
if (! x.is())
|
|
|
|
{
|
2004-10-22 08:03:03 +00:00
|
|
|
if (osl_decrementInterlockedCount( &m_refCount ) == 0 && m_refCount == 0 )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2004-10-22 08:03:03 +00:00
|
|
|
OSL_ENSURE( m_refCount == 0, "OSubComponent::release: why the hell is this false!" );
|
2000-09-18 15:18:56 +00:00
|
|
|
if (! rBHelper.bDisposed)
|
|
|
|
{
|
|
|
|
Reference< XInterface > xHoldAlive( *this );
|
|
|
|
// remember the parent
|
|
|
|
Reference< XInterface > xParent;
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( rBHelper.rMutex );
|
|
|
|
xParent = m_xParent;
|
|
|
|
m_xParent = NULL;
|
|
|
|
}
|
|
|
|
|
2004-10-22 08:03:03 +00:00
|
|
|
OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count!" );
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// First dispose
|
|
|
|
dispose();
|
|
|
|
|
|
|
|
// only the alive ref holds the object
|
2001-04-03 13:16:03 +00:00
|
|
|
OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count!" );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// release the parent in the ~
|
|
|
|
if (xParent.is())
|
|
|
|
{
|
|
|
|
MutexGuard aGuard( rBHelper.rMutex );
|
|
|
|
m_xParent = xParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// destroy the object if xHoldAlive decrement the refcount to 0
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// restore the reference count
|
|
|
|
osl_incrementInterlockedCount( &m_refCount );
|
|
|
|
}
|
|
|
|
|
|
|
|
// as we cover the job of the componenthelper we use the ...
|
|
|
|
OWeakAggObject::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Any OSubComponent::queryInterface( const Type & rType ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
Any aReturn;
|
|
|
|
if (!rType.equals(::getCppuType(static_cast< Reference< XAggregation >* >(NULL))))
|
|
|
|
aReturn = OComponentHelper::queryInterface(rType);
|
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|