diff options
author | Frank Schönheit <fs@openoffice.org> | 2002-01-18 15:35:28 +0000 |
---|---|---|
committer | Frank Schönheit <fs@openoffice.org> | 2002-01-18 15:35:28 +0000 |
commit | bf37f042c9d2d53abb75bc5ec8b245a231612477 (patch) | |
tree | 42214e98a299a3f00582b8dc14e07f73124b2a5e /connectivity/source/drivers | |
parent | 0684ab32a28c94e2a328b045c69eab1cb511ec64 (diff) |
#96445# massive re-arrangements regarding the ref-counts of the ADO system objects
Diffstat (limited to 'connectivity/source/drivers')
-rw-r--r-- | connectivity/source/drivers/ado/ACatalog.cxx | 11 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AColumn.cxx | 81 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AConnection.cxx | 79 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ADatabaseMetaData.cxx | 21 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx | 55 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ADriver.cxx | 34 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AGroup.cxx | 13 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AIndex.cxx | 13 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AKey.cxx | 12 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/APreparedStatement.cxx | 21 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AResultSet.cxx | 17 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AStatement.cxx | 64 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ATable.cxx | 58 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/Aolevariant.cxx | 64 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/Awrapado.cxx | 183 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/adoimp.cxx | 10 |
16 files changed, 426 insertions, 310 deletions
diff --git a/connectivity/source/drivers/ado/ACatalog.cxx b/connectivity/source/drivers/ado/ACatalog.cxx index 8e588be769ab..3ff74c10b03a 100644 --- a/connectivity/source/drivers/ado/ACatalog.cxx +++ b/connectivity/source/drivers/ado/ACatalog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ACatalog.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:15:37 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -95,6 +95,13 @@ OCatalog::OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon) : connectivity::sd { } // ----------------------------------------------------------------------------- +OCatalog::~OCatalog() +{ + if(m_aCatalog.IsValid()) + m_aCatalog.putref_ActiveConnection(NULL); + m_aCatalog.clear(); +} +// ----------------------------------------------------------------------------- void OCatalog::refreshTables() { TStringVector aVector; diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index ed1a7300e199..04c7616304be 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AColumn.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:15:37 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,16 +97,20 @@ void WpADOColumn::Create() IClassFactory2* pIUnknown = NULL; IUnknown *pOuter = NULL; HRESULT hr = -1; - _ADOColumn* pCommand; + + _ADOColumn* pColumn = NULL; hr = CoCreateInstance(ADOS::CLSID_ADOCOLUMN_25, NULL, CLSCTX_INPROC_SERVER, ADOS::IID_ADOCOLUMN_25, - (void**)&pCommand ); + (void**)&pColumn ); if( !FAILED( hr ) ) - operator=(pCommand); + { + operator=( pColumn ); + pColumn->Release( ); + } } // ------------------------------------------------------------------------- OAdoColumn::OAdoColumn(sal_Bool _bCase,OConnection* _pConnection,_ADOColumn* _pColumn) @@ -167,6 +171,8 @@ void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& r { if(m_aColumn.IsValid()) { + const sal_Char* pAdoPropertyName = NULL; + switch(nHandle) { case PROPERTY_ID_ISASCENDING: @@ -222,46 +228,27 @@ void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& r break; case PROPERTY_ID_ISROWVERSION: break; + case PROPERTY_ID_ISAUTOINCREMENT: - { - ADOProperties* pProps = m_aColumn.get_Properties(); - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Autoincrement")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - aProp.PutValue(getString(rValue)); - pProps->Release(); - } + pAdoPropertyName = "Autoincrement"; break; + case PROPERTY_ID_DESCRIPTION: - { - ADOProperties* pProps = m_aColumn.get_Properties(); - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Default")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - aProp.PutValue(getString(rValue)); - pProps->Release(); - } + pAdoPropertyName = "Default"; break; + case PROPERTY_ID_DEFAULTVALUE: - { - ADOProperties* pProps = m_aColumn.get_Properties(); - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - aProp.PutValue(getString(rValue)); - pProps->Release(); - } + pAdoPropertyName = "Description"; break; + case PROPERTY_ID_ISCURRENCY: m_aColumn.put_Type(adCurrency); break; } + + if ( pAdoPropertyName ) + OTools::putValue( m_aColumn.get_Properties(), ::rtl::OUString::createFromAscii( pAdoPropertyName ), getString( rValue ) ); + } OColumn_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); } @@ -286,25 +273,15 @@ void OAdoColumn::fillPropertyValues() m_IsCurrency = (m_aColumn.get_Type() == adCurrency); // fill some specific props { - ADOProperties* pProps = m_aColumn.get_Properties(); - if(pProps) + WpADOProperties aProps( m_aColumn.get_Properties() ); + + if ( aProps.IsValid() ) { - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Autoincrement")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - m_IsAutoIncrement = aProp.GetValue(); + m_IsAutoIncrement = OTools::getValue( aProps, ::rtl::OUString::createFromAscii( "Autoincrement" ) ); + + m_Description = OTools::getValue( aProps, ::rtl::OUString::createFromAscii( "Description" ) ); - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); - aProp = pProp; - if(pProp) - m_Description = (::rtl::OUString)aProp.GetValue(); - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Default")),&pProp); - aProp = pProp; - if(pProp) - m_DefaultValue = (::rtl::OUString)aProp.GetValue(); - pProps->Release(); + m_DefaultValue = OTools::getValue( aProps, ::rtl::OUString::createFromAscii( "Default" ) ); } } } diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index 2238aac16993..0f9b5b471081 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AConnection.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-08-30 13:20:59 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,9 @@ #ifndef _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_ #include "ado/APreparedStatement.hxx" #endif +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif #ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> #endif @@ -109,6 +112,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; //------------------------------------------------------------------------------ IMPLEMENT_SERVICE_INFO(OConnection,"com.sun.star.sdbcx.AConnection","com.sun.star.sdbc.Connection"); @@ -139,8 +143,6 @@ OConnection::OConnection(const ::rtl::OUString& url, const Sequence< PropertyVal if( !FAILED( hr ) ) { - pIUnknown->AddRef(); - ADOConnection *pCon = NULL; hr = pIUnknown->CreateInstanceLic( pOuter, NULL, @@ -150,11 +152,15 @@ OConnection::OConnection(const ::rtl::OUString& url, const Sequence< PropertyVal if( !FAILED( hr ) ) { - m_pAdoConnection = new WpADOConnection(pCon); - // Class Factory is no longer needed + OSL_ENSURE( pCon, "OConnection::OConnection: invalid ADO object!" ); + m_pAdoConnection = new WpADOConnection( pCon ); + // CreateInstanceLic returned an object which was already acquired + pCon->Release( ); } + + // Class Factory is no longer needed pIUnknown->Release(); } @@ -164,6 +170,7 @@ OConnection::OConnection(const ::rtl::OUString& url, const Sequence< PropertyVal OConnection::~OConnection() { delete m_pAdoConnection; + ModuleContext::ReleaseRef(); } //----------------------------------------------------------------------------- @@ -200,31 +207,13 @@ void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyV if(m_pAdoConnection->get_State() != adStateOpen) ::dbtools::throwFunctionSequenceException(*this); - ADOProperties* pProps=m_pAdoConnection->get_Properties(); - if(pProps) + WpADOProperties aProps = m_pAdoConnection->get_Properties(); + if(aProps.IsValid()) { - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Jet OLEDB:ODBC Parsing")),&pProp); - { - WpADOProperty aProp(pProp); - if(pProp) - { - aProp.PutValue(OLEVariant(sal_True)); - OLEVariant aVar = aProp.GetValue(); - } - } - pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Jet OLEDB:Engine Type")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - { - OLEVariant aVar = aProp.GetValue(); - if(!aVar.isNull() && !aVar.isEmpty()) - m_nEngineType = aVar; - } - - pProps->Release(); + OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True); + OLEVariant aVar(OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:Engine Type")))); + if(!aVar.isNull() && !aVar.isEmpty()) + m_nEngineType = aVar; } buildTypeInfo(); //bErg = TRUE; @@ -282,23 +271,15 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl:: ::rtl::OUString sql = _sql; - ADOProperties* pProps=m_pAdoConnection->get_Properties(); - if(pProps) + WpADOProperties aProps = m_pAdoConnection->get_Properties(); + if(aProps.IsValid()) { - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Jet OLEDB:ODBC Parsing")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - { - pProp->put_Value(OLEVariant(sal_True)); - WpADOCommand aCommand; - aCommand.Create(); - aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection); - aCommand.put_CommandText(sql); - sql = aCommand.get_CommandText(); - } - pProps->Release(); + OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True); + WpADOCommand aCommand; + aCommand.Create(); + aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection); + aCommand.put_CommandText(sql); + sql = aCommand.get_CommandText(); } return sql; @@ -391,7 +372,6 @@ void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQ ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - m_pAdoConnection->PutDefaultDatabase(catalog); ADOS::ThrowException(*m_pAdoConnection,*this); } @@ -401,7 +381,6 @@ void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQ ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - return m_pAdoConnection->GetDefaultDatabase(); } // -------------------------------------------------------------------------------- @@ -558,10 +537,6 @@ void OConnection::disposing() } m_aStatements.clear(); -// Reference< XComponent > xComp2(m_xCatalog.get(), UNO_QUERY); -// if(xComp2.is()) -// xComp2->dispose(); - m_bClosed = sal_True; m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>(); diff --git a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx index f2b90c4e767b..a13bd2d02512 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaData.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-09-17 14:09:15 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,7 +110,7 @@ ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) // ------------------------------------------------------------------------- sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); + connectivity::ado::WpADOProperties aProps(m_pADOConnection->get_Properties()); // ADOS::ThrowException(*m_pADOConnection,*this); OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection"); ADO_PROP(_aProperty); @@ -123,7 +123,7 @@ sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) // ------------------------------------------------------------------------- sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); + connectivity::ado::WpADOProperties aProps(m_pADOConnection->get_Properties()); ADOS::ThrowException(*m_pADOConnection,*this); OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection"); ADO_PROP(_aProperty); @@ -132,7 +132,7 @@ sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) // ------------------------------------------------------------------------- ::rtl::OUString ODatabaseMetaData::getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { - WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(m_pADOConnection->get_Properties()); + connectivity::ado::WpADOProperties aProps(m_pADOConnection->get_Properties()); ADOS::ThrowException(*m_pADOConnection,*this); OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection"); @@ -1094,17 +1094,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) // ------------------------------------------------------------------------- sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException) { -// ADOProperties* pProps = m_pADOConnection->get_Properties(); -// OSL_ENSURE(pProps,"There are no properties at the connection"); -// if(!pProps) -// return sal_False; -// pProps->AddRef(); -// ADO_PROP("Maximum Row Size"INCLUDESBLOB); -// sal_Bool bValue(sal_False); -// bValue = (!aVar.isNull() && !aVar.isEmpty() ? aVar.getBool() : sal_False); -// pProps->Release(); -// return bValue; - return sal_True; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx index ac6170da4129..0d76e68d2f90 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaDataImpl.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-11-15 10:50:24 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -465,16 +465,20 @@ void WpADOIndex::Create() IClassFactory2* pIUnknown = NULL; IUnknown *pOuter = NULL; HRESULT hr = -1; - _ADOIndex* pCommand; + + _ADOIndex* pIndex = NULL; hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25, NULL, CLSCTX_INPROC_SERVER, ADOS::IID_ADOINDEX_25, - (void**)&pCommand ); + (void**)&pIndex ); if( !FAILED( hr ) ) - operator=(pCommand); + { + operator=( pIndex ); + pIndex->Release(); + } } // ------------------------------------------------------------------------- void OAdoIndex::fillPropertyValues() @@ -493,16 +497,19 @@ void WpADOKey::Create() IClassFactory2* pIUnknown = NULL; IUnknown *pOuter = NULL; HRESULT hr = -1; - _ADOKey* pCommand; + _ADOKey* pKey = NULL; hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25, NULL, CLSCTX_INPROC_SERVER, ADOS::IID_ADOKEY_25, - (void**)&pCommand ); + (void**)&pKey ); if( !FAILED( hr ) ) - operator=(pCommand); + { + operator=( pKey ); + pKey->Release(); + } } // ------------------------------------------------------------------------- void OAdoKey::fillPropertyValues() @@ -600,16 +607,19 @@ void WpADOTable::Create() IClassFactory2* pIUnknown = NULL; IUnknown *pOuter = NULL; HRESULT hr = -1; - _ADOTable* pCommand; + _ADOTable* pTable = NULL; hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25, NULL, CLSCTX_INPROC_SERVER, ADOS::IID_ADOTABLE_25, - (void**)&pCommand ); + (void**)&pTable ); if( !FAILED( hr ) ) - operator=(pCommand); + { + operator=( pTable ); + pTable->Release(); + } } // ------------------------------------------------------------------------- ::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum) @@ -634,17 +644,9 @@ void OAdoTable::fillPropertyValues() m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable); } { - ADOProperties* pProps = m_aTable.get_Properties(); - if(pProps) - { - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - m_Description = aProp.GetValue(); - pProps->Release(); - } + WpADOProperties aProps = m_aTable.get_Properties(); + if(aProps.IsValid()) + m_Description = OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description"))); } } } @@ -654,16 +656,19 @@ void WpADOUser::Create() IClassFactory2* pIUnknown = NULL; IUnknown *pOuter = NULL; HRESULT hr = -1; - _ADOUser* pCommand; + _ADOUser* pUser = NULL; hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25, NULL, CLSCTX_INPROC_SERVER, ADOS::IID_ADOUSER_25, - (void**)&pCommand ); + (void**)&pUser ); if( !FAILED( hr ) ) - operator=(pCommand); + { + operator=( pUser ); + pUser->Release(); + } } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx index f82a1d580f97..dbda06ee8351 100644 --- a/connectivity/source/drivers/ado/ADriver.cxx +++ b/connectivity/source/drivers/ado/ADriver.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADriver.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-09-28 07:00:09 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,18 +65,18 @@ #ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_ #include "ado/AConnection.hxx" #endif -//#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ -//#include "ado/Awrapadox.hxx" -//#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ +#include "ado/Awrapadox.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif #ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ #include "ado/Awrapado.hxx" #endif #ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_ #include "ado/adoimp.hxx" #endif -#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ -#include "ado/ACatalog.hxx" -#endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> #endif @@ -218,6 +218,7 @@ Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( co } } + Reference< XTablesSupplier > xTab = NULL; if(pConnection) { @@ -239,23 +240,6 @@ Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::r } // ----------------------------------------------------------------------------- -void OLEVariant::ChangeType(VARTYPE vartype, const OLEVariant* pSrc) -{ - // - // If pDest is NULL, convert type in place - // - if (pSrc == NULL) - pSrc = this; - - if ((this != pSrc) || (vartype != V_VT(this))) - { - if(FAILED(::VariantChangeType(static_cast<VARIANT*>(this), - const_cast<VARIANT*>(static_cast<const VARIANT*>(pSrc)), - 0, vartype))) - throw ::com::sun::star::sdbc::SQLException(::rtl::OUString::createFromAscii("Could not convert type!"),NULL,::rtl::OUString(),1000,::com::sun::star::uno::Any()); - } -} -// ----------------------------------------------------------------------------- void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) { ADOErrors *pErrors = NULL; diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx index 9b52a99af406..64b9e38efe3a 100644 --- a/connectivity/source/drivers/ado/AGroup.cxx +++ b/connectivity/source/drivers/ado/AGroup.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AGroup.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:05:38 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,16 +98,19 @@ void WpADOGroup::Create() IClassFactory2* pIUnknown = NULL; IUnknown *pOuter = NULL; HRESULT hr = -1; - ADOGroup* pCommand; + ADOGroup* pGroup = NULL; hr = CoCreateInstance(ADOS::CLSID_ADOGROUP_25, NULL, CLSCTX_INPROC_SERVER, ADOS::IID_ADOGROUP_25, - (void**)&pCommand ); + (void**)&pGroup ); if( !FAILED( hr ) ) - operator=(pCommand); + { + operator=( pGroup ); + pGroup->Release(); + } } // ------------------------------------------------------------------------- OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent) diff --git a/connectivity/source/drivers/ado/AIndex.cxx b/connectivity/source/drivers/ado/AIndex.cxx index 19ac91e3af10..c38804fee6c6 100644 --- a/connectivity/source/drivers/ado/AIndex.cxx +++ b/connectivity/source/drivers/ado/AIndex.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AIndex.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:05:38 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -119,8 +119,13 @@ void OAdoIndex::refreshColumns() { TStringVector aVector; - WpADOColumns aColumns = m_aIndex.get_Columns(); - aColumns.fillElementNames(aVector); + WpADOColumns aColumns; + if ( m_aIndex.IsValid() ) + { + aColumns = m_aIndex.get_Columns(); + aColumns.fillElementNames(aVector); + } + if(m_pColumns) m_pColumns->reFill(aVector); else diff --git a/connectivity/source/drivers/ado/AKey.cxx b/connectivity/source/drivers/ado/AKey.cxx index 5ab0937b97c9..8c9c6afe4c14 100644 --- a/connectivity/source/drivers/ado/AKey.cxx +++ b/connectivity/source/drivers/ado/AKey.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AKey.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:05:38 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,8 +110,12 @@ void OAdoKey::refreshColumns() { TStringVector aVector; - WpADOColumns aColumns = m_aKey.get_Columns(); - aColumns.fillElementNames(aVector); + WpADOColumns aColumns; + if ( m_aKey.IsValid() ) + { + aColumns = m_aKey.get_Columns(); + aColumns.fillElementNames(aVector); + } if(m_pColumns) m_pColumns->reFill(aVector); diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx index bf111a3e13e3..e86d318368e1 100644 --- a/connectivity/source/drivers/ado/APreparedStatement.cxx +++ b/connectivity/source/drivers/ado/APreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: APreparedStatement.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-12-11 09:10:12 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -137,6 +137,18 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OTypeInf osl_decrementInterlockedCount( &m_refCount ); } + +// ------------------------------------------------------------------------- +OPreparedStatement::~OPreparedStatement() +{ + if (m_pParameters) + { + OSL_ENSURE( sal_False, "OPreparedStatement::~OPreparedStatement: not disposed!" ); + m_pParameters->Release(); + m_pParameters = NULL; + } +} + // ------------------------------------------------------------------------- Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) @@ -170,8 +182,11 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) thr void OPreparedStatement::disposing() { m_xMetaData = NULL; - if(m_pParameters) + if (m_pParameters) + { m_pParameters->Release(); + m_pParameters = NULL; + } OStatement_Base::disposing(); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index e0cd49e43f59..475a01a51c7d 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AResultSet.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:05:38 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -177,9 +177,13 @@ OResultSet::OResultSet(ADORecordset* _pRecordSet) : OResultSet_BASE(m_aMutex) void OResultSet::construct() { osl_incrementInterlockedCount( &m_refCount ); - OSL_ENSURE(m_pRecordSet,"No RecordSet !"); - if(!m_pRecordSet) - ::dbtools::throwFunctionSequenceException(*this); + if (!m_pRecordSet) + { + OSL_ENSURE( sal_False, "OResultSet::construct: no RecordSet!" ); + Reference< XInterface > xInt( *this ); + osl_decrementInterlockedCount( &m_refCount ); + ::dbtools::throwFunctionSequenceException( xInt ); + } m_pRecordSet->AddRef(); VARIANT_BOOL bIsAtBOF; CHECK_RETURN(m_pRecordSet->get_BOF(&bIsAtBOF)) @@ -925,7 +929,8 @@ sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw(SQLException, Runtim ADOProperties* pProps = NULL; m_pRecordSet->get_Properties(&pProps); - WpOLEAppendCollection<ADOProperties, ADOProperty, WpADOProperty> aProps(pProps); + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this); OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection"); diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx index d2202a3bc265..26022e3a0022 100644 --- a/connectivity/source/drivers/ado/AStatement.cxx +++ b/connectivity/source/drivers/ado/AStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AStatement.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: fs $ $Date: 2001-12-10 14:36:23 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -159,7 +159,12 @@ void OStatement_Base::disposing() disposeResultSet(); + if ( m_Command.IsValid() ) + m_Command.putref_ActiveConnection( NULL ); m_Command.clear(); + + if ( m_RecordSet.IsValid() ) + m_RecordSet.PutRefDataSource( NULL ); m_RecordSet.clear(); if (m_pConnection) @@ -228,21 +233,6 @@ void OStatement_Base::reset() throw (SQLException) if (m_xResultSet.get().is()) clearMyResultSet(); - else - { - if(0) - { - m_Command.clear(); - m_Command.Create(); - if(m_Command.IsValid()) - m_Command.putref_ActiveConnection(m_pConnection->getConnection()); - else - ADOS::ThrowException(*m_pConnection->getConnection(),*this); - - m_RecordsAffected.setNoArg(); - m_Parameters.setNoArg(); - } - } } //-------------------------------------------------------------------- // clearMyResultSet @@ -309,6 +299,18 @@ void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException) m_aLastWarning = ex; } // ------------------------------------------------------------------------- +void OStatement_Base::assignRecordSet( ADORecordset* _pRS ) +{ + WpADORecordset aOldRS( m_RecordSet ); + m_RecordSet = WpADORecordset( _pRS ); + + if ( aOldRS.IsValid() ) + aOldRS.PutRefDataSource( NULL ); + + if ( m_RecordSet.IsValid() ) + m_RecordSet.PutRefDataSource( (IDispatch*)&m_Command ); +} +// ------------------------------------------------------------------------- sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -319,13 +321,16 @@ sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(S reset(); - try { + try + { ADORecordset* pSet = NULL; CHECK_RETURN(m_Command.put_CommandText(sql)) CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet)) - m_RecordSet = WpADORecordset(pSet); + + assignRecordSet( pSet ); } - catch (SQLWarning& ex) { + catch (SQLWarning& ex) + { // Save pointer to warning and save with ResultSet // object once it is created. @@ -411,15 +416,19 @@ Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen) aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";"); - ADORecordset* pSet=NULL; + + if ( m_RecordSet.IsValid() ) + m_RecordSet.PutRefDataSource( NULL ); m_RecordSet.clear(); m_RecordSet.Create(); CHECK_RETURN(m_Command.put_CommandText(aBatchSql)) - m_RecordSet.PutRefDataSource((IDispatch*)&m_Command); + if ( m_RecordSet.IsValid() ) + m_RecordSet.PutRefDataSource((IDispatch*)&m_Command); CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll)) + ADORecordset* pSet=NULL; Sequence< sal_Int32 > aRet(nLen); sal_Int32* pArray = aRet.getArray(); for(sal_Int32 j=0;j<nLen;++j) @@ -428,7 +437,8 @@ Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, OLEVariant aRecordsAffected; if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) { - m_RecordSet = WpADORecordset(pSet); + assignRecordSet( pSet ); + sal_Int32 nValue; if(m_RecordSet.get_RecordCount(nValue)) pArray[j] = nValue; @@ -503,13 +513,15 @@ sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, Runtim // Call SQLMoreResults - try { + try + { ADORecordset* pSet=NULL; OLEVariant aRecordsAffected; if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) - m_RecordSet = WpADORecordset(pSet); + assignRecordSet( pSet ); } - catch (SQLWarning &ex) { + catch (SQLWarning &ex) + { // Save pointer to warning and save with ResultSet // object once it is created. diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx index 8dc2aa3c2222..d6aba60552f0 100644 --- a/connectivity/source/drivers/ado/ATable.cxx +++ b/connectivity/source/drivers/ado/ATable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ATable.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-11-09 07:05:38 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -146,8 +146,12 @@ void OAdoTable::refreshColumns() { TStringVector aVector; - WpADOColumns aColumns = m_aTable.get_Columns(); - aColumns.fillElementNames(aVector); + WpADOColumns aColumns; + if ( m_aTable.IsValid() ) + { + aColumns = m_aTable.get_Columns(); + aColumns.fillElementNames(aVector); + } if(m_pColumns) m_pColumns->reFill(aVector); @@ -159,8 +163,12 @@ void OAdoTable::refreshKeys() { TStringVector aVector; - WpADOKeys aKeys = m_aTable.get_Keys(); - aKeys.fillElementNames(aVector); + WpADOKeys aKeys; + if(m_aTable.IsValid()) + { + aKeys = m_aTable.get_Keys(); + aKeys.fillElementNames(aVector); + } if(m_pKeys) m_pKeys->reFill(aVector); @@ -172,8 +180,12 @@ void OAdoTable::refreshIndexes() { TStringVector aVector; - WpADOIndexes aIndexes = m_aTable.get_Indexes(); - aIndexes.fillElementNames(aVector); + WpADOIndexes aIndexes; + if(m_aTable.IsValid()) + { + aIndexes = m_aTable.get_Indexes(); + aIndexes.fillElementNames(aVector); + } if(m_pIndexes) m_pIndexes->reFill(aVector); @@ -260,32 +272,22 @@ void OAdoTable::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rV case PROPERTY_ID_NAME: m_aTable.put_Name(getString(rValue)); break; + case PROPERTY_ID_TYPE: - { - ADOProperties* pProps = m_aTable.get_Properties(); - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - aProp.PutValue(getString(rValue)); - pProps->Release(); - } + OTools::putValue( m_aTable.get_Properties(), + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), + getString(rValue)); break; + case PROPERTY_ID_DESCRIPTION: - { - ADOProperties* pProps = m_aTable.get_Properties(); - pProps->AddRef(); - ADOProperty* pProp = NULL; - pProps->get_Item(OLEVariant(::rtl::OUString::createFromAscii("Description")),&pProp); - WpADOProperty aProp(pProp); - if(pProp) - aProp.PutValue(getString(rValue)); - pProps->Release(); - } + OTools::putValue( m_aTable.get_Properties(), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")), + getString(rValue)); break; + case PROPERTY_ID_SCHEMANAME: break; + default: throw Exception(); } diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index a3d1ee10c657..b7923f7f7dfa 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Aolevariant.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-10-08 06:07:58 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,6 +104,16 @@ OLEString& OLEString::operator=(const ::rtl::OUString& _rSrc) m_sStr = ::SysAllocString(_rSrc); return *this; } +OLEString& OLEString::operator=(const OLEString& _rSrc) +{ + if(this != &_rSrc) + { + if(m_sStr) + ::SysFreeString(m_sStr); + m_sStr = ::SysAllocString(_rSrc.m_sStr); + } + return *this; +} OLEString& OLEString::operator=(const BSTR& _rSrc) { if(m_sStr) @@ -195,8 +205,7 @@ OLEVariant::OLEVariant(const double &x) OLEVariant::OLEVariant(IDispatch* pDispInterface) { VariantInit(this); - vt = VT_DISPATCH; - pdispVal = pDispInterface; + setIDispatch( pDispInterface ); } OLEVariant::OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x) @@ -245,9 +254,6 @@ void OLEVariant::setBool(sal_Bool b) { VariantClear(this); vt = void OLEVariant::setString(const rtl::OUString& us){ VariantClear(this); vt = VT_BSTR; bstrVal = ::SysAllocString(us);} void OLEVariant::setNoArg() { VariantClear(this); vt = VT_ERROR; scode = DISP_E_PARAMNOTFOUND;} -void OLEVariant::setIDispatch(IDispatch* pDispInterface) - { VariantClear(this); vt = VT_DISPATCH; pdispVal = pDispInterface;} - void OLEVariant::setNull() { VariantClear(this); vt = VT_NULL;} void OLEVariant::setEmpty() { VariantClear(this); vt = VT_EMPTY;} @@ -257,6 +263,18 @@ void OLEVariant::setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr) void OLEVariant::setArray(SAFEARRAY* pSafeArray, VARTYPE vtType) { VariantClear(this); vt = VT_ARRAY|vtType; parray = pSafeArray; } +void OLEVariant::setIDispatch(IDispatch* pDispInterface) +{ + VariantClear(this); + + vt = VT_DISPATCH; + pdispVal = pDispInterface; + + if ( pDispInterface ) + pDispInterface->AddRef(); +} + + sal_Bool OLEVariant::isNull() const { return (vt == VT_NULL); } sal_Bool OLEVariant::isEmpty() const { return (vt == VT_EMPTY); } @@ -317,6 +335,36 @@ OLEVariant::operator rtl::OUString() const return V_BSTR(&varDest); } + +// ----------------------------------------------------------------------------- +void OLEVariant::ChangeType(VARTYPE vartype, const OLEVariant* pSrc) +{ + // + // If pDest is NULL, convert type in place + // + if (pSrc == NULL) + pSrc = this; + + if ( ( this != pSrc ) + || ( vartype != V_VT( this ) ) + ) + { + if ( FAILED( ::VariantChangeType( static_cast< VARIANT* >( this ), + const_cast< VARIANT* >( static_cast< const VARIANT* >( pSrc ) ), + 0, + vartype ) ) ) + { + throw ::com::sun::star::sdbc::SQLException( + ::rtl::OUString::createFromAscii( "Could not convert type!" ), + NULL, + ::rtl::OUString::createFromAscii( "S1000" ), + 1000, + ::com::sun::star::uno::Any() + ); + } + } +} + // ----------------------------------------------------------------------------- OLEVariant::operator ::com::sun::star::uno::Sequence< sal_Int8 >() const { @@ -376,7 +424,6 @@ IUnknown* OLEVariant::getIUnknown() const { if (V_VT(this) == VT_UNKNOWN) { - V_UNKNOWN(this)->AddRef(); return V_UNKNOWN(this); } if(isNull()) @@ -394,7 +441,6 @@ IDispatch* OLEVariant::getIDispatch() const { if (V_VT(this) == VT_DISPATCH) { - V_DISPATCH(this)->AddRef(); return V_DISPATCH(this); } diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx index 957169b73035..441133d86e2e 100644 --- a/connectivity/source/drivers/ado/Awrapado.cxx +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Awrapado.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: fs $ $Date: 2002-01-16 08:48:52 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:35:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,15 +92,17 @@ void WpADOCatalog::Create() if( !FAILED( hr ) ) - operator=(pCommand); + setWithOutAddRef(pCommand); } -ADOProperties* WpADOConnection::get_Properties() const +WpADOProperties WpADOConnection::get_Properties() const { ADOProperties* pProps=NULL; pInterface->get_Properties(&pProps); - return pProps; + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); + return aProps; } rtl::OUString WpADOConnection::GetConnectionString() const @@ -308,7 +310,10 @@ sal_Bool WpADOConnection::OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OL sal_Bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon) { OSL_ENSURE(pInterface,"Interface is null!"); - return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface)); + if(pCon) + return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface)); + else + return SUCCEEDED(pInterface->putref_ActiveConnection(NULL)); } void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn) @@ -330,7 +335,6 @@ void WpADOCommand::Create() if( !FAILED( hr ) ) { - pInterface2->AddRef(); ADOCommand* pCommand=NULL; hr = pInterface2->CreateInstanceLic( pOuter, @@ -340,7 +344,10 @@ void WpADOCommand::Create() (void**) &pCommand); if( !FAILED( hr ) ) + { operator=(pCommand); + pCommand->Release(); + } pInterface2->Release(); } @@ -499,12 +506,15 @@ sal_Bool WpADOCommand::Cancel() pInterface->get_NativeError(&nErrNr); return nErrNr; } - ADOProperties* WpADOField::get_Properties() +WpADOProperties WpADOField::get_Properties() { OSL_ENSURE(pInterface,"Interface is null!"); ADOProperties* pProps = NULL; pInterface->get_Properties(&pProps); - return pProps; + WpADOProperties aProps; + + aProps.setWithOutAddRef(pProps); + return aProps; } sal_Int32 WpADOField::GetActualSize() const @@ -671,23 +681,24 @@ OLEVariant WpADOField::GetUnderlyingValue() const return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); } - OLEVariant WpADOProperty::GetValue() const +OLEVariant WpADOProperty::GetValue() const { - OSL_ENSURE(pInterface,"Interface is null!"); OLEVariant aValVar; - pInterface->get_Value(&aValVar); + if(pInterface) + pInterface->get_Value(&aValVar); return aValVar; } - void WpADOProperty::GetValue(OLEVariant &aValVar) const +void WpADOProperty::GetValue(OLEVariant &aValVar) const { - OSL_ENSURE(pInterface,"Interface is null!"); - pInterface->get_Value(&aValVar); + OSL_ENSURE(pInterface,"Interface is null!"); + if(pInterface) + pInterface->get_Value(&aValVar); } - sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar) +sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar) { - OSL_ENSURE(pInterface,"Interface is null!"); + OSL_ENSURE(pInterface,"Interface is null!"); return (SUCCEEDED(pInterface->put_Value(aValVar))); } @@ -733,8 +744,6 @@ OLEVariant WpADOField::GetUnderlyingValue() const if( !FAILED( hr ) ) { - pInterface2->AddRef(); - ADORecordset *pRec = NULL; hr = pInterface2->CreateInstanceLic( pOuter, NULL, @@ -743,7 +752,10 @@ OLEVariant WpADOField::GetUnderlyingValue() const (void**) &pRec); if( !FAILED( hr ) ) + { operator=(pRec); + pRec->Release(); + } pInterface2->Release(); } @@ -847,12 +859,14 @@ CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVar } - ADOFields* WpADORecordset::GetFields() const +WpADOFields WpADORecordset::GetFields() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOFields* pFields=NULL; pInterface->get_Fields(&pFields); - return pFields; + WpADOFields aFields; + aFields.setWithOutAddRef(pFields); + return aFields; } @@ -902,12 +916,14 @@ CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVar return SUCCEEDED(pInterface->CancelUpdate()); } - ADOProperties* WpADORecordset::get_Properties() const +WpADOProperties WpADORecordset::get_Properties() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOProperties* pProps=NULL; pInterface->get_Properties(&pProps); - return pProps; + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); + return aProps; } sal_Bool WpADORecordset::NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset) @@ -1142,12 +1158,15 @@ sal_Bool WpADOColumn::put_Attributes(const ColumnAttributesEnum& _eNum) return SUCCEEDED(pInterface->put_Attributes(_eNum)); } -ADOProperties* WpADOColumn::get_Properties() const +WpADOProperties WpADOColumn::get_Properties() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOProperties* pProps = NULL; pInterface->get_Properties(&pProps); - return pProps; + WpADOProperties aProps; + + aProps.setWithOutAddRef(pProps); + return aProps; } ::rtl::OUString WpADOKey::get_Name() const @@ -1224,12 +1243,14 @@ void WpADOKey::put_UpdateRule(const RuleEnum& _eNum) pInterface->put_UpdateRule(_eNum); } -ADOColumns* WpADOKey::get_Columns() const +WpADOColumns WpADOKey::get_Columns() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOColumns* pCols = NULL; pInterface->get_Columns(&pCols); - return pCols; + WpADOColumns aCols; + aCols.setWithOutAddRef(pCols); + return aCols; } ::rtl::OUString WpADOIndex::get_Name() const @@ -1290,12 +1311,14 @@ void WpADOIndex::put_PrimaryKey(sal_Bool _b) pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE); } -ADOColumns* WpADOIndex::get_Columns() const +WpADOColumns WpADOIndex::get_Columns() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOColumns* pCols = NULL; pInterface->get_Columns(&pCols); - return pCols; + WpADOColumns aCols; + aCols.setWithOutAddRef(pCols); + return aCols; } void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon) @@ -1304,36 +1327,44 @@ void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon) pInterface->putref_ActiveConnection(pCon); } -ADOTables* WpADOCatalog::get_Tables() +WpADOTables WpADOCatalog::get_Tables() { OSL_ENSURE(pInterface,"Interface is null!"); ADOTables* pRet = NULL; pInterface->get_Tables(&pRet); - return pRet; + WpADOTables aRet; + aRet.setWithOutAddRef(pRet); + return aRet; } -ADOViews* WpADOCatalog::get_Views() +WpADOViews WpADOCatalog::get_Views() { OSL_ENSURE(pInterface,"Interface is null!"); ADOViews* pRet = NULL; pInterface->get_Views(&pRet); - return pRet; + WpADOViews aRet; + aRet.setWithOutAddRef(pRet); + return aRet; } -ADOGroups* WpADOCatalog::get_Groups() +WpADOGroups WpADOCatalog::get_Groups() { OSL_ENSURE(pInterface,"Interface is null!"); ADOGroups* pRet = NULL; pInterface->get_Groups(&pRet); - return pRet; + WpADOGroups aRet; + aRet.setWithOutAddRef(pRet); + return aRet; } -ADOUsers* WpADOCatalog::get_Users() +WpADOUsers WpADOCatalog::get_Users() { OSL_ENSURE(pInterface,"Interface is null!"); ADOUsers* pRet = NULL; pInterface->get_Users(&pRet); - return pRet; + WpADOUsers aRet; + aRet.setWithOutAddRef(pRet); + return aRet; } ADOProcedures* WpADOCatalog::get_Procedures() @@ -1368,28 +1399,34 @@ void WpADOTable::put_Name(const ::rtl::OUString& _rName) return aBSTR; } -ADOColumns* WpADOTable::get_Columns() const +WpADOColumns WpADOTable::get_Columns() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOColumns* pCols = NULL; pInterface->get_Columns(&pCols); - return pCols; + WpADOColumns aCols; + aCols.setWithOutAddRef(pCols); + return aCols; } -ADOIndexes* WpADOTable::get_Indexes() const +WpADOIndexes WpADOTable::get_Indexes() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOIndexes* pCols = NULL; pInterface->get_Indexes(&pCols); - return pCols; + WpADOIndexes aRet; + aRet.setWithOutAddRef(pCols); + return aRet; } -ADOKeys* WpADOTable::get_Keys() const +WpADOKeys WpADOTable::get_Keys() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOKeys* pCols = NULL; pInterface->get_Keys(&pCols); - return pCols; + WpADOKeys aRet; + aRet.setWithOutAddRef(pCols); + return aRet; } WpADOCatalog WpADOTable::get_ParentCatalog() const @@ -1397,15 +1434,19 @@ WpADOCatalog WpADOTable::get_ParentCatalog() const OSL_ENSURE(pInterface,"Interface is null!"); ADOCatalog* pCat = NULL; pInterface->get_ParentCatalog(&pCat); - return WpADOCatalog(pCat); + WpADOCatalog aRet; + aRet.setWithOutAddRef(pCat); + return aRet; } -ADOProperties* WpADOTable::get_Properties() const +WpADOProperties WpADOTable::get_Properties() const { OSL_ENSURE(pInterface,"Interface is null!"); ADOProperties* pProps = NULL; pInterface->get_Properties(&pProps); - return pProps; + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); + return aProps; } ::rtl::OUString WpADOView::get_Name() const @@ -1463,11 +1504,13 @@ sal_Bool WpADOGroup::SetPermissions( return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); } -ADOUsers* WpADOGroup::get_Users( ) +WpADOUsers WpADOGroup::get_Users( ) { ADOUsers* pRet = NULL; pInterface->get_Users( &pRet); - return pRet; + WpADOUsers aRet; + aRet.setWithOutAddRef(pRet); + return aRet; } ::rtl::OUString WpADOUser::get_Name() const @@ -1492,11 +1535,13 @@ sal_Bool WpADOUser::ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUS return bErg; } -ADOGroups* WpADOUser::get_Groups() +WpADOGroups WpADOUser::get_Groups() { ADOGroups* pRet = NULL; pInterface->get_Groups(&pRet); - return pRet; + WpADOGroups aRet; + aRet.setWithOutAddRef(pRet); + return aRet; } RightsEnum WpADOUser::GetPermissions( @@ -1528,7 +1573,10 @@ WpBase::WpBase(IDispatch* pInt) :pIUnknown(pInt) { if (pIUnknown) - pIUnknown->AddRef(); + { + ULONG nCount = pIUnknown->AddRef(); + // OSL_ENSURE(nCount == 1,"Count is greater than 1"); + } } //inline @@ -2113,6 +2161,39 @@ ADORecordset* WpADOConnection::getTypeInfo( ) return pRec; } +// ----------------------------------------------------------------------------- +void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OSL_ENSURE(SUCCEEDED(pInterface->put_ParentCatalog(ppvObject)),"Could not set ParentCatalog!"); +} +// ----------------------------------------------------------------------------- +void WpADOTable::putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OSL_ENSURE(SUCCEEDED(pInterface->putref_ParentCatalog(ppvObject)),"Could not set ParentCatalog!"); +} +// ----------------------------------------------------------------------------- +void WpBase::setIDispatch(IDispatch* _pIUnknown) +{ + pIUnknown = _pIUnknown; +} +// ----------------------------------------------------------------------------- +void OTools::putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar) +{ + OSL_ENSURE(_rProps.IsValid(),"Properties are not valid!"); + WpADOProperty aProp(_rProps.GetItem(_aPosition)); + if(aProp.IsValid()) + aProp.PutValue(_aValVar); +} +// ----------------------------------------------------------------------------- +OLEVariant OTools::getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition) +{ + WpADOProperty aProp(_rProps.GetItem(_aPosition)); + return aProp.GetValue(); +} +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx index fe657345a04a..949cde6bc326 100644 --- a/connectivity/source/drivers/ado/adoimp.cxx +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: adoimp.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-08-30 13:20:58 $ + * last change: $Author: fs $ $Date: 2002-01-18 16:33:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,6 +125,12 @@ const IID ADOS::IID_ADOUSER_25 = MYADOID(0x00000619); const CLSID ADOS::CLSID_ADOVIEW_25 = MYADOID(0x00000612); const IID ADOS::IID_ADOVIEW_25 = MYADOID(0x00000613); +OLEString& ADOS::GetKeyStr() +{ + static OLEString sKeyStr(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gxwaezucfyqpwjgqbcmtsncuhwsnyhiohwxz"))); + return sKeyStr; +} + // ------------------------------------------------------------------------- sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType) { |