diff options
Diffstat (limited to 'connectivity/source/drivers/ado')
39 files changed, 13592 insertions, 0 deletions
diff --git a/connectivity/source/drivers/ado/ACallableStatement.cxx b/connectivity/source/drivers/ado/ACallableStatement.cxx new file mode 100644 index 000000000000..f4739f3ab3ea --- /dev/null +++ b/connectivity/source/drivers/ado/ACallableStatement.cxx @@ -0,0 +1,235 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ACallableStatement.hxx" +#include <connectivity/dbexception.hxx> + +using namespace connectivity::ado; +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::container; +using namespace com::sun::star::lang; + +IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement"); + +#define GET_PARAM() \ + ADOParameter* pParam = NULL; \ + m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam); \ + if(pParam) \ + pParam->get_Value(&m_aValue); +//************************************************************** +//************ Class: java.sql.CallableStatement +//************************************************************** +OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql ) + : OPreparedStatement( _pConnection, _TypeInfo, sql ) +{ + m_Command.put_CommandType(adCmdStoredProc); +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPreparedStatement::queryInterface(rType); + return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this)); +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException) +{ + return m_aValue.isNull(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- +double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return (sal_Int64)m_aValue.getCurrency().int64; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this ); + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + + ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + + ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + GET_PARAM() + return m_aValue; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException) +{ + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam); + if(pParam) + { + pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType())); + pParam->put_Direction(adParamOutput); + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam); + if(pParam) + { + pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType())); + pParam->put_Direction(adParamOutput); + pParam->put_NumericScale((sal_Int8)scale); + } +} +// ------------------------------------------------------------------------- + + +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this ); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this ); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this ); + return NULL; +} +// ------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +void SAL_CALL OCallableStatement::acquire() throw() +{ + OPreparedStatement::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OCallableStatement::release() throw() +{ + OPreparedStatement::release(); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ACatalog.cxx b/connectivity/source/drivers/ado/ACatalog.cxx new file mode 100644 index 000000000000..4db595636eb4 --- /dev/null +++ b/connectivity/source/drivers/ado/ACatalog.cxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ACatalog.hxx" +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#include "ado/AGroups.hxx" +#include "ado/AUsers.hxx" +#include "ado/ATables.hxx" +#include "ado/AViews.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> + + +// ------------------------------------------------------------------------- +using namespace connectivity; +using namespace connectivity::ado; +// ------------------------------------------------------------------------- +OCatalog::OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) + ,m_pConnection(_pCon) + ,m_aCatalog(_pCatalog) +{ +} +// ----------------------------------------------------------------------------- +OCatalog::~OCatalog() +{ + if(m_aCatalog.IsValid()) + m_aCatalog.putref_ActiveConnection(NULL); + m_aCatalog.clear(); +} +// ----------------------------------------------------------------------------- +void OCatalog::refreshTables() +{ + TStringVector aVector; + + WpADOTables aTables(m_aCatalog.get_Tables()); + if ( aTables.IsValid() ) + { + aTables.Refresh(); + sal_Int32 nCount = aTables.GetItemCount(); + aVector.reserve(nCount); + for(sal_Int32 i=0;i< nCount;++i) + { + WpADOTable aElement = aTables.GetItem(i); + if ( aElement.IsValid() ) + { + ::rtl::OUString sTypeName = aElement.get_Type(); + if ( !sTypeName.equalsIgnoreAsciiCaseAscii("SYSTEM TABLE") && !sTypeName.equalsIgnoreAsciiCaseAscii("ACCESS TABLE") ) + aVector.push_back(aElement.get_Name()); + } + } + } + + if(m_pTables) + m_pTables->reFill(aVector); + else + m_pTables = new OTables(this,m_aMutex,aVector,aTables,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshViews() +{ + TStringVector aVector; + + WpADOViews aViews = m_aCatalog.get_Views(); + aViews.fillElementNames(aVector); + + if(m_pViews) + m_pViews->reFill(aVector); + else + m_pViews = new OViews(this,m_aMutex,aVector,aViews,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshGroups() +{ + TStringVector aVector; + + WpADOGroups aGroups = m_aCatalog.get_Groups(); + aGroups.fillElementNames(aVector); + + if(m_pGroups) + m_pGroups->reFill(aVector); + else + m_pGroups = new OGroups(this,m_aMutex,aVector,aGroups,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- +void OCatalog::refreshUsers() +{ + TStringVector aVector; + + WpADOUsers aUsers = m_aCatalog.get_Users(); + aUsers.fillElementNames(aVector); + + if(m_pUsers) + m_pUsers->reFill(aVector); + else + m_pUsers = new OUsers(this,m_aMutex,aVector,aUsers,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx new file mode 100644 index 000000000000..aa287c185b26 --- /dev/null +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -0,0 +1,300 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AColumn.hxx" +#include "ado/AConnection.hxx" +#include "ado/Awrapado.hxx" +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <comphelper/extract.hxx> +#include <comphelper/types.hxx> +#include "ado/ACatalog.hxx" + +using namespace ::comphelper; + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +void WpADOColumn::Create() +{ + HRESULT hr = -1; + + _ADOColumn* pColumn = NULL; + hr = CoCreateInstance(ADOS::CLSID_ADOCOLUMN_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOCOLUMN_25, + (void**)&pColumn ); + + + if( !FAILED( hr ) ) + { + operator=( pColumn ); + pColumn->Release( ); + } +} +// ------------------------------------------------------------------------- +OAdoColumn::OAdoColumn(sal_Bool _bCase,OConnection* _pConnection,_ADOColumn* _pColumn) + : connectivity::sdbcx::OColumn(::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),0,0,0,0,sal_False,sal_False,sal_False,_bCase) + ,m_pConnection(_pConnection) +{ + construct(); + OSL_ENSURE(_pColumn,"Column can not be null!"); + m_aColumn = WpADOColumn(_pColumn); + // m_aColumn.put_ParentCatalog(_pConnection->getAdoCatalog()->getCatalog()); + fillPropertyValues(); +} +// ------------------------------------------------------------------------- +OAdoColumn::OAdoColumn(sal_Bool _bCase,OConnection* _pConnection) + : connectivity::sdbcx::OColumn(_bCase) + ,m_pConnection(_pConnection) +{ + m_aColumn.Create(); + m_aColumn.put_ParentCatalog(_pConnection->getAdoCatalog()->getCatalog()); + construct(); + fillPropertyValues(); + m_Type = DataType::OTHER; +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoColumn::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoColumn::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OColumn_ADO::getSomething(rId); +} +// ------------------------------------------------------------------------- +void OAdoColumn::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY; + + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING), PROPERTY_ID_ISASCENDING, nAttrib,&m_IsAscending, ::getBooleanCppuType()); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN), PROPERTY_ID_RELATEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} +// ----------------------------------------------------------------------------- +void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aColumn.IsValid()) + { + const sal_Char* pAdoPropertyName = NULL; + + switch(nHandle) + { + case PROPERTY_ID_ISASCENDING: + m_aColumn.put_SortOrder(::cppu::any2bool(rValue) ? adSortAscending : adSortDescending); + break; + case PROPERTY_ID_RELATEDCOLUMN: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aColumn.put_RelatedColumn(aVal); + } + break; + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aColumn.put_Name(aVal); + } + break; + case PROPERTY_ID_TYPE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aColumn.put_Type(ADOS::MapJdbc2ADOType(nVal,m_pConnection->getEngineType())); + } + break; + case PROPERTY_ID_TYPENAME: + // rValue <<= m_pTable->getCatalog()->getConnection()->getTypeInfo()->find(); + break; + case PROPERTY_ID_PRECISION: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aColumn.put_Precision(nVal); + } + break; + case PROPERTY_ID_SCALE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aColumn.put_NumericScale((sal_Int8)nVal); + } + break; + case PROPERTY_ID_ISNULLABLE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + if ( nVal == ColumnValue::NULLABLE ) + m_aColumn.put_Attributes( adColNullable ); + } + break; + case PROPERTY_ID_ISROWVERSION: + break; + + case PROPERTY_ID_ISAUTOINCREMENT: + OTools::putValue( m_aColumn.get_Properties(), ::rtl::OUString::createFromAscii( "Autoincrement" ), getBOOL( rValue ) ); + break; + + case PROPERTY_ID_IM001: + case PROPERTY_ID_DESCRIPTION: + pAdoPropertyName = "Description"; + break; + + case PROPERTY_ID_DEFAULTVALUE: + pAdoPropertyName = "Default"; + break; + } + + if ( pAdoPropertyName ) + OTools::putValue( m_aColumn.get_Properties(), ::rtl::OUString::createFromAscii( pAdoPropertyName ), getString( rValue ) ); + } + OColumn_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); +} +// ----------------------------------------------------------------------------- +void OAdoColumn::fillPropertyValues() +{ + if(m_aColumn.IsValid()) + { + m_IsAscending = m_aColumn.get_SortOrder() == adSortAscending; + m_ReferencedColumn = m_aColumn.get_RelatedColumn(); + m_Name = m_aColumn.get_Name(); + m_Precision = m_aColumn.get_Precision(); + m_Scale = m_aColumn.get_NumericScale(); + m_IsNullable = ((m_aColumn.get_Attributes() & adColNullable) == adColNullable) ? ColumnValue::NULLABLE : ColumnValue::NO_NULLS; + + DataTypeEnum eType = m_aColumn.get_Type(); + m_IsCurrency = (eType == adCurrency); + m_Type = ADOS::MapADOType2Jdbc(eType); + + sal_Bool bForceTo = sal_True; + const OTypeInfoMap* pTypeInfoMap = m_pConnection->getTypeInfo(); + const OExtendedTypeInfo* pTypeInfo = OConnection::getTypeInfoFromType(*m_pConnection->getTypeInfo(),eType,::rtl::OUString(),m_Precision,m_Scale,bForceTo); + if ( pTypeInfo ) + m_TypeName = pTypeInfo->aSimpleType.aTypeName; + else if ( eType == adVarBinary && ADOS::isJetEngine(m_pConnection->getEngineType()) ) + { + ::comphelper::TStringMixEqualFunctor aCase(sal_False); + OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(), + pTypeInfoMap->end(), + ::std::compose1( + ::std::bind2nd(aCase, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VarBinary"))), + ::std::compose1( + ::std::mem_fun(&OExtendedTypeInfo::getDBName), + ::std::select2nd<OTypeInfoMap::value_type>()) + ) + + ); + + if ( aFind != pTypeInfoMap->end() ) // change column type if necessary + { + eType = aFind->first; + pTypeInfo = aFind->second; + } + + if ( !pTypeInfo ) + { + pTypeInfo = OConnection::getTypeInfoFromType(*m_pConnection->getTypeInfo(),adBinary,::rtl::OUString(),m_Precision,m_Scale,bForceTo); + eType = adBinary; + } + + if ( pTypeInfo ) + { + m_TypeName = pTypeInfo->aSimpleType.aTypeName; + m_Type = ADOS::MapADOType2Jdbc(eType); + } + } + + + // fill some specific props + { + WpADOProperties aProps( m_aColumn.get_Properties() ); + + if ( aProps.IsValid() ) + { + m_IsAutoIncrement = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Autoincrement")) ); + + m_Description = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")) ); + + m_DefaultValue = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Default")) ); + +#if OSL_DEBUG_LEVEL > 0 + sal_Int32 nCount = aProps.GetItemCount(); + for (sal_Int32 i = 0; i<nCount; ++i) + { + WpADOProperty aProp = aProps.GetItem(i); + ::rtl::OUString sName = aProp.GetName(); + ::rtl::OUString sVal = aProp.GetValue(); + } +#endif + } + } + } +} +// ----------------------------------------------------------------------------- +WpADOColumn OAdoColumn::getColumnImpl() const +{ + return m_aColumn; +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoColumn::acquire() throw() +{ + OColumn_ADO::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoColumn::release() throw() +{ + OColumn_ADO::release(); +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/ado/AColumns.cxx b/connectivity/source/drivers/ado/AColumns.cxx new file mode 100644 index 000000000000..60140e9be93e --- /dev/null +++ b/connectivity/source/drivers/ado/AColumns.cxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AColumns.hxx" +#include "ado/AColumn.hxx" +#include "ado/AConnection.hxx" +#include "ado/Awrapado.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <comphelper/property.hxx> +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#ifdef __MINGW32__ +#include <algorithm> +#endif +#include "resource/ado_res.hrc" + +using namespace connectivity::ado; +using namespace connectivity; +using namespace comphelper; +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::container; + +sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName) +{ + return new OAdoColumn(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName)); +} + +// ------------------------------------------------------------------------- +void OColumns::impl_refresh() throw(RuntimeException) +{ + m_aCollection.Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OColumns::createDescriptor() +{ + return new OAdoColumn(isCaseSensitive(),m_pConnection); +} +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OColumns::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor ) +{ + OAdoColumn* pColumn = NULL; + Reference< XPropertySet > xColumn; + if ( !getImplementation( pColumn, descriptor ) || pColumn == NULL ) + { + // m_pConnection->throwGenericSQLException( STR_INVALID_COLUMN_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + pColumn = new OAdoColumn(isCaseSensitive(),m_pConnection); + xColumn = pColumn; + ::comphelper::copyProperties(descriptor,xColumn); + } + + WpADOColumn aColumn = pColumn->getColumnImpl(); + +#if OSL_DEBUG_LEVEL > 0 + sal_Int32 nPrecision; + sal_Int32 nScale; + sal_Int32 nType; + nPrecision = aColumn.get_Precision(); + nScale = aColumn.get_NumericScale(); + nType = ADOS::MapADOType2Jdbc(aColumn.get_Type()); +#endif + + ::rtl::OUString sTypeName; + pColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sTypeName; + + const OTypeInfoMap* pTypeInfoMap = m_pConnection->getTypeInfo(); + ::comphelper::TStringMixEqualFunctor aCase(sal_False); + // search for typeinfo where the typename is equal sTypeName + OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(), + pTypeInfoMap->end(), + ::std::compose1( + ::std::bind2nd(aCase, sTypeName), + ::std::compose1( + ::std::mem_fun(&OExtendedTypeInfo::getDBName), + ::std::select2nd<OTypeInfoMap::value_type>()) + ) + + ); + + if ( aFind != pTypeInfoMap->end() ) // change column type if necessary + aColumn.put_Type(aFind->first); + + if ( SUCCEEDED(((ADOColumns*)m_aCollection)->Append(OLEVariant(aColumn.get_Name()),aColumn.get_Type(),aColumn.get_DefinedSize())) ) + { + WpADOColumn aAddedColumn = m_aCollection.GetItem(OLEVariant(aColumn.get_Name())); + if ( aAddedColumn.IsValid() ) + { + sal_Bool bAutoIncrement = sal_False; + pColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement; + if ( bAutoIncrement ) + OTools::putValue( aAddedColumn.get_Properties(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Autoincrement")), bAutoIncrement ); + + if ( aFind != pTypeInfoMap->end() && aColumn.get_Type() != aAddedColumn.get_Type() ) // change column type if necessary + aColumn.put_Type(aFind->first); + aAddedColumn.put_Precision(aColumn.get_Precision()); + aAddedColumn.put_NumericScale(aColumn.get_NumericScale()); + aAddedColumn.put_Attributes(aColumn.get_Attributes()); + aAddedColumn.put_SortOrder(aColumn.get_SortOrder()); + aAddedColumn.put_RelatedColumn(aColumn.get_RelatedColumn()); + } + } + ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this)); + + return new OAdoColumn(isCaseSensitive(),m_pConnection,pColumn->getColumnImpl()); +} +// ------------------------------------------------------------------------- +// XDrop +void OColumns::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + if(!m_aCollection.Delete(_sElementName)) + ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this)); +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx new file mode 100644 index 000000000000..a7e2ec4df490 --- /dev/null +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -0,0 +1,625 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AConnection.hxx" +#include "ado/ADatabaseMetaData.hxx" +#include "ado/ADriver.hxx" +#include "ado/AStatement.hxx" +#include "ado/ACallableStatement.hxx" +#include "ado/APreparedStatement.hxx" +#include "ado/ACatalog.hxx" +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/TransactionIsolation.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <cppuhelper/typeprovider.hxx> +#include "connectivity/dbexception.hxx" +#include <osl/file.hxx> +#include "resource/ado_res.hrc" + +using namespace dbtools; +using namespace connectivity::ado; +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"); +// -------------------------------------------------------------------------------- +OConnection::OConnection(ODriver* _pDriver) throw(SQLException, RuntimeException) + : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this), + m_bClosed(sal_False), + m_xCatalog(NULL), + m_pDriver(_pDriver), + m_pAdoConnection(NULL), + m_bAutocommit(sal_True), + m_nEngineType(0), + m_pCatalog(NULL) +{ + osl_incrementInterlockedCount( &m_refCount ); + + IClassFactory2* pIUnknown = NULL; + IUnknown *pOuter = NULL; + HRESULT hr; + hr = CoGetClassObject( ADOS::CLSID_ADOCONNECTION_21, + CLSCTX_INPROC_SERVER, + NULL, + IID_IClassFactory2, + (void**)&pIUnknown ); + + if( !FAILED( hr ) ) + { + ADOConnection *pCon = NULL; + hr = pIUnknown->CreateInstanceLic( pOuter, + NULL, + ADOS::IID_ADOCONNECTION_21, + ADOS::GetKeyStr(), + (void**) &pCon); + + if( !FAILED( hr ) ) + { + 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(); + } + + osl_decrementInterlockedCount( &m_refCount ); +} +//----------------------------------------------------------------------------- +OConnection::~OConnection() +{ +} +//----------------------------------------------------------------------------- +void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) +{ + osl_incrementInterlockedCount( &m_refCount ); + + setConnectionInfo(info); + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; + if ( aDSN.compareToAscii("access:",7) == 0 ) + aDSN = aDSN.copy(7); + + sal_Int32 nTimeout = 20; + sal_Bool bSilent = sal_True; + const PropertyValue *pIter = info.getConstArray(); + const PropertyValue *pEnd = pIter + info.getLength(); + for(;pIter != pEnd;++pIter) + { + if(!pIter->Name.compareToAscii("Timeout")) + pIter->Value >>= nTimeout; + else if(!pIter->Name.compareToAscii("Silent")) + pIter->Value >>= bSilent; + else if(!pIter->Name.compareToAscii("user")) + pIter->Value >>= aUID; + else if(!pIter->Name.compareToAscii("password")) + pIter->Value >>= aPWD; + } + try + { + if(m_pAdoConnection) + { + if(m_pAdoConnection->Open(aDSN,aUID,aPWD,adConnectUnspecified)) + m_pAdoConnection->PutCommandTimeout(nTimeout); + else + ADOS::ThrowException(*m_pAdoConnection,*this); + if(m_pAdoConnection->get_State() != adStateOpen) + throwGenericSQLException( STR_NO_CONNECTION,*this ); + + WpADOProperties aProps = m_pAdoConnection->get_Properties(); + if(aProps.IsValid()) + { + 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; + } + else + ::dbtools::throwFunctionSequenceException(*this); + + } + catch(const Exception ) + { + osl_decrementInterlockedCount( &m_refCount ); + throw; + } + osl_decrementInterlockedCount( &m_refCount ); +} +//----------------------------------------------------------------------------- +void SAL_CALL OConnection::release() throw() +{ + relase_ChildImpl(); +} +// -------------------------------------------------------------------------------- +Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + OStatement* pStmt = new OStatement(this); + Reference< XStatement > xStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return pStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql); + Reference< XPreparedStatement > xPStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return xPStmt; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + OCallableStatement* pStmt = new OCallableStatement(this,m_aTypeInfo,sql); + Reference< XPreparedStatement > xPStmt = pStmt; + m_aStatements.push_back(WeakReferenceHelper(*pStmt)); + return xPStmt; +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + ::rtl::OUString sql = _sql; + WpADOProperties aProps = m_pAdoConnection->get_Properties(); + if(aProps.IsValid()) + { + 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; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + m_bAutocommit = autoCommit; + if(!autoCommit) + m_pAdoConnection->BeginTrans(); + else + m_pAdoConnection->RollbackTrans(); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + return m_bAutocommit; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + m_pAdoConnection->CommitTrans(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + m_pAdoConnection->RollbackTrans(); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return OConnection_BASE::rBHelper.bDisposed && !m_pAdoConnection->get_State(); +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + Reference< XDatabaseMetaData > xMetaData = m_xMetaData; + if(!xMetaData.is()) + { + xMetaData = new ODatabaseMetaData(this); + m_xMetaData = xMetaData; + } + + return xMetaData; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + + m_pAdoConnection->put_Mode(readOnly ? adModeRead : adModeReadWrite); + ADOS::ThrowException(*m_pAdoConnection,*this); +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + return m_pAdoConnection->get_Mode() == adModeRead; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + m_pAdoConnection->PutDefaultDatabase(catalog); + ADOS::ThrowException(*m_pAdoConnection,*this); +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + return m_pAdoConnection->GetDefaultDatabase(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + IsolationLevelEnum eIso; + switch(level) + { + case TransactionIsolation::NONE: + eIso = adXactUnspecified; + break; + case TransactionIsolation::READ_UNCOMMITTED: + eIso = adXactReadUncommitted; + break; + case TransactionIsolation::READ_COMMITTED: + eIso = adXactReadCommitted; + break; + case TransactionIsolation::REPEATABLE_READ: + eIso = adXactRepeatableRead; + break; + case TransactionIsolation::SERIALIZABLE: + eIso = adXactSerializable; + break; + default: + OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level"); + return; + } + m_pAdoConnection->put_IsolationLevel(eIso); + ADOS::ThrowException(*m_pAdoConnection,*this); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + sal_Int32 nRet = 0; + switch(m_pAdoConnection->get_IsolationLevel()) + { + case adXactUnspecified: + nRet = TransactionIsolation::NONE; + break; + case adXactReadUncommitted: + nRet = TransactionIsolation::READ_UNCOMMITTED; + break; + case adXactReadCommitted: + nRet = TransactionIsolation::READ_COMMITTED; + break; + case adXactRepeatableRead: + nRet = TransactionIsolation::REPEATABLE_READ; + break; + case adXactSerializable: + nRet = TransactionIsolation::SERIALIZABLE; + break; + default: + OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level"); + } + ADOS::ThrowException(*m_pAdoConnection,*this); + return nRet; +} +// -------------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + + return NULL; +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this ); +} +// -------------------------------------------------------------------------------- +// XCloseable +void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OConnection_BASE::rBHelper.bDisposed); + + } + dispose(); +} +// -------------------------------------------------------------------------------- +// XWarningsSupplier +Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +//-------------------------------------------------------------------- +void OConnection::buildTypeInfo() throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ADORecordset *pRecordset = m_pAdoConnection->getTypeInfo(); + if ( pRecordset ) + { + pRecordset->AddRef(); + VARIANT_BOOL bIsAtBOF; + pRecordset->get_BOF(&bIsAtBOF); + + sal_Bool bOk = sal_True; + if ( bIsAtBOF == VARIANT_TRUE ) + bOk = SUCCEEDED(pRecordset->MoveNext()); + + if ( bOk ) + { + // HACK for access + static const ::rtl::OUString s_sVarChar(RTL_CONSTASCII_USTRINGPARAM("VarChar")); + do + { + sal_Int32 nPos = 1; + OExtendedTypeInfo* aInfo = new OExtendedTypeInfo(); + aInfo->aSimpleType.aTypeName = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->eType = (DataTypeEnum)(sal_Int32)ADOS::getField(pRecordset,nPos++).get_Value(); + if ( aInfo->eType == adWChar && aInfo->aSimpleType.aTypeName == s_sVarChar ) + aInfo->eType = adVarWChar; + aInfo->aSimpleType.nType = (sal_Int16)ADOS::MapADOType2Jdbc(static_cast<DataTypeEnum>(aInfo->eType)); + aInfo->aSimpleType.nPrecision = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.aLiteralPrefix = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.aLiteralSuffix = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.aCreateParams = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.bNullable = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.bCaseSensitive = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.nSearchType = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.bUnsigned = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.bCurrency = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.bAutoIncrement = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value(); + aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value(); + // Now that we have the type info, save it + // in the Hashtable if we don't already have an + // entry for this SQL type. + + m_aTypeInfo.insert(OTypeInfoMap::value_type(aInfo->eType,aInfo)); + } + while ( SUCCEEDED(pRecordset->MoveNext()) ); + } + pRecordset->Release(); + } +} +//------------------------------------------------------------------------------ +void OConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + OConnection_BASE::disposing(); + + m_bClosed = sal_True; + m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>(); + m_xCatalog = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>(); + m_pDriver = NULL; + + m_pAdoConnection->Close(); + + OTypeInfoMap::iterator aIter = m_aTypeInfo.begin(); + for (; aIter != m_aTypeInfo.end(); ++aIter) + delete aIter->second; + + m_aTypeInfo.clear(); + + delete m_pAdoConnection; + m_pAdoConnection = NULL; + + dispose_ChildImpl(); +} +// ----------------------------------------------------------------------------- +sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + reinterpret_cast< sal_Int64 >( this ) + : + OConnection_BASE::getSomething(rId); +} +// ----------------------------------------------------------------------------- +Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} +// ----------------------------------------------------------------------------- +const OExtendedTypeInfo* OConnection::getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo, + DataTypeEnum _nType, + const ::rtl::OUString& _sTypeName, + sal_Int32 _nPrecision, + sal_Int32 _nScale, + sal_Bool& _brForceToType) +{ + const OExtendedTypeInfo* pTypeInfo = NULL; + _brForceToType = sal_False; + // search for type + ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType); + OTypeInfoMap::const_iterator aIter = aPair.first; + if(aIter != _rTypeInfo.end()) // compare with end is correct here + { + for(;aIter != aPair.second;++aIter) + { + // search the best matching type + OExtendedTypeInfo* pInfo = aIter->second; + #ifdef DBG_UTIL + ::rtl::OUString sDBTypeName = pInfo->aSimpleType.aTypeName; + sal_Int32 nDBTypePrecision = pInfo->aSimpleType.nPrecision; (void)nDBTypePrecision; + sal_Int32 nDBTypeScale = pInfo->aSimpleType.nMaximumScale; (void)nDBTypeScale; + sal_Int32 nAdoType = pInfo->eType; (void)nAdoType; + #endif + if ( ( !_sTypeName.getLength() + || (pInfo->aSimpleType.aTypeName.equalsIgnoreAsciiCase(_sTypeName)) + ) + && (pInfo->aSimpleType.nPrecision >= _nPrecision) + && (pInfo->aSimpleType.nMaximumScale >= _nScale) + + ) + break; + } + + if (aIter == aPair.second) + { + for(aIter = aPair.first; aIter != aPair.second; ++aIter) + { + // search the best matching type (now comparing the local names) + if ( (aIter->second->aSimpleType.aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName)) + && (aIter->second->aSimpleType.nPrecision >= _nPrecision) + && (aIter->second->aSimpleType.nMaximumScale >= _nScale) + ) + { +// we can not assert here because we could be in d&d +/* + OSL_ENSURE(sal_False, + ( ::rtl::OString("getTypeInfoFromType: assuming column type ") + += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding()) + += ::rtl::OString("\" (expected type name ") + += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) + += ::rtl::OString(" matches the type's local name).")).getStr()); +*/ + break; + } + } + } + + if (aIter == aPair.second) + { // no match for the names, no match for the local names + // -> drop the precision and the scale restriction, accept any type with the property + // type id (nType) + + // we can not assert here because we could be in d&d + pTypeInfo = aPair.first->second; + _brForceToType = sal_True; + } + else + pTypeInfo = aIter->second; + } + else if ( _sTypeName.getLength() ) + { + ::comphelper::TStringMixEqualFunctor aCase(sal_False); + // search for typeinfo where the typename is equal _sTypeName + OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(), + _rTypeInfo.end(), + ::std::compose1( + ::std::bind2nd(aCase, _sTypeName), + ::std::compose1( + ::std::mem_fun(&OExtendedTypeInfo::getDBName), + ::std::select2nd<OTypeInfoMap::value_type>()) + ) + ); + if(aFind != _rTypeInfo.end()) + pTypeInfo = aFind->second; + } + +// we can not assert here because we could be in d&d +// OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!"); + return pTypeInfo; +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx new file mode 100644 index 000000000000..022295710595 --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx @@ -0,0 +1,1093 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ADatabaseMetaData.hxx" +#include "ado/ADatabaseMetaDataResultSet.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/TransactionIsolation.hpp> +#include "ado/AConnection.hxx" +#include "ado/adoimp.hxx" +#include "FDatabaseMetaDataResultSet.hxx" +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> + +using namespace ::comphelper; + +using namespace connectivity; +using namespace connectivity::ado; +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 connectivity; + +ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) + : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo()) + ,m_pADOConnection(_pCon->getConnection()) + ,m_pConnection(_pCon) +{ +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + 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); + sal_Int32 nValue(0); + if(!aVar.isNull() && !aVar.isEmpty()) + nValue = aVar; + return nValue; +} + +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + 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); + return (!aVar.isNull() && !aVar.isEmpty() ? aVar.getBool() : sal_False); +} +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + 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); + ::rtl::OUString aValue; + if(!aVar.isNull() && !aVar.isEmpty() && aVar.getType() == VT_BSTR) + aValue = aVar; + + return aValue; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( ) +{ + ADORecordset *pRecordset = m_pADOConnection->getTypeInfo(); + // ADOS::ThrowException(*m_pADOConnection,*this); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setTypeInfoMap(ADOS::isJetEngine(m_pConnection->getEngineType())); + Reference< XResultSet > xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) +{ + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + ADORecordset *pRecordset = NULL; + m_pADOConnection->OpenSchema(adSchemaCatalogs,vtEmpty,vtEmpty,&pRecordset); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCatalogsMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( ) +{ + return getLiteral(DBLITERAL_CATALOG_SEPARATOR); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) +{ + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + ADORecordset *pRecordset = NULL; + m_pADOConnection->OpenSchema(adSchemaSchemata,vtEmpty,vtEmpty,&pRecordset); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setSchemasMap(); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getColumnPrivileges(catalog,schema,table,columnNamePattern); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setColumnPrivilegesMap(); + xRef = pResult; + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getColumns(catalog,schemaPattern,tableNamePattern,columnNamePattern); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setColumnsMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getTables(catalog,schemaPattern,tableNamePattern,types); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setTablesMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getProcedureColumns(catalog,schemaPattern,procedureNamePattern,columnNamePattern); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setProcedureColumnsMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( + const Any& catalog, const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) +{ + // Create elements used in the array + ADORecordset *pRecordset = m_pADOConnection->getProcedures(catalog,schemaPattern,procedureNamePattern); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setProceduresMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_BINARY_LITERAL); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Maximum Row Size")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_CATALOG_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_CHAR_LITERAL); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_COLUMN_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) +{ + // return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Index")); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_CURSOR_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Active Sessions")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Table")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_TEXT_COMMAND); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_TABLE_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( ) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Maximum Tables in SELECT")); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getExportedKeys(catalog,schema,table); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCrossReferenceMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getImportedKeys(catalog,schema,table); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCrossReferenceMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getPrimaryKeys(catalog,schema,table); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setPrimaryKeysMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo( + const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getIndexInfo(catalog,schema,table,unique,approximate); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setIndexInfoMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( + const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) +{ + Reference< XResultSet > xRef; + if(!ADOS::isJetEngine(m_pConnection->getEngineType())) + { // the jet provider doesn't support this method + // Create elements used in the array + + ADORecordset *pRecordset = m_pADOConnection->getTablePrivileges(catalog,schemaPattern,tableNamePattern); + ADOS::ThrowException(*m_pADOConnection,*this); + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setTablePrivilegesMap(); + xRef = pResult; + } + else + { + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTablePrivileges); + xRef = pResult; + ::connectivity::ODatabaseMetaDataResultSet::ORows aRows; + ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8); + aRows.reserve(8); + + aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[2] = new ::connectivity::ORowSetValueDecorator(tableNamePattern); + aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName()); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue(); + aRow[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); + + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue(); + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue(); + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue(); + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue(); + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue(); + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue(); + aRows.push_back(aRow); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue(); + aRows.push_back(aRow); + pResult->setRows(aRows); + } + + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference( + const Any& primaryCatalog, const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, const Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = m_pADOConnection->getCrossReference(primaryCatalog,primarySchema,primaryTable,foreignCatalog,foreignSchema,foreignTable); + ADOS::ThrowException(*m_pADOConnection,*this); + + Reference< XResultSet > xRef; + + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset); + pResult->setCrossReferenceMap(); + xRef = pResult; + + return xRef; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Maximum Row Size Includes BLOB")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER) == DBPROPVAL_IC_LOWER ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER) == DBPROPVAL_IC_LOWER ; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( ) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER) == DBPROPVAL_IC_UPPER ; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER) == DBPROPVAL_IC_UPPER ; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( ) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( ) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Maximum Index Size")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("NULL Concatenation Behavior")) == DBPROPVAL_CB_NON_NULL; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Catalog Term")); +} +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( ) +{ + return getLiteral(DBLITERAL_QUOTE_PREFIX); + +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) +{ + // return getStringProperty(::rtl::OUString::createFromAscii("Special Characters")); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_CORRELATION_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( ) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Catalog Location")) == DBPROPVAL_CL_START; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DDL_IGNORE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DDL_COMMIT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DML; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_ALL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Prepare Abort Behavior")) == DBPROPVAL_CB_PRESERVE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Prepare Commit Behavior")) == DBPROPVAL_CB_PRESERVE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Isolation Retention")) & DBPROPVAL_TR_COMMIT) == DBPROPVAL_TR_COMMIT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Isolation Retention")) & DBPROPVAL_TR_ABORT) == DBPROPVAL_TR_ABORT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException) +{ + sal_Bool bValue(sal_False); + + sal_Int32 nTxn = getInt32Property(::rtl::OUString::createFromAscii("Isolation Levels")); + if(level == TransactionIsolation::NONE) + bValue = sal_True; + else if(level == TransactionIsolation::READ_UNCOMMITTED) + bValue = (nTxn & DBPROPVAL_TI_READUNCOMMITTED) == DBPROPVAL_TI_READUNCOMMITTED; + else if(level == TransactionIsolation::READ_COMMITTED) + bValue = (nTxn & DBPROPVAL_TI_READCOMMITTED) == DBPROPVAL_TI_READCOMMITTED; + else if(level == TransactionIsolation::REPEATABLE_READ) + bValue = (nTxn & DBPROPVAL_TI_REPEATABLEREAD) == DBPROPVAL_TI_REPEATABLEREAD; + else if(level == TransactionIsolation::SERIALIZABLE) + bValue = (nTxn & DBPROPVAL_TI_SERIALIZABLE) == DBPROPVAL_TI_SERIALIZABLE; + + return bValue; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( ) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_DML_STATEMENTS) == DBPROPVAL_SU_DML_STATEMENTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI92_FULL) == DBPROPVAL_SQL_ANSI92_FULL); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI92_ENTRY) == DBPROPVAL_SQL_ANSI92_ENTRY); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI89_IEF) == DBPROPVAL_SQL_ANSI89_IEF); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_INDEX_DEFINITION) == DBPROPVAL_SU_INDEX_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( ) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_TABLE_DEFINITION) == DBPROPVAL_SU_TABLE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( ) +{ + // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_TABLE_DEFINITION) == DBPROPVAL_CU_TABLE_DEFINITION; + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_INDEX_DEFINITION) == DBPROPVAL_CU_INDEX_DEFINITION; + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( ) +{ + // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_DML_STATEMENTS) == DBPROPVAL_CU_DML_STATEMENTS; + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) +{ + if ( ADOS::isJetEngine(m_pConnection->getEngineType()) ) + return sal_True; + return getBoolProperty(::rtl::OUString::createFromAscii("Outer Join Capabilities")); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) +{ + return new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( ) +{ + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_PROCEDURE_NAME); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_SCHEMA_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_NONE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Read-Only Data Source")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("NULL Concatenation Behavior")) == DBPROPVAL_CB_NULL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_COLUMN_ALIAS); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_CORRELATION_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("Rowset Conversions on Command")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("ORDER BY Columns in Select List")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) != DBPROPVAL_GB_NOT_SUPPORTED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) != DBPROPVAL_GB_CONTAINS_SELECT; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) == DBPROPVAL_GB_NO_RELATION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) +{ + return isCapable(DBLITERAL_ESCAPE_PERCENT); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) +{ + return getBoolProperty(::rtl::OUString::createFromAscii("ORDER BY Columns in Select List")); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( ) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_END) == DBPROPVAL_NC_END; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_START) == DBPROPVAL_NC_START; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_HIGH) == DBPROPVAL_NC_HIGH; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_LOW) == DBPROPVAL_NC_LOW; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_PRIVILEGE_DEFINITION) == DBPROPVAL_SU_PRIVILEGE_DEFINITION; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_PRIVILEGE_DEFINITION) == DBPROPVAL_CU_PRIVILEGE_DEFINITION; + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_CORRELATEDSUBQUERIES) == DBPROPVAL_SQ_CORRELATEDSUBQUERIES; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_COMPARISON) == DBPROPVAL_SQ_COMPARISON; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_EXISTS) == DBPROPVAL_SQ_EXISTS; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_IN) == DBPROPVAL_SQ_IN; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) +{ + return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_QUANTIFIED) == DBPROPVAL_SQ_QUANTIFIED; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI92_INTERMEDIATE) == DBPROPVAL_SQL_ANSI92_INTERMEDIATE); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString::createFromAscii("sdbc:ado:")+ m_pADOConnection->GetConnectionString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("User Name")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Provider Friendly Name")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Provider Version")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("DBMS Version")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("DBMS Name")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Procedure Term")); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) +{ + return getStringProperty(::rtl::OUString::createFromAscii("Schema Term")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nRet = TransactionIsolation::NONE; + switch(m_pADOConnection->get_IsolationLevel()) + { + case adXactReadCommitted: + nRet = TransactionIsolation::READ_COMMITTED; + break; + case adXactRepeatableRead: + nRet = TransactionIsolation::REPEATABLE_READ; + break; + case adXactSerializable: + nRet = TransactionIsolation::SERIALIZABLE; + break; + case adXactReadUncommitted: + nRet = TransactionIsolation::READ_UNCOMMITTED; + break; + default: + ; + } + return nRet; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) +{ + ADORecordset *pRecordset = NULL; + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + m_pADOConnection->OpenSchema(adSchemaDBInfoKeywords,vtEmpty,vtEmpty,&pRecordset); + OSL_ENSURE(pRecordset,"getSQLKeywords: no resultset!"); + ADOS::ThrowException(*m_pADOConnection,*this); + if ( pRecordset ) + { + WpADORecordset aRecordset(pRecordset); + + aRecordset.MoveFirst(); + OLEVariant aValue; + ::rtl::OUString aRet,aComma = ::rtl::OUString::createFromAscii(","); + while(!aRecordset.IsAtEOF()) + { + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields()); + WpADOField aField(aFields.GetItem(0)); + aField.get_Value(aValue); + aRet = aRet + aValue + aComma; + aRecordset.MoveNext(); + } + aRecordset.Close(); + if ( aRet.getLength() ) + return aRet.copy(0,aRet.lastIndexOf(',')); + } + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) +{ + return getLiteral(DBLITERAL_ESCAPE_PERCENT); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue.copy(0,aValue.lastIndexOf(',')); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ODBC_EXTENDED) == DBPROPVAL_SQL_ODBC_EXTENDED); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ODBC_CORE) == DBPROPVAL_SQL_ODBC_CORE); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support")); + return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ODBC_MINIMUM) == DBPROPVAL_SQL_ODBC_MINIMUM); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) +{ + if ( ADOS::isJetEngine(m_pConnection->getEngineType()) ) + return sal_True; + return (getInt32Property(::rtl::OUString::createFromAscii("Outer Join Capabilities")) & 0x00000004L) == 0x00000004L; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) +{ + return supportsFullOuterJoins( ); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in GROUP BY")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) +{ + return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in ORDER BY")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) +{ + return 0; // getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Select")); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) +{ + return getMaxSize(DBLITERAL_USER_NAME); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + return ResultSetType::FORWARD_ONLY != setType; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XDatabaseMetaData::getUDTs", *this ); + return Reference< XResultSet >(); +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx new file mode 100644 index 000000000000..33ebcc4a9e3a --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx @@ -0,0 +1,608 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ADatabaseMetaData.hxx" +#include "ado/ADatabaseMetaDataResultSetMetaData.hxx" +#include "ado/Awrapado.hxx" +#include "ado/AGroup.hxx" +#include "ado/adoimp.hxx" +#include "ado/AIndex.hxx" +#include "ado/AKey.hxx" +#include "ado/ATable.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ProcedureResult.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#ifdef DELETE +#undef DELETE +#endif +#include <com/sun/star/sdbcx/Privilege.hpp> +#include <com/sun/star/sdbcx/PrivilegeObject.hpp> +#include <com/sun/star/sdbc/KeyRule.hpp> +#include <com/sun/star/sdbcx/KeyType.hpp> + +using namespace connectivity::ado; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::uno; + +// ------------------------------------------------------------------------- +void ODatabaseMetaData::fillLiterals() +{ + ADORecordset *pRecordset = NULL; + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + m_pADOConnection->OpenSchema(adSchemaDBInfoLiterals,vtEmpty,vtEmpty,&pRecordset); + + ADOS::ThrowException(*m_pADOConnection,*this); + + OSL_ENSURE(pRecordset,"fillLiterals: no resultset!"); + if ( pRecordset ) + { + WpADORecordset aRecordset(pRecordset); + + aRecordset.MoveFirst(); + OLEVariant aValue; + LiteralInfo aInfo; + while(!aRecordset.IsAtEOF()) + { + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields()); + WpADOField aField(aFields.GetItem(1)); + aInfo.pwszLiteralValue = aField.get_Value(); + aField = aFields.GetItem(5); + aInfo.fSupported = aField.get_Value(); + aField = aFields.GetItem(6); + aInfo.cchMaxLen = aField.get_Value().getUInt32(); + + aField = aFields.GetItem(4); + sal_uInt32 nId = aField.get_Value().getUInt32(); + m_aLiteralInfo[nId] = aInfo; + + aRecordset.MoveNext(); + } + aRecordset.Close(); + } +} +// ------------------------------------------------------------------------- +sal_Int32 ODatabaseMetaData::getMaxSize(sal_uInt32 _nId) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + + sal_Int32 nSize = 0; + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) + nSize = ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen; + return nSize; +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + sal_Bool bSupported = sal_False; + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end()) + bSupported = (*aIter).second.fSupported; + return bSupported; +} + +// ------------------------------------------------------------------------- +::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId) +{ + if(!m_aLiteralInfo.size()) + fillLiterals(); + ::rtl::OUString sStr; + ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId); + if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported) + sStr = (*aIter).second.pwszLiteralValue; + return sStr; +} +// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap() +{ + m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"), + ColumnValue::NULLABLE, + 3,3,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setColumnsMap() +{ + m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"), + ColumnValue::NO_NULLS, + 0,0,0, + DataType::VARCHAR); + m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_DEF"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CHAR_OCTET_LENGTH"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setTablesMap() +{ + m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap() +{ + m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap() +{ + m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap() +{ + m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NON_UNIQUE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::BIT); + m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_QUALIFIER"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap() +{ + m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); + m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap() +{ + m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap() +{ + m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::BIT); + m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); + m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"), + ColumnValue::NO_NULLS, + 1,1,0, + DataType::INTEGER); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSetMetaData::setProceduresMap() +{ + m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"), + ColumnValue::NULLABLE, + 0,0,0, + DataType::VARCHAR); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isSearchable(); + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isAutoIncrement(); + return sal_False; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnServiceName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getTableName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getCatalogName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnTypeName(); + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isCaseSensitive(); + return sal_True; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getSchemaName(); + return ::rtl::OUString(); +} +// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------- +ObjectTypeEnum OAdoGroup::MapObjectType(sal_Int32 _ObjType) +{ + ObjectTypeEnum eNumType= adPermObjTable; + switch(_ObjType) + { + case PrivilegeObject::TABLE: + break; + case PrivilegeObject::VIEW: + eNumType = adPermObjView; + break; + case PrivilegeObject::COLUMN: + eNumType = adPermObjColumn; + break; + } + return eNumType; +} +// ------------------------------------------------------------------------- +sal_Int32 OAdoGroup::MapRight(RightsEnum _eNum) +{ + sal_Int32 nRight = 0; + if(_eNum & adRightRead) + nRight |= Privilege::SELECT; + if(_eNum & adRightInsert) + nRight |= Privilege::INSERT; + if(_eNum & adRightUpdate) + nRight |= Privilege::UPDATE; + if(_eNum & adRightDelete) + nRight |= Privilege::DELETE; + if(_eNum & adRightReadDesign) + nRight |= Privilege::READ; + if(_eNum & adRightCreate) + nRight |= Privilege::CREATE; + if(_eNum & adRightWriteDesign) + nRight |= Privilege::ALTER; + if(_eNum & adRightReference) + nRight |= Privilege::REFERENCE; + if(_eNum & adRightDrop) + nRight |= Privilege::DROP; + + return nRight; +} +// ------------------------------------------------------------------------- +RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum) +{ + sal_Int32 nRight = adRightNone; + if(_eNum & Privilege::SELECT) + nRight |= adRightRead; + + if(_eNum & Privilege::INSERT) + nRight |= adRightInsert; + + if(_eNum & Privilege::UPDATE) + nRight |= adRightUpdate; + + if(_eNum & Privilege::DELETE) + nRight |= adRightDelete; + + if(_eNum & Privilege::READ) + nRight |= adRightReadDesign; + + if(_eNum & Privilege::CREATE) + nRight |= adRightCreate; + + if(_eNum & Privilege::ALTER) + nRight |= adRightWriteDesign; + + if(_eNum & Privilege::REFERENCE) + nRight |= adRightReference; + + if(_eNum & Privilege::DROP) + nRight |= adRightDrop; + + return (RightsEnum)nRight; +} +// ------------------------------------------------------------------------- +void WpADOIndex::Create() +{ + HRESULT hr = -1; + + _ADOIndex* pIndex = NULL; + hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOINDEX_25, + (void**)&pIndex ); + + + if( !FAILED( hr ) ) + { + operator=( pIndex ); + pIndex->Release(); + } +} +// ------------------------------------------------------------------------- +void OAdoIndex::fillPropertyValues() +{ + if(m_aIndex.IsValid()) + { + m_Name = m_aIndex.get_Name(); + m_IsUnique = m_aIndex.get_Unique(); + m_IsPrimaryKeyIndex = m_aIndex.get_PrimaryKey(); + m_IsClustered = m_aIndex.get_Clustered(); + } +} +// ----------------------------------------------------------------------------- +void WpADOKey::Create() +{ + HRESULT hr = -1; + _ADOKey* pKey = NULL; + hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOKEY_25, + (void**)&pKey ); + + + if( !FAILED( hr ) ) + { + operator=( pKey ); + pKey->Release(); + } +} +// ------------------------------------------------------------------------- +void OAdoKey::fillPropertyValues() +{ + if(m_aKey.IsValid()) + { + m_aProps->m_Type = MapKeyRule(m_aKey.get_Type()); + m_Name = m_aKey.get_Name(); + m_aProps->m_ReferencedTable = m_aKey.get_RelatedTable(); + m_aProps->m_UpdateRule = MapRule(m_aKey.get_UpdateRule()); + m_aProps->m_DeleteRule = MapRule(m_aKey.get_DeleteRule()); + } +} +// ------------------------------------------------------------------------- +sal_Int32 OAdoKey::MapRule(const RuleEnum& _eNum) +{ + sal_Int32 eNum = KeyRule::NO_ACTION; + switch(_eNum) + { + case adRICascade: + eNum = KeyRule::CASCADE; + break; + case adRISetNull: + eNum = KeyRule::SET_NULL; + break; + case adRINone: + eNum = KeyRule::NO_ACTION; + break; + case adRISetDefault: + eNum = KeyRule::SET_DEFAULT; + break; + } + return eNum; +} +// ------------------------------------------------------------------------- +RuleEnum OAdoKey::Map2Rule(const sal_Int32& _eNum) +{ + RuleEnum eNum = adRINone; + switch(_eNum) + { + case KeyRule::CASCADE: + eNum = adRICascade; + break; + case KeyRule::SET_NULL: + eNum = adRISetNull; + break; + case KeyRule::NO_ACTION: + eNum = adRINone; + break; + case KeyRule::SET_DEFAULT: + eNum = adRISetDefault; + break; + } + return eNum; +} +// ------------------------------------------------------------------------- +sal_Int32 OAdoKey::MapKeyRule(const KeyTypeEnum& _eNum) +{ + sal_Int32 nKeyType = KeyType::PRIMARY; + switch(_eNum) + { + case adKeyPrimary: + nKeyType = KeyType::PRIMARY; + break; + case adKeyForeign: + nKeyType = KeyType::FOREIGN; + break; + case adKeyUnique: + nKeyType = KeyType::UNIQUE; + break; + } + return nKeyType; +} +// ------------------------------------------------------------------------- +KeyTypeEnum OAdoKey::Map2KeyRule(const sal_Int32& _eNum) +{ + KeyTypeEnum eNum( adKeyPrimary ); + switch(_eNum) + { + case KeyType::PRIMARY: + eNum = adKeyPrimary; + break; + case KeyType::FOREIGN: + eNum = adKeyForeign; + break; + case KeyType::UNIQUE: + eNum = adKeyUnique; + break; + default: + OSL_ENSURE( false, "OAdoKey::Map2KeyRule: invalid key type!" ); + } + return eNum; +} +// ----------------------------------------------------------------------------- +void WpADOTable::Create() +{ + HRESULT hr = -1; + _ADOTable* pTable = NULL; + hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOTABLE_25, + (void**)&pTable ); + + + if( !FAILED( hr ) ) + { + operator=( pTable ); + pTable->Release(); + } +} +// ------------------------------------------------------------------------- +::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum) +{ + OLEVariant _rVar; + _rVar.setNoArg(); + OLEString aBSTR; + OLEString sStr1(_rName); + pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR); + return aBSTR; +} +// ----------------------------------------------------------------------------- +void OAdoTable::fillPropertyValues() +{ + if(m_aTable.IsValid()) + { + m_Name = m_aTable.get_Name(); + m_Type = m_aTable.get_Type(); + { + WpADOCatalog aCat(m_aTable.get_ParentCatalog()); + if(aCat.IsValid()) + m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable); + } + { + WpADOProperties aProps = m_aTable.get_Properties(); + if(aProps.IsValid()) + m_Description = OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description"))); + } + } +} +// ----------------------------------------------------------------------------- +void WpADOUser::Create() +{ + HRESULT hr = -1; + _ADOUser* pUser = NULL; + hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOUSER_25, + (void**)&pUser ); + + + if( !FAILED( hr ) ) + { + operator=( pUser ); + pUser->Release(); + } +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx new file mode 100644 index 000000000000..f35ba90d84f7 --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx @@ -0,0 +1,1218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include <comphelper/sequence.hxx> +#include "ado/ADatabaseMetaDataResultSet.hxx" +#include "ado/ADatabaseMetaDataResultSetMetaData.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/KeyRule.hpp> +#include <com/sun/star/sdbc/ProcedureResult.hpp> +#include <com/sun/star/sdbc/IndexType.hpp> +#include <comphelper/property.hxx> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/FetchDirection.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/seqstream.hxx> +#include "connectivity/dbexception.hxx" + + +#include <oledb.h> + +using namespace dbtools; +using namespace connectivity::ado; +using namespace cppu; +using namespace ::comphelper; +//------------------------------------------------------------------------------ +using namespace ::com::sun::star::lang; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(ADORecordset* _pRecordSet) + :ODatabaseMetaDataResultSet_BASE(m_aMutex) + ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper) + ,m_aStatement(NULL) + ,m_xMetaData(NULL) + ,m_pRecordSet(_pRecordSet) + ,m_bEOF(sal_False) +{ + osl_incrementInterlockedCount( &m_refCount ); + m_aColMapping.push_back(-1); + if(_pRecordSet) + { + m_pRecordSet->AddRef(); + VARIANT_BOOL bIsAtBOF; + m_pRecordSet->get_BOF(&bIsAtBOF); + m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE; + } + else + m_bOnFirstAfterOpen = sal_False; + osl_decrementInterlockedCount( &m_refCount ); + // allocBuffer(); +} + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() +{ + if(m_pRecordSet) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + if(m_pRecordSet) + m_pRecordSet->Close(); + m_aStatement = NULL; +m_xMetaData.clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes()); +} +// ----------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::checkRecordSet() throw(SQLException) +{ + if(!m_pRecordSet) + throwFunctionSequenceException(*this); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + sal_Int32 i = 1; + for(;i<=nLen;++i) + if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : + columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) + break; + return i; +} +#define BLOCK_SIZE 256 +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + columnIndex = mapColumn(columnIndex); + WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); + if((aField.GetAttributes() & adFldLong) == adFldLong) + { + //Copy the data only upto the Actual Size of Field. + sal_Int32 nSize = aField.GetActualSize(); + Sequence<sal_Int8> aData(nSize); + long index = 0; + while(index < nSize) + { + m_aValue = aField.GetChunk(BLOCK_SIZE); + if(m_aValue.isNull()) + break; + UCHAR chData; + for(long index2 = 0;index2 < BLOCK_SIZE;++index2) + { + HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData); + if(SUCCEEDED(hr)) + { + //Take BYTE by BYTE and advance Memory Location + aData.getArray()[index++] = chData; + } + else + break; + } + } + return index ? Reference< ::com::sun::star::io::XInputStream >(new SequenceInputStream(aData)) : Reference< ::com::sun::star::io::XInputStream >(); + } + // else we ask for a bytesequence + aField.get_Value(m_aValue); + if(m_aValue.isNull()) + return NULL; + return new SequenceInputStream(m_aValue); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this ); + return NULL; +} + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + if ( !m_aValueRange.empty() && columnIndex == 11 && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end() ) + { + getValue(2); + if ( static_cast<sal_Int16>(m_aValue) != adCurrency ) + return sal_False; + } + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + getValue(columnIndex); + + columnIndex = mapColumn(columnIndex); + + if(m_aValue.isNull()) + return 0; + if ( !m_aValueRange.empty() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) + return (sal_Int8)(*m_aValueRangeIter).second[(sal_Int32)m_aValue]; + else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) + return (sal_Int8)(*m_aStrValueRangeIter).second[m_aValue]; + + return m_aValue; +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + + getValue(columnIndex); + + columnIndex = mapColumn(columnIndex); + if(m_aValue.isNull()) + return 0; + + if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) + return (*m_aValueRangeIter).second[(sal_Int32)m_aValue]; + else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) + return (*m_aStrValueRangeIter).second[m_aValue]; + + return m_aValue; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XResultSet::getRow", *this ); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this ); + return sal_Int64(0); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + if(!m_xMetaData.is()) + m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + + return m_xMetaData; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); + return NULL; +} + +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + columnIndex = mapColumn(columnIndex); + return Any(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + getValue(columnIndex); + + columnIndex = mapColumn(columnIndex); + if(m_aValue.isNull()) + return 0; + + if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) + return (sal_Int16)(*m_aValueRangeIter).second[(sal_Int32)m_aValue]; + else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) + return (sal_Int16)(*m_aStrValueRangeIter).second[m_aValue]; + + return m_aValue; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + getValue(columnIndex); + + + columnIndex = mapColumn(columnIndex); + if(m_aValue.isNull()) + return ::rtl::OUString(); + if(m_aIntValueRange.size() && (m_aIntValueRangeIter = m_aIntValueRange.find(columnIndex)) != m_aIntValueRange.end()) + return (*m_aIntValueRangeIter).second[m_aValue]; + + return m_aValue; +} + +// ------------------------------------------------------------------------- + + +::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + VARIANT_BOOL bIsAtEOF; + m_pRecordSet->get_EOF(&bIsAtEOF); + return bIsAtEOF == VARIANT_TRUE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + return m_nRowPos == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + return sal_True; +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + if(first()) + previous(); +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + if(last()) + next(); + m_bEOF = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + } + dispose(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + + if(!m_pRecordSet) + return sal_False; + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveFirst()); + if ( bRet ) + m_nRowPos = 1; + return bRet; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + + return m_pRecordSet && SUCCEEDED(m_pRecordSet->MoveLast()) ? sal_True : sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + + if(first()) + { + OLEVariant aEmpty; + aEmpty.setNoArg(); + sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); + if(bRet) + m_nRowPos = row; + return bRet; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + + if(!m_pRecordSet) + return sal_False; + + OLEVariant aEmpty; + aEmpty.setNoArg(); + sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); + if(bRet) + m_nRowPos += row; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + + if(!m_pRecordSet) + return sal_False; + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious()); + if(bRet) + --m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ + return m_aStatement.get(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecDeleted) == adRecDeleted; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecNew) == adRecNew; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecModified) == adRecModified; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + + if(!m_pRecordSet) + return sal_True; + + VARIANT_BOOL bIsAtBOF; + m_pRecordSet->get_BOF(&bIsAtBOF); + return bIsAtBOF == VARIANT_TRUE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + + if(!m_pRecordSet) + return sal_False; + + if(m_bOnFirstAfterOpen) + { + m_bOnFirstAfterOpen = sal_False; + return sal_True; + } + else + return SUCCEEDED(m_pRecordSet->MoveNext()); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + return m_aValue.isNull(); +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues); +} +// ------------------------------------------------------------------------- + +void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + + m_pRecordSet->Cancel(); +} +// ------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return ResultSetConcurrency::READ_ONLY; +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return ResultSetType::FORWARD_ONLY; +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return FetchDirection::FORWARD; +} +//------------------------------------------------------------------------------ +sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nValue=-1; + if(m_pRecordSet) + m_pRecordSet->get_CacheSize(&nValue); + return nValue; +} +//------------------------------------------------------------------------------ +::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return ::rtl::OUString(); +} + +//------------------------------------------------------------------------------ +void ODatabaseMetaDataResultSet::setFetchDirection(sal_Int32 /*_par0*/) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this ); +} +//------------------------------------------------------------------------------ +void ODatabaseMetaDataResultSet::setFetchSize(sal_Int32 _par0) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + if(m_pRecordSet) + m_pRecordSet->put_CacheSize(_par0); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const +{ + + Sequence< com::sun::star::beans::Property > aProps(5); + com::sun::star::beans::Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP0(CURSORNAME, ::rtl::OUString); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); + DECL_PROP0(RESULTSETTYPE, sal_Int32); + + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper() +{ + return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::lang::IllegalArgumentException(); + break; + case PROPERTY_ID_FETCHDIRECTION: + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const Any& /*rValue*/ + ) + throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + case PROPERTY_ID_FETCHDIRECTION: + case PROPERTY_ID_FETCHSIZE: + throw Exception(); + break; + default: + OSL_ENSURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!"); + } +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::getFastPropertyValue( + Any& rValue, + sal_Int32 nHandle + ) const +{ + switch(nHandle) + { + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + } +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setProceduresMap() +{ + + for(sal_Int32 i=1;i<4;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(5); + m_aColMapping.push_back(7); + m_aColMapping.push_back(8); + m_aColMapping.push_back(6); + m_aColMapping.push_back(4); + + TInt2IntMap aMap; + aMap[DB_PT_UNKNOWN] = ProcedureResult::UNKNOWN; + aMap[DB_PT_PROCEDURE] = ProcedureResult::NONE; + aMap[DB_PT_FUNCTION] = ProcedureResult::RETURN; + m_aValueRange[4] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setProceduresMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setCatalogsMap() +{ + m_aColMapping.push_back(1); + + m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setSchemasMap() +{ + m_aColMapping.push_back(2); + + m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setColumnPrivilegesMap() +{ + + m_aColMapping.push_back(3); + m_aColMapping.push_back(4); + m_aColMapping.push_back(5); + m_aColMapping.push_back(6); + m_aColMapping.push_back(2); + m_aColMapping.push_back(9); + m_aColMapping.push_back(10); + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setColumnPrivilegesMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setColumnsMap() +{ + + for(sal_Int32 i=1;i<5;++i) + m_aColMapping.push_back(i); + + m_aColMapping.push_back(12); + m_aColMapping.push_back(12); // is used as TYPE_NAME + + m_aColMapping.push_back(14); + m_aColMapping.push_back(6); + m_aColMapping.push_back(17); + m_aColMapping.push_back(18); + + m_aColMapping.push_back(11); + m_aColMapping.push_back(29); + m_aColMapping.push_back(9); + m_aColMapping.push_back(18); + m_aColMapping.push_back(18); + + m_aColMapping.push_back(15); + m_aColMapping.push_back(7); + m_aColMapping.push_back(11); + + TInt2IntMap aMap; + aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty); + aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt); + aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt); + aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger); + aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt); + aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt); + aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt); + aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt); + aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt); + aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle); + aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble); + aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency); + aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal); + aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric); + aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean); + aMap[adError] = ADOS::MapADOType2Jdbc(adError); + aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined); + aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant); + aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch); + aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown); + aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID); + aMap[adDate] = ADOS::MapADOType2Jdbc(adDate); + aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate); + aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime); + aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp); + aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR); + aMap[adChar] = ADOS::MapADOType2Jdbc(adChar); + aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar); + aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar); + aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar); + aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar); + aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar); + aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary); + aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary); + aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary); + aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter); + aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime); + aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant); + aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric); +// aMap[adArray] = ADOS::MapADOType2Jdbc(adArray); + + m_aValueRange[12] = aMap; + + ::std::map< sal_Int32,::rtl::OUString> aMap2; + aMap2[0] = ::rtl::OUString::createFromAscii("YES"); + aMap2[1] = ::rtl::OUString::createFromAscii("NO"); + m_aIntValueRange[18] = aMap2; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setColumnsMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setTablesMap() +{ + + for(sal_Int32 i=1;i<5;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(6); + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setTablesMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setProcedureColumnsMap() +{ + + for(sal_Int32 i=1;i<5;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(6); + m_aColMapping.push_back(10); + m_aColMapping.push_back(16); + m_aColMapping.push_back(13); + m_aColMapping.push_back(11); + m_aColMapping.push_back(12); + + m_aColMapping.push_back(9); + m_aColMapping.push_back(14); + + TInt2IntMap aMap; + aMap[DBTYPE_EMPTY] = DataType::SQLNULL; + aMap[DBTYPE_NULL] = DataType::SQLNULL; + aMap[DBTYPE_I2] = DataType::SMALLINT; + aMap[DBTYPE_I4] = DataType::INTEGER; + aMap[DBTYPE_R4] = DataType::FLOAT; + aMap[DBTYPE_R8] = DataType::DOUBLE; + aMap[DBTYPE_CY] = DataType::BIGINT; + aMap[DBTYPE_DATE] = DataType::DATE; + aMap[DBTYPE_BSTR] = DataType::VARCHAR; + aMap[DBTYPE_IDISPATCH] = DataType::OBJECT; + aMap[DBTYPE_ERROR] = DataType::OTHER; + aMap[DBTYPE_BOOL] = DataType::BIT; + aMap[DBTYPE_VARIANT] = DataType::STRUCT; + aMap[DBTYPE_IUNKNOWN] = DataType::OTHER; + aMap[DBTYPE_DECIMAL] = DataType::DECIMAL; + aMap[DBTYPE_UI1] = DataType::TINYINT; + aMap[DBTYPE_ARRAY] = DataType::ARRAY; + aMap[DBTYPE_BYREF] = DataType::REF; + aMap[DBTYPE_I1] = DataType::CHAR; + aMap[DBTYPE_UI2] = DataType::SMALLINT; + aMap[DBTYPE_UI4] = DataType::INTEGER; + + // aMap[The] = ; + // aMap[in] = ; + aMap[DBTYPE_I8] = DataType::BIGINT; + aMap[DBTYPE_UI8] = DataType::BIGINT; + aMap[DBTYPE_GUID] = DataType::OTHER; + aMap[DBTYPE_VECTOR] = DataType::OTHER; + aMap[DBTYPE_FILETIME] = DataType::OTHER; + aMap[DBTYPE_RESERVED] = DataType::OTHER; + + // aMap[The] = ; + aMap[DBTYPE_BYTES] = DataType::VARBINARY; + aMap[DBTYPE_STR] = DataType::LONGVARCHAR; + aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR; + aMap[DBTYPE_NUMERIC] = DataType::NUMERIC; + aMap[DBTYPE_UDT] = DataType::OTHER; + aMap[DBTYPE_DBDATE] = DataType::DATE; + aMap[DBTYPE_DBTIME] = DataType::TIME; + aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP; + aMap[DBTYPE_HCHAPTER] = DataType::OTHER; + aMap[DBTYPE_PROPVARIANT] = DataType::OTHER; + aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC; + + m_aValueRange[10] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setProcedureColumnsMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setPrimaryKeysMap() +{ + + sal_Int32 i=1; + for(;i<5;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(7); + m_aColMapping.push_back(8); + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setProcedureColumnsMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setIndexInfoMap() +{ + + sal_Int32 i=1; + for(;i<4;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(8); + m_aColMapping.push_back(4); + m_aColMapping.push_back(6); + m_aColMapping.push_back(10); + m_aColMapping.push_back(17); + m_aColMapping.push_back(18); + m_aColMapping.push_back(21); + m_aColMapping.push_back(22); + m_aColMapping.push_back(23); + m_aColMapping.push_back(24); + + TInt2IntMap aMap; + aMap[DBPROPVAL_IT_HASH] = IndexType::HASHED; + aMap[DBPROPVAL_IT_CONTENT] = IndexType::OTHER; + aMap[DBPROPVAL_IT_OTHER] = IndexType::OTHER; + aMap[DBPROPVAL_IT_BTREE] = IndexType::OTHER; + + m_aValueRange[10] = aMap; + + TInt2IntMap aMap2; + aMap[0] = 1; + aMap[1] = 0; + m_aValueRange[8] = aMap2; + + ::std::map< sal_Int32,::rtl::OUString> aMap3; + aMap3[0] = ::rtl::OUString(); + aMap3[DB_COLLATION_ASC] = ::rtl::OUString::createFromAscii("A"); + aMap3[DB_COLLATION_DESC] = ::rtl::OUString::createFromAscii("D"); + + m_aIntValueRange[21] = aMap3; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setIndexInfoMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setTablePrivilegesMap() +{ + + sal_Int32 i=3; + for(;i<6;i++) + m_aColMapping.push_back(i); + m_aColMapping.push_back(1); + m_aColMapping.push_back(2); + m_aColMapping.push_back(6); + m_aColMapping.push_back(7); + + ::std::map< sal_Int32,::rtl::OUString> aMap; + aMap[0] = ::rtl::OUString::createFromAscii("YES"); + aMap[1] = ::rtl::OUString::createFromAscii("NO"); + m_aIntValueRange[7] = aMap; + + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setTablePrivilegesMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setCrossReferenceMap() +{ + + sal_Int32 i=1; + for(;i<5;i++) + m_aColMapping.push_back(i); + for(i=7;i<11;i++) + m_aColMapping.push_back(i); + + m_aColMapping.push_back(13); + m_aColMapping.push_back(14); + m_aColMapping.push_back(15); + m_aColMapping.push_back(17); + m_aColMapping.push_back(16); + m_aColMapping.push_back(18); + + ::std::map< ::rtl::OUString,sal_Int32> aMap; + aMap[ ::rtl::OUString::createFromAscii("CASCADE")] = KeyRule::CASCADE; + aMap[ ::rtl::OUString::createFromAscii("RESTRICT")] = KeyRule::RESTRICT; + aMap[ ::rtl::OUString::createFromAscii("SET NULL")] = KeyRule::SET_NULL; + aMap[ ::rtl::OUString::createFromAscii("SET DEFAULT")] = KeyRule::SET_DEFAULT; + aMap[ ::rtl::OUString::createFromAscii("NO ACTION")] = KeyRule::NO_ACTION; + + m_aStrValueRange[14] = aMap; + m_aStrValueRange[15] = aMap; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setCrossReferenceMap(); + m_xMetaData = pMetaData; +} +// ------------------------------------------------------------------------- +void ODatabaseMetaDataResultSet::setTypeInfoMap(sal_Bool _bJetEngine) +{ + sal_Int32 i=1; + for(;i<19;i++) + m_aColMapping.push_back(i); + + ::std::map< ::rtl::OUString,sal_Int32> aMap1; + aMap1[ ::rtl::OUString()] = 10; + + m_aStrValueRange[18] = aMap1; + + TInt2IntMap aMap; + aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty); + aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt); + aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt); + aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger); + aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt); + aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt); + aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt); + aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt); + aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt); + aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle); + aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble); + aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency); + aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal); + aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric); + aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean); + aMap[adError] = ADOS::MapADOType2Jdbc(adError); + aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined); + aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant); + aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch); + aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown); + aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID); + aMap[adDate] = _bJetEngine ? ADOS::MapADOType2Jdbc(adDBTimeStamp) : ADOS::MapADOType2Jdbc(adDate); + aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate); + aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime); + aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp); + aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR); + aMap[adChar] = ADOS::MapADOType2Jdbc(adChar); + aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar); + aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar); + aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar); + aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar); + aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar); + aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary); + aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary); + aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary); + aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter); + aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime); + aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant); + aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric); +// aMap[adArray] = ADOS::MapADOType2Jdbc(adArray); + + m_aValueRange[2] = aMap; + + TInt2IntMap aColumnValueMapping; + aColumnValueMapping[VARIANT_FALSE] = ColumnValue::NO_NULLS; + aColumnValueMapping[VARIANT_TRUE] = ColumnValue::NULLABLE; + m_aValueRange[7] = aColumnValueMapping; + + // now adjust the column mapping + // OJ 24.01.2002 96860 + TInt2IntMap aSerachMapping; + aSerachMapping[DB_UNSEARCHABLE] = ColumnSearch::NONE; + aSerachMapping[DB_LIKE_ONLY] = ColumnSearch::CHAR; + aSerachMapping[DB_ALL_EXCEPT_LIKE] = ColumnSearch::BASIC; + aSerachMapping[DB_SEARCHABLE] = ColumnSearch::FULL; + + m_aValueRange[9] = aSerachMapping; + + TInt2IntMap aCurrencyMapping; + m_aValueRange[11] = aCurrencyMapping; + + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this); + pMetaData->setTypeInfoMap(); + m_xMetaData = pMetaData; +} +// ----------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw() +{ + ODatabaseMetaDataResultSet_BASE::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ODatabaseMetaDataResultSet::release() throw() +{ + ODatabaseMetaDataResultSet_BASE::release(); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} +// ----------------------------------------------------------------------------- +OLEVariant ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); + + checkRecordSet(); + + WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx new file mode 100644 index 000000000000..a204ec477564 --- /dev/null +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ADatabaseMetaDataResultSetMetaData.hxx" +#include "ado/Awrapado.hxx" +#include "connectivity/dbexception.hxx" + + +using namespace connectivity; +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData() +{ + if(m_pRecordSet) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + sal_Int32 nSize = 0; + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + nSize = (*m_mColumnsIter).second.getColumnDisplaySize(); + else if(m_pRecordSet) + { + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + nSize = aField.GetActualSize(); + } + return nSize; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + sal_Int32 nType = 0; + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + nType = (*m_mColumnsIter).second.getColumnType(); + else if(m_pRecordSet) + { + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + nType = ADOS::MapADOType2Jdbc(aField.GetADOType()); + } + return nType; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + if(!m_pRecordSet) + return 0; + if(m_nColCount != -1) + return m_nColCount; + + if(m_vMapping.size()) + return m_mColumns.size(); + + ADOFields* pFields = NULL; + m_pRecordSet->get_Fields(&pFields); + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields); + m_nColCount = aFields.GetItemCount(); + return m_nColCount; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnName(); + if(!m_pRecordSet) + return ::rtl::OUString(); + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + return aField.GetName(); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnLabel(); + return getColumnName(column); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isCurrency(); + if(!m_pRecordSet) + return 0; + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldFixed) == adFldFixed; + } + return sal_False; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isSigned(); + if(!m_pRecordSet) + return 0; + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getPrecision(); + if(!m_pRecordSet) + return 0; + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + return aField.GetPrecision(); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getScale(); + + if(!m_pRecordSet) + return 0; + + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + return aField.GetNumericScale(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isNullable(); + + if(!m_pRecordSet) + return 0; + + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldIsNullable) == adFldIsNullable; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isReadOnly(); + + if(!m_pRecordSet) + return 0; + + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + { + // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isDefinitelyWritable(); + + if(!m_pRecordSet) + return 0; + + WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable; + } + return sal_False; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isWritable(); + return isDefinitelyWritable(column); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx new file mode 100644 index 000000000000..5b89623c28d8 --- /dev/null +++ b/connectivity/source/drivers/ado/ADriver.cxx @@ -0,0 +1,302 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ADriver.hxx" +#include "ado/AConnection.hxx" +#include "ado/Awrapadox.hxx" +#include "ado/ACatalog.hxx" +#include "ado/Awrapado.hxx" +#include "ado/adoimp.hxx" +#include <com/sun/star/lang/DisposedException.hpp> +#include "connectivity/dbexception.hxx" +#include "resource/ado_res.hrc" +#include <Objbase.h> + + +#include "resource/sharedresources.hxx" + +using namespace connectivity; +using namespace connectivity::ado; +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; +using namespace com::sun::star::lang; + +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- +ODriver::ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) + : ODriver_BASE(m_aMutex) + ,m_xORB(_xORB) +{ + if ( FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) ) + { + CoUninitialize(); + int h = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + (void)h; + ++h; + } +} +// ------------------------------------------------------------------------- +ODriver::~ODriver() +{ + CoUninitialize(); + CoInitialize(NULL); +} +//------------------------------------------------------------------------------ +void ODriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_xConnections.clear(); + + ODriver_BASE::disposing(); +} +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.ado.ODriver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver"); + return aSNS; +} +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::ado::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) +{ + return *(new ODriver(_rxFactory)); +} + +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); + for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) + ; + + return pSupported != pEnd; +} + +// -------------------------------------------------------------------------------- +Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + if ( ! acceptsURL(url) ) + return NULL; + + OConnection* pCon = new OConnection(this); + pCon->construct(url,info); + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:ado:"),9)); +} +// ----------------------------------------------------------------------------- +void ODriver::impl_checkURL_throw(const ::rtl::OUString& _sUrl) +{ + if ( !acceptsURL(_sUrl) ) + { + SharedResources aResources; + const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); + ::dbtools::throwGenericSQLException(sMessage ,*this); + } // if ( !acceptsURL(_sUrl) ) +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException) +{ + impl_checkURL_throw(url); + if ( acceptsURL(url) ) + { + ::std::vector< DriverPropertyInfo > aDriverInfo; + + Sequence< ::rtl::OUString > aBooleanValues(2); + aBooleanValues[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ); + aBooleanValues[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ); + + aDriverInfo.push_back(DriverPropertyInfo( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreDriverPrivileges")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Ignore the privileges from the database driver.")) + ,sal_False + ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ) + ,aBooleanValues) + ); + aDriverInfo.push_back(DriverPropertyInfo( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EscapeDateTime")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Escape date time format.")) + ,sal_False + ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) + ,aBooleanValues) + ); + aDriverInfo.push_back(DriverPropertyInfo( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings")) + ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Defines how the type info of the database metadata should be manipulated.")) + ,sal_False + ,::rtl::OUString( ) + ,Sequence< ::rtl::OUString > ()) + ); + return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()); + } + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// -------------------------------------------------------------------------------- +// XDataDefinitionSupplier +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + OConnection* pConnection = NULL; + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY); + if(xTunnel.is()) + { + OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelImplementationId()) ); + + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection) + { + pConnection = pSearchConnection; + break; + } + } + + } + + Reference< XTablesSupplier > xTab = NULL; + if(pConnection) + { + WpADOCatalog aCatalog; + aCatalog.Create(); + if(aCatalog.IsValid()) + { + aCatalog.putref_ActiveConnection(*pConnection->getConnection()); + OCatalog* pCatalog = new OCatalog(aCatalog,pConnection); + xTab = pCatalog; + pConnection->setCatalog(xTab); + pConnection->setCatalog(pCatalog); + } + } + return xTab; +} +// -------------------------------------------------------------------------------- +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + impl_checkURL_throw(url); + return getDataDefinitionByConnection(connect(url,info)); +} + +// ----------------------------------------------------------------------------- +void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException) +{ + ADOErrors *pErrors = NULL; + _pAdoCon->get_Errors(&pErrors); + if(!pErrors) + return; // no error found + + pErrors->AddRef( ); + + // alle aufgelaufenen Fehler auslesen und ausgeben + sal_Int32 nLen; + pErrors->get_Count(&nLen); + if (nLen) + { + ::rtl::OUString sError; + ::rtl::OUString aSQLState; + SQLException aException; + aException.ErrorCode = 1000; + for (sal_Int32 i = nLen-1; i>=0; --i) + { + ADOError *pError = NULL; + pErrors->get_Item(OLEVariant(i),&pError); + WpADOError aErr(pError); + OSL_ENSURE(pError,"No error in collection found! BAD!"); + if(pError) + { + if(i==nLen-1) + aException = SQLException(aErr.GetDescription(),_xInterface,aErr.GetSQLState(),aErr.GetNumber(),Any()); + else + { + SQLException aTemp = SQLException(aErr.GetDescription(), + _xInterface,aErr.GetSQLState(),aErr.GetNumber(),makeAny(aException)); + aTemp.NextException <<= aException; + aException = aTemp; + } + } + } + pErrors->Clear(); + pErrors->Release(); + throw aException; + } + pErrors->Release(); +} + + diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx new file mode 100644 index 000000000000..2058469d44da --- /dev/null +++ b/connectivity/source/drivers/ado/AGroup.cxx @@ -0,0 +1,192 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#ifndef _CONNECTIVITY_ADO_GROUP_HXX_ +#include "ado/AGroup.hxx" +#endif +#include "ado/AUsers.hxx" +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#include "TConnection.hxx" + +using namespace connectivity::ado; +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; + +// ------------------------------------------------------------------------- +void WpADOGroup::Create() +{ + HRESULT hr = -1; + ADOGroup* pGroup = NULL; + hr = CoCreateInstance(ADOS::CLSID_ADOGROUP_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOGROUP_25, + (void**)&pGroup ); + + + if( !FAILED( hr ) ) + { + operator=( pGroup ); + pGroup->Release(); + } +} +// ------------------------------------------------------------------------- +OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent) +{ + construct(); + if(_pGroup) + m_aGroup = WpADOGroup(_pGroup); + else + m_aGroup.Create(); + +} +// ------------------------------------------------------------------------- +OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase),m_pCatalog(_pParent) +{ + construct(); + m_aGroup.Create(); + m_aGroup.put_Name(_Name); +} +// ------------------------------------------------------------------------- +void OAdoGroup::refreshUsers() +{ + TStringVector aVector; + + WpADOUsers aUsers = m_aGroup.get_Users(); + aUsers.fillElementNames(aVector); + + if(m_pUsers) + m_pUsers->reFill(aVector); + else + m_pUsers = new OUsers(m_pCatalog,m_aMutex,aVector,aUsers,isCaseSensitive()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoGroup::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OGroup_ADO::getSomething(rId); +} + +// ------------------------------------------------------------------------- +void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aGroup.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aGroup.put_Name(aVal); + } + break; + } + } +} +// ------------------------------------------------------------------------- +void OAdoGroup::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aGroup.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aGroup.get_Name(); + break; + } + } +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OAdoGroup::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + return MapRight(m_aGroup.GetPermissions(objName,MapObjectType(objType))); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdoGroup::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + RightsEnum eNum = m_aGroup.GetPermissions(objName,MapObjectType(objType)); + if(eNum & adRightWithGrant) + return MapRight(eNum); + return 0; +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoGroup::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessGrant,Map2Right(objPrivileges)); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoGroup::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessDeny,Map2Right(objPrivileges)); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoGroup::acquire() throw() +{ + OGroup_ADO::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoGroup::release() throw() +{ + OGroup_ADO::release(); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AGroups.cxx b/connectivity/source/drivers/ado/AGroups.cxx new file mode 100644 index 000000000000..f5732ca16c91 --- /dev/null +++ b/connectivity/source/drivers/ado/AGroups.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AGroups.hxx" +#include "ado/AGroup.hxx" +#include "ado/ATable.hxx" +#include "ado/AConnection.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include "connectivity/sdbcx/IRefreshable.hxx" +#include "TConnection.hxx" +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#include "resource/ado_res.hrc" + +using namespace comphelper; +using namespace connectivity; +using namespace connectivity::ado; +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::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; +// ------------------------------------------------------------------------- +sdbcx::ObjectType OGroups::createObject(const ::rtl::OUString& _rName) +{ + return new OAdoGroup(m_pCatalog,isCaseSensitive(),_rName); +} +// ------------------------------------------------------------------------- +void OGroups::impl_refresh() throw(RuntimeException) +{ + m_aCollection.Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OGroups::createDescriptor() +{ + return new OAdoGroup(m_pCatalog,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OGroups::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) +{ + OAdoGroup* pGroup = NULL; + if ( !getImplementation(pGroup,descriptor) || pGroup == NULL ) + m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_GROUP_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + + m_aCollection.Append( pGroup->getImpl() ); + return createObject( _rForName ); +} +// ------------------------------------------------------------------------- +// XDrop +void OGroups::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + m_aCollection.Delete(_sElementName); +} +// ----------------------------------------------------------------------------- + + + + diff --git a/connectivity/source/drivers/ado/AIndex.cxx b/connectivity/source/drivers/ado/AIndex.cxx new file mode 100644 index 000000000000..a55498494e87 --- /dev/null +++ b/connectivity/source/drivers/ado/AIndex.cxx @@ -0,0 +1,157 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AIndex.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include "ado/AColumns.hxx" +#include <comphelper/extract.hxx> +#include "TConnection.hxx" +#include <comphelper/types.hxx> + +using namespace ::comphelper; + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection,ADOIndex* _pIndex) + : OIndex_ADO(::rtl::OUString(),::rtl::OUString(),sal_False,sal_False,sal_False,_bCase) + ,m_pConnection(_pConnection) +{ + construct(); + m_aIndex = WpADOIndex(_pIndex); + fillPropertyValues(); +} +// ------------------------------------------------------------------------- +OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection) + : OIndex_ADO(_bCase) + ,m_pConnection(_pConnection) +{ + construct(); + m_aIndex.Create(); +} + +// ------------------------------------------------------------------------- + +void OAdoIndex::refreshColumns() +{ + TStringVector aVector; + + WpADOColumns aColumns; + if ( m_aIndex.IsValid() ) + { + aColumns = m_aIndex.get_Columns(); + aColumns.fillElementNames(aVector); + } + + if ( m_pColumns ) + m_pColumns->reFill(aVector); + else + m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection); +} + +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OIndex_ADO::getSomething(rId); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aIndex.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aIndex.put_Name(aVal); + } + break; + case PROPERTY_ID_CATALOG: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aIndex.put_Name(aVal); + } + break; + case PROPERTY_ID_ISUNIQUE: + m_aIndex.put_Unique(getBOOL(rValue)); + break; + case PROPERTY_ID_ISPRIMARYKEYINDEX: + m_aIndex.put_PrimaryKey(getBOOL(rValue)); + break; + case PROPERTY_ID_ISCLUSTERED: + m_aIndex.put_Clustered(getBOOL(rValue)); + break; + } + } + OIndex_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoIndex::acquire() throw() +{ + OIndex_ADO::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoIndex::release() throw() +{ + OIndex_ADO::release(); +} +// ----------------------------------------------------------------------------- + + + + diff --git a/connectivity/source/drivers/ado/AIndexes.cxx b/connectivity/source/drivers/ado/AIndexes.cxx new file mode 100644 index 000000000000..c6f6311d07ee --- /dev/null +++ b/connectivity/source/drivers/ado/AIndexes.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AIndexes.hxx" +#include "ado/AIndex.hxx" +#include "ado/AConnection.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/IndexType.hpp> +#include "TConnection.hxx" +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#include "resource/ado_res.hrc" +using namespace ::comphelper; + + +using namespace connectivity; +using namespace connectivity::ado; +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::container; + +sdbcx::ObjectType OIndexes::createObject(const ::rtl::OUString& _rName) +{ + return new OAdoIndex(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName)); +} +// ------------------------------------------------------------------------- +void OIndexes::impl_refresh() throw(RuntimeException) +{ + m_aCollection.Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OIndexes::createDescriptor() +{ + return new OAdoIndex(isCaseSensitive(),m_pConnection); +} +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) +{ + OAdoIndex* pIndex = NULL; + if ( !getImplementation(pIndex,descriptor) || pIndex == NULL ) + m_pConnection->throwGenericSQLException( STR_INVALID_INDEX_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + + ADOIndexes* pIndexes = m_aCollection; + if ( FAILED( pIndexes->Append( OLEVariant( _rForName ), OLEVariant( pIndex->getImpl() ) ) ) ) + { + ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this)); + m_pConnection->throwGenericSQLException( STR_INVALID_INDEX_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + } + + return new OAdoIndex(isCaseSensitive(),m_pConnection,pIndex->getImpl()); +} +// ------------------------------------------------------------------------- +// XDrop +void OIndexes::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + m_aCollection.Delete(_sElementName); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AKey.cxx b/connectivity/source/drivers/ado/AKey.cxx new file mode 100644 index 000000000000..f053b4a83f6c --- /dev/null +++ b/connectivity/source/drivers/ado/AKey.cxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AKey.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include "ado/AColumns.hxx" +#include "ado/AConnection.hxx" + +using namespace connectivity::ado; +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; + +// ------------------------------------------------------------------------- +OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection, ADOKey* _pKey) + : OKey_ADO(_bCase) + ,m_pConnection(_pConnection) +{ + construct(); + m_aKey = WpADOKey(_pKey); + fillPropertyValues(); +} +// ------------------------------------------------------------------------- +OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection) + : OKey_ADO(_bCase) + ,m_pConnection(_pConnection) +{ + construct(); + m_aKey.Create(); +} +// ------------------------------------------------------------------------- +void OAdoKey::refreshColumns() +{ + TStringVector aVector; + + WpADOColumns aColumns; + if ( m_aKey.IsValid() ) + { + aColumns = m_aKey.get_Columns(); + aColumns.fillElementNames(aVector); + } + + if(m_pColumns) + m_pColumns->reFill(aVector); + else + m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection); +} +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoKey::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OKey_ADO::getSomething(rId); +} +// ------------------------------------------------------------------------- +void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aKey.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aKey.put_Name(aVal); + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + } + break; + case PROPERTY_ID_TYPE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aKey.put_Type(Map2KeyRule(nVal)); + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + } + break; + case PROPERTY_ID_REFERENCEDTABLE: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aKey.put_RelatedTable(aVal); + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + } + break; + case PROPERTY_ID_UPDATERULE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aKey.put_UpdateRule(Map2Rule(nVal)); + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + } + break; + case PROPERTY_ID_DELETERULE: + { + sal_Int32 nVal=0; + rValue >>= nVal; + m_aKey.put_DeleteRule(Map2Rule(nVal)); + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + } + break; + } + } + OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue); +} +// ------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoKey::acquire() throw() +{ + OKey_ADO::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoKey::release() throw() +{ + OKey_ADO::release(); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AKeyColumn.cxx b/connectivity/source/drivers/ado/AKeyColumn.cxx new file mode 100644 index 000000000000..16870dc9edb4 --- /dev/null +++ b/connectivity/source/drivers/ado/AKeyColumn.cxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#ifndef _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_ +#include "adabas/BKeyColumn.hxx" +#endif + +using namespace connectivity::adabas; +namespace starbeans = ::com::sun::star::beans; +// ------------------------------------------------------------------------- +OKeyColumn::OKeyColumn() : OColumn() +{ + construct(); +} +// ------------------------------------------------------------------------- +OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _TypeName, + const ::rtl::OUString& _DefaultValue, + sal_Int32 _IsNullable, + sal_Int32 _Precision, + sal_Int32 _Scale, + sal_Int32 _Type, + sal_Bool _IsAutoIncrement + ) : OColumn(_Name, + _TypeName, + _DefaultValue, + _IsNullable, + _Precision, + _Scale, + _Type, + _IsAutoIncrement) + , m_ReferencedColumn(_ReferencedColumn) +{ + construct(); +} + +// ------------------------------------------------------------------------- +void OKeyColumn::construct() +{ + sal_Int32 nAttrib = isNew() ? 0 : starbeans::PropertyAttribute::READONLY; + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN), PROPERTY_ID_RELATEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + diff --git a/connectivity/source/drivers/ado/AKeyColumns.cxx b/connectivity/source/drivers/ado/AKeyColumns.cxx new file mode 100644 index 000000000000..37d8e77031e9 --- /dev/null +++ b/connectivity/source/drivers/ado/AKeyColumns.cxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "adabas/BKeyColumns.hxx" +#ifndef _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_ +#include "adabas/BKeyColumn.hxx" +#endif +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include "adabas/BTable.hxx" + +using namespace connectivity::adabas; +// ------------------------------------------------------------------------- +sdbcx::ObjectType OKeyColumns::createObject(const ::rtl::OUString& _rName) +{ + + Reference< starsdbc::XResultSet > + xResult = m_pTable->getConnection()->getMetaData()->getImportedKeys(Any(), + m_pTable->getSchema(),m_pTable->getName()); + + ::rtl::OUString aRefColumnName; + if(xResult.is()) + { + Reference< starsdbc::XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(8) == _rName) + { + aRefColumnName = xRow->getString(4); + break; + } + } + } + + xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(), + m_pTable->getSchema(),m_pTable->getName(),_rName); + + sdbcx::ObjectType xRet = NULL; + if(xResult.is()) + { + Reference< starsdbc::XRow > xRow(xResult,UNO_QUERY); + if(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + OKeyColumn* pRet = new OKeyColumn(aRefColumnName, + _rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False); + xRet = pRet; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OKeyColumns::createDescriptor() +{ + OKeyColumn* pNew = new OKeyColumn(); + return pNew; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/AKeys.cxx b/connectivity/source/drivers/ado/AKeys.cxx new file mode 100644 index 000000000000..dccf4b5a4cf5 --- /dev/null +++ b/connectivity/source/drivers/ado/AKeys.cxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AKeys.hxx" +#ifndef _CONNECTIVITY_ADO_INDEX_HXX_ +#include "ado/AKey.hxx" +#endif +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbcx/KeyType.hpp> +#include <com/sun/star/sdbc/KeyRule.hpp> +#include "ado/AConnection.hxx" +#include <comphelper/types.hxx> +#include "ado/Awrapado.hxx" +#include <comphelper/property.hxx> +#include <connectivity/dbexception.hxx> +#include "resource/ado_res.hrc" + +using namespace ::comphelper; +using namespace connectivity; +using namespace connectivity::ado; +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; +using namespace com::sun::star::container; + +sdbcx::ObjectType OKeys::createObject(const ::rtl::OUString& _rName) +{ + return new OAdoKey(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName)); +} +// ------------------------------------------------------------------------- +void OKeys::impl_refresh() throw(RuntimeException) +{ + m_aCollection.Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OKeys::createDescriptor() +{ + return new OAdoKey(isCaseSensitive(),m_pConnection); +} +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OKeys::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor ) +{ + OAdoKey* pKey = NULL; + if ( !getImplementation( pKey, descriptor ) || pKey == NULL) + m_pConnection->throwGenericSQLException( STR_INVALID_KEY_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + + // To pass as column parameter to Key's Apppend method + OLEVariant vOptional; + vOptional.setNoArg(); + +#if OSL_DEBUG_LEVEL > 0 + KeyTypeEnum eKey = +#endif + OAdoKey::Map2KeyRule(getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); +#if OSL_DEBUG_LEVEL > 0 + (void)eKey; +#endif + + WpADOKey aKey = pKey->getImpl(); + ::rtl::OUString sName = aKey.get_Name(); + if(!sName.getLength()) + aKey.put_Name(::rtl::OUString::createFromAscii("PrimaryKey") ); + + ADOKeys* pKeys = m_aCollection; + if ( FAILED(pKeys->Append(OLEVariant((ADOKey*)aKey), + adKeyPrimary, // must be every time adKeyPrimary + vOptional)) ) + { + ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this)); + // just make sure that an SQLExceptionis thrown here + m_pConnection->throwGenericSQLException( STR_INVALID_KEY_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + } + + return new OAdoKey(isCaseSensitive(),m_pConnection,pKey->getImpl()); +} +// ------------------------------------------------------------------------- +// XDrop +void OKeys::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + if(!m_aCollection.Delete(OLEVariant(_sElementName))) + ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this)); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx new file mode 100644 index 000000000000..077ab0d974c8 --- /dev/null +++ b/connectivity/source/drivers/ado/APreparedStatement.cxx @@ -0,0 +1,564 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "connectivity/sqlparse.hxx" +#include "ado/APreparedStatement.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include "ado/AResultSetMetaData.hxx" +#include "ado/AResultSet.hxx" +#include "ado/ADriver.hxx" +#include <com/sun/star/lang/DisposedException.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include "connectivity/dbexception.hxx" +#include "connectivity/dbtools.hxx" +#include "resource/ado_res.hrc" + +#include <limits> + +#define CHECK_RETURN(x) \ + if(!x) \ + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + +#ifdef max +# undef max +#endif + +//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +using namespace connectivity::ado; +using namespace connectivity; +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::util; + + +IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.APreparedStatement","com.sun.star.sdbc.PreparedStatement"); + +OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql) + : OStatement_Base( _pConnection ) + ,m_aTypeInfo(_TypeInfo) +{ + osl_incrementInterlockedCount( &m_refCount ); + + OSQLParser aParser(_pConnection->getDriver()->getORB()); + ::rtl::OUString sErrorMessage; + ::rtl::OUString sNewSql; + OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,sql); + if(pNode) + { // special handling for parameters + /* we recusive replace all occurences of ? in the statement and replace them with name like "æ¬å" */ + sal_Int32 nParameterCount = 0; + ::rtl::OUString sDefaultName = ::rtl::OUString::createFromAscii("parame"); + replaceParameterNodeName(pNode,sDefaultName,nParameterCount); + pNode->parseNodeToStr( sNewSql, _pConnection ); + delete pNode; + } + else + sNewSql = sql; + CHECK_RETURN(m_Command.put_CommandText(sNewSql)) + CHECK_RETURN(m_Command.put_Prepared(VARIANT_TRUE)) + m_pParameters = m_Command.get_Parameters(); + m_pParameters->AddRef(); + m_pParameters->Refresh(); + + 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) +{ + Any aRet = OStatement_Base::queryInterface(rType); + return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, + static_cast< XPreparedStatement*>(this), + static_cast< XParameters*>(this), + static_cast< XPreparedBatchExecution*>(this), + static_cast< XResultSetMetaDataSupplier*>(this)); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 )); + + return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_Base::getTypes()); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) +{ + if(!m_xMetaData.is() && m_RecordSet.IsValid()) + m_xMetaData = new OResultSetMetaData(m_RecordSet); + return m_xMetaData; +} +// ------------------------------------------------------------------------- +void OPreparedStatement::disposing() +{ +m_xMetaData.clear(); + if (m_pParameters) + { + m_pParameters->Release(); + m_pParameters = NULL; + } + OStatement_Base::disposing(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException) +{ + + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + } + dispose(); + +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + SQLWarning warning; + + // Reset warnings + + clearWarnings (); + + // Reset the statement handle, warning and saved Resultset + + // reset(); + + // Call SQLExecute + + try { + ADORecordset* pSet=NULL; + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet)) + m_RecordSet = WpADORecordset(pSet); + } + catch (SQLWarning& ex) + { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + warning = ex; + } + return m_RecordSet.IsValid(); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + ADORecordset* pSet=NULL; + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet)) + if ( VT_ERROR == m_RecordsAffected.getType() ) + { + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + // to be sure that we get the error really thrown + throw SQLException(); + } + m_RecordSet = WpADORecordset(pSet); + return static_cast<sal_Int32>(m_RecordsAffected); +} + +// ------------------------------------------------------------------------- +void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const DataTypeEnum& _eType, + const sal_Int32& _nSize,const OLEVariant& _Val) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + sal_Int32 nCount = 0; + m_pParameters->get_Count(&nCount); + if(nCount < (parameterIndex-1)) + { + ::rtl::OUString sDefaultName = ::rtl::OUString::createFromAscii("parame"); + sDefaultName += ::rtl::OUString::valueOf(parameterIndex); + ADOParameter* pParam = m_Command.CreateParameter(sDefaultName,_eType,adParamInput,_nSize,_Val); + if(pParam) + { + m_pParameters->Append(pParam); +#if OSL_DEBUG_LEVEL > 0 + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam); + WpADOParameter aParam(pParam); + if(pParam) + { + DataTypeEnum eType = aParam.GetADOType(); + (void)eType; + } +#endif + } + } + else + { + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam); + WpADOParameter aParam(pParam); + if(pParam) + { +#if OSL_DEBUG_LEVEL > 0 + ::rtl::OUString sParam = aParam.GetName(); + +#endif // OSL_DEBUG_LEVEL + + DataTypeEnum eType = aParam.GetADOType(); + if ( _eType != eType && _eType != adDBTimeStamp ) + { + aParam.put_Type(_eType); + eType = _eType; + aParam.put_Size(_nSize); + } + + if ( adVarBinary == eType && aParam.GetAttributes() == adParamLong ) + { + aParam.AppendChunk(_Val); + } + else + CHECK_RETURN(aParam.PutValue(_Val)); + } + } + ADOS::ThrowException(*m_pConnection->getConnection(),*this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + setParameter( parameterIndex, adLongVarWChar, ::std::numeric_limits< sal_Int32 >::max(), x ); +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + // first clear the old things +m_xMetaData.clear(); + disposeResultSet(); + if(m_RecordSet.IsValid()) + m_RecordSet.Close(); + m_RecordSet.clear(); + + + // the create the new onces + m_RecordSet.Create(); + OLEVariant aCmd; + aCmd.setIDispatch(m_Command); + OLEVariant aCon; + aCon.setNoArg(); + CHECK_RETURN(m_RecordSet.put_CacheSize(m_nFetchSize)) + CHECK_RETURN(m_RecordSet.put_MaxRecords(m_nMaxRows)) + CHECK_RETURN(m_RecordSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified)) + CHECK_RETURN(m_RecordSet.get_CacheSize(m_nFetchSize)) + CHECK_RETURN(m_RecordSet.get_MaxRecords(m_nMaxRows)) + CHECK_RETURN(m_RecordSet.get_CursorType(m_eCursorType)) + CHECK_RETURN(m_RecordSet.get_LockType(m_eLockType)) + + OResultSet* pSet = new OResultSet(m_RecordSet,this); + Reference< XResultSet > xRs = pSet; + pSet->construct(); + pSet->setMetaData(getMetaData()); + m_xResultSet = WeakReference<XResultSet>(xRs); + + return xRs; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adBoolean,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adTinyInt,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDBDate,sizeof(x),x); +} +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDBTime,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDBTimeStamp,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adDouble,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adSingle,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adInteger,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adBigInt,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException) +{ + OLEVariant aVal; + aVal.setNull(); + setParameter(parameterIndex,adEmpty,0,aVal); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setClob", *this ); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setBlob", *this ); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setArray", *this ); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setRef", *this ); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) +{ + switch(sqlType) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + setString(parameterIndex,::comphelper::getString(x)); + break; + default: + ::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale); + break; + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException) +{ + setNull(parameterIndex,sqlType); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + if(!::dbtools::implSetObject(this,parameterIndex,x)) + { + const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution( + STR_UNKNOWN_PARA_TYPE, + "$position$", ::rtl::OUString::valueOf(parameterIndex) + ) ); + ::dbtools::throwGenericSQLException(sError,*this); + } + // setObject (parameterIndex, x, sqlType, 0); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adSmallInt,sizeof(x),x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + setParameter(parameterIndex,adVarBinary,sizeof(sal_Int8)*x.getLength(),x); +} + +// ------------------------------------------------------------------------- + + +void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XParameters::setCharacterStream", *this ); +} + +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + if(x.is()) + { + Sequence< sal_Int8 > aData; + x->readBytes(aData,length); + setBytes(parameterIndex,aData); + } +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + if(m_pParameters) + { + sal_Int32 nCount = 0; + m_pParameters->get_Count(&nCount); + OLEVariant aVal; + aVal.setEmpty(); + for(sal_Int32 i=0;i<nCount;++i) + { + ADOParameter* pParam = NULL; + m_pParameters->get_Item(OLEVariant(i),&pParam); + WpADOParameter aParam(pParam); + if(pParam) + { + ::rtl::OUString sParam = aParam.GetName(); + CHECK_RETURN(aParam.PutValue(aVal)); + } + } + // m_pParameters->Delete(OLEVariant(i)); + + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException) +{ + // clearParameters( ); + // m_aBatchList.erase(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException) +{ + return Sequence< sal_Int32 > (); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::acquire() throw() +{ + OStatement_Base::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OPreparedStatement::release() throw() +{ + OStatement_Base::release(); +} +// ----------------------------------------------------------------------------- +void OPreparedStatement::replaceParameterNodeName(OSQLParseNode* _pNode, + const ::rtl::OUString& _sDefaultName, + sal_Int32& _rParameterCount) +{ + sal_Int32 nCount = _pNode->count(); + for(sal_Int32 i=0;i < nCount;++i) + { + OSQLParseNode* pChildNode = _pNode->getChild(i); + if(SQL_ISRULE(pChildNode,parameter) && pChildNode->count() == 1) + { + OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString::createFromAscii(":") ,SQL_NODE_PUNCTUATION,0); + delete pChildNode->replace(pChildNode->getChild(0),pNewNode); + ::rtl::OUString sParameterName = _sDefaultName; + sParameterName += ::rtl::OUString::valueOf(++_rParameterCount); + pChildNode->append(new OSQLParseNode( sParameterName,SQL_NODE_NAME,0)); + } + else + replaceParameterNodeName(pChildNode,_sDefaultName,_rParameterCount); + + } +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx new file mode 100644 index 000000000000..0c5db12c3355 --- /dev/null +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -0,0 +1,1173 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AResultSet.hxx" +#include "ado/AResultSetMetaData.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/KeyRule.hpp> +#include <com/sun/star/sdbc/IndexType.hpp> +#include <comphelper/property.hxx> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/FetchDirection.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <comphelper/seqstream.hxx> +#include "connectivity/dbexception.hxx" +#include "connectivity/dbtools.hxx" +#include <comphelper/types.hxx> + +using namespace ::comphelper; + + +#include <oledb.h> + +#define CHECK_RETURN(x) \ + if(!SUCCEEDED(x)) \ + ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this); + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +//------------------------------------------------------------------------------ +// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.AResultSet","com.sun.star.sdbc.ResultSet"); +::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \ +{ + return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ado.ResultSet"); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2); + aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); + aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet"); + return aSupported; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); + for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) + ; + + return pSupported != pEnd; +} +// ------------------------------------------------------------------------- +OResultSet::OResultSet(ADORecordset* _pRecordSet,OStatement_Base* pStmt) : OResultSet_BASE(m_aMutex) + ,OPropertySetHelper(OResultSet_BASE::rBHelper) + ,m_xStatement(*pStmt) + ,m_pStmt(pStmt) + ,m_nRowPos(0) + ,m_xMetaData(NULL) + ,m_pRecordSet(_pRecordSet) + ,m_bEOF(sal_False) +{ +} +// ------------------------------------------------------------------------- +OResultSet::OResultSet(ADORecordset* _pRecordSet) : OResultSet_BASE(m_aMutex) + ,OPropertySetHelper(OResultSet_BASE::rBHelper) + ,m_xStatement(NULL) + ,m_xMetaData(NULL) + ,m_pRecordSet(_pRecordSet) + ,m_bEOF(sal_False) +{ +} +// ----------------------------------------------------------------------------- +void OResultSet::construct() +{ + osl_incrementInterlockedCount( &m_refCount ); + 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)) + m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE; + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +OResultSet::~OResultSet() +{ + if(m_pRecordSet) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +void OResultSet::disposing(void) +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + if(m_pRecordSet) + m_pRecordSet->Close(); +m_xStatement.clear(); +m_xMetaData.clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); +} + +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + sal_Int32 i = 1; + for(;i<=nLen;++i) + if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : + columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) + break; + return i; +} +#define BLOCK_SIZE 256 +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); + + if((aField.GetAttributes() & adFldLong) == adFldLong) + { + //Copy the data only upto the Actual Size of Field. + sal_Int32 nSize = aField.GetActualSize(); + Sequence<sal_Int8> aData(nSize); + long index = 0; + while(index < nSize) + { + m_aValue = aField.GetChunk(BLOCK_SIZE); + if(m_aValue.isNull()) + break; + UCHAR chData; + for(long index2 = 0;index2 < BLOCK_SIZE;++index2) + { + HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData); + if(SUCCEEDED(hr)) + { + //Take BYTE by BYTE and advance Memory Location + aData.getArray()[index++] = chData; + } + else + break; + } + } + + return new ::comphelper::SequenceInputStream(aData); + } + // else we ask for a bytesequence + aField.get_Value(m_aValue); + + return m_aValue.isNull() ? NULL : new ::comphelper::SequenceInputStream(m_aValue); +} +// ------------------------------------------------------------------------- +Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this ); + return NULL; +} +// ----------------------------------------------------------------------------- +OLEVariant OResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); + aField.get_Value(m_aValue); + return m_aValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + PositionEnum aPos; + m_pRecordSet->get_AbsolutePosition(&aPos); + return (aPos > 0) ? aPos : m_nRowPos; + // return the rowcount from driver if the driver doesn't support this return our count +} +// ------------------------------------------------------------------------- + +sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this ); + return sal_Int64(0); +} +// ------------------------------------------------------------------------- + +Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + if(!m_xMetaData.is()) + m_xMetaData = new OResultSetMetaData(m_pRecordSet); + return m_xMetaData; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this ); + return NULL; +} + +// ------------------------------------------------------------------------- + +Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this ); + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this ); + return NULL; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex).makeAny(); +} +// ------------------------------------------------------------------------- + +sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} + +// ------------------------------------------------------------------------- + + +::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + + +::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + return getValue(columnIndex); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + VARIANT_BOOL bIsAtEOF; + CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF)) + return bIsAtEOF == VARIANT_TRUE; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + return m_nRowPos == 1; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + return sal_True; +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + if(first()) + previous(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + if(last()) + next(); + m_bEOF = sal_True; +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + } + dispose(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + if(SUCCEEDED(m_pRecordSet->MoveFirst())) + { + m_nRowPos = 1; + m_bOnFirstAfterOpen = sal_False; + return sal_True; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveLast()); + if(bRet) + { + m_pRecordSet->get_RecordCount(&m_nRowPos); + m_bOnFirstAfterOpen = sal_False; + } + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + if(!row) // absolute with zero not allowed + ::dbtools::throwFunctionSequenceException(*this); + + sal_Bool bCheck = sal_True; + if(row < 0) + { + bCheck = SUCCEEDED(m_pRecordSet->MoveLast()); + if ( bCheck ) + { + while(++row < 0 && bCheck) + bCheck = SUCCEEDED(m_pRecordSet->MovePrevious()); + } + } + else + { + first(); + OLEVariant aEmpty; + aEmpty.setNoArg(); + bCheck = SUCCEEDED(m_pRecordSet->Move(row-1,aEmpty)); // move to row -1 because we stand already on the first + if(bCheck) + m_nRowPos = row; + } + if(bCheck) + m_bOnFirstAfterOpen = sal_False; + return bCheck; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + OLEVariant aEmpty; + aEmpty.setNoArg(); + sal_Int32 nNewPos = row; + if ( m_bOnFirstAfterOpen && nNewPos > 0 ) + --nNewPos; + sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty)); + if(bRet) + { + m_nRowPos += row; + m_bOnFirstAfterOpen = sal_False; + } + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious()); + if(bRet) + { + --m_nRowPos; + m_bOnFirstAfterOpen = sal_False; + } + return bRet; +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + return m_xStatement; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + sal_Bool bRet = (eRec & adRecDeleted) == adRecDeleted; + if(bRet) + --m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) +{ ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + sal_Bool bRet = (eRec & adRecNew) == adRecNew; + if(bRet) + ++m_nRowPos; + return bRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + RecordStatusEnum eRec; + m_pRecordSet->get_Status((sal_Int32*)&eRec); + return (eRec & adRecModified) == adRecModified; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + OSL_ENSURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!"); + VARIANT_BOOL bIsAtBOF = VARIANT_TRUE; + if(!m_bOnFirstAfterOpen) + { + OSL_ENSURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!"); + m_pRecordSet->get_BOF(&bIsAtBOF); + } + return bIsAtBOF == VARIANT_TRUE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + sal_Bool bRet = sal_True; + if(m_bOnFirstAfterOpen) + { + m_bOnFirstAfterOpen = sal_False; + ++m_nRowPos; + } + else + { + bRet = SUCCEEDED(m_pRecordSet->MoveNext()); + + if(bRet) + { + VARIANT_BOOL bIsAtEOF; + CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF)) + bRet = bIsAtEOF != VARIANT_TRUE; + ++m_nRowPos; + } + else + ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this); + } + + return bRet; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + return m_aValue.isNull(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_pRecordSet->Cancel(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException) +{ + return Any(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + OLEVariant aEmpty; + aEmpty.setNoArg(); + m_pRecordSet->AddNew(aEmpty,aEmpty); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + OLEVariant aEmpty; + aEmpty.setNoArg(); + m_pRecordSet->Update(aEmpty,aEmpty); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_pRecordSet->Delete(adAffectCurrent); + m_pRecordSet->UpdateBatch(adAffectCurrent); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_pRecordSet->CancelUpdate(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) +{ + // ::osl::MutexGuard aGuard( m_aMutex ); + //checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + // if ( getResultSetConcurrency() == ResultSetConcurrency::READ_ONLY ) + // throw SQLException(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) +{ +} +// ----------------------------------------------------------------------------- +void OResultSet::updateValue(sal_Int32 columnIndex,const OLEVariant& x) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex); + aField.PutValue(x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +{ + OLEVariant x; + x.setNull(); + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ----------------------------------------------------------------------- +void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) +{ + updateValue(columnIndex,x); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + if(!x.is()) + ::dbtools::throwFunctionSequenceException(*this); + + Sequence<sal_Int8> aSeq; + x->readBytes(aSeq,length); + updateBytes(columnIndex,aSeq); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) +{ + if(!x.is()) + ::dbtools::throwFunctionSequenceException(*this); + + Sequence<sal_Int8> aSeq; + x->readBytes(aSeq,length); + updateBytes(columnIndex,aSeq); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues); +} +// ------------------------------------------------------------------------- +void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) +{ + if (!::dbtools::implUpdateObject(this, columnIndex, x)) + throw SQLException(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException) +{ + if (!::dbtools::implUpdateObject(this, columnIndex, x)) + throw SQLException(); +} +//------------------------------------------------------------------------------ +// XRowLocate +Any SAL_CALL OResultSet::getBookmark( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + if(m_nRowPos < (sal_Int32)m_aBookmarks.size()) // this bookmark was already fetched + return makeAny(sal_Int32(m_nRowPos-1)); + + OLEVariant aVar; + m_pRecordSet->get_Bookmark(&aVar); + m_aBookmarks.push_back(aVar); + return makeAny((sal_Int32)(m_aBookmarks.size()-1)); + +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + sal_Int32 nPos; + bookmark >>= nPos; + OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector"); + if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size()) + ::dbtools::throwFunctionSequenceException(*this); + + return SUCCEEDED(m_pRecordSet->Move(0,m_aBookmarks[nPos])); +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + sal_Int32 nPos; + bookmark >>= nPos; + nPos += rows; + OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector"); + if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size()) + ::dbtools::throwFunctionSequenceException(*this); + return SUCCEEDED(m_pRecordSet->Move(rows,m_aBookmarks[nPos])); +} +//------------------------------------------------------------------------------ +sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& first, const Any& second ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nPos1; + first >>= nPos1; + sal_Int32 nPos2; + second >>= nPos2; + if(nPos1 == nPos2) // they should be equal + return sal_True; + + OSL_ENSURE((nPos1 >= 0 && nPos1 < (sal_Int32)m_aBookmarks.size()) || (nPos1 >= 0 && nPos2 < (sal_Int32)m_aBookmarks.size()),"Invalid Index for vector"); + + CompareEnum eNum; + m_pRecordSet->CompareBookmarks(m_aBookmarks[nPos1],m_aBookmarks[nPos2],&eNum); + return ((sal_Int32)eNum) +1; +} +//------------------------------------------------------------------------------ +sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + ADOProperties* pProps = NULL; + m_pRecordSet->get_Properties(&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"); + + WpADOProperty aProp(aProps.GetItem(::rtl::OUString::createFromAscii("Bookmarks Ordered"))); + OLEVariant aVar; + if(aProp.IsValid()) + aVar = aProp.GetValue(); + else + ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this); + + sal_Bool bValue(sal_False); + if(!aVar.isNull() && !aVar.isEmpty()) + bValue = aVar; + return bValue; +} +//------------------------------------------------------------------------------ +sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + sal_Int32 nPos; + bookmark >>= nPos; + return nPos; +} +//------------------------------------------------------------------------------ +// XDeleteRows +Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); + + + OLEVariant aVar; + sal_Int32 nPos; + + // Create SafeArray Bounds and initialize the array + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = rows.getLength(); + SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + const Any* pBegin = rows.getConstArray(); + const Any* pEnd = pBegin + rows.getLength(); + for(sal_Int32 i=0;pBegin != pEnd ;++pBegin,++i) + { + *pBegin >>= nPos; + SafeArrayPutElement(psa,&i,&m_aBookmarks[nPos]); + } + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + m_pRecordSet->put_Filter(vsa); + m_pRecordSet->Delete(adAffectGroup); + m_pRecordSet->UpdateBatch(adAffectGroup); + + Sequence< sal_Int32 > aSeq(rows.getLength()); + if(first()) + { + sal_Int32* pSeq = aSeq.getArray(); + sal_Int32 i=0; + do + { + OSL_ENSURE(i<aSeq.getLength(),"Index greater than length of sequence"); + m_pRecordSet->get_Status(&pSeq[i]); + if(pSeq[i++] == adRecDeleted) + --m_nRowPos; + } + while(next()); + } + return aSeq; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getResultSetConcurrency() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nValue=ResultSetConcurrency::READ_ONLY; + LockTypeEnum eRet; + if(!SUCCEEDED(m_pRecordSet->get_LockType(&eRet))) + { + switch(eRet) + { + case adLockReadOnly: + nValue = ResultSetConcurrency::READ_ONLY; + break; + default: + nValue = ResultSetConcurrency::UPDATABLE; + break; + } + } + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getResultSetType() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nValue=0; + CursorTypeEnum eRet; + if(!SUCCEEDED(m_pRecordSet->get_CursorType(&eRet))) + { + switch(eRet) + { + case adOpenUnspecified: + case adOpenForwardOnly: + nValue = ResultSetType::FORWARD_ONLY; + break; + case adOpenStatic: + case adOpenKeyset: + nValue = ResultSetType::SCROLL_INSENSITIVE; + break; + case adOpenDynamic: + nValue = ResultSetType::SCROLL_SENSITIVE; + break; + } + } + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getFetchDirection() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return FetchDirection::FORWARD; +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getFetchSize() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nValue=-1; + m_pRecordSet->get_CacheSize(&nValue); + return nValue; +} +//------------------------------------------------------------------------------ +::rtl::OUString OResultSet::getCursorName() const + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return ::rtl::OUString(); +} + +//------------------------------------------------------------------------------ +void OResultSet::setFetchDirection(sal_Int32 /*_par0*/) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this ); +} +//------------------------------------------------------------------------------ +void OResultSet::setFetchSize(sal_Int32 _par0) + throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + m_pRecordSet->put_CacheSize(_par0); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const +{ + Sequence< com::sun::star::beans::Property > aProps(5); + com::sun::star::beans::Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + + // DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY); + DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY); + + return new ::cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OResultSet::getInfoHelper() +{ + return *const_cast<OResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool OResultSet::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw ::com::sun::star::lang::IllegalArgumentException(); + break; + case PROPERTY_ID_FETCHDIRECTION: + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + case PROPERTY_ID_FETCHSIZE: + return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + default: + ; + } + return sal_False; +} +// ------------------------------------------------------------------------- +void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + throw Exception(); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(getINT32(rValue)); + break; + default: + ; + } +} +// ------------------------------------------------------------------------- +void OResultSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + switch(nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + { + VARIANT_BOOL bBool; + m_pRecordSet->Supports(adBookmark,&bBool); + sal_Bool bRet = bBool == VARIANT_TRUE; + rValue.setValue(&bRet, ::getCppuBooleanType() ); + } + break; + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL OResultSet::acquire() throw() +{ + OResultSet_BASE::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OResultSet::release() throw() +{ + OResultSet_BASE::release(); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} +// ----------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/ado/AResultSetMetaData.cxx b/connectivity/source/drivers/ado/AResultSetMetaData.cxx new file mode 100644 index 000000000000..41f8b6f45b75 --- /dev/null +++ b/connectivity/source/drivers/ado/AResultSetMetaData.cxx @@ -0,0 +1,262 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AResultSetMetaData.hxx" +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include "ado/Awrapado.hxx" +#include "connectivity/dbexception.hxx" + +using namespace connectivity; +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +OResultSetMetaData::OResultSetMetaData( ADORecordset* _pRecordSet) + : m_pRecordSet(_pRecordSet), + m_nColCount(-1) +{ + if ( m_pRecordSet ) + m_pRecordSet->AddRef(); +} +// ------------------------------------------------------------------------- +OResultSetMetaData::~OResultSetMetaData() +{ + if ( m_pRecordSet ) + m_pRecordSet->Release(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid() && aField.GetActualSize() != -1) + return aField.GetActualSize(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + return ADOS::MapADOType2Jdbc(aField.GetADOType()); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) +{ + if(m_nColCount != -1 ) + return m_nColCount; + + if ( !m_pRecordSet ) + return 0; + + ADOFields* pFields = NULL; + m_pRecordSet->get_Fields(&pFields); + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields); + m_nColCount = aFields.GetItemCount(); + return m_nColCount; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + sal_Bool bRet = sal_False; + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if ( aField.IsValid() ) + { + WpADOProperties aProps( aField.get_Properties() ); + if ( aProps.IsValid() ) + bRet = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ISCASESENSITIVE")) ); + } + return bRet; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + return aField.GetName(); + + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString sTableName; + + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if ( aField.IsValid() ) + { + WpADOProperties aProps( aField.get_Properties() ); + if ( aProps.IsValid() ) + sTableName = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BASETABLENAME")) ); + } + return sTableName; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return getColumnName(column); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + { + return ((aField.GetAttributes() & adFldFixed) == adFldFixed) && (aField.GetADOType() == adCurrency); + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + sal_Bool bRet = sal_False; + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if ( aField.IsValid() ) + { + WpADOProperties aProps( aField.get_Properties() ); + if ( aProps.IsValid() ) + { + bRet = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ISAUTOINCREMENT")) ); +#if OSL_DEBUG_LEVEL > 0 + sal_Int32 nCount = aProps.GetItemCount(); + for (sal_Int32 i = 0; i<nCount; ++i) + { + WpADOProperty aProp = aProps.GetItem(i); + ::rtl::OUString sName = aProp.GetName(); + ::rtl::OUString sVal = aProp.GetValue(); + } +#endif + } + } + return bRet; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + { + DataTypeEnum eType = aField.GetADOType(); + return !(eType == adUnsignedBigInt || eType == adUnsignedInt || eType == adUnsignedSmallInt || eType == adUnsignedTinyInt); + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + return aField.GetPrecision(); + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + return aField.GetNumericScale(); + return 0; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldIsNullable) == adFldIsNullable; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + { + // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly; + } + return sal_False; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + WpADOField aField = ADOS::getField(m_pRecordSet,column); + if(aField.IsValid()) + { + return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable; + } + return sal_False; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) +{ + return isDefinitelyWritable(column); +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx new file mode 100644 index 000000000000..27491954ad41 --- /dev/null +++ b/connectivity/source/drivers/ado/AStatement.cxx @@ -0,0 +1,841 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AStatement.hxx" +#include "ado/AConnection.hxx" +#include "ado/AResultSet.hxx" +#include <comphelper/property.hxx> +#include <comphelper/uno3.hxx> +#include <osl/thread.h> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/FetchDirection.hpp> +#include "connectivity/dbexception.hxx" +#include <comphelper/types.hxx> + +#undef max + +#include <algorithm> + +using namespace ::comphelper; + +#define CHECK_RETURN(x) \ + if(!x) \ + ADOS::ThrowException(*m_pConnection->getConnection(),*this); + + + +using namespace connectivity::ado; + +//------------------------------------------------------------------------------ +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 ::std; +//------------------------------------------------------------------------------ +OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex) + ,OPropertySetHelper(OStatement_BASE::rBHelper) + ,OSubComponent<OStatement_Base, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this) + ,m_pConnection(_pConnection) + ,m_nFetchSize(1) + ,m_nMaxRows(0) + ,m_eLockType(adLockReadOnly) + ,m_eCursorType(adOpenForwardOnly) +{ + osl_incrementInterlockedCount( &m_refCount ); + + 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(); + + m_pConnection->acquire(); + + osl_decrementInterlockedCount( &m_refCount ); +} +//------------------------------------------------------------------------------ +void OStatement_Base::disposeResultSet() +{ + // free the cursor if alive + Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + m_xResultSet = Reference< XResultSet>(); +} + +//------------------------------------------------------------------------------ +void OStatement_Base::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + + 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) + m_pConnection->release(); + + dispose_ChildImpl(); + OStatement_BASE::disposing(); +} +//----------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::release() throw() +{ + relase_ChildImpl(); +} +//----------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = OStatement_BASE::queryInterface(rType); + return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), + ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); + + return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); +} + +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + CHECK_RETURN(m_Command.Cancel()) +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + } + dispose(); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException) +{ + +} +// ------------------------------------------------------------------------- + +void OStatement_Base::reset() throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + clearWarnings (); + + if (m_xResultSet.get().is()) + clearMyResultSet(); +} +//-------------------------------------------------------------------- +// clearMyResultSet +// If a ResultSet was created for this Statement, close it +//-------------------------------------------------------------------- + +void OStatement_Base::clearMyResultSet () throw (SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + try + { + Reference<XCloseable> xCloseable; + if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) ) + xCloseable->close(); + } + catch( const DisposedException& ) { } + + m_xResultSet = Reference< XResultSet >(); +} +//-------------------------------------------------------------------- +sal_Int32 OStatement_Base::getRowCount () throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + return m_RecordsAffected; +} +//-------------------------------------------------------------------- +// getPrecision +// Given a SQL type, return the maximum precision for the column. +// Returns -1 if not known +//-------------------------------------------------------------------- + +sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + sal_Int32 prec = -1; + OTypeInfo aInfo; + aInfo.nType = (sal_Int16)sqlType; + if (!m_aTypeInfo.empty()) + { + ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo); + for(;aIter != m_aTypeInfo.end();++aIter) + { + prec = ::std::max(prec,(*aIter).nPrecision); + } + } + + return prec; +} +//-------------------------------------------------------------------- +// setWarning +// Sets the warning +//-------------------------------------------------------------------- + +void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + 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 ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + // Reset the statement handle and warning + + reset(); + + try + { + ADORecordset* pSet = NULL; + CHECK_RETURN(m_Command.put_CommandText(sql)) + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet)) + + assignRecordSet( pSet ); + } + catch (SQLWarning& ex) + { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + m_aLastWarning = ex; + } + + return m_RecordSet.IsValid(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + reset(); + + m_xResultSet = WeakReference<XResultSet>(NULL); + + WpADORecordset aSet; + aSet.Create(); + CHECK_RETURN(m_Command.put_CommandText(sql)) + OLEVariant aCmd; + aCmd.setIDispatch(m_Command); + OLEVariant aCon; + aCon.setNoArg(); + CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize)) + CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows)) + CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified)) + + + CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize)) + CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows)) + CHECK_RETURN(aSet.get_CursorType(m_eCursorType)) + CHECK_RETURN(aSet.get_LockType(m_eLockType)) + + OResultSet* pSet = new OResultSet(aSet,this); + Reference< XResultSet > xRs = pSet; + pSet->construct(); + + m_xResultSet = WeakReference<XResultSet>(xRs); + + return xRs; +} +// ------------------------------------------------------------------------- + +Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + return (Reference< XConnection >)m_pConnection; +} +// ------------------------------------------------------------------------- + +Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); + return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType); +} +// ------------------------------------------------------------------------- + +void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + m_aBatchList.push_back(sql); +} +// ------------------------------------------------------------------------- +Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + reset(); + + ::rtl::OUString aBatchSql; + sal_Int32 nLen = 0; + for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen) + aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";"); + + + if ( m_RecordSet.IsValid() ) + m_RecordSet.PutRefDataSource( NULL ); + m_RecordSet.clear(); + m_RecordSet.Create(); + + CHECK_RETURN(m_Command.put_CommandText(aBatchSql)) + 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) + { + pSet = NULL; + OLEVariant aRecordsAffected; + if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) + { + assignRecordSet( pSet ); + + sal_Int32 nValue; + if(m_RecordSet.get_RecordCount(nValue)) + pArray[j] = nValue; + } + } + return aRet; +} +// ------------------------------------------------------------------------- + + +sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + reset(); + + try { + ADORecordset* pSet = NULL; + CHECK_RETURN(m_Command.put_CommandText(sql)) + CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet)) + } + catch (SQLWarning& ex) { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + m_aLastWarning = ex; + } + if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR) + return m_RecordsAffected; + + return 0; +} +// ------------------------------------------------------------------------- + +Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + return m_xResultSet; +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + sal_Int32 nRet; + if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet)) + return nRet; + return -1; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + SQLWarning warning; + + // clear previous warnings + + clearWarnings (); + + // Call SQLMoreResults + + try + { + ADORecordset* pSet=NULL; + OLEVariant aRecordsAffected; + if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet) + assignRecordSet( pSet ); + } + catch (SQLWarning &ex) + { + + // Save pointer to warning and save with ResultSet + // object once it is created. + + warning = ex; + } + return m_RecordSet.IsValid(); +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + return makeAny(m_aLastWarning); +} +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + m_aLastWarning = SQLWarning(); +} +// ------------------------------------------------------------------------- +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getQueryTimeOut() const throw(SQLException, RuntimeException) +{ + return m_Command.get_CommandTimeout(); +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException) +{ + sal_Int32 nRet=-1; + if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet))) + ::dbtools::throwFunctionSequenceException(NULL); + return nRet; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException) +{ + return m_eLockType; + sal_Int32 nValue=0; + switch(m_eLockType) + { + case adLockReadOnly: + nValue = ResultSetConcurrency::READ_ONLY; + break; + default: + nValue = ResultSetConcurrency::UPDATABLE; + break; + } + + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException) +{ + sal_Int32 nValue=0; + switch(m_eCursorType) + { + case adOpenUnspecified: + case adOpenForwardOnly: + nValue = ResultSetType::FORWARD_ONLY; + break; + case adOpenStatic: + case adOpenKeyset: + nValue = ResultSetType::SCROLL_INSENSITIVE; + break; + case adOpenDynamic: + nValue = ResultSetType::SCROLL_SENSITIVE; + break; + } + return nValue; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException) +{ + return FetchDirection::FORWARD; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException) +{ + return m_nFetchSize; +} +//------------------------------------------------------------------------------ +sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException) +{ + return 0; +} +//------------------------------------------------------------------------------ +::rtl::OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException) +{ + return m_Command.GetName(); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + m_Command.put_CommandTimeout(seconds); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + m_nMaxRows = _par0; +} +//------------------------------------------------------------------------------ +void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + switch(_par0) + { + case ResultSetConcurrency::READ_ONLY: + m_eLockType = adLockReadOnly; + break; + default: + m_eLockType = adLockOptimistic; + break; + } +} +//------------------------------------------------------------------------------ +void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + switch(_par0) + { + case ResultSetType::FORWARD_ONLY: + m_eCursorType = adOpenForwardOnly; + break; + case ResultSetType::SCROLL_INSENSITIVE: + m_eCursorType = adOpenKeyset; + break; + case ResultSetType::SCROLL_SENSITIVE: + m_eCursorType = adOpenDynamic; + break; + } +} +//------------------------------------------------------------------------------ +void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + ::dbtools::throwFeatureNotImplementedException( "Statement::FetchDirection", *this ); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + + m_nFetchSize = _par0; + // m_RecordSet.put_CacheSize(_par0); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + ::dbtools::throwFeatureNotImplementedException( "Statement::MaxFieldSize", *this ); +} +//------------------------------------------------------------------------------ +void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OStatement_BASE::rBHelper.bDisposed); + + m_Command.put_Name(_par0); +} + +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const +{ + Sequence< com::sun::star::beans::Property > aProps(10); + com::sun::star::beans::Property* pProperties = aProps.getArray(); + sal_Int32 nPos = 0; + DECL_PROP0(CURSORNAME, ::rtl::OUString); + DECL_BOOL_PROP0(ESCAPEPROCESSING); + DECL_PROP0(FETCHDIRECTION,sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP0(MAXFIELDSIZE,sal_Int32); + DECL_PROP0(MAXROWS, sal_Int32); + DECL_PROP0(QUERYTIMEOUT,sal_Int32); + DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); + DECL_PROP0(RESULTSETTYPE,sal_Int32); + DECL_BOOL_PROP0(USEBOOKMARKS); + + + return new ::cppu::OPropertyArrayHelper(aProps); +} + +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() +{ + return *const_cast<OStatement_Base*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool OStatement_Base::convertFastPropertyValue( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) +{ + sal_Bool bModified = sal_False; + + sal_Bool bValidAdoRS = m_RecordSet.IsValid(); + // some of the properties below, when set, are remembered in a member, and applied in the next execute + // For these properties, the record set does not need to be valid to allow setting them. + // For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid. + + try + { + switch(nHandle) + { + case PROPERTY_ID_MAXROWS: + bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows ); + break; + + case PROPERTY_ID_RESULTSETTYPE: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType()); + break; + case PROPERTY_ID_FETCHSIZE: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency()); + break; + case PROPERTY_ID_QUERYTIMEOUT: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut()); + break; + case PROPERTY_ID_MAXFIELDSIZE: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize()); + break; + case PROPERTY_ID_CURSORNAME: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName()); + break; + case PROPERTY_ID_FETCHDIRECTION: + bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); + break; + } + } + catch( const Exception& e ) + { + bModified = sal_True; // will ensure that the property is set + OSL_ENSURE( sal_False, "OStatement_Base::convertFastPropertyValue: caught something strange!" ); + (void)e; + } + return bModified; +} +// ------------------------------------------------------------------------- +void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + setQueryTimeOut(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_MAXFIELDSIZE: + setMaxFieldSize(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_MAXROWS: + setMaxRows(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_CURSORNAME: + setCursorName(comphelper::getString(rValue)); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + setResultSetConcurrency(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_RESULTSETTYPE: + setResultSetType(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHDIRECTION: + setFetchDirection(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_FETCHSIZE: + setFetchSize(comphelper::getINT32(rValue)); + break; + case PROPERTY_ID_ESCAPEPROCESSING: + // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + case PROPERTY_ID_USEBOOKMARKS: + // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); + default: + ; + } +} +// ------------------------------------------------------------------------- +void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + switch(nHandle) + { + case PROPERTY_ID_QUERYTIMEOUT: + rValue <<= getQueryTimeOut(); + break; + case PROPERTY_ID_MAXFIELDSIZE: + rValue <<= getMaxFieldSize(); + break; + case PROPERTY_ID_MAXROWS: + rValue <<= getMaxRows(); + break; + case PROPERTY_ID_CURSORNAME: + rValue <<= getCursorName(); + break; + case PROPERTY_ID_RESULTSETCONCURRENCY: + rValue <<= getResultSetConcurrency(); + break; + case PROPERTY_ID_RESULTSETTYPE: + rValue <<= getResultSetType(); + break; + case PROPERTY_ID_FETCHDIRECTION: + rValue <<= getFetchDirection(); + break; + case PROPERTY_ID_FETCHSIZE: + rValue <<= getFetchSize(); + break; + case PROPERTY_ID_ESCAPEPROCESSING: + rValue <<= sal_True; + break; + case PROPERTY_ID_USEBOOKMARKS: + default: + ; + } +} +// ------------------------------------------------------------------------- +OStatement::~OStatement() +{ +} +IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement"); +// ----------------------------------------------------------------------------- +void SAL_CALL OStatement_Base::acquire() throw() +{ + OStatement_BASE::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStatement::acquire() throw() +{ + OStatement_Base::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OStatement::release() throw() +{ + OStatement_Base::release(); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx new file mode 100644 index 000000000000..2450ec6f969d --- /dev/null +++ b/connectivity/source/drivers/ado/ATable.cxx @@ -0,0 +1,257 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ATable.hxx" +#include "ado/AIndexes.hxx" +#include "ado/AColumns.hxx" +#include "ado/AColumn.hxx" +#include "ado/AKeys.hxx" +#include "ado/AConnection.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbcx/KeyType.hpp> +#include <com/sun/star/sdbc/KeyRule.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include "ado/Awrapado.hxx" +#include <comphelper/sequence.hxx> +#include "TConnection.hxx" +#include <comphelper/types.hxx> + +using namespace ::comphelper; + +using namespace connectivity; +using namespace connectivity::ado; +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::container; +using namespace com::sun::star::lang; + +// ------------------------------------------------------------------------- +OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable) + : OTable_TYPEDEF(_pTables,_bCase,::rtl::OUString(),::rtl::OUString()) + ,m_pCatalog(_pCatalog) +{ + construct(); + m_aTable = WpADOTable(_pTable); + // m_aTable.putref_ParentCatalog(_pCatalog->getCatalog()); + fillPropertyValues(); + +} +// ----------------------------------------------------------------------------- +OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog) + : OTable_TYPEDEF(_pTables,_bCase) + ,m_pCatalog(_pCatalog) +{ + construct(); + m_aTable.Create(); + m_aTable.putref_ParentCatalog(_pCatalog->getCatalog()); + +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoTable::disposing(void) +{ + OTable_TYPEDEF::disposing(); + m_aTable.clear(); +} +// ------------------------------------------------------------------------- +void OAdoTable::refreshColumns() +{ + TStringVector aVector; + + WpADOColumns aColumns; + if ( m_aTable.IsValid() ) + { + aColumns = m_aTable.get_Columns(); + aColumns.fillElementNames(aVector); + } + + if(m_pColumns) + m_pColumns->reFill(aVector); + else + m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pCatalog->getConnection()); +} +// ------------------------------------------------------------------------- +void OAdoTable::refreshKeys() +{ + TStringVector aVector; + + WpADOKeys aKeys; + if(m_aTable.IsValid()) + { + aKeys = m_aTable.get_Keys(); + aKeys.fillElementNames(aVector); + } + + if(m_pKeys) + m_pKeys->reFill(aVector); + else + m_pKeys = new OKeys(*this,m_aMutex,aVector,aKeys,isCaseSensitive(),m_pCatalog->getConnection()); +} +// ------------------------------------------------------------------------- +void OAdoTable::refreshIndexes() +{ + TStringVector aVector; + + WpADOIndexes aIndexes; + if(m_aTable.IsValid()) + { + aIndexes = m_aTable.get_Indexes(); + aIndexes.fillElementNames(aVector); + } + + if(m_pIndexes) + m_pIndexes->reFill(aVector); + else + m_pIndexes = new OIndexes(*this,m_aMutex,aVector,aIndexes,isCaseSensitive(),m_pCatalog->getConnection()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OTable_TYPEDEF::getSomething(rId); +} +// ------------------------------------------------------------------------- +// XRename +void SAL_CALL OAdoTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed); + + m_aTable.put_Name(newName); + ADOS::ThrowException(*(m_pCatalog->getConnection()->getConnection()),*this); + + OTable_TYPEDEF::rename(newName); +} +// ----------------------------------------------------------------------------- +Reference< XDatabaseMetaData> OAdoTable::getMetaData() const +{ + return m_pCatalog->getConnection()->getMetaData(); +} +// ------------------------------------------------------------------------- +// XAlterTable +void SAL_CALL OAdoTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed); + + sal_Bool bError = sal_True; + OAdoColumn* pColumn = NULL; + if(::comphelper::getImplementation(pColumn,descriptor) && pColumn != NULL) + { + WpADOColumns aColumns = m_aTable.get_Columns(); + bError = !aColumns.Delete(colName); + bError = bError || !aColumns.Append(pColumn->getColumnImpl()); + } + if(bError) + ADOS::ThrowException(*(m_pCatalog->getConnection()->getConnection()),*this); + + m_pColumns->refresh(); + refreshColumns(); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed); + + Reference< XPropertySet > xOld; + m_pColumns->getByIndex(index) >>= xOld; + if(xOld.is()) + alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor); +} +// ------------------------------------------------------------------------- +void OAdoTable::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aTable.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + m_aTable.put_Name(getString(rValue)); + break; + + case PROPERTY_ID_TYPE: + OTools::putValue( m_aTable.get_Properties(), + OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), + getString(rValue)); + break; + + case PROPERTY_ID_DESCRIPTION: + OTools::putValue( m_aTable.get_Properties(), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")), + getString(rValue)); + break; + + case PROPERTY_ID_SCHEMANAME: + break; + + default: + throw Exception(); + } + } + OTable_TYPEDEF::setFastPropertyValue_NoBroadcast(nHandle,rValue); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoTable::acquire() throw() +{ + OTable_TYPEDEF::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoTable::release() throw() +{ + OTable_TYPEDEF::release(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OAdoTable::getName() throw(::com::sun::star::uno::RuntimeException) +{ + return m_aTable.get_Name(); +} + diff --git a/connectivity/source/drivers/ado/ATables.cxx b/connectivity/source/drivers/ado/ATables.cxx new file mode 100644 index 000000000000..d64fcb94057b --- /dev/null +++ b/connectivity/source/drivers/ado/ATables.cxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ATables.hxx" +#include "ado/ATable.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/KeyRule.hpp> +#include <com/sun/star/sdbcx/KeyType.hpp> +#include "ado/ACatalog.hxx" +#include "ado/AConnection.hxx" +#include "ado/Awrapado.hxx" +#include "TConnection.hxx" +#include <comphelper/types.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <connectivity/dbexception.hxx> +#include "resource/ado_res.hrc" + +using namespace ::cppu; +using namespace connectivity; +using namespace comphelper; +using namespace connectivity::ado; +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::container; +using namespace com::sun::star::lang; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); + return new OAdoTable(this,isCaseSensitive(),m_pCatalog,m_aCollection.GetItem(_rName)); +} +// ------------------------------------------------------------------------- +void OTables::impl_refresh( ) throw(RuntimeException) +{ + OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); + m_aCollection.Refresh(); + m_pCatalog->refreshTables(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OTables::createDescriptor() +{ + return new OAdoTable(this,isCaseSensitive(),m_pCatalog); +} +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor ) +{ + OAdoTable* pTable = NULL; + if ( !getImplementation( pTable, descriptor ) || pTable == NULL ) + m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_TABLE_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + + OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); + if(!m_aCollection.Append(pTable->getImpl())) + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); + m_aCollection.Refresh(); + + return new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable->getImpl()); +} +// ------------------------------------------------------------------------- +// XDrop +void OTables::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); + if ( !m_aCollection.Delete(_sElementName) ) + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); +} +// ----------------------------------------------------------------------------- +void OTables::appendNew(const ::rtl::OUString& _rsNewTable) +{ + OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid"); + m_aCollection.Refresh(); + + insertElement(_rsNewTable,NULL); + + // notify our container listeners + ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any()); + OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners); + while (aListenerLoop.hasMoreElements()) + static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AUser.cxx b/connectivity/source/drivers/ado/AUser.cxx new file mode 100644 index 000000000000..99733d1f79e5 --- /dev/null +++ b/connectivity/source/drivers/ado/AUser.cxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AUser.hxx" +#include "ado/ACatalog.hxx" +#include "ado/AGroups.hxx" +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif +#include "ado/Awrapado.hxx" + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// ------------------------------------------------------------------------- +OAdoUser::OAdoUser(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser) + : OUser_TYPEDEF(_bCase) + ,m_pCatalog(_pParent) +{ + construct(); + + if(_pUser) + m_aUser = WpADOUser(_pUser); + else + m_aUser.Create(); +} +// ------------------------------------------------------------------------- +OAdoUser::OAdoUser(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) + : OUser_TYPEDEF(_Name,_bCase) + , m_pCatalog(_pParent) +{ + construct(); + m_aUser.Create(); + m_aUser.put_Name(_Name); +} +// ------------------------------------------------------------------------- +void OAdoUser::refreshGroups() +{ + TStringVector aVector; + WpADOGroups aGroups(m_aUser.get_Groups()); + aGroups.fillElementNames(aVector); + if(m_pGroups) + m_pGroups->reFill(aVector); + else + m_pGroups = new OGroups(m_pCatalog,m_aMutex,aVector,aGroups,isCaseSensitive()); +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoUser::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoUser::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OUser_TYPEDEF::getSomething(rId); +} + +// ------------------------------------------------------------------------- +void OAdoUser::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) +{ + if(m_aUser.IsValid()) + { + + switch(nHandle) + { + case PROPERTY_ID_NAME: + { + ::rtl::OUString aVal; + rValue >>= aVal; + m_aUser.put_Name(aVal); + } + break; + } + } +} +// ------------------------------------------------------------------------- +void OAdoUser::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aUser.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aUser.get_Name(); + break; + } + } +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser) + : OAdoUser(_pParent,_bCase,_pUser) +{ +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) + : OAdoUser(_pParent,_bCase,_Name) +{ +} + +// ------------------------------------------------------------------------- +void OUserExtend::construct() +{ + OUser_TYPEDEF::construct(); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} +// ----------------------------------------------------------------------------- +cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const +{ + Sequence< com::sun::star::beans::Property > aProps; + describeProperties(aProps); + return new cppu::OPropertyArrayHelper(aProps); +} +// ------------------------------------------------------------------------- +cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper() +{ + return *OUserExtend_PROP::getArrayHelper(); +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoUser::acquire() throw() +{ + OUser_TYPEDEF::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoUser::release() throw() +{ + OUser_TYPEDEF::release(); +} +// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdoUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed); + + return ADOS::mapAdoRights2Sdbc(m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType))); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdoUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed); + + sal_Int32 nRights = 0; + RightsEnum eRights = m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType)); + if((eRights & adRightWithGrant) == adRightWithGrant) + nRights = ADOS::mapAdoRights2Sdbc(eRights); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); + return nRights; +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed); + m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessGrant,RightsEnum(ADOS::mapRights2Ado(objPrivileges))); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed); + m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessRevoke,RightsEnum(ADOS::mapRights2Ado(objPrivileges))); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); +} +// ----------------------------------------------------------------------------- +// XUser +void SAL_CALL OAdoUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed); + m_aUser.ChangePassword(objPassword,newPassword); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); +} +// ----------------------------------------------------------------------------- + + + + + diff --git a/connectivity/source/drivers/ado/AUsers.cxx b/connectivity/source/drivers/ado/AUsers.cxx new file mode 100644 index 000000000000..f3877af922e2 --- /dev/null +++ b/connectivity/source/drivers/ado/AUsers.cxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AUsers.hxx" +#include "ado/AUser.hxx" +#include "ado/ATable.hxx" +#include "ado/AConnection.hxx" +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include "connectivity/sdbcx/IRefreshable.hxx" +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#include "resource/ado_res.hrc" + +using namespace comphelper; +using namespace connectivity; +using namespace connectivity::ado; +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::container; + +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName) +{ + return new OAdoUser(m_pCatalog,isCaseSensitive(),_rName); +} +// ------------------------------------------------------------------------- +void OUsers::impl_refresh() throw(RuntimeException) +{ + m_aCollection.Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OUsers::createDescriptor() +{ + return new OUserExtend(m_pCatalog,isCaseSensitive()); +} +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) +{ + OUserExtend* pUser = NULL; + if ( !getImplementation( pUser, descriptor ) || pUser == NULL ) + m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_USER_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + + ADOUsers* pUsers = (ADOUsers*)m_aCollection; + pUsers->Append(OLEVariant(pUser->getImpl()),OLEString(pUser->getPassword())); + + return createObject( _rForName ); +} +// ------------------------------------------------------------------------- +// XDrop +void OUsers::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + m_aCollection.Delete(_sElementName); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AView.cxx b/connectivity/source/drivers/ado/AView.cxx new file mode 100644 index 000000000000..a6f9f419d091 --- /dev/null +++ b/connectivity/source/drivers/ado/AView.cxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AView.hxx" +#include <com/sun/star/lang/DisposedException.hpp> +#include "ado/adoimp.hxx" +#include <cppuhelper/typeprovider.hxx> +#include "ado/Awrapado.hxx" +#include <comphelper/sequence.hxx> +#include <comphelper/types.hxx> +#include "TConnection.hxx" + +// ------------------------------------------------------------------------- +using namespace comphelper; +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +// IMPLEMENT_SERVICE_INFO(OAdoView,"com.sun.star.sdbcx.AView","com.sun.star.sdbcx.View"); +// ------------------------------------------------------------------------- +OAdoView::OAdoView(sal_Bool _bCase,ADOView* _pView) : OView_ADO(_bCase,NULL) +,m_aView(_pView) +{ +} +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdoView::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdoView::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? reinterpret_cast< sal_Int64 >( this ) + : OView_ADO::getSomething(rId); +} + +// ------------------------------------------------------------------------- +void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const +{ + if(m_aView.IsValid()) + { + switch(nHandle) + { + case PROPERTY_ID_NAME: + rValue <<= m_aView.get_Name(); + break; + case PROPERTY_ID_CATALOGNAME: + break; + case PROPERTY_ID_SCHEMANAME: + // rValue <<= m_aView.get_Type(); + break; + case PROPERTY_ID_COMMAND: + { + OLEVariant aVar; + m_aView.get_Command(aVar); + if(!aVar.isNull() && !aVar.isEmpty()) + { + ADOCommand* pCom = (ADOCommand*)aVar.getIDispatch(); + OLEString aBSTR; + pCom->get_CommandText(&aBSTR); + rValue <<= (::rtl::OUString) aBSTR; + } + } + break; + } + } + else + OView_ADO::getFastPropertyValue(rValue,nHandle); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoView::acquire() throw() +{ + OView_ADO::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OAdoView::release() throw() +{ + OView_ADO::release(); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AViews.cxx b/connectivity/source/drivers/ado/AViews.cxx new file mode 100644 index 000000000000..350daef0cb71 --- /dev/null +++ b/connectivity/source/drivers/ado/AViews.cxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/AViews.hxx" +#include "ado/AView.hxx" +#include "ado/ATables.hxx" +#include "ado/ACatalog.hxx" +#include "ado/AConnection.hxx" +#include "ado/Awrapado.hxx" +#include "TConnection.hxx" +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#include "resource/ado_res.hrc" + +using namespace ::comphelper; + +using namespace connectivity; +using namespace connectivity::ado; +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::container; + +sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName) +{ + OAdoView* pView = new OAdoView(isCaseSensitive(),m_aCollection.GetItem(_rName)); + pView->setNew(sal_False); + return pView; +} +// ------------------------------------------------------------------------- +void OViews::impl_refresh( ) throw(RuntimeException) +{ + m_aCollection.Refresh(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OViews::createDescriptor() +{ + return new OAdoView(isCaseSensitive()); +} + +// ------------------------------------------------------------------------- +// XAppend +sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) +{ + OAdoView* pView = NULL; + if ( !getImplementation( pView, descriptor ) || pView == NULL ) + m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_VIEW_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) ); + + WpADOCommand aCommand; + aCommand.Create(); + if ( !aCommand.IsValid() ) + m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) ); + + ::rtl::OUString sName( _rForName ); + aCommand.put_Name(sName); + aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)))); + ADOViews* pViews = (ADOViews*)m_aCollection; + if(FAILED(pViews->Append(OLEString(sName),aCommand))) + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); + + OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables()); + if ( pTables ) + pTables->appendNew(sName); + + return createObject( _rForName ); +} +// ------------------------------------------------------------------------- +// XDrop +void OViews::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName) +{ + if(!m_aCollection.Delete(_sElementName)) + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this)); +} +// ------------------------------------------------------------------------- + + + diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx new file mode 100644 index 000000000000..3f04d359cba0 --- /dev/null +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -0,0 +1,791 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/Aolevariant.hxx" +#include "connectivity/dbconversion.hxx" +#include <com/sun/star/sdbc/SQLException.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include "diagnose_ex.h" +#include "resource/sharedresources.hxx" +#include "resource/ado_res.hrc" +#include "com/sun/star/bridge/oleautomation/Date.hpp" +#include "com/sun/star/bridge/oleautomation/Currency.hpp" +#include "com/sun/star/bridge/oleautomation/SCode.hpp" +#include "com/sun/star/bridge/oleautomation/Decimal.hpp" + +using namespace com::sun::star::beans; +using namespace com::sun::star::uno; +using namespace com::sun::star::bridge::oleautomation; +using namespace connectivity::ado; +using ::rtl::OUString; + +OLEString::OLEString() + :m_sStr(NULL) +{ +} +OLEString::OLEString(const BSTR& _sBStr) + :m_sStr(_sBStr) +{ +} +OLEString::OLEString(const ::rtl::OUString& _sBStr) +{ + m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_sBStr.getStr())); +} +OLEString::~OLEString() +{ + if(m_sStr) + ::SysFreeString(m_sStr); +} +OLEString& OLEString::operator=(const ::rtl::OUString& _rSrc) +{ + if(m_sStr) + ::SysFreeString(m_sStr); + m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_rSrc.getStr())); + 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) + ::SysFreeString(m_sStr); + m_sStr = _rSrc; + return *this; +} +OLEString::operator ::rtl::OUString() const +{ + return (m_sStr != NULL) ? ::rtl::OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : ::rtl::OUString(); +} +OLEString::operator BSTR() const +{ + return m_sStr; +} +BSTR* OLEString::operator &() +{ + return &m_sStr; +} +sal_Int32 OLEString::length() const +{ + return (m_sStr != NULL) ? ::SysStringLen(m_sStr) : 0; +} + +OLEVariant::OLEVariant() +{ + VariantInit(this); +} +OLEVariant::OLEVariant(const VARIANT& varSrc) +{ + ::VariantInit(this); + HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(&varSrc)); + OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!"); + OSL_UNUSED(eRet); +} +OLEVariant::OLEVariant(const OLEVariant& varSrc) +{ + ::VariantInit(this); + HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc))); + OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!"); + OSL_UNUSED(eRet); +} + +OLEVariant::OLEVariant(sal_Bool x) { VariantInit(this); vt = VT_BOOL; boolVal = (x ? VARIANT_TRUE : VARIANT_FALSE);} +OLEVariant::OLEVariant(sal_Int8 n) { VariantInit(this); vt = VT_I1; bVal = n;} +OLEVariant::OLEVariant(sal_Int16 n) { VariantInit(this); vt = VT_I2; intVal = n;} +OLEVariant::OLEVariant(sal_Int32 n) { VariantInit(this); vt = VT_I4; lVal = n;} +OLEVariant::OLEVariant(sal_Int64 x) { VariantInit(this); vt = VT_I4; lVal = (LONG)x;} + +OLEVariant::OLEVariant(const rtl::OUString& us) +{ + ::VariantInit(this); + vt = VT_BSTR; + bstrVal = SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr())); +} +OLEVariant::~OLEVariant() +{ + HRESULT eRet = ::VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); +} // clears all the memory that was allocated before + +OLEVariant::OLEVariant(const ::com::sun::star::util::Date& x ) +{ + VariantInit(this); + vt = VT_DATE; + dblVal = ::dbtools::DBTypeConversion::toDouble(x,::com::sun::star::util::Date(30,12,1899)); +} +OLEVariant::OLEVariant(const ::com::sun::star::util::Time& x ) +{ + VariantInit(this); + vt = VT_DATE; + dblVal = ::dbtools::DBTypeConversion::toDouble(x); +} +OLEVariant::OLEVariant(const ::com::sun::star::util::DateTime& x ) +{ + VariantInit(this); + vt = VT_DATE; + dblVal = ::dbtools::DBTypeConversion::toDouble(x,::com::sun::star::util::Date(30,12,1899)); +} +OLEVariant::OLEVariant(const float &x) +{ + VariantInit(this); + vt = VT_R4; + fltVal = x; +} +OLEVariant::OLEVariant(const double &x) +{ + VariantInit(this); + vt = VT_R8; + dblVal = x; +} + + +OLEVariant::OLEVariant(IDispatch* pDispInterface) +{ + VariantInit(this); + setIDispatch( pDispInterface ); +} + +OLEVariant::OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x) +{ + VariantInit(this); + + vt = VT_ARRAY|VT_UI1; + + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = x.getLength(); + // parray = SafeArrayCreate(VT_UI1,1,rgsabound); + parray = SafeArrayCreateVector(VT_UI1, 0, x.getLength()); + const sal_Int8* pBegin = x.getConstArray(); + const sal_Int8* pEnd = pBegin + x.getLength(); + + for(sal_Int32 i=0;pBegin != pEnd;++i,++pBegin) + { + sal_Int32 nData = *pBegin; + HRESULT rs = SafeArrayPutElement(parray,&i,&nData); + OSL_ENSURE(S_OK == rs,"Error while copy byte data"); + OSL_UNUSED(rs); + } +} +// +OLEVariant& OLEVariant::operator=(const OLEVariant& varSrc) +{ + HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc))); + OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!"); + OSL_UNUSED(eRet); + return *this; +} +// Assign a const VARIANT& (::VariantCopy handles everything) +// +OLEVariant& OLEVariant::operator=(const tagVARIANT& varSrc) +{ + HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(&varSrc)); + OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!"); + OSL_UNUSED(eRet); + + return *this; +} + +// Assign a const VARIANT* (::VariantCopy handles everything) +// +OLEVariant& OLEVariant::operator=(const VARIANT* pSrc) +{ + HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(pSrc)); + OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!"); + OSL_UNUSED(eRet); + + return *this; +} + +void OLEVariant::setByte(sal_uInt8 n) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_UI1; + bVal = n; +} +void OLEVariant::setInt16(sal_Int16 n) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_I2; + iVal = n; +} +void OLEVariant::setInt32(sal_Int32 n) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_I4; + lVal = n; +} +void OLEVariant::setFloat(float f) +{ HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_R4; + fltVal = f; +} +void OLEVariant::setDouble(double d) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_R8; + dblVal = d; +} +void OLEVariant::setDate(DATE d) +{ HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_DATE; + date = d; +} +void OLEVariant::setChar(unsigned char a) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_UI1; + bVal = a; +} +void OLEVariant::setCurrency(double aCur) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_CY; + set(aCur*10000); +} +void OLEVariant::setBool(sal_Bool b) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_BOOL; + boolVal = b ? VARIANT_TRUE : VARIANT_FALSE; +} +void OLEVariant::setString(const rtl::OUString& us) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_BSTR; + bstrVal = ::SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr())); +} +void OLEVariant::setNoArg() +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_ERROR; + scode = DISP_E_PARAMNOTFOUND; +} + +void OLEVariant::setNull() +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_NULL; +} +void OLEVariant::setEmpty() +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_EMPTY; +} + +void OLEVariant::setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = VT_ARRAY|VT_UI1; parray = pSafeAr; +} + +void OLEVariant::setArray(SAFEARRAY* pSafeArray, VARTYPE vtType) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + vt = (VARTYPE)(VT_ARRAY|vtType); + parray = pSafeArray; +} + +void OLEVariant::setIDispatch(IDispatch* pDispInterface) +{ + HRESULT eRet = VariantClear(this); + OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); + OSL_UNUSED(eRet); + + 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); } + +VARTYPE OLEVariant::getType() const { return vt; } + +OLEVariant::operator ::com::sun::star::util::Date() const +{ + return isNull() ? ::com::sun::star::util::Date(30,12,1899) : ::dbtools::DBTypeConversion::toDate(getDate(),::com::sun::star::util::Date(30,12,1899)); +} +OLEVariant::operator ::com::sun::star::util::Time() const +{ + return isNull() ? ::com::sun::star::util::Time() : ::dbtools::DBTypeConversion::toTime(getDate()); +} +OLEVariant::operator ::com::sun::star::util::DateTime()const +{ + return isNull() ? ::com::sun::star::util::DateTime() : ::dbtools::DBTypeConversion::toDateTime(getDate(),::com::sun::star::util::Date(30,12,1899)); +} + +VARIANT_BOOL OLEVariant::VariantBool(sal_Bool bEinBoolean) +{ + return (bEinBoolean ? VARIANT_TRUE : VARIANT_FALSE); +} + +void OLEVariant::CHS() +{ + cyVal.Lo ^= (sal_uInt32)-1; + cyVal.Hi ^= -1; + cyVal.Lo++; + if( !cyVal.Lo ) + cyVal.Hi++; +} + +void OLEVariant::set(double n) +{ + if( n >= 0 ) + { + cyVal.Hi = (sal_Int32)(n / (double)4294967296.0); + cyVal.Lo = (sal_uInt32)(n - ((double)cyVal.Hi * (double)4294967296.0)); + } + else { + cyVal.Hi = (sal_Int32)(-n / (double)4294967296.0); + cyVal.Lo = (sal_uInt32)(-n - ((double)cyVal.Hi * (double)4294967296.0)); + CHS(); + } +} + +OLEVariant::operator rtl::OUString() const +{ + if (V_VT(this) == VT_BSTR) + return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(this))); + + if(isNull()) + return ::rtl::OUString(); + + OLEVariant varDest; + + varDest.ChangeType(VT_BSTR, this); + + return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(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 ) ) ) + { + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceString(STR_TYPE_NOT_CONVERT)); + throw ::com::sun::star::sdbc::SQLException( + sError, + NULL, + ::rtl::OUString::createFromAscii( "S1000" ), + 1000, + ::com::sun::star::uno::Any() + ); + } + } +} + +// ----------------------------------------------------------------------------- +OLEVariant::operator ::com::sun::star::uno::Sequence< sal_Int8 >() const +{ + ::com::sun::star::uno::Sequence< sal_Int8 > aRet; + if(V_VT(this) == VT_BSTR) + { + OLEString sStr(V_BSTR(this)); + aRet = ::com::sun::star::uno::Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>((const wchar_t*)sStr),sizeof(sal_Unicode)*sStr.length()); + } + else if(!isNull()) + { + SAFEARRAY* pArray = getUI1SAFEARRAYPtr(); + + if(pArray) + { + HRESULT hresult1,hresult2; + long lBound,uBound; + // Verify that the SafeArray is the proper shape. + hresult1 = ::SafeArrayGetLBound(pArray, 1, &lBound); + hresult2 = ::SafeArrayGetUBound(pArray, 1, &uBound); + if ( SUCCEEDED(hresult1) && SUCCEEDED(hresult2) ) + { + long nCount = uBound-lBound+1; + aRet.realloc(nCount); + sal_Int8* pData = aRet.getArray(); + for(long i=0; SUCCEEDED(hresult1) && lBound <= uBound ;++i,++lBound) + { + sal_Int32 nData = 0; + hresult1 = ::SafeArrayGetElement(pArray,&lBound,&nData); + if ( SUCCEEDED(hresult1) ) + { + *pData = static_cast<sal_Int8>(nData); + ++pData; + } + } + } + } + } + + return aRet; +} +// ----------------------------------------------------------------------------- +::rtl::OUString OLEVariant::getString() const +{ + if(isNull()) + return ::rtl::OUString(); + else + return *this; +} +// ----------------------------------------------------------------------------- +sal_Bool OLEVariant::getBool() const +{ + if (V_VT(this) == VT_BOOL) + return V_BOOL(this) == VARIANT_TRUE ? sal_True : sal_False; + if(isNull()) + return sal_False; + + OLEVariant varDest; + + varDest.ChangeType(VT_BOOL, this); + + return V_BOOL(&varDest) == VARIANT_TRUE ? sal_True : sal_False; +} +// ----------------------------------------------------------------------------- +IUnknown* OLEVariant::getIUnknown() const +{ + if (V_VT(this) == VT_UNKNOWN) + { + return V_UNKNOWN(this); + } + if(isNull()) + return NULL; + + OLEVariant varDest; + + varDest.ChangeType(VT_UNKNOWN, this); + + V_UNKNOWN(&varDest)->AddRef(); + return V_UNKNOWN(&varDest); +} +// ----------------------------------------------------------------------------- +IDispatch* OLEVariant::getIDispatch() const +{ + if (V_VT(this) == VT_DISPATCH) + { + return V_DISPATCH(this); + } + + if(isNull()) + return NULL; + + OLEVariant varDest; + + varDest.ChangeType(VT_DISPATCH, this); + + V_DISPATCH(&varDest)->AddRef(); + return V_DISPATCH(&varDest); +} +// ----------------------------------------------------------------------------- +sal_uInt8 OLEVariant::getByte() const +{ + if (V_VT(this) == VT_UI1) + return V_UI1(this); + + if(isNull()) + return sal_Int8(0); + OLEVariant varDest; + + varDest.ChangeType(VT_UI1, this); + + return V_UI1(&varDest); +} +// ----------------------------------------------------------------------------- +sal_Int16 OLEVariant::getInt16() const +{ + if (V_VT(this) == VT_I2) + return V_I2(this); + + if(isNull()) + return sal_Int16(0); + OLEVariant varDest; + + varDest.ChangeType(VT_I2, this); + + return V_I2(&varDest); +} +// ----------------------------------------------------------------------------- +sal_Int8 OLEVariant::getInt8() const +{ + if (V_VT(this) == VT_I1) + return V_I1(this); + + if(isNull()) + return sal_Int8(0); + + OLEVariant varDest; + + varDest.ChangeType(VT_I1, this); + + return V_I1(&varDest); +} +// ----------------------------------------------------------------------------- +sal_Int32 OLEVariant::getInt32() const +{ + if (V_VT(this) == VT_I4) + return V_I4(this); + + if(isNull()) + return sal_Int32(0); + + OLEVariant varDest; + + varDest.ChangeType(VT_I4, this); + + return V_I4(&varDest); +} +// ----------------------------------------------------------------------------- +sal_uInt32 OLEVariant::getUInt32() const +{ + if (V_VT(this) == VT_UI4) + return V_UI4(this); + + if(isNull()) + return sal_uInt32(0); + + OLEVariant varDest; + + varDest.ChangeType(VT_UI4, this); + + return V_UI4(&varDest); +} +// ----------------------------------------------------------------------------- +float OLEVariant::getFloat() const +{ + if (V_VT(this) == VT_R4) + return V_R4(this); + + if(isNull()) + return float(0); + OLEVariant varDest; + + varDest.ChangeType(VT_R4, this); + + return V_R4(&varDest); +} +// ----------------------------------------------------------------------------- +double OLEVariant::getDouble() const +{ + if (V_VT(this) == VT_R8) + return V_R8(this); + + if(isNull()) + return double(0); + OLEVariant varDest; + + varDest.ChangeType(VT_R8, this); + + return V_R8(&varDest); +} +// ----------------------------------------------------------------------------- +double OLEVariant::getDate() const +{ + if (V_VT(this) == VT_DATE) + return V_DATE(this); + + if(isNull()) + return double(0); + OLEVariant varDest; + + varDest.ChangeType(VT_DATE, this); + + return V_DATE(&varDest); +} +// ----------------------------------------------------------------------------- +CY OLEVariant::getCurrency() const +{ + if (V_VT(this) == VT_CY) + return V_CY(this); + + if(isNull()) + { + CY aVar; + aVar.int64 = sal_Int64(0); + return aVar; + } + OLEVariant varDest; + + varDest.ChangeType(VT_CY, this); + + return V_CY(&varDest); +} +// ----------------------------------------------------------------------------- +SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const +{ + if (V_VT(this) == (VT_ARRAY|VT_UI1)) + return V_ARRAY(this); + + if(isNull()) + return (0); + OLEVariant varDest; + + varDest.ChangeType((VT_ARRAY|VT_UI1), this); + + return V_ARRAY(&varDest); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Any OLEVariant::makeAny() const +{ + ::com::sun::star::uno::Any aValue; + switch (V_VT(this)) + { + case VT_EMPTY: + case VT_NULL: + aValue.setValue(NULL, Type()); + break; + case VT_I2: + aValue.setValue( & iVal, getCppuType( (sal_Int16*)0)); + break; + case VT_I4: + aValue.setValue( & lVal, getCppuType( (sal_Int32*)0)); + break; + case VT_R4: + aValue.setValue( & fltVal, getCppuType( (float*)0)); + break; + case VT_R8: + aValue.setValue(& dblVal, getCppuType( (double*)0)); + break; + case VT_CY: + { + Currency cy(cyVal.int64); + aValue <<= cy; + break; + } + case VT_DATE: + { + aValue <<= (::com::sun::star::util::Date)*this; + break; + } + case VT_BSTR: + { + OUString b(reinterpret_cast<const sal_Unicode*>(bstrVal)); + aValue.setValue( &b, getCppuType( &b)); + break; + } + case VT_BOOL: + { + sal_Bool b= boolVal == VARIANT_TRUE; + aValue.setValue( &b, getCppuType( &b)); + break; + } + case VT_I1: + aValue.setValue( & cVal, getCppuType((sal_Int8*)0)); + break; + case VT_UI1: // there is no unsigned char in UNO + aValue.setValue( & bVal, getCppuType( (sal_Int8*)0)); + break; + case VT_UI2: + aValue.setValue( & uiVal, getCppuType( (sal_uInt16*)0)); + break; + case VT_UI4: + aValue.setValue( & ulVal, getCppuType( (sal_uInt32*)0)); + break; + case VT_INT: + aValue.setValue( & intVal, getCppuType( (sal_Int32*)0)); + break; + case VT_UINT: + aValue.setValue( & uintVal, getCppuType( (sal_uInt32*)0)); + break; + case VT_VOID: + aValue.setValue( NULL, Type()); + break; + case VT_DECIMAL: + { + Decimal dec; + dec.Scale = decVal.scale; + dec.Sign = decVal.sign; + dec.LowValue = decVal.Lo32; + dec.MiddleValue = decVal.Mid32; + dec.HighValue = decVal.Hi32; + aValue <<= dec; + break; + } + + default: + break; + } + return aValue; +} +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/Aservices.cxx b/connectivity/source/drivers/ado/Aservices.cxx new file mode 100644 index 000000000000..71d90f289a7d --- /dev/null +++ b/connectivity/source/drivers/ado/Aservices.cxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/ADriver.hxx" +#include <cppuhelper/factory.hxx> + +using namespace connectivity::ado; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames , + rtl_ModuleCount* _pT + ); + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment ** /*ppEnv*/ + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine"; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* /*pRegistryKey*/) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), + ODriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + + diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx new file mode 100644 index 000000000000..442c1bdde439 --- /dev/null +++ b/connectivity/source/drivers/ado/Awrapado.cxx @@ -0,0 +1,2201 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "ado/Awrapado.hxx" +#include "ado/Awrapadox.hxx" +#include <comphelper/types.hxx> +#include <rtl/ustrbuf.hxx> +#include "diagnose_ex.h" + +namespace connectivity +{ + namespace ado + { + sal_Int32 nAdoObjectCounter = 0; + } +} + +using namespace connectivity::ado; + +void WpADOCatalog::Create() +{ + HRESULT hr = -1; + _ADOCatalog* pCommand; + hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25, + NULL, + CLSCTX_INPROC_SERVER, + ADOS::IID_ADOCATALOG_25, + (void**)&pCommand ); + + + if( !FAILED( hr ) ) + setWithOutAddRef(pCommand); +} + + +WpADOProperties WpADOConnection::get_Properties() const +{ + ADOProperties* pProps=NULL; + pInterface->get_Properties(&pProps); + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); + return aProps; +} + +rtl::OUString WpADOConnection::GetConnectionString() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_ConnectionString(&aBSTR); + return aBSTR; +} + +sal_Bool WpADOConnection::PutConnectionString(const ::rtl::OUString &aCon) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(aCon); + sal_Bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr)); + + return bErg; +} + +sal_Int32 WpADOConnection::GetCommandTimeout() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nRet=0; + pInterface->get_CommandTimeout(&nRet); + return nRet; +} + +void WpADOConnection::PutCommandTimeout(sal_Int32 nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_CommandTimeout(nRet); +} + +sal_Int32 WpADOConnection::GetConnectionTimeout() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nRet=0; + pInterface->get_ConnectionTimeout(&nRet); + return nRet; +} + +void WpADOConnection::PutConnectionTimeout(sal_Int32 nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_ConnectionTimeout(nRet); +} + +sal_Bool WpADOConnection::Close( ) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->Close())); +} + +sal_Bool WpADOConnection::Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString sStr1(_CommandText); + sal_Bool bErg = SUCCEEDED(pInterface->Execute(sStr1,&RecordsAffected,Options,(_ADORecordset**)ppiRset)); + return bErg; +} + +sal_Bool WpADOConnection::BeginTrans() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nIso=0; + return SUCCEEDED(pInterface->BeginTrans(&nIso)); +} + +sal_Bool WpADOConnection::CommitTrans( ) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->CommitTrans()); +} + +sal_Bool WpADOConnection::RollbackTrans( ) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->RollbackTrans()); +} + +sal_Bool WpADOConnection::Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString sStr1(ConnectionString); + OLEString sStr2(UserID); + OLEString sStr3(Password); + sal_Bool bErg = SUCCEEDED(pInterface->Open(sStr1,sStr2,sStr3,Options)); + return bErg; +} + +sal_Bool WpADOConnection::GetErrors(ADOErrors** pErrors) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->get_Errors(pErrors)); +} + +::rtl::OUString WpADOConnection::GetDefaultDatabase() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; pInterface->get_DefaultDatabase(&aBSTR); + return aBSTR; +} + +sal_Bool WpADOConnection::PutDefaultDatabase(const ::rtl::OUString& _bstr) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_bstr); + sal_Bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr)); + + return bErg; +} + +IsolationLevelEnum WpADOConnection::get_IsolationLevel() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + IsolationLevelEnum eNum=adXactUnspecified; + pInterface->get_IsolationLevel(&eNum); + return eNum; +} + +sal_Bool WpADOConnection::put_IsolationLevel(const IsolationLevelEnum& eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_IsolationLevel(eNum)); +} + +sal_Int32 WpADOConnection::get_Attributes() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nRet=0; + pInterface->get_Attributes(&nRet); + return nRet; +} + +sal_Bool WpADOConnection::put_Attributes(sal_Int32 nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_Attributes(nRet)); +} + +CursorLocationEnum WpADOConnection::get_CursorLocation() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + CursorLocationEnum eNum=adUseNone; + pInterface->get_CursorLocation(&eNum); + return eNum; +} + +sal_Bool WpADOConnection::put_CursorLocation(const CursorLocationEnum &eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_CursorLocation(eNum)); +} + +ConnectModeEnum WpADOConnection::get_Mode() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ConnectModeEnum eNum=adModeUnknown; + pInterface->get_Mode(&eNum); + return eNum; +} + +sal_Bool WpADOConnection::put_Mode(const ConnectModeEnum &eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_Mode(eNum)); +} + +::rtl::OUString WpADOConnection::get_Provider() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; pInterface->get_Provider(&aBSTR); + return aBSTR; +} + +sal_Bool WpADOConnection::put_Provider(const ::rtl::OUString& _bstr) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_bstr); + return SUCCEEDED(pInterface->put_Provider(bstr)); +} + +sal_Int32 WpADOConnection::get_State() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nRet=0; + pInterface->get_State(&nRet); + return nRet; +} + +sal_Bool WpADOConnection::OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->OpenSchema(eNum,Restrictions,SchemaID,pprset)); +} + +::rtl::OUString WpADOConnection::get_Version() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Version(&aBSTR); + return aBSTR; +} + +sal_Bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + if(pCon) + return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface)); + else + return SUCCEEDED(pInterface->putref_ActiveConnection(NULL)); +} + +void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_ActiveConnection(vConn); +} + +void WpADOCommand::Create() +{ + IClassFactory2* pInterface2 = NULL; + IUnknown *pOuter = NULL; + HRESULT hr; + hr = CoGetClassObject( ADOS::CLSID_ADOCOMMAND_21, + CLSCTX_INPROC_SERVER, + NULL, + IID_IClassFactory2, + (void**)&pInterface2 ); + + if( !FAILED( hr ) ) + { + ADOCommand* pCommand=NULL; + + hr = pInterface2->CreateInstanceLic( pOuter, + NULL, + ADOS::IID_ADOCOMMAND_21, + ADOS::GetKeyStr(), + (void**) &pCommand); + + if( !FAILED( hr ) ) + { + operator=(pCommand); + pCommand->Release(); + } + + pInterface2->Release(); + } +} + +sal_Int32 WpADOCommand::get_State() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nRet=0; + pInterface->get_State(&nRet); + return nRet; +} + +::rtl::OUString WpADOCommand::get_CommandText() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_CommandText(&aBSTR); + return aBSTR; +} + +sal_Bool WpADOCommand::put_CommandText(const ::rtl::OUString &aCon) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(aCon); + sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr)); + + return bErg; +} + +sal_Int32 WpADOCommand::get_CommandTimeout() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nRet=0; + pInterface->get_CommandTimeout(&nRet); + return nRet; +} + +void WpADOCommand::put_CommandTimeout(sal_Int32 nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_CommandTimeout(nRet); +} + +sal_Bool WpADOCommand::get_Prepared() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL bPrepared = VARIANT_FALSE; + pInterface->get_Prepared(&bPrepared); + return bPrepared == VARIANT_TRUE; +} + +sal_Bool WpADOCommand::put_Prepared(VARIANT_BOOL bPrepared) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_Prepared(bPrepared)); +} + +sal_Bool WpADOCommand::Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->Execute(&RecordsAffected,&Parameters,Options,ppiRset)); +} + +ADOParameter* WpADOCommand::CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOParameter* pPara = NULL; + OLEString bstr(_bstr); + sal_Bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr,Type,Direction,nSize,Value,&pPara)); + + return bErg ? pPara : NULL; +} + +ADOParameters* WpADOCommand::get_Parameters() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOParameters* pPara=NULL; + pInterface->get_Parameters(&pPara); + return pPara; +} + +sal_Bool WpADOCommand::put_CommandType( /* [in] */ CommandTypeEnum lCmdType) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_CommandType(lCmdType)); +} + +CommandTypeEnum WpADOCommand::get_CommandType( ) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + CommandTypeEnum eNum=adCmdUnspecified; + pInterface->get_CommandType(&eNum); + return eNum; +} + +// gibt den Namen des Feldes zur"ueck +::rtl::OUString WpADOCommand::GetName() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +sal_Bool WpADOCommand::put_Name(const ::rtl::OUString& _Name) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_Name); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + + return bErg; +} +sal_Bool WpADOCommand::Cancel() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->Cancel()); +} + +::rtl::OUString WpADOError::GetDescription() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Description(&aBSTR); + return aBSTR; +} + + ::rtl::OUString WpADOError::GetSource() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Source(&aBSTR); + return aBSTR; +} + + sal_Int32 WpADOError::GetNumber() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nErrNr=0; + pInterface->get_Number(&nErrNr); + return nErrNr; +} + + ::rtl::OUString WpADOError::GetSQLState() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_SQLState(&aBSTR); + return aBSTR; +} + + sal_Int32 WpADOError::GetNativeError() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nErrNr=0; + pInterface->get_NativeError(&nErrNr); + return nErrNr; +} +WpADOProperties WpADOField::get_Properties() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOProperties* pProps = NULL; + pInterface->get_Properties(&pProps); + WpADOProperties aProps; + + aProps.setWithOutAddRef(pProps); + return aProps; +} + + sal_Int32 WpADOField::GetActualSize() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nActualSize=0; + pInterface->get_ActualSize(&nActualSize); + return nActualSize; +} + + sal_Int32 WpADOField::GetAttributes() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 eADOSFieldAttributes=0; + pInterface->get_Attributes(&eADOSFieldAttributes); + return eADOSFieldAttributes; +} + +sal_Int32 WpADOField::GetStatus() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 eADOSFieldAttributes=0; + // pInterface->get_Status(&eADOSFieldAttributes); + return eADOSFieldAttributes; +} + +sal_Int32 WpADOField::GetDefinedSize() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nDefinedSize=0; + pInterface->get_DefinedSize(&nDefinedSize); + return nDefinedSize; +} + +// gibt den Namen des Feldes zur"ueck +::rtl::OUString WpADOField::GetName() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + + DataTypeEnum WpADOField::GetADOType() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + DataTypeEnum eType=adEmpty; + pInterface->get_Type(&eType); + return eType; +} + + void WpADOField::get_Value(OLEVariant& aValVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + aValVar.setEmpty(); + sal_Bool bOk = SUCCEEDED(pInterface->get_Value(&aValVar)); + (void)bOk; +} + + OLEVariant WpADOField::get_Value() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEVariant aValVar; + pInterface->get_Value(&aValVar); + return aValVar; +} + + sal_Bool WpADOField::PutValue(const OLEVariant& aVariant) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Value(aVariant))); +} + +sal_Int32 WpADOField::GetPrecision() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_uInt8 eType=0; + pInterface->get_Precision(&eType); + return eType; +} + + sal_Int32 WpADOField::GetNumericScale() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_uInt8 eType=0; + pInterface->get_NumericScale(&eType); + return eType; +} + + sal_Bool WpADOField::AppendChunk(const OLEVariant& _Variant) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->AppendChunk(_Variant))); +} + +OLEVariant WpADOField::GetChunk(long Length) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEVariant aValVar; + pInterface->GetChunk(Length,&aValVar); + return aValVar; +} + +void WpADOField::GetChunk(long Length,OLEVariant &aValVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->GetChunk(Length,&aValVar); +} + +OLEVariant WpADOField::GetOriginalValue() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEVariant aValVar; + pInterface->get_OriginalValue(&aValVar); + return aValVar; +} + +void WpADOField::GetOriginalValue(OLEVariant &aValVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->get_OriginalValue(&aValVar); +} + +OLEVariant WpADOField::GetUnderlyingValue() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEVariant aValVar; + pInterface->get_UnderlyingValue(&aValVar); + return aValVar; +} + + void WpADOField::GetUnderlyingValue(OLEVariant &aValVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->get_UnderlyingValue(&aValVar); +} + + sal_Bool WpADOField::PutPrecision(sal_Int8 _prec) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Precision(_prec))); +} + + sal_Bool WpADOField::PutNumericScale(sal_Int8 _prec) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_NumericScale(_prec))); +} + + void WpADOField::PutADOType(DataTypeEnum eType) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Type(eType); +} + + sal_Bool WpADOField::PutDefinedSize(sal_Int32 _nDefSize) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_DefinedSize(_nDefSize))); +} + + sal_Bool WpADOField::PutAttributes(sal_Int32 _nDefSize) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); +} + +OLEVariant WpADOProperty::GetValue() const +{ + OLEVariant aValVar; + if(pInterface) + pInterface->get_Value(&aValVar); + return aValVar; +} + +void WpADOProperty::GetValue(OLEVariant &aValVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + if(pInterface) + pInterface->get_Value(&aValVar); +} + +sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Value(aValVar))); +} + + ::rtl::OUString WpADOProperty::GetName() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + + DataTypeEnum WpADOProperty::GetADOType() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + DataTypeEnum eType=adEmpty; + pInterface->get_Type(&eType); + return eType; +} + + sal_Int32 WpADOProperty::GetAttributes() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 eADOSFieldAttributes=0; + pInterface->get_Attributes(&eADOSFieldAttributes); + return eADOSFieldAttributes; +} + + sal_Bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Attributes(_nDefSize))); +} + void WpADORecordset::Create() +{ + IClassFactory2* pInterface2 = NULL; + IUnknown *pOuter = NULL; + HRESULT hr; + hr = CoGetClassObject( ADOS::CLSID_ADORECORDSET_21, + CLSCTX_INPROC_SERVER, + NULL, + IID_IClassFactory2, + (void**)&pInterface2 ); + + if( !FAILED( hr ) ) + { + ADORecordset *pRec = NULL; + hr = pInterface2->CreateInstanceLic( pOuter, + NULL, + ADOS::IID_ADORECORDSET_21, + ADOS::GetKeyStr(), + (void**) &pRec); + + if( !FAILED( hr ) ) + { + operator=(pRec); + pRec->Release(); + } + + pInterface2->Release(); + } +} + + sal_Bool WpADORecordset::Open( + /* [optional][in] */ VARIANT Source, + /* [optional][in] */ VARIANT ActiveConnection, + /* [defaultvalue][in] */ CursorTypeEnum CursorType, + /* [defaultvalue][in] */ LockTypeEnum LockType, + /* [defaultvalue][in] */ sal_Int32 Options) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->Open(Source,ActiveConnection,CursorType,LockType,Options))); +} + + +LockTypeEnum WpADORecordset::GetLockType() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + LockTypeEnum eType=adLockUnspecified; + pInterface->get_LockType(&eType); + return eType; +} + +void WpADORecordset::Close() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->Close(); +} + + sal_Bool WpADORecordset::Cancel() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->Cancel())); +} + + sal_Int32 WpADORecordset::get_State( ) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nState = 0; + pInterface->get_State(&nState); + return nState; +} + + sal_Bool WpADORecordset::Supports( /* [in] */ CursorOptionEnum CursorOptions) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL bSupports=VARIANT_FALSE; + pInterface->Supports(CursorOptions,&bSupports); + return bSupports == VARIANT_TRUE; +} + +PositionEnum WpADORecordset::get_AbsolutePosition() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + PositionEnum aTemp=adPosUnknown; + pInterface->get_AbsolutePosition(&aTemp); + return aTemp; +} + + void WpADORecordset::GetDataSource(IUnknown** _pInterface) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->get_DataSource(_pInterface); +} + + void WpADORecordset::PutRefDataSource(IUnknown* _pInterface) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->putref_DataSource(_pInterface); +} + + void WpADORecordset::GetBookmark(VARIANT& var) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->get_Bookmark(&var); +} + + OLEVariant WpADORecordset::GetBookmark() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEVariant var; + pInterface->get_Bookmark(&var); + return var; +} + +CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVariant& right) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + CompareEnum eNum=adCompareNotComparable; + pInterface->CompareBookmarks(left,right,&eNum); + return eNum; +} + + sal_Bool WpADORecordset::SetBookmark(const OLEVariant &pSafeAr) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_Bookmark(pSafeAr)); +} + + +WpADOFields WpADORecordset::GetFields() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOFields* pFields=NULL; + pInterface->get_Fields(&pFields); + WpADOFields aFields; + aFields.setWithOutAddRef(pFields); + return aFields; +} + + + sal_Bool WpADORecordset::Move(sal_Int32 nRows, VARIANT aBmk) {return pInterface && SUCCEEDED(pInterface->Move(nRows, aBmk));} + sal_Bool WpADORecordset::MoveNext() {return pInterface && SUCCEEDED(pInterface->MoveNext());} + sal_Bool WpADORecordset::MovePrevious() {return pInterface && SUCCEEDED(pInterface->MovePrevious());} + sal_Bool WpADORecordset::MoveFirst() {return pInterface && SUCCEEDED(pInterface->MoveFirst());} + sal_Bool WpADORecordset::MoveLast() {return pInterface && SUCCEEDED(pInterface->MoveLast());} + + sal_Bool WpADORecordset::IsAtBOF() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL bIsAtBOF=VARIANT_FALSE; + pInterface->get_BOF(&bIsAtBOF); + return bIsAtBOF == VARIANT_TRUE; +} + + sal_Bool WpADORecordset::IsAtEOF() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL bIsAtEOF=VARIANT_FALSE; + pInterface->get_EOF(&bIsAtEOF); + return bIsAtEOF == VARIANT_TRUE; +} + + sal_Bool WpADORecordset::Delete(AffectEnum eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->Delete(eNum)); +} + + sal_Bool WpADORecordset::AddNew(const OLEVariant &FieldList,const OLEVariant &Values) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->AddNew(FieldList,Values)); +} + + sal_Bool WpADORecordset::Update(const OLEVariant &FieldList,const OLEVariant &Values) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->Update(FieldList,Values)); +} + + sal_Bool WpADORecordset::CancelUpdate() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->CancelUpdate()); +} + +WpADOProperties WpADORecordset::get_Properties() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOProperties* pProps=NULL; + pInterface->get_Properties(&pProps); + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); + return aProps; +} + + sal_Bool WpADORecordset::NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->NextRecordset(&RecordsAffected,ppiRset)); +} + + sal_Bool WpADORecordset::get_RecordCount(sal_Int32 &_nRet) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->get_RecordCount(&_nRet)); +} + + sal_Bool WpADORecordset::get_MaxRecords(sal_Int32 &_nRet) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->get_MaxRecords(&_nRet)); +} + + sal_Bool WpADORecordset::put_MaxRecords(sal_Int32 _nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_MaxRecords(_nRet)); +} + + sal_Bool WpADORecordset::get_CursorType(CursorTypeEnum &_nRet) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->get_CursorType(&_nRet)); +} + + sal_Bool WpADORecordset::put_CursorType(CursorTypeEnum _nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_CursorType(_nRet)); +} + + sal_Bool WpADORecordset::get_LockType(LockTypeEnum &_nRet) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->get_LockType(&_nRet)); +} + + sal_Bool WpADORecordset::put_LockType(LockTypeEnum _nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_LockType(_nRet)); +} + + sal_Bool WpADORecordset::get_CacheSize(sal_Int32 &_nRet) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->get_CacheSize(&_nRet)); +} + + sal_Bool WpADORecordset::put_CacheSize(sal_Int32 _nRet) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_CacheSize(_nRet)); +} + + sal_Bool WpADORecordset::UpdateBatch(AffectEnum AffectRecords) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->UpdateBatch(AffectRecords)); +} + + ::rtl::OUString WpADOParameter::GetName() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + + DataTypeEnum WpADOParameter::GetADOType() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + DataTypeEnum eType=adEmpty; + pInterface->get_Type(&eType); + return eType; +} + +void WpADOParameter::put_Type(const DataTypeEnum& _eType) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Type(_eType); +} + + sal_Int32 WpADOParameter::GetAttributes() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 eADOSFieldAttributes=0; + pInterface->get_Attributes(&eADOSFieldAttributes); + return eADOSFieldAttributes; +} + + sal_Int32 WpADOParameter::GetPrecision() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_uInt8 eType=0; + pInterface->get_Precision(&eType); + return eType; +} + + sal_Int32 WpADOParameter::GetNumericScale() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_uInt8 eType=0; + pInterface->get_NumericScale(&eType); + return eType; +} + + ParameterDirectionEnum WpADOParameter::get_Direction() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ParameterDirectionEnum alParmDirection=adParamUnknown; + pInterface->get_Direction(&alParmDirection); + return alParmDirection; +} + + void WpADOParameter::GetValue(OLEVariant& aValVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->get_Value(&aValVar); +} + + OLEVariant WpADOParameter::GetValue() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEVariant aValVar; + pInterface->get_Value(&aValVar); + return aValVar; +} + +sal_Bool WpADOParameter::PutValue(const OLEVariant& aVariant) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Value(aVariant))); +} +sal_Bool WpADOParameter::AppendChunk(const OLEVariant& aVariant) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->AppendChunk(aVariant))); +} +sal_Bool WpADOParameter::put_Size(const sal_Int32& _nSize) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return (SUCCEEDED(pInterface->put_Size(_nSize))); +} + + ::rtl::OUString WpADOColumn::get_Name() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +::rtl::OUString WpADOColumn::get_RelatedColumn() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_RelatedColumn(&aBSTR); + return aBSTR; +} + +void WpADOColumn::put_Name(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + (void)bErg; +} +void WpADOColumn::put_RelatedColumn(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedColumn(bstr)); + (void)bErg; +} + +DataTypeEnum WpADOColumn::get_Type() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + DataTypeEnum eNum = adVarChar; + pInterface->get_Type(&eNum); + return eNum; +} + +void WpADOColumn::put_Type(const DataTypeEnum& _eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Type(_eNum); +} + +sal_Int32 WpADOColumn::get_Precision() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nPrec=0; + pInterface->get_Precision(&nPrec); + return nPrec; +} + +void WpADOColumn::put_Precision(sal_Int32 _nPre) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Precision(_nPre); +} + +sal_Int32 WpADOColumn::get_DefinedSize() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Int32 nPrec=0; + pInterface->get_DefinedSize(&nPrec); + return nPrec; +} +sal_uInt8 WpADOColumn::get_NumericScale() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_uInt8 nPrec=0; + pInterface->get_NumericScale(&nPrec); + return nPrec; +} + +void WpADOColumn::put_NumericScale(sal_Int8 _nScale) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_NumericScale(_nScale); +} + +SortOrderEnum WpADOColumn::get_SortOrder() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + SortOrderEnum nPrec=adSortAscending; + pInterface->get_SortOrder(&nPrec); + return nPrec; +} + +void WpADOColumn::put_SortOrder(SortOrderEnum _nScale) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_SortOrder(_nScale); +} + +ColumnAttributesEnum WpADOColumn::get_Attributes() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ColumnAttributesEnum eNum=adColNullable; + pInterface->get_Attributes(&eNum); + return eNum; +} + +sal_Bool WpADOColumn::put_Attributes(const ColumnAttributesEnum& _eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + return SUCCEEDED(pInterface->put_Attributes(_eNum)); +} + +WpADOProperties WpADOColumn::get_Properties() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOProperties* pProps = NULL; + pInterface->get_Properties(&pProps); + WpADOProperties aProps; + + aProps.setWithOutAddRef(pProps); + return aProps; +} + +::rtl::OUString WpADOKey::get_Name() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +void WpADOKey::put_Name(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + (void)bErg; +} + +KeyTypeEnum WpADOKey::get_Type() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + KeyTypeEnum eNum=adKeyPrimary; + pInterface->get_Type(&eNum); + return eNum; +} + +void WpADOKey::put_Type(const KeyTypeEnum& _eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Type(_eNum); +} + +::rtl::OUString WpADOKey::get_RelatedTable() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_RelatedTable(&aBSTR); + return aBSTR; +} + +void WpADOKey::put_RelatedTable(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedTable(bstr)); + (void)bErg; +} + +RuleEnum WpADOKey::get_DeleteRule() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + RuleEnum eNum = adRINone; + pInterface->get_DeleteRule(&eNum); + return eNum; +} + +void WpADOKey::put_DeleteRule(const RuleEnum& _eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_DeleteRule(_eNum); +} + +RuleEnum WpADOKey::get_UpdateRule() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + RuleEnum eNum = adRINone; + pInterface->get_UpdateRule(&eNum); + return eNum; +} + +void WpADOKey::put_UpdateRule(const RuleEnum& _eNum) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_UpdateRule(_eNum); +} + +WpADOColumns WpADOKey::get_Columns() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOColumns* pCols = NULL; + pInterface->get_Columns(&pCols); + WpADOColumns aCols; + aCols.setWithOutAddRef(pCols); + return aCols; +} + +::rtl::OUString WpADOIndex::get_Name() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +void WpADOIndex::put_Name(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + (void)bErg; +} + +sal_Bool WpADOIndex::get_Clustered() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL eNum = VARIANT_FALSE; + pInterface->get_Clustered(&eNum); + return eNum == VARIANT_TRUE; +} + +void WpADOIndex::put_Clustered(sal_Bool _b) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Clustered(_b ? VARIANT_TRUE : VARIANT_FALSE); +} + +sal_Bool WpADOIndex::get_Unique() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL eNum = VARIANT_FALSE; + pInterface->get_Unique(&eNum); + return eNum == VARIANT_TRUE; +} + +void WpADOIndex::put_Unique(sal_Bool _b) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_Unique(_b ? VARIANT_TRUE : VARIANT_FALSE); +} + +sal_Bool WpADOIndex::get_PrimaryKey() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + VARIANT_BOOL eNum = VARIANT_FALSE; + pInterface->get_PrimaryKey(&eNum); + return eNum == VARIANT_TRUE; +} + +void WpADOIndex::put_PrimaryKey(sal_Bool _b) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE); +} + +WpADOColumns WpADOIndex::get_Columns() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOColumns* pCols = NULL; + pInterface->get_Columns(&pCols); + WpADOColumns aCols; + aCols.setWithOutAddRef(pCols); + return aCols; +} + +void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->putref_ActiveConnection(pCon); +} + +WpADOTables WpADOCatalog::get_Tables() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOTables* pRet = NULL; + pInterface->get_Tables(&pRet); + WpADOTables aRet; + aRet.setWithOutAddRef(pRet); + return aRet; +} + +WpADOViews WpADOCatalog::get_Views() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOViews* pRet = NULL; + pInterface->get_Views(&pRet); + WpADOViews aRet; + aRet.setWithOutAddRef(pRet); + return aRet; +} + +WpADOGroups WpADOCatalog::get_Groups() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOGroups* pRet = NULL; + pInterface->get_Groups(&pRet); + WpADOGroups aRet; + aRet.setWithOutAddRef(pRet); + return aRet; +} + +WpADOUsers WpADOCatalog::get_Users() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOUsers* pRet = NULL; + pInterface->get_Users(&pRet); + WpADOUsers aRet; + aRet.setWithOutAddRef(pRet); + return aRet; +} + +ADOProcedures* WpADOCatalog::get_Procedures() +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOProcedures* pRet = NULL; + pInterface->get_Procedures(&pRet); + return pRet; +} + +::rtl::OUString WpADOTable::get_Name() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +void WpADOTable::put_Name(const ::rtl::OUString& _rName) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + (void)bErg; +} + +::rtl::OUString WpADOTable::get_Type() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Type(&aBSTR); + return aBSTR; +} + +WpADOColumns WpADOTable::get_Columns() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOColumns* pCols = NULL; + pInterface->get_Columns(&pCols); + WpADOColumns aCols; + aCols.setWithOutAddRef(pCols); + return aCols; +} + +WpADOIndexes WpADOTable::get_Indexes() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOIndexes* pCols = NULL; + pInterface->get_Indexes(&pCols); + WpADOIndexes aRet; + aRet.setWithOutAddRef(pCols); + return aRet; +} + +WpADOKeys WpADOTable::get_Keys() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOKeys* pCols = NULL; + pInterface->get_Keys(&pCols); + WpADOKeys aRet; + aRet.setWithOutAddRef(pCols); + return aRet; +} + +WpADOCatalog WpADOTable::get_ParentCatalog() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOCatalog* pCat = NULL; + pInterface->get_ParentCatalog(&pCat); + WpADOCatalog aRet; + aRet.setWithOutAddRef(pCat); + return aRet; +} + +WpADOProperties WpADOTable::get_Properties() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + ADOProperties* pProps = NULL; + pInterface->get_Properties(&pProps); + WpADOProperties aProps; + aProps.setWithOutAddRef(pProps); + return aProps; +} + +::rtl::OUString WpADOView::get_Name() const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +void WpADOView::get_Command(OLEVariant& _rVar) const +{ + OSL_ENSURE(pInterface,"Interface is null!"); + pInterface->get_Command(&_rVar); +} + +void WpADOView::put_Command(OLEVariant& _rVar) +{ + pInterface->put_Command(_rVar); +} + +::rtl::OUString WpADOGroup::get_Name() const +{ + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +void WpADOGroup::put_Name(const ::rtl::OUString& _rName) +{ + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + (void)bErg; +} + +RightsEnum WpADOGroup::GetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType) +{ + RightsEnum Rights=adRightNone; + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights); + return Rights; +} + +sal_Bool WpADOGroup::SetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType, + /* [in] */ ActionEnum Action, + /* [in] */ RightsEnum Rights) +{ + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); +} + +WpADOUsers WpADOGroup::get_Users( ) +{ + ADOUsers* pRet = NULL; + pInterface->get_Users( &pRet); + WpADOUsers aRet; + aRet.setWithOutAddRef(pRet); + return aRet; +} + +::rtl::OUString WpADOUser::get_Name() const +{ + OLEString aBSTR; + pInterface->get_Name(&aBSTR); + return aBSTR; +} + +void WpADOUser::put_Name(const ::rtl::OUString& _rName) +{ + OLEString bstr(_rName); + sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr)); + (void)bErg; +} + +sal_Bool WpADOUser::ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUString& _rNewPwd) +{ + OLEString sStr1(_rPwd); + OLEString sStr2(_rNewPwd); + sal_Bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1,sStr2)); + return bErg; +} + +WpADOGroups WpADOUser::get_Groups() +{ + ADOGroups* pRet = NULL; + pInterface->get_Groups(&pRet); + WpADOGroups aRet; + aRet.setWithOutAddRef(pRet); + return aRet; +} + +RightsEnum WpADOUser::GetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType) +{ + RightsEnum Rights=adRightNone; + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights); + return Rights; +} + +sal_Bool WpADOUser::SetPermissions( + /* [in] */ const OLEVariant& Name, + /* [in] */ ObjectTypeEnum ObjectType, + /* [in] */ ActionEnum Action, + /* [in] */ RightsEnum Rights) +{ + OLEVariant ObjectTypeId; + ObjectTypeId.setNoArg(); + return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId)); +} + +WpBase::WpBase() : pIUnknown(NULL) +{ +} +WpBase::WpBase(IDispatch* pInt) + :pIUnknown(pInt) +{ + if (pIUnknown) + { + ULONG nCount = pIUnknown->AddRef(); + (void)nCount; + // OSL_ENSURE(nCount == 1,"Count is greater than 1"); + } +} + +//inline +WpBase& WpBase::operator=(const WpBase& rhs) +{ + if (rhs.pIUnknown != pIUnknown) + { + if (pIUnknown) + pIUnknown->Release(); + pIUnknown = rhs.pIUnknown; + if (pIUnknown) + pIUnknown->AddRef(); + } + return *this; +}; + +WpBase& WpBase::operator=(IDispatch* rhs) +{ + if (pIUnknown != rhs) + { + if (pIUnknown) + pIUnknown->Release(); + pIUnknown = rhs; + if (pIUnknown) + pIUnknown->AddRef(); + } + return *this; +} + +WpBase::WpBase(const WpBase& aWrapper) +{ + operator=(aWrapper); +} + +WpBase::~WpBase() +{ + if (pIUnknown) + { + pIUnknown->Release(); + pIUnknown = NULL; + } +} + +void WpBase::clear() +{ + if (pIUnknown) + { + pIUnknown->Release(); + pIUnknown = NULL; + } +} + + +sal_Bool WpBase::IsValid() const +{ + return pIUnknown != NULL; +} +WpBase::operator IDispatch*() +{ + return pIUnknown; +} + +ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[6]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.getLength() && schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[6]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.getLength() && schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + + return pRecordset; + +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[3]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.getLength() && schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getIndexInfo( + const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, + sal_Bool /*unique*/, sal_Bool /*approximate*/ ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[5]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.getLength() && schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern ) +{ + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[5]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.getLength() && schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(tableNamePattern.toChar() != '%') + varCriteria[nPos].setString(tableNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, + const ::rtl::OUString& primarySchema, + const ::rtl::OUString& primaryTable, + const ::com::sun::star::uno::Any& foreignCatalog, + const ::rtl::OUString& foreignSchema, + const ::rtl::OUString& foreignTable) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[6]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(primaryCatalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(primaryCatalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(primarySchema.getLength() && primarySchema.toChar() != '%') + varCriteria[nPos].setString(primarySchema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(primaryTable); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + if(foreignCatalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(foreignCatalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(foreignSchema.getLength() && foreignSchema.toChar() != '%') + varCriteria[nPos].setString(foreignSchema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(foreignTable); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern ) +{ + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[3]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.getLength() && schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(procedureNamePattern.toChar() != '%') + varCriteria[nPos].setString(procedureNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& procedureNamePattern, + const ::rtl::OUString& columnNamePattern ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.getLength() && schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(procedureNamePattern.toChar() != '%') + varCriteria[nPos].setString(procedureNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + if(columnNamePattern.toChar() != '%') + varCriteria[nPos].setString(columnNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getTables( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + OLEVariant varCriteria[4]; + + sal_Int32 nPos=0; + ::rtl::OUString sCatalog; + if ( catalog.hasValue() && (catalog >>= sCatalog) ) + varCriteria[nPos].setString(sCatalog); + + ++nPos; + if(schemaPattern.getLength() && schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + + ++nPos; + if(tableNamePattern.toChar() != '%') + varCriteria[nPos].setString(tableNamePattern); + + ++nPos; + ::rtl::OUStringBuffer aTypes; + ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(","); + const ::rtl::OUString* pIter = types.getConstArray(); + const ::rtl::OUString* pEnd = pIter + types.getLength(); + for( ; pIter != pEnd ; ++pIter) + { + if ( aTypes.getLength() ) + aTypes.append(aComma); + aTypes.append(*pIter); + } + + ::rtl::OUString sTypeNames = aTypes.makeStringAndClear(); + if ( sTypeNames.getLength() ) + varCriteria[nPos].setString(sTypeNames); + + // Create SafeArray Bounds and initialize the array + const sal_Int32 nCrit = sizeof varCriteria / sizeof varCriteria[0]; + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = nCrit; + SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + // Set the values for each element of the array + for( long i = 0 ; i < nCrit && SUCCEEDED( hr );i++) + { + hr = SafeArrayPutElement(psa, &i,&varCriteria[i]); + } + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schemaPattern, + const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schemaPattern.getLength() && schemaPattern.toChar() != '%') + varCriteria[nPos].setString(schemaPattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + if(tableNamePattern.toChar() != '%') + varCriteria[nPos].setString(tableNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + varCriteria[nPos].setString(columnNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, + const ::rtl::OUString& schema, + const ::rtl::OUString& table, + const ::rtl::OUString& columnNamePattern ) +{ + // Create elements used in the array + HRESULT hr = S_OK; + SAFEARRAYBOUND rgsabound[1]; + SAFEARRAY *psa = NULL; + OLEVariant varCriteria[4]; + + // Create SafeArray Bounds and initialize the array + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0]; + psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos=0; + if(catalog.hasValue()) + varCriteria[nPos].setString(::comphelper::getString(catalog)); + + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG + if(schema.getLength() && schema.toChar() != '%') + varCriteria[nPos].setString(schema); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA + + varCriteria[nPos].setString(table); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME + + varCriteria[nPos].setString(columnNamePattern); + hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME + + OLEVariant vtEmpty; + vtEmpty.setNoArg(); + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + ADORecordset *pRecordset = NULL; + OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset); + + return pRecordset; +} +// ----------------------------------------------------------------------------- +ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/) +{ + // Create elements used in the array + OLEVariant varCriteria[2]; + const int nCrit = sizeof varCriteria / sizeof varCriteria[0]; + // Create SafeArray Bounds and initialize the array + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = nCrit; + SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound ); + + sal_Int32 nPos = 0; + SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; + SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++; + + // Initialize and fill the SafeArray + OLEVariant vsa; + vsa.setArray(psa,VT_VARIANT); + + OLEVariant aEmpty; + aEmpty.setNoArg(); + + ADORecordset *pRec=NULL; + OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec); + + return pRec; +} +// ----------------------------------------------------------------------------- +void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Bool bRet = SUCCEEDED(pInterface->put_ParentCatalog(ppvObject)); + OSL_ENSURE(bRet,"Could not set ParentCatalog!"); + OSL_UNUSED(bRet); +} +// ----------------------------------------------------------------------------- +void WpADOTable::putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject) +{ + OSL_ENSURE(pInterface,"Interface is null!"); + sal_Bool bRet = SUCCEEDED(pInterface->putref_ParentCatalog(ppvObject)); + OSL_ENSURE(bRet,"Could not set ParentCatalog!"); + OSL_UNUSED(bRet); +} +// ----------------------------------------------------------------------------- +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() ) + { + sal_Bool bRet = aProp.PutValue(_aValVar); + OSL_ENSURE(bRet,"Could not put value!"); + OSL_UNUSED(bRet); + } +} +// ----------------------------------------------------------------------------- +OLEVariant OTools::getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition) +{ + WpADOProperty aProp(_rProps.GetItem(_aPosition)); + return aProp.GetValue(); +} diff --git a/connectivity/source/drivers/ado/ado.component b/connectivity/source/drivers/ado/ado.component new file mode 100644 index 000000000000..1962a6b710a7 --- /dev/null +++ b/connectivity/source/drivers/ado/ado.component @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* 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. +* +* 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). +* +* 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. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.sdbc.ado.ODriver"> + <service name="com.sun.star.sdbc.Driver"/> + <service name="com.sun.star.sdbcx.Driver"/> + </implementation> +</component> diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu new file mode 100755 index 000000000000..e95e1a676c12 --- /dev/null +++ b/connectivity/source/drivers/ado/ado.xcu @@ -0,0 +1,264 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--*********************************************************************** + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************ --> +<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <node oor:name="Installed"> + <node oor:name="sdbc:ado:*" oor:op="replace"> + <prop oor:name="Driver"> + <value>com.sun.star.comp.sdbc.ado.ODriver</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">ADO</value> + </prop> + <node oor:name="Properties"> + <node oor:name="CharSet" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:string"> + <value></value> + </prop> + </node> + </node> + <node oor:name="Features"> + <node oor:name="GeneratedValues" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseSQL92NamingConstraints" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="AppendTableAliasInSelect" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="IgnoreDriverPrivileges" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="DisplayVersionColumns" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseCatalogInSelect" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseSchemaInSelect" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseIndexDirectionKeyword" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseDOSLineEnds" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="BooleanComparisonMode" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="FormsCheckRequiredFields" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="EscapeDateTime" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + <node oor:name="MetaData"> + <node oor:name="SupportsTableCreation" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="SupportsBrowsing" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="Authentication" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:string"> + <value>UserPassword</value> + </prop> + </node> + <node oor:name="SupportsColumnDescription" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + </node> + <node oor:name="sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=*" oor:op="replace"> + <prop oor:name="Driver"> + <value>com.sun.star.comp.sdbc.ado.ODriver</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">Microsoft Access</value> + </prop> + <node oor:name="Properties"> + <node oor:name="CharSet" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:string"> + <value></value> + </prop> + </node> + <node oor:name="BooleanComparisonMode" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:int"> + <value>3</value> + </prop> + </node> + <node oor:name="ColumnAliasInOrderBy" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> + <node oor:name="TypeInfoSettings" oor:op="replace"> + <prop oor:name="Value" oor:type="oor:string-list"> + <value oor:separator=",">Column(2) = 16,Column(3) = 1</value> + </prop> + </node> + </node> + <node oor:name="Features"> + <node oor:name="UseSQL92NamingConstraints" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="AppendTableAliasInSelect" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="UseDOSLineEnds" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="BooleanComparisonMode" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="FormsCheckRequiredFields" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="EscapeDateTime" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + <node oor:name="MetaData"> + <node oor:name="ColumnAliasInOrderBy" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> + <node oor:name="SupportsTableCreation" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="SupportsBrowsing" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="FileSystemBased" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + <node oor:name="MediaType" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:string"> + <value>application/msaccess</value> + </prop> + </node> + <node oor:name="Extension" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:string"> + <value>mdb</value> + </prop> + </node> + <node oor:name="SupportsColumnDescription" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + </node> + <node oor:name="sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=*" oor:op="replace"> + <prop oor:name="ParentURLPattern"> + <value>sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=*</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">Microsoft Access 2007</value> + </prop> + <node oor:name="MetaData"> + <node oor:name="Extension" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:string"> + <value></value> + </prop> + </node> + </node> + </node> + </node> +</oor:component-data> diff --git a/connectivity/source/drivers/ado/ado.xml b/connectivity/source/drivers/ado/ado.xml new file mode 100644 index 000000000000..dbd903e40fc4 --- /dev/null +++ b/connectivity/source/drivers/ado/ado.xml @@ -0,0 +1,29 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> ado </module-name> + <component-description> + <author>Ocke Janssen</author> + <name>com.sun.star.comp.sdbc.ado.ODriver</name> + <description> + This is the implementation of the ado-sdbc bridge. + </description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language>c++</language> + <status value="final"/> + <supported-service> com.sun.star.sdbc.Driver</supported-service> + </component-description> + <project-build-dependency>cppuhelper</project-build-dependency> + <project-build-dependency>cppu</project-build-dependency> + <project-build-dependency>sal</project-build-dependency> + <project-build-dependency>vos</project-build-dependency> + <runtime-module-dependency>cppuhelper</runtime-module-dependency> + <runtime-module-dependency>cppu</runtime-module-dependency> + <runtime-module-dependency>sal</runtime-module-dependency> + <runtime-module-dependency>vos</runtime-module-dependency> + <runtime-module-dependency>osl</runtime-module-dependency> + <runtime-module-dependency>dbtools</runtime-module-dependency> + <runtime-module-dependency>comphelper</runtime-module-dependency> +</module-description> + + diff --git a/connectivity/source/drivers/ado/ado_post_sys_include.h b/connectivity/source/drivers/ado/ado_post_sys_include.h new file mode 100644 index 000000000000..a368593027c7 --- /dev/null +++ b/connectivity/source/drivers/ado/ado_post_sys_include.h @@ -0,0 +1,32 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#undef ADO_REDUCED_WARN_LEVEL + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/connectivity/source/drivers/ado/ado_pre_sys_include.h b/connectivity/source/drivers/ado/ado_pre_sys_include.h new file mode 100644 index 000000000000..6eee7ab0948e --- /dev/null +++ b/connectivity/source/drivers/ado/ado_pre_sys_include.h @@ -0,0 +1,37 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#ifdef ADO_REDUCED_WARN_LEVEL + #error "ado_pre_sys_include.h included twice!" +#endif + +#ifdef _MSC_VER +#pragma warning(push,1) +#pragma warning(disable:4917) +#endif + +#define ADO_REDUCED_WARN_LEVEL diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx new file mode 100644 index 000000000000..b59f41a597fa --- /dev/null +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -0,0 +1,337 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include <com/sun/star/sdbcx/Privilege.hpp> +#include <com/sun/star/sdbcx/PrivilegeObject.hpp> +#include "connectivity/dbexception.hxx" +#include "ado/Awrapado.hxx" +#include "ado/adoimp.hxx" +#include <osl/diagnose.h> +#include <com/sun/star/sdbc/DataType.hpp> + + +using namespace connectivity::ado; +using namespace com::sun::star::uno; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; + + +#define MYADOID(l) {l, 0,0x10,0x80,0,0,0xAA,0,0x6D,0x2E,0xA4}; + +const CLSID ADOS::CLSID_ADOCONNECTION_21 = MYADOID(0x00000514); +const IID ADOS::IID_ADOCONNECTION_21 = MYADOID(0x00000550); + +const CLSID ADOS::CLSID_ADOCOMMAND_21 = MYADOID(0x00000507); +const IID ADOS::IID_ADOCOMMAND_21 = MYADOID(0x0000054E); + +const CLSID ADOS::CLSID_ADORECORDSET_21 = MYADOID(0x00000535); +const IID ADOS::IID_ADORECORDSET_21 = MYADOID(0x0000054F); + +const CLSID ADOS::CLSID_ADOCATALOG_25 = MYADOID(0x00000602); +const IID ADOS::IID_ADOCATALOG_25 = MYADOID(0x00000603); + +const CLSID ADOS::CLSID_ADOINDEX_25 = MYADOID(0x0000061E); +const IID ADOS::IID_ADOINDEX_25 = MYADOID(0x0000061F); + +const CLSID ADOS::CLSID_ADOTABLE_25 = MYADOID(0x00000609); +const IID ADOS::IID_ADOTABLE_25 = MYADOID(0x00000610); + +const CLSID ADOS::CLSID_ADOKEY_25 = MYADOID(0x00000621); +const IID ADOS::IID_ADOKEY_25 = MYADOID(0x00000622); + +const CLSID ADOS::CLSID_ADOCOLUMN_25 = MYADOID(0x0000061B); +const IID ADOS::IID_ADOCOLUMN_25 = MYADOID(0x0000061C); + +const CLSID ADOS::CLSID_ADOGROUP_25 = MYADOID(0x00000615); +const IID ADOS::IID_ADOGROUP_25 = MYADOID(0x00000616); + +const CLSID ADOS::CLSID_ADOUSER_25 = MYADOID(0x00000618); +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) +{ + sal_Int32 nType = DataType::VARCHAR;; + switch (eType) + { + case adUnsignedSmallInt: + case adSmallInt: nType = DataType::SMALLINT; break; + case adUnsignedInt: + case adInteger: nType = DataType::INTEGER; break; + case adUnsignedBigInt: + case adBigInt: nType = DataType::BIGINT; break; + case adSingle: nType = DataType::FLOAT; break; + case adDouble: nType = DataType::DOUBLE; break; + case adCurrency: nType = DataType::DOUBLE; break; + case adVarNumeric: + case adNumeric: nType = DataType::NUMERIC; break; + case adDecimal: nType = DataType::DECIMAL; break; + case adDBDate: nType = DataType::DATE; break; + case adDBTime: nType = DataType::TIME; break; + case adDate: + case adDBTimeStamp: nType = DataType::TIMESTAMP; break; + case adBoolean: nType = DataType::BOOLEAN; break; +// case adArray: nType = DataType::ARRAY; break; + case adBinary: nType = DataType::BINARY; break; + case adGUID: nType = DataType::OBJECT; break; + case adBSTR: + case adVarWChar: + case adWChar: + case adVarChar: nType = DataType::VARCHAR; break; + case adLongVarWChar: + case adLongVarChar: nType = DataType::LONGVARCHAR; break; + case adVarBinary: nType = DataType::VARBINARY; break; + case adLongVarBinary: nType = DataType::LONGVARBINARY;break; + case adChar: nType = DataType::CHAR; break; + case adUnsignedTinyInt: + case adTinyInt: nType = DataType::TINYINT; break; + case adEmpty: nType = DataType::SQLNULL; break; + case adUserDefined: + case adPropVariant: + case adFileTime: + case adChapter: + case adIDispatch: + case adIUnknown: + case adError: + case adVariant: + nType = DataType::OTHER; break; + default: + OSL_ENSURE(0,"MapADOType2Jdbc: Unknown Type!"); + ; + } + return nType; +} +// ------------------------------------------------------------------------- +DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine) +{ + switch (_nType) + { + case DataType::SMALLINT: return adSmallInt; break; + case DataType::INTEGER: return adInteger; break; + case DataType::BIGINT: return adBigInt; break; + case DataType::FLOAT: return adSingle; break; + case DataType::DOUBLE: return adDouble; break; + case DataType::NUMERIC: return adNumeric; break; + case DataType::DECIMAL: return adDecimal; break; + case DataType::DATE: return isJetEngine(_nJetEngine) ? adDate : adDBDate; break; + case DataType::TIME: return adDBTime; break; + case DataType::TIMESTAMP: return isJetEngine(_nJetEngine) ? adDate : adDBTimeStamp; break; + case DataType::BOOLEAN: + case DataType::BIT: return adBoolean; break; + case DataType::BINARY: return adBinary; break; + case DataType::VARCHAR: return adVarWChar; break; + case DataType::CLOB: + case DataType::LONGVARCHAR: return adLongVarWChar; break; + case DataType::VARBINARY: return adVarBinary; break; + case DataType::BLOB: + case DataType::LONGVARBINARY: return adLongVarBinary; break; + case DataType::CHAR: return adWChar; break; + case DataType::TINYINT: return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break; + case DataType::OBJECT: return adGUID; break; + default: + OSL_ENSURE(0,"MapJdbc2ADOType: Unknown Type!"); + ; + } + return adEmpty; +} +// ----------------------------------------------------------------------------- +const int JET_ENGINETYPE_UNKNOWN = 0; +const int JET_ENGINETYPE_JET10 = 1; +const int JET_ENGINETYPE_JET11 = 2; +const int JET_ENGINETYPE_JET20 = 3; +const int JET_ENGINETYPE_JET3X = 4; +const int JET_ENGINETYPE_JET4X = 5; +const int JET_ENGINETYPE_DBASE3 = 10; +const int JET_ENGINETYPE_DBASE4 = 11; +const int JET_ENGINETYPE_DBASE5 = 12; +const int JET_ENGINETYPE_EXCEL30 = 20; +const int JET_ENGINETYPE_EXCEL40 = 21; +const int JET_ENGINETYPE_EXCEL50 = 22; +const int JET_ENGINETYPE_EXCEL80 = 23; +const int JET_ENGINETYPE_EXCEL90 = 24; +const int JET_ENGINETYPE_EXCHANGE4 = 30; +const int JET_ENGINETYPE_LOTUSWK1 = 40; +const int JET_ENGINETYPE_LOTUSWK3 = 41; +const int JET_ENGINETYPE_LOTUSWK4 = 42; +const int JET_ENGINETYPE_PARADOX3X = 50; +const int JET_ENGINETYPE_PARADOX4X = 51; +const int JET_ENGINETYPE_PARADOX5X = 52; +const int JET_ENGINETYPE_PARADOX7X = 53; +const int JET_ENGINETYPE_TEXT1X = 60; +const int JET_ENGINETYPE_HTML1X = 70; + +sal_Bool ADOS::isJetEngine(sal_Int32 _nEngineType) +{ + sal_Bool bRet = sal_False; + switch(_nEngineType) + { + case JET_ENGINETYPE_UNKNOWN: + case JET_ENGINETYPE_JET10: + case JET_ENGINETYPE_JET11: + case JET_ENGINETYPE_JET20: + case JET_ENGINETYPE_JET3X: + case JET_ENGINETYPE_JET4X: + case JET_ENGINETYPE_DBASE3: + case JET_ENGINETYPE_DBASE4: + case JET_ENGINETYPE_DBASE5: + case JET_ENGINETYPE_EXCEL30: + case JET_ENGINETYPE_EXCEL40: + case JET_ENGINETYPE_EXCEL50: + case JET_ENGINETYPE_EXCEL80: + case JET_ENGINETYPE_EXCEL90: + case JET_ENGINETYPE_EXCHANGE4: + case JET_ENGINETYPE_LOTUSWK1: + case JET_ENGINETYPE_LOTUSWK3: + case JET_ENGINETYPE_LOTUSWK4: + case JET_ENGINETYPE_PARADOX3X: + case JET_ENGINETYPE_PARADOX4X: + case JET_ENGINETYPE_PARADOX5X: + case JET_ENGINETYPE_PARADOX7X: + case JET_ENGINETYPE_TEXT1X: + case JET_ENGINETYPE_HTML1X: + bRet = sal_True; + break; + } + return bRet; +} +// ----------------------------------------------------------------------------- +ObjectTypeEnum ADOS::mapObjectType2Ado(sal_Int32 objType) +{ + ObjectTypeEnum eType = adPermObjTable; + switch(objType) + { + case PrivilegeObject::TABLE: + eType = adPermObjTable; + break; + case PrivilegeObject::VIEW: + eType = adPermObjView; + break; + case PrivilegeObject::COLUMN: + eType = adPermObjColumn; + break; + } + return eType; +} +// ----------------------------------------------------------------------------- +sal_Int32 ADOS::mapAdoType2Object(ObjectTypeEnum objType) +{ + sal_Int32 nType = PrivilegeObject::TABLE; + switch(objType) + { + case adPermObjTable: + nType = PrivilegeObject::TABLE; + break; + case adPermObjView: + nType = PrivilegeObject::VIEW; + break; + case adPermObjColumn: + nType = PrivilegeObject::COLUMN; + break; + default: + OSL_ENSURE( false, "ADOS::mapAdoType2Object: privilege type cannot be translated!" ); + break; + } + return nType; +} +#ifdef DELETE +#undef DELETE +#endif +// ----------------------------------------------------------------------------- +sal_Int32 ADOS::mapAdoRights2Sdbc(RightsEnum eRights) +{ + sal_Int32 nRights = 0; + if((eRights & adRightInsert) == adRightInsert) + nRights |= Privilege::INSERT; + if((eRights & adRightDelete) == adRightDelete) + nRights |= ::com::sun::star::sdbcx::Privilege::DELETE; + if((eRights & adRightUpdate) == adRightUpdate) + nRights |= Privilege::UPDATE; + if((eRights & adRightWriteDesign) == adRightWriteDesign) + nRights |= Privilege::ALTER; + if((eRights & adRightRead) == adRightRead) + nRights |= Privilege::SELECT; + if((eRights & adRightReference) == adRightReference) + nRights |= Privilege::REFERENCE; + if((eRights & adRightDrop) == adRightDrop) + nRights |= Privilege::DROP; + + return nRights; +} +// ----------------------------------------------------------------------------- +sal_Int32 ADOS::mapRights2Ado(sal_Int32 nRights) +{ + sal_Int32 eRights = adRightNone; + + if((nRights & Privilege::INSERT) == Privilege::INSERT) + eRights |= adRightInsert; + if((nRights & Privilege::DELETE) == Privilege::DELETE) + eRights |= adRightDelete; + if((nRights & Privilege::UPDATE) == Privilege::UPDATE) + eRights |= adRightUpdate; + if((nRights & Privilege::ALTER) == Privilege::ALTER) + eRights |= adRightWriteDesign; + if((nRights & Privilege::SELECT) == Privilege::SELECT) + eRights |= adRightRead; + if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE) + eRights |= adRightReference; + if((nRights & Privilege::DROP) == Privilege::DROP) + eRights |= adRightDrop; + + return eRights; +} +// ----------------------------------------------------------------------------- +WpADOField ADOS::getField(ADORecordset* _pRecordSet,sal_Int32 _nColumnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + if ( !_pRecordSet ) + return WpADOField(); + + ADOFields* pFields = NULL; + _pRecordSet->get_Fields(&pFields); + WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields); + if(_nColumnIndex <= 0 || _nColumnIndex > aFields.GetItemCount()) + ::dbtools::throwInvalidIndexException(NULL); + WpADOField aField(aFields.GetItem(_nColumnIndex-1)); + if(!aField.IsValid()) + ::dbtools::throwInvalidIndexException(NULL); + return aField; +} +// ----------------------------------------------------------------------------- + + + + diff --git a/connectivity/source/drivers/ado/exports.dxp b/connectivity/source/drivers/ado/exports.dxp new file mode 100644 index 000000000000..f0e1c69934bc --- /dev/null +++ b/connectivity/source/drivers/ado/exports.dxp @@ -0,0 +1,2 @@ +component_getImplementationEnvironment +component_getFactory diff --git a/connectivity/source/drivers/ado/makefile.mk b/connectivity/source/drivers/ado/makefile.mk new file mode 100644 index 000000000000..2b3c91a2010c --- /dev/null +++ b/connectivity/source/drivers/ado/makefile.mk @@ -0,0 +1,122 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# 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. +# +# 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). +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=ado +VISIBILITY_HIDDEN=TRUE + +# ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : $(PRJ)$/version.mk +.INCLUDE : $(PRJ)$/makefile.pmk + +.IF "$(GUI)"=="WNT" +# --- Files ------------------------------------- + +EXCEPTIONSFILES= \ + $(SLO)$/ADatabaseMetaDataImpl.obj \ + $(SLO)$/Aolevariant.obj \ + $(SLO)$/ADatabaseMetaData.obj \ + $(SLO)$/AColumn.obj \ + $(SLO)$/AColumns.obj \ + $(SLO)$/AIndex.obj \ + $(SLO)$/AIndexes.obj \ + $(SLO)$/AKey.obj \ + $(SLO)$/AKeys.obj \ + $(SLO)$/AUser.obj \ + $(SLO)$/AUsers.obj \ + $(SLO)$/AGroup.obj \ + $(SLO)$/AGroups.obj \ + $(SLO)$/ACatalog.obj \ + $(SLO)$/AView.obj \ + $(SLO)$/AViews.obj \ + $(SLO)$/ATable.obj \ + $(SLO)$/ATables.obj \ + $(SLO)$/ACallableStatement.obj \ + $(SLO)$/ADatabaseMetaDataResultSetMetaData.obj \ + $(SLO)$/ADatabaseMetaDataResultSet.obj \ + $(SLO)$/AResultSet.obj \ + $(SLO)$/AConnection.obj \ + $(SLO)$/AStatement.obj \ + $(SLO)$/APreparedStatement.obj \ + $(SLO)$/AResultSetMetaData.obj \ + $(SLO)$/ADriver.obj \ + $(SLO)$/Aservices.obj + +SLOFILES=\ + $(EXCEPTIONSFILES) \ + $(SLO)$/Awrapado.obj \ + $(SLO)$/adoimp.obj +# --- Library ----------------------------------- + +SHL1TARGET= $(ADO_TARGET)$(DLLPOSTFIX) +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(OLE32LIB) \ + $(OLEAUT32LIB) \ + $(UUIDLIB) \ + $(DBTOOLSLIB) \ + $(COMPHELPERLIB) + +.IF "$(COMPHELPERLIB)" == "" +SHL1STDLIBS+= icomphelp2.lib +.ENDIF + +#SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +.ELSE +dummy: + @echo "Nothing to build for GUI $(GUI)" +.ENDIF # "$(GUI)"=="WNT" +# --- Targets ---------------------------------- +.INCLUDE : $(PRJ)$/target.pmk + + +ALLTAR : $(MISC)/ado.component + +$(MISC)/ado.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + ado.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt ado.component |