diff options
Diffstat (limited to 'connectivity/source/drivers/evoab2')
18 files changed, 1047 insertions, 811 deletions
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx index d8dcb3616fb6..8de1f8f59c0c 100644 --- a/connectivity/source/drivers/evoab2/EApi.cxx +++ b/connectivity/source/drivers/evoab2/EApi.cxx @@ -69,6 +69,7 @@ typedef void (*SymbolFunc) (void); SYM_MAP( e_book_query_and ), SYM_MAP( e_book_query_or ), SYM_MAP( e_book_query_not ), + SYM_MAP( e_book_query_ref ), SYM_MAP( e_book_query_unref ), SYM_MAP( e_book_query_from_string ), SYM_MAP( e_book_query_to_string ), @@ -83,7 +84,7 @@ tryLink( oslModule &aModule, const char *pName ) for( guint i = 0; i < G_N_ELEMENTS( aApiMap ); i++ ) { SymbolFunc aMethod; - aMethod = (SymbolFunc) osl_getSymbol + aMethod = (SymbolFunc) osl_getFunctionSymbol ( aModule, rtl::OUString::createFromAscii ( aApiMap[ i ].sym_name ).pData ); if( !aMethod ) { diff --git a/connectivity/source/drivers/evoab2/EApi.h b/connectivity/source/drivers/evoab2/EApi.h index ce969f38673a..34dfc8930949 100644 --- a/connectivity/source/drivers/evoab2/EApi.h +++ b/connectivity/source/drivers/evoab2/EApi.h @@ -124,6 +124,7 @@ EAPI_EXTERN EBookQuery* (*e_book_query_field_test) (EContactField field, EAPI_EXTERN EBookQuery* (*e_book_query_and) (int nqs, EBookQuery **qs, gboolean unref); EAPI_EXTERN EBookQuery* (*e_book_query_or) (int nqs, EBookQuery **qs, gboolean unref); EAPI_EXTERN EBookQuery* (*e_book_query_not) (EBookQuery *q, gboolean unref); +EAPI_EXTERN EBookQuery* (*e_book_query_ref) (EBookQuery *q); EAPI_EXTERN void (*e_book_query_unref) (EBookQuery *q); EAPI_EXTERN char* (*e_book_query_to_string) (EBookQuery *q); EAPI_EXTERN EBookQuery* (*e_book_query_from_string) (const char *query_string); diff --git a/connectivity/source/drivers/evoab2/NConnection.cxx b/connectivity/source/drivers/evoab2/NConnection.cxx index f999a49c7df0..b38ad6b9e629 100644 --- a/connectivity/source/drivers/evoab2/NConnection.cxx +++ b/connectivity/source/drivers/evoab2/NConnection.cxx @@ -82,11 +82,10 @@ using namespace ::com::sun::star::lang; } // -------------------------------------------------------------------------------- -OEvoabConnection::OEvoabConnection(OEvoabDriver* _pDriver) - :OSubComponent<OEvoabConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this) - ,m_pDriver(_pDriver) +OEvoabConnection::OEvoabConnection( OEvoabDriver& _rDriver ) + :OSubComponent<OEvoabConnection, OConnection_BASE>( (::cppu::OWeakObject*)(&_rDriver), this ) + ,m_rDriver(_rDriver) ,m_xCatalog(NULL) - ,m_aPassword() { } //----------------------------------------------------------------------------- @@ -98,8 +97,6 @@ OEvoabConnection::~OEvoabConnection() acquire(); close(); } - - m_pDriver = NULL; } //----------------------------------------------------------------------------- @@ -195,8 +192,9 @@ Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( con ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement(this, sql); + OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement( this ); Reference< XPreparedStatement > xStmt = pStmt; + pStmt->construct( sql ); m_aStatements.push_back(WeakReferenceHelper(*pStmt)); return xStmt; @@ -228,11 +226,11 @@ void SAL_CALL OEvoabConnection::close( ) throw(SQLException, RuntimeException) // XWarningsSupplier Any SAL_CALL OEvoabConnection::getWarnings( ) throw(SQLException, RuntimeException) { - return Any(); // when you collected some warnings -> return it + return m_aWarnings.getWarnings(); } void SAL_CALL OEvoabConnection::clearWarnings( ) throw(SQLException, RuntimeException) { - // you should clear your collected warnings here + m_aWarnings.clearWarnings(); } //------------------------------------------------------------------------------ diff --git a/connectivity/source/drivers/evoab2/NConnection.hxx b/connectivity/source/drivers/evoab2/NConnection.hxx index bcd3b3b61ce4..3ffa903e92cf 100644 --- a/connectivity/source/drivers/evoab2/NConnection.hxx +++ b/connectivity/source/drivers/evoab2/NConnection.hxx @@ -37,10 +37,12 @@ #include "OSubComponent.hxx" #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include "connectivity/CommonTools.hxx" +#include "connectivity/warningscontainer.hxx" #include "TConnection.hxx" #include <cppuhelper/weakref.hxx> #include <osl/module.h> #include "EApi.h" + namespace connectivity { namespace evoab @@ -57,35 +59,29 @@ namespace connectivity typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding - class OEvoabConnection : public OConnection_BASE, - public connectivity::OSubComponent<OEvoabConnection, OConnection_BASE> + class OEvoabConnection :public OConnection_BASE + ,public connectivity::OSubComponent<OEvoabConnection, OConnection_BASE> { - friend class connectivity::OSubComponent<OEvoabConnection, OConnection_BASE>; private: - OEvoabDriver *m_pDriver; - ::rtl::OUString m_pCurrentTableName; + const OEvoabDriver& m_rDriver; SDBCAddress::sdbc_address_type m_eSDBCAddressType; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > + m_xCatalog; + ::rtl::OString m_aPassword; + ::dbtools::WarningsContainer m_aWarnings; - protected: - - ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; - rtl::OString m_aPassword; - - - public: - OEvoabConnection(OEvoabDriver* _pDriver); virtual ~OEvoabConnection(); + public: + OEvoabConnection( OEvoabDriver& _rDriver ); virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); inline rtl::OString getPassword() { return m_aPassword; } inline void setPassword( rtl::OString aStr ) { m_aPassword = aStr; } - inline rtl::OUString& getCurrentTableName() {return m_pCurrentTableName;} - inline void setCurrentTableName(::rtl::OUString _name) {m_pCurrentTableName=_name;} // own methods - inline const OEvoabDriver* getDriver() const { return static_cast< const OEvoabDriver* >( m_pDriver ); } + inline const OEvoabDriver& getDriver() const { return m_rDriver; } SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;} void setSDBCAddressType(SDBCAddress::sdbc_address_type _eSDBCAddressType) {m_eSDBCAddressType = _eSDBCAddressType;} @@ -124,8 +120,6 @@ namespace connectivity // XWarningsSupplier virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - }; } } diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 259d5bbbc0b0..9765a30359a0 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NDatabaseMetaData.cxx,v $ - * $Revision: 1.12 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -174,21 +171,24 @@ namespace connectivity return NULL; } - sal_Int32 - getFieldType( guint nCol ) + GType + getGFieldType( guint nCol ) { - sal_Int32 nType = DataType::VARCHAR; initFields(); + + sal_Int32 nType = G_TYPE_STRING; if ( nCol < nFields ) - { - if( ((GParamSpec *)pFields[nCol]->pField)->value_type == G_TYPE_STRING ) - nType = DataType::VARCHAR; - else - nType = DataType::BIT; - } + return ((GParamSpec *)pFields[nCol]->pField)->value_type; return nType; } + sal_Int32 + getFieldType( guint nCol ) + { + sal_Int32 nType = getGFieldType( nCol ); + return nType == G_TYPE_STRING ? DataType::VARCHAR : DataType::BIT; + } + guint findEvoabField(const rtl::OUString& aColName) { guint nRet = (guint)-1; @@ -271,9 +271,7 @@ OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData() } // ------------------------------------------------------------------------- -ODatabaseMetaDataResultSet::ORows& SAL_CALL OEvoabDatabaseMetaData::getColumnRows( - const ::rtl::OUString& /*tableNamePattern*/, - const ::rtl::OUString& columnNamePattern ) throw(SQLException) +ODatabaseMetaDataResultSet::ORows& OEvoabDatabaseMetaData::getColumnRows( const ::rtl::OUString& columnNamePattern ) { static ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORow aRow(19); @@ -322,7 +320,7 @@ ODatabaseMetaDataResultSet::ORows& SAL_CALL OEvoabDatabaseMetaData::getColumnRow aRow[5] = new ORowSetValueDecorator( static_cast<sal_Int16>( getFieldType( i ) ) ); aRow[6] = new ORowSetValueDecorator( getFieldTypeName( i ) ); - OSL_TRACE( " ColumnName = '%s'", g_param_spec_get_name( pFields[i]->pField ) ); + OSL_TRACE( "ColumnName = '%s'", g_param_spec_get_name( pFields[i]->pField ) ); // COLUMN_NAME aRow[4] = new ORowSetValueDecorator( getFieldName( i ) ); // ORDINAL_POSITION @@ -1019,18 +1017,9 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) throw static ::rtl::OUString sTableTypes[] = { ::rtl::OUString::createFromAscii("TABLE"), - //m_pConnection->getCurrentTableName(), - // // Currently we only support a 'TABLE' nothing more complex - // - // ::rtl::OUString::createFromAscii("VIEW"), - // ::rtl::OUString::createFromAscii("SYSTEM TABLE"), - // ::rtl::OUString::createFromAscii("GLOBAL TEMPORARY"), - // ::rtl::OUString::createFromAscii("LOCAL TEMPORARY"), - // ::rtl::OUString::createFromAscii("ALIAS"), - // ::rtl::OUString::createFromAscii("SYNONYM") }; - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); Reference< XResultSet > xRef = pResult; // here we fill the rows which should be visible when ask for data from the resultset returned here @@ -1043,7 +1032,6 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) throw aRow.push_back(new ORowSetValueDecorator(sTableTypes[i])); // bound row - ODatabaseMetaDataResultSet::ORow::iterator aIter = aRow.begin(); aRows.push_back(aRow); } // here we set the rows at the resultset @@ -1076,7 +1064,7 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL)); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -1099,14 +1087,14 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) } // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( - const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern, + const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*tableNamePattern*/, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { // this returns an empty resultset where the column-names are already set // in special the metadata of the resultset already returns the right columns ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns ); Reference< XResultSet > xResultSet = pResultSet; - pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ) ); + pResultSet->setRows( getColumnRows( columnNamePattern ) ); return xResultSet; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx index 0432597e353a..d0e1803f3f5a 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NDatabaseMetaData.hxx,v $ - * $Revision: 1.10 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -70,6 +67,7 @@ namespace connectivity const ColumnProperty *getField(guint n); guint getFieldCount() ; + GType getGFieldType(guint nCol) ; sal_Int32 getFieldType(guint nCol) ; rtl::OUString getFieldTypeName(guint nCol) ; rtl::OUString getFieldName(guint nCol) ; @@ -81,7 +79,7 @@ namespace connectivity { OEvoabConnection* m_pConnection; - ODatabaseMetaDataResultSet::ORows& SAL_CALL getColumnRows( const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw( ::com::sun::star::sdbc::SQLException ); + ODatabaseMetaDataResultSet::ORows& getColumnRows( const ::rtl::OUString& columnNamePattern ); protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw(); diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx index ccbb47ce963f..9e2eddb8750a 100644 --- a/connectivity/source/drivers/evoab2/NDriver.cxx +++ b/connectivity/source/drivers/evoab2/NDriver.cxx @@ -82,7 +82,7 @@ void OEvoabDriver::disposing() xComp->dispose(); } catch (com::sun::star::lang::DisposedException e) { - xComp=NULL; + xComp.clear(); } } } @@ -147,7 +147,7 @@ Reference< XConnection > SAL_CALL OEvoabDriver::connect( const ::rtl::OUString& if ( ! acceptsURL(url) ) return NULL; - OEvoabConnection* pCon = new OEvoabConnection(this); + OEvoabConnection* pCon = new OEvoabConnection( *this ); pCon->construct(url,info); Reference< XConnection > xCon = pCon; m_xConnections.push_back(WeakReferenceHelper(*pCon)); diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx index 029349f834de..3efcdc740ebf 100644 --- a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx +++ b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NPreparedStatement.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -40,6 +37,7 @@ #include "propertyids.hxx" #include <connectivity/dbexception.hxx> #include <connectivity/dbtools.hxx> +#include <tools/diagnose_ex.h> #include "resource/common_res.hrc" @@ -55,49 +53,67 @@ using namespace com::sun::star::util; IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); -OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection, const ::rtl::OUString& sql) - :OStatement_BASE2(_pConnection) - ,m_nNumParams(0) - ,m_sSqlStatement(sql) - ,m_bPrepared(sal_False) +OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection ) + :OCommonStatement(_pConnection) + ,m_sSqlStatement() + ,m_xMetaData() { } + +// ----------------------------------------------------------------------------- +void OEvoabPreparedStatement::construct( const ::rtl::OUString& _sql ) +{ + m_sSqlStatement = _sql; + + m_aQueryData = impl_getEBookQuery_throw( m_sSqlStatement ); + ENSURE_OR_THROW( m_aQueryData.getQuery(), "no EBookQuery" ); + ENSURE_OR_THROW( m_aQueryData.xSelectColumns.isValid(), "no SelectColumn" ); + + // create our meta data + OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( m_aQueryData.sTable ); + m_xMetaData = pMeta; + pMeta->setEvoabFields( m_aQueryData.xSelectColumns ); +} + // ----------------------------------------------------------------------------- OEvoabPreparedStatement::~OEvoabPreparedStatement() { } + // ----------------------------------------------------------------------------- void SAL_CALL OEvoabPreparedStatement::acquire() throw() { - OStatement_BASE2::acquire(); + OCommonStatement::acquire(); } + // ----------------------------------------------------------------------------- void SAL_CALL OEvoabPreparedStatement::release() throw() { - OStatement_BASE2::release(); + OCommonStatement::release(); } + // ----------------------------------------------------------------------------- Any SAL_CALL OEvoabPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = OStatement_BASE2::queryInterface(rType); + Any aRet = OCommonStatement::queryInterface(rType); if(!aRet.hasValue()) aRet = OPreparedStatement_BASE::queryInterface(rType); return aRet; } // ------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OEvoabPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +Sequence< Type > SAL_CALL OEvoabPreparedStatement::getTypes( ) throw(RuntimeException) { - return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OStatement_BASE2::getTypes()); + return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes()); } // ------------------------------------------------------------------------- Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - if(!m_xMetaData.is()) - m_xMetaData = new OEvoabResultSetMetaData(m_pConnection->getCurrentTableName()); + // the meta data should have been created at construction time + ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" ); return m_xMetaData; } // ------------------------------------------------------------------------- @@ -105,13 +121,13 @@ Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( void SAL_CALL OEvoabPreparedStatement::close( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); free_column_resources(); // Reset last warning message try { clearWarnings (); - OStatement_BASE2::close(); + OCommonStatement::close(); } catch (SQLException &) { // If we get an error, ignore @@ -123,11 +139,9 @@ void SAL_CALL OEvoabPreparedStatement::close( ) throw(SQLException, RuntimeExce sal_Bool SAL_CALL OEvoabPreparedStatement::execute( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - Reference< XResultSet> xRS = OStatement_Base::executeQuery( m_sSqlStatement ); - // same as in statement with the difference that this statement also can contain parameter + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + Reference< XResultSet> xRS = impl_executeQuery_throw( m_aQueryData ); return xRS.is(); } // ------------------------------------------------------------------------- @@ -135,9 +149,8 @@ sal_Bool SAL_CALL OEvoabPreparedStatement::execute( ) throw(SQLException, Runti sal_Int32 SAL_CALL OEvoabPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - // same as in statement with the difference that this statement also can contain parameter + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this ); return 0; } // ------------------------------------------------------------------------- @@ -151,19 +164,18 @@ void SAL_CALL OEvoabPreparedStatement::setString( sal_Int32 /*parameterIndex*/, Reference< XConnection > SAL_CALL OEvoabPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - return (Reference< XConnection >)m_pConnection; + return impl_getConnection(); } // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - Reference< XResultSet > rs = OStatement_Base::executeQuery( m_sSqlStatement ); - return rs; + return impl_executeQuery_throw( m_aQueryData ); } // ------------------------------------------------------------------------- @@ -268,7 +280,7 @@ void SAL_CALL OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex, cons { if(!::dbtools::implSetObject(this,parameterIndex,x)) { - const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution( + const ::rtl::OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution( STR_UNKNOWN_PARA_TYPE, "$position$", ::rtl::OUString::valueOf(parameterIndex) ) ); @@ -290,13 +302,13 @@ void SAL_CALL OEvoabPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, c // ------------------------------------------------------------------------- -void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) { ::dbtools::throwFunctionNotSupportedException( "XParameters::setCharacterStream", *this ); } // ------------------------------------------------------------------------- -void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) { ::dbtools::throwFunctionNotSupportedException( "XParameters::setBinaryStream", *this ); } @@ -305,35 +317,18 @@ void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterInd void SAL_CALL OEvoabPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) { } -// ------------------------------------------------------------------------- -void OEvoabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) -{ - switch(nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - break; - case PROPERTY_ID_RESULTSETTYPE: - break; - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_USEBOOKMARKS: - break; - default: - OStatement_Base::setFastPropertyValue_NoBroadcast(nHandle,rValue); - } -} // ----------------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( ) throw(SQLException, RuntimeException) { return NULL; } // ----------------------------------------------------------------------------- -sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( ) throw(SQLException, RuntimeException) { return 0; } // ----------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( ) throw(SQLException, RuntimeException) { return sal_False; } diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx index b86e5a4db64b..a20ef1e7f084 100644 --- a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx +++ b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NPreparedStatement.hxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -53,8 +50,8 @@ namespace connectivity ::com::sun::star::sdbc::XMultipleResults, ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE; - class OEvoabPreparedStatement : public OStatement_BASE2, - public OPreparedStatement_BASE + class OEvoabPreparedStatement :public OCommonStatement + ,public OPreparedStatement_BASE { protected: struct Parameter @@ -74,25 +71,23 @@ namespace connectivity // Data attributes //==================================================================== - sal_Int32 m_nNumParams; // Number of parameter markers - // for the prepared statement - - ::rtl::OUString m_sSqlStatement; + // our SQL statement + ::rtl::OUString m_sSqlStatement; + // the EBookQuery we're working with + QueryData m_aQueryData; + // our meta data ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; - sal_Bool m_bPrepared; - protected: - virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue) - throw (::com::sun::star::uno::Exception); virtual ~OEvoabPreparedStatement(); + public: - DECLARE_SERVICE_INFO(); - // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: - //OEvoabPreparedStatement( OEvoabConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql); - OEvoabPreparedStatement( OEvoabConnection* _pConnection, const ::rtl::OUString& sql); + OEvoabPreparedStatement( OEvoabConnection* _pConnection ); + void construct( const ::rtl::OUString& _sql ); + + protected: + DECLARE_SERVICE_INFO(); //XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL acquire() throw(); @@ -137,7 +132,6 @@ namespace connectivity virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; } } diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index 0001f12ae158..d71908e0afd8 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NResultSet.cxx,v $ - * $Revision: 1.8.56.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,34 +27,43 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" -#include <comphelper/property.hxx> -#include <comphelper/sequence.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/extract.hxx> + +#include "NDatabaseMetaData.hxx" +#include "NConnection.hxx" +#include "NResultSet.hxx" +#include "propertyids.hxx" +#include "resource/evoab2_res.hrc" +#include "TSortIndex.hxx" +#include <algorithm> + +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> +#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/FetchDirection.hpp> #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> + +#include <comphelper/componentcontext.hxx> +#include <comphelper/extract.hxx> +#include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <connectivity/dbexception.hxx> -#include <TSortIndex.hxx> +#include <connectivity/sqlerror.hxx> +#include <cppuhelper/typeprovider.hxx> #include <rtl/string.hxx> +#include <tools/diagnose_ex.h> +#include <svtools/syslocale.hxx> +#include <unotools/intlwrapper.hxx> + +#include <cstring> #include <vector> -#include <algorithm> -#include "NResultSet.hxx" -#include "NDatabaseMetaData.hxx" -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <cppuhelper/typeprovider.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include "propertyids.hxx" -#include <svtools/logindlg.hxx> -#include "resource/evoab2_res.hrc" + +namespace connectivity { namespace evoab { using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::evoab; -using namespace cppu; +using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; @@ -65,7 +71,7 @@ using namespace com::sun::star::sdbc; using namespace com::sun::star::sdbcx; using namespace com::sun::star::container; using namespace com::sun::star::io; -using namespace ::com::sun::star::util; +namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition; //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException) \ @@ -92,9 +98,9 @@ sal_Bool SAL_CALL OEvoabResultSet::supportsService( const ::rtl::OUString& _rSer } // ------------------------------------------------------------------------- -OEvoabResultSet::OEvoabResultSet(OStatement_Base* pStmt,OEvoabConnection *pConnection,OSQLParseTreeIterator& _aSQLIterator) - : OResultSet_BASE(m_aMutex) - ,OPropertySetHelper(OResultSet_BASE::rBHelper) +OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pConnection ) + :OResultSet_BASE(m_aMutex) + ,::comphelper::OPropertyContainer( OResultSet_BASE::rBHelper ) ,m_pStatement(pStmt) ,m_pConnection(pConnection) ,m_xMetaData(NULL) @@ -106,18 +112,24 @@ OEvoabResultSet::OEvoabResultSet(OStatement_Base* pStmt,OEvoabConnection *pConne ,m_pContacts(NULL) ,m_nIndex(-1) ,m_nLength(0) - ,m_aSQLIterator(_aSQLIterator) { -} + #define REGISTER_PROP( id, member ) \ + registerProperty( \ + OMetaConnection::getPropMap().getNameByIndex( id ), \ + id, \ + PropertyAttribute::READONLY, \ + &member, \ + ::getCppuType( &member ) \ + ); -// ------------------------------------------------------------------------- -OEvoabResultSet::~OEvoabResultSet() -{ + REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); + REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); + REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); + REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); } // ------------------------------------------------------------------------- - -void OEvoabResultSet::construct(void) +OEvoabResultSet::~OEvoabResultSet() { } @@ -188,11 +200,29 @@ static rtl::OString getUserName( EBook *pBook ) return aName; } +static ::rtl::OUString +valueToOUString( GValue& _rValue ) +{ + const char *pStr = g_value_get_string( &_rValue ); + rtl::OString aStr( pStr ? pStr : "" ); + ::rtl::OUString sResult( ::rtl::OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) ); + g_value_unset( &_rValue ); + return sResult; +} + +static bool +valueToBool( GValue& _rValue ) +{ + bool bResult = g_value_get_boolean( &_rValue ); + g_value_unset( &_rValue ); + return bResult; +} + static bool -executeQuery (EBook *pBook, EBookQuery *pQuery, GList **ppList, +executeQuery (EBook* pBook, EBookQuery* pQuery, GList **ppList, rtl::OString &rPassword, GError **pError) { - ESource *pSource = e_book_get_source (pBook); + ESource *pSource = e_book_get_source( pBook ); bool bSuccess = false; bool bAuthSuccess = true; @@ -211,63 +241,6 @@ executeQuery (EBook *pBook, EBookQuery *pQuery, GList **ppList, return bSuccess; } -void OEvoabResultSet::construct( EBookQuery *pQuery, rtl::OString aTable, bool bIsWithoutWhere ) -{ - EBook *pBook = openBook( aTable ); - - if (pBook) - { - g_list_free(m_pContacts); - m_pContacts = NULL; - if( bIsWithoutWhere && !isLocal( pBook ) ) - { - OSL_TRACE( "large query on non-local book - ignored" ); - m_pConnection->throwGenericSQLException(STR_USE_WHERE_CRIT,*this); - } - else - { - OSL_TRACE( "Query without where ? '%d'", bIsWithoutWhere ); - rtl::OString aPassword = m_pConnection->getPassword(); - executeQuery( pBook, pQuery, &m_pContacts, aPassword, NULL ); - m_pConnection->setPassword( aPassword ); - } - m_nLength = g_list_length( m_pContacts ); - - OSL_TRACE( "Query return %d records", m_nLength ); - m_nIndex = -1; - } -} - -// ------------------------------------------------------------------------- -void OEvoabResultSet::disposing(void) -{ - OPropertySetHelper::disposing(); - - ::osl::MutexGuard aGuard(m_aMutex); - g_list_free(m_pContacts); - m_pContacts = NULL; - m_pStatement = NULL; - m_xMetaData = NULL; -} -// ------------------------------------------------------------------------- -Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; -} -// ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) -{ - OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), - ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), - ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 )); - - /* Dont know what is this yet */ - return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); -} - static int whichAddress(int value) { @@ -311,7 +284,7 @@ whichAddress(int value) * The search order is Work->Home->other(defaults). */ static EContactAddress * -getDefaultContactAddress(EContact *pContact,int *value) +getDefaultContactAddress( EContact *pContact,int *value ) { EContactAddress *ec = (EContactAddress *)e_contact_get(pContact,whichAddress(WORK_ADDR_LINE1)); if ( ec && (strlen(ec->street)>0) ) @@ -334,7 +307,7 @@ getDefaultContactAddress(EContact *pContact,int *value) } static EContactAddress* -getContactAddress(EContact *pContact, int * address_enum) +getContactAddress( EContact *pContact, int * address_enum ) { EContactAddress *ec = NULL; switch (*address_enum) { @@ -353,9 +326,8 @@ getContactAddress(EContact *pContact, int * address_enum) } static bool -handleSplitAddress(EContact *pContact,GValue *pStackValue,int value) +handleSplitAddress( EContact *pContact,GValue *pStackValue, int value ) { - EContactAddress *ec = getContactAddress(pContact,&value) ; if (ec==NULL) @@ -403,65 +375,232 @@ handleSplitAddress(EContact *pContact,GValue *pStackValue,int value) } -return false; + return false; } -// ------------------------------------------------------------------------- -// XRow Interface - -bool -OEvoabResultSet::getValue( sal_Int32 nColumnNum, GType nType, GValue *pStackValue) +static bool +getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackValue, bool& _out_rWasNull ) { - const ColumnProperty * pSpecs = evoab::getField (nColumnNum ); - if (!pSpecs) - return sal_False; - GParamSpec *pSpec = pSpecs->pField; - gboolean bIsSplittedColumn=pSpecs->bIsSplittedValue; - EContact *pContact = getCur(); + const ColumnProperty * pSpecs = evoab::getField( nColumnNum ); + if ( !pSpecs ) + return false; + + GParamSpec* pSpec = pSpecs->pField; + gboolean bIsSplittedColumn = pSpecs->bIsSplittedValue; - m_bWasNull = true; - if (!pSpec || !pContact) { + _out_rWasNull = true; + if ( !pSpec || !pContact) return false; - } - if (G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType) + + if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType ) { -#ifdef DEBUG - g_warning ("Wrong type (0x%x) (0x%x) '%s'", + + OSL_TRACE( "Wrong type (0x%x) (0x%x) '%s'", (int)G_PARAM_SPEC_VALUE_TYPE (pSpec), (int) nType, pSpec->name ? pSpec->name : "<noname>"); -#endif return false; } - g_value_init (pStackValue, nType); - if (bIsSplittedColumn) + + g_value_init( pStackValue, nType ); + if ( bIsSplittedColumn ) { const SplitEvoColumns* evo_addr( get_evo_addr() ); for (int i=0;i<OTHER_ZIP;i++) { if (0 == strcmp (g_param_spec_get_name ((GParamSpec *)pSpec), evo_addr[i].pColumnName)) { - m_bWasNull = handleSplitAddress (pContact, pStackValue, evo_addr[i].value); + _out_rWasNull = handleSplitAddress( pContact, pStackValue, evo_addr[i].value ); return true; } } } else { - g_object_get_property (G_OBJECT (pContact), + g_object_get_property( G_OBJECT (pContact), g_param_spec_get_name ((GParamSpec *) pSpec), - pStackValue); - if (G_VALUE_TYPE (pStackValue) != nType) + pStackValue ); + if ( G_VALUE_TYPE( pStackValue ) != nType ) { -#ifdef DEBUG - g_warning ("Fetched type mismatch"); -#endif - g_value_unset (pStackValue); + OSL_TRACE( "Fetched type mismatch" ); + g_value_unset( pStackValue ); return false; } } - m_bWasNull = false; + _out_rWasNull = false; return true; } +namespace +{ + struct ComparisonData + { + const SortDescriptor& rSortOrder; + IntlWrapper aIntlWrapper; + + ComparisonData( const SortDescriptor& _rSortOrder, const Reference< XMultiServiceFactory >& _rxFactory ) + :rSortOrder( _rSortOrder ) + ,aIntlWrapper( _rxFactory, SvtSysLocale().GetLocaleData().getLocale() ) + { + } + }; +} + +extern "C" +int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData ) +{ + EContact* lhs = static_cast< EContact* >( const_cast< gpointer >( _lhs ) ); + EContact* rhs = static_cast< EContact* >( const_cast< gpointer >( _rhs ) ); + + GValue aLhsValue = { 0, { { 0 } } }; + GValue aRhsValue = { 0, { { 0 } } }; + bool bLhsNull = true; + bool bRhsNull = true; + + ::rtl::OUString sLhs, sRhs; + bool bLhs(false), bRhs(false); + + const ComparisonData& rCompData = *static_cast< const ComparisonData* >( _userData ); + for ( SortDescriptor::const_iterator sortCol = rCompData.rSortOrder.begin(); + sortCol != rCompData.rSortOrder.end(); + ++sortCol + ) + { + sal_Int32 nField = sortCol->nField; + GType eFieldType = evoab::getGFieldType( nField ); + + bool success = getValue( lhs, nField, eFieldType, &aLhsValue, bLhsNull ) + && getValue( rhs, nField, eFieldType, &aRhsValue, bRhsNull ); + OSL_ENSURE( success, "CompareContacts: could not retrieve both values!" ); + if ( !success ) + return 0; + + if ( bLhsNull && !bRhsNull ) + return -1; + if ( !bLhsNull && bRhsNull ) + return 1; + if ( bLhsNull && bRhsNull ) + continue; + + if ( eFieldType == G_TYPE_STRING ) + { + sLhs = valueToOUString( aLhsValue ); + sRhs = valueToOUString( aRhsValue ); + sal_Int32 nCompResult = rCompData.aIntlWrapper.getCaseCollator()->compareString( sLhs, sRhs ); + if ( nCompResult != 0 ) + return nCompResult; + continue; + } + + bLhs = valueToBool( aLhsValue ); + bRhs = valueToBool( aRhsValue ); + if ( bLhs && !bRhs ) + return -1; + if ( !bLhs && bRhs ) + return 1; + continue; + } + + return 0; +} + +static GList* +sortContacts( GList* _pContactList, const ComparisonData& _rCompData ) +{ + OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" ); + ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" ); + + return g_list_sort_with_data( _pContactList, &CompareContacts, const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) ); +} + +// ------------------------------------------------------------------------- +void OEvoabResultSet::construct( const QueryData& _rData ) +{ + ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" ); + + EBook *pBook = openBook( ::rtl::OUStringToOString( _rData.sTable, RTL_TEXTENCODING_UTF8 ) ); + if ( !pBook ) + m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this ); + + g_list_free(m_pContacts); + m_pContacts = NULL; + bool bExecuteQuery = true; + switch ( _rData.eFilterType ) + { + case eFilterNone: + if ( !isLocal( pBook ) ) + { + SQLError aErrorFactory( m_pConnection->getDriver().getMSFactory() ); + SQLException aAsException = aErrorFactory.getSQLException( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED, *this ); + m_aWarnings.appendWarning( SQLWarning( + aAsException.Message, + aAsException.Context, + aAsException.SQLState, + aAsException.ErrorCode, + aAsException.NextException + ) ); + bExecuteQuery = false; + } + break; + case eFilterAlwaysFalse: + bExecuteQuery = false; + break; + case eFilterOther: + bExecuteQuery = true; + break; + } + if ( bExecuteQuery ) + { + rtl::OString aPassword = m_pConnection->getPassword(); + executeQuery( pBook, _rData.getQuery(), &m_pContacts, aPassword, NULL ); + m_pConnection->setPassword( aPassword ); + + if ( m_pContacts && !_rData.aSortOrder.empty() ) + { + ComparisonData aCompData( _rData.aSortOrder, getConnection()->getDriver().getMSFactory() ); + m_pContacts = sortContacts( m_pContacts, aCompData ); + } + } + m_nLength = g_list_length( m_pContacts ); + OSL_TRACE( "Query return %d records", m_nLength ); + m_nIndex = -1; + + // create our meta data (need the EBookQuery for this) + OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( _rData.sTable ); + m_xMetaData = pMeta; + + pMeta->setEvoabFields( _rData.xSelectColumns ); +} + +// ------------------------------------------------------------------------- +void OEvoabResultSet::disposing(void) +{ + ::comphelper::OPropertyContainer::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + g_list_free(m_pContacts); + m_pContacts = NULL; + m_pStatement = NULL; +m_xMetaData.clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::comphelper::OPropertyContainer::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) +{ + return ::comphelper::concatSequences( + OResultSet_BASE::getTypes(), + ::comphelper::OPropertyContainer::getTypes() + ); +} + +// ------------------------------------------------------------------------- +// XRow Interface + /** * getString: * @nColumnNum: The column index from the table. @@ -475,17 +614,12 @@ OEvoabResultSet::getValue( sal_Int32 nColumnNum, GType nType, GValue *pStackValu checkDisposed(OResultSet_BASE::rBHelper.bDisposed); rtl::OUString aResult; if ( m_xMetaData.is()) - { - OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); - sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); - GValue aValue = {0, {{0}}}; - if (getValue (nFieldNumber, G_TYPE_STRING, &aValue)) - { - const char *pStr = g_value_get_string (&aValue); - rtl::OString aStr (pStr ? pStr : ""); - aResult = rtl::OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ); - g_value_unset (&aValue); - } + { + OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); + sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); + GValue aValue = { 0, { { 0 } } }; + if ( getValue( getCur(), nFieldNumber, G_TYPE_STRING, &aValue, m_bWasNull ) ) + aResult = valueToOUString( aValue ); } return aResult; } @@ -497,15 +631,12 @@ sal_Bool SAL_CALL OEvoabResultSet::getBoolean( sal_Int32 nColumnNum ) throw(SQLE sal_Bool bResult = sal_False; if ( m_xMetaData.is()) - { - OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); - sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); - GValue aValue = {0, {{0}}}; - if (getValue (nFieldNumber, G_TYPE_BOOLEAN, &aValue)) - { - bResult = g_value_get_boolean (&aValue); - g_value_unset (&aValue); - } + { + OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); + sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); + GValue aValue = { 0, { { 0 } } }; + if ( getValue( getCur(), nFieldNumber, G_TYPE_BOOLEAN, &aValue, m_bWasNull ) ) + bResult = valueToBool( aValue ); } return bResult ? sal_True : sal_False; } @@ -558,7 +689,7 @@ sal_Int16 SAL_CALL OEvoabResultSet::getShort( sal_Int32 /*nColumnNum*/ ) throw(S return ::com::sun::star::util::Time(); } // ------------------------------------------------------------------------- -DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) +util::DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) { ::dbtools::throwFunctionNotSupportedException( "XRow::getTimestamp", *this ); return ::com::sun::star::util::DateTime(); @@ -620,9 +751,8 @@ Reference< XResultSetMetaData > SAL_CALL OEvoabResultSet::getMetaData( ) throw( ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - OSL_TRACE("OEvoabResultSet::getMetaData"); - if(!m_xMetaData.is()) - m_xMetaData = new OEvoabResultSetMetaData(m_pConnection->getCurrentTableName()); + // the meta data should have been created at construction time + ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" ); return m_xMetaData; } // XResultSetMetaDataSupplier Interface Ends @@ -829,12 +959,13 @@ void SAL_CALL OEvoabResultSet::close( ) throw(SQLException, RuntimeException) void SAL_CALL OEvoabResultSet::clearWarnings( ) throw(SQLException, RuntimeException) { OSL_TRACE("In/Out: OEvoabResultSet::clearWarnings" ); + m_aWarnings.clearWarnings(); } // ------------------------------------------------------------------------- Any SAL_CALL OEvoabResultSet::getWarnings( ) throw(SQLException, RuntimeException) { OSL_TRACE("In/Out: OEvoabResultSet::getWarnings" ); - return Any(); + return m_aWarnings.getWarnings(); } // ------------------------------------------------------------------------- //XColumnLocate Interface @@ -857,93 +988,17 @@ sal_Int32 SAL_CALL OEvoabResultSet::findColumn( const ::rtl::OUString& columnNam //XColumnLocate interface ends // ------------------------------------------------------------------------- -IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const +::cppu::IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const { - Sequence< Property > aProps(6); - 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 OPropertyArrayHelper(aProps); + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); } // ------------------------------------------------------------------------- -IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() +::cppu::IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() { return *const_cast<OEvoabResultSet*>(this)->getArrayHelper(); } -// ------------------------------------------------------------------------- -sal_Bool OEvoabResultSet::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: - case PROPERTY_ID_FETCHSIZE: - default: - ; - } - return sal_False; -} -// ------------------------------------------------------------------------- -void OEvoabResultSet::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: - break; - case PROPERTY_ID_FETCHSIZE: - break; - default: - ; - } -} -// ------------------------------------------------------------------------- -void OEvoabResultSet::getFastPropertyValue( - Any& rValue, - sal_Int32 nHandle - ) const -{ - - switch(nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - rValue <<= (sal_Int32)m_nResultSetConcurrency; - break; - case PROPERTY_ID_RESULTSETTYPE: - rValue <<= m_nResultSetType; - break; - case PROPERTY_ID_FETCHDIRECTION: - rValue <<= m_nFetchDirection; - break; - case PROPERTY_ID_FETCHSIZE: - rValue <<= m_nFetchSize; - break; - } - -} // ----------------------------------------------------------------------------- void SAL_CALL OEvoabResultSet::acquire() throw() { @@ -961,3 +1016,5 @@ OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeExce return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); } // ----------------------------------------------------------------------------- + +} } // connectivity::evoab diff --git a/connectivity/source/drivers/evoab2/NResultSet.hxx b/connectivity/source/drivers/evoab2/NResultSet.hxx index 927db78f319f..b01928ab19e7 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.hxx +++ b/connectivity/source/drivers/evoab2/NResultSet.hxx @@ -42,12 +42,12 @@ #include <com/sun/star/sdbc/XRowUpdate.hpp> #include <com/sun/star/sdbcx/XRowLocate.hpp> #include <com/sun/star/sdbcx/XDeleteRows.hpp> -#ifndef _CPPUHELPER_COMPBASE12_HXX_ #include <cppuhelper/compbase8.hxx> -#endif #include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> #include "connectivity/CommonTools.hxx" #include "connectivity/FValue.hxx" +#include "connectivity/warningscontainer.hxx" #include "NStatement.hxx" #include "OSubComponent.hxx" #include "NResultSetMetaData.hxx" @@ -56,76 +56,61 @@ namespace connectivity { namespace evoab { - typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::sdbc::XResultSet, - ::com::sun::star::sdbc::XRow, - ::com::sun::star::sdbc::XResultSetMetaDataSupplier, - ::com::sun::star::util::XCancellable, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbc::XCloseable, - ::com::sun::star::sdbc::XColumnLocate, - ::com::sun::star::lang::XServiceInfo> OResultSet_BASE; - - - class OEvoabResultSet : public comphelper::OBaseMutex, - public OResultSet_BASE, - public ::cppu::OPropertySetHelper, - public ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet> + typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::sdbc::XResultSet + , ::com::sun::star::sdbc::XRow + , ::com::sun::star::sdbc::XResultSetMetaDataSupplier + , ::com::sun::star::util::XCancellable + , ::com::sun::star::sdbc::XWarningsSupplier + , ::com::sun::star::sdbc::XCloseable + , ::com::sun::star::sdbc::XColumnLocate + , ::com::sun::star::lang::XServiceInfo + > OResultSet_BASE; + + + class OEvoabResultSet :public comphelper::OBaseMutex + ,public OResultSet_BASE + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet> { protected: - OStatement_Base *m_pStatement; - OEvoabConnection *m_pConnection; - ::com::sun::star::uno::WeakReferenceHelper m_aStatement; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + OCommonStatement* m_pStatement; + OEvoabConnection* m_pConnection; + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; + ::dbtools::WarningsContainer m_aWarnings; - sal_Bool m_bWasNull; + bool m_bWasNull; + // <properties> sal_Int32 m_nFetchSize; sal_Int32 m_nResultSetType; sal_Int32 m_nFetchDirection; sal_Int32 m_nResultSetConcurrency; + // </properties> // Data & iteration GList *m_pContacts; sal_Int32 m_nIndex; sal_Int32 m_nLength; - connectivity::OSQLParseTreeIterator& m_aSQLIterator; EContact *getCur() { gpointer pData = g_list_nth_data (m_pContacts, m_nIndex); return pData ? E_CONTACT (pData) : NULL; } - bool getValue( sal_Int32 nColumnIndex, GType nType, GValue *pStackValue); // OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - // you can't delete objects of this type virtual ~OEvoabResultSet(); public: DECLARE_SERVICE_INFO(); - OEvoabResultSet(OStatement_Base *pStmt, OEvoabConnection *pConnection,OSQLParseTreeIterator& _aSQLIterator); - virtual void construct(void); - void construct( EBookQuery *pQuery, rtl::OString aTable, bool bIsWithoutWhere ); + OEvoabResultSet( OCommonStatement *pStmt, OEvoabConnection *pConnection ); + void construct( const QueryData& _rData ); OEvoabConnection * getConnection() { return m_pConnection; } diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx index f8b79f01a561..b36a86fb96b0 100644 --- a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NResultSetMetaData.cxx,v $ - * $Revision: 1.7.56.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -177,7 +174,7 @@ sal_Int32 SAL_CALL OEvoabResultSetMetaData::isNullable( sal_Int32 /*nColumnNum*/ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OEvoabResultSetMetaData::isSearchable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) { - return sal_False; + return sal_True; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OEvoabResultSetMetaData::isReadOnly( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/evoab2/NServices.cxx b/connectivity/source/drivers/evoab2/NServices.cxx index bbecf7a0c9a2..efa9b6d56c72 100644 --- a/connectivity/source/drivers/evoab2/NServices.cxx +++ b/connectivity/source/drivers/evoab2/NServices.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NServices.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -117,7 +114,7 @@ struct ProviderRequest //--------------------------------------------------------------------------------------- -extern "C" void SAL_CALL component_getImplementationEnvironment( +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) @@ -126,7 +123,7 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( } //--------------------------------------------------------------------------------------- -extern "C" sal_Bool SAL_CALL component_writeInfo( +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey ) @@ -151,7 +148,7 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( } //--------------------------------------------------------------------------------------- -extern "C" void* SAL_CALL component_getFactory( +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName, void* pServiceManager, void* /*pRegistryKey*/) diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx index 76f9f0885033..2ddcd84c87a0 100644 --- a/connectivity/source/drivers/evoab2/NStatement.cxx +++ b/connectivity/source/drivers/evoab2/NStatement.cxx @@ -1,4 +1,4 @@ - /************************************************************************* +/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NStatement.cxx,v $ - * $Revision: 1.12.2.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -42,12 +39,16 @@ #include "propertyids.hxx" #include "NStatement.hxx" #include "NConnection.hxx" +#include "NDatabaseMetaData.hxx" #include "NResultSet.hxx" #include "NDebug.hxx" +#include "resource/evoab2_res.hrc" #include <resource/common_res.hrc> #include <connectivity/dbexception.hxx> +#include <tools/diagnose_ex.h> + +namespace connectivity { namespace evoab { -using namespace connectivity::evoab; //------------------------------------------------------------------------------ using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -58,25 +59,53 @@ using namespace com::sun::star::container; using namespace com::sun::star::io; using namespace com::sun::star::util; //------------------------------------------------------------------------------ -OStatement_Base::OStatement_Base(OEvoabConnection* _pConnection) - : OStatement_BASE(m_aMutex) - , OPropertySetHelper(OStatement_BASE::rBHelper) +OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection) + : OCommonStatement_IBase(m_aMutex) + , ::comphelper::OPropertyContainer(OCommonStatement_IBase::rBHelper) + , OStatement_CBase( (::cppu::OWeakObject*)_pConnection, this ) , m_xResultSet(NULL) , m_pResultSet(NULL) , m_pConnection(_pConnection) - , m_aParser(_pConnection->getDriver()->getMSFactory()) + , m_aParser(_pConnection->getDriver().getMSFactory()) , m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) , m_pParseTree(NULL) - , rBHelper(OStatement_BASE::rBHelper) + , m_nMaxFieldSize(0) + , m_nMaxRows(0) + , m_nQueryTimeOut(0) + , m_nFetchSize(0) + , m_nResultSetType(ResultSetType::FORWARD_ONLY) + , m_nFetchDirection(FetchDirection::FORWARD) + , m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) + , m_bEscapeProcessing(sal_True) + , rBHelper(OCommonStatement_IBase::rBHelper) { m_pConnection->acquire(); + +#define REGISTER_PROP( id, member ) \ + registerProperty( \ + OMetaConnection::getPropMap().getNameByIndex( id ), \ + id, \ + 0, \ + &member, \ + ::getCppuType( &member ) \ + ); + + REGISTER_PROP( PROPERTY_ID_CURSORNAME, m_aCursorName ); + REGISTER_PROP( PROPERTY_ID_MAXFIELDSIZE, m_nMaxFieldSize ); + REGISTER_PROP( PROPERTY_ID_MAXROWS, m_nMaxRows ); + REGISTER_PROP( PROPERTY_ID_QUERYTIMEOUT, m_nQueryTimeOut ); + REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); + REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); + REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); + REGISTER_PROP( PROPERTY_ID_ESCAPEPROCESSING, m_bEscapeProcessing ); + REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); } // ----------------------------------------------------------------------------- -OStatement_Base::~OStatement_Base() +OCommonStatement::~OCommonStatement() { } //------------------------------------------------------------------------------ -void OStatement_Base::disposeResultSet() +void OCommonStatement::disposeResultSet() { // free the cursor if alive Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); @@ -85,7 +114,7 @@ void OStatement_Base::disposeResultSet() m_xResultSet = Reference< XResultSet>(); } //------------------------------------------------------------------------------ -void OStatement_BASE2::disposing() +void OCommonStatement::disposing() { ::osl::MutexGuard aGuard(m_aMutex); @@ -96,55 +125,50 @@ void OStatement_BASE2::disposing() m_pConnection = NULL; dispose_ChildImpl(); - OStatement_Base::disposing(); -} -//----------------------------------------------------------------------------- -void SAL_CALL OStatement_BASE2::release() throw() -{ - relase_ChildImpl(); + OCommonStatement_IBase::disposing(); } //----------------------------------------------------------------------------- -Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) +Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = OStatement_BASE::queryInterface(rType); + Any aRet = OCommonStatement_IBase::queryInterface(rType); if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); + aRet = ::comphelper::OPropertyContainer::queryInterface(rType); return aRet; } // ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException) +Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) throw(RuntimeException) { ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ), ::getCppuType( (const Reference< XFastPropertySet > *)0 ), ::getCppuType( (const Reference< XPropertySet > *)0 )); - return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); + return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBase::getTypes()); } // ------------------------------------------------------------------------- -//void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException) +//void SAL_CALL OCommonStatement::cancel( ) throw(RuntimeException) //{ //::osl::MutexGuard aGuard( m_aMutex ); -//checkDisposed(OStatement_BASE::rBHelper.bDisposed); +//checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); //// cancel the current sql statement //} // ------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException) +void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException) { { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); } dispose(); } // ------------------------------------------------------------------------- -void OStatement_Base::reset() throw (SQLException) +void OCommonStatement::reset() throw (SQLException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); clearWarnings (); @@ -153,10 +177,10 @@ void OStatement_Base::reset() throw (SQLException) clearMyResultSet(); } -void OStatement_Base::clearMyResultSet () throw (SQLException) +void OCommonStatement::clearMyResultSet () throw (SQLException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); try { @@ -170,48 +194,105 @@ void OStatement_Base::clearMyResultSet () throw (SQLException) } EBookQuery * -OStatement_Base::createTrue() +OCommonStatement::createTrue() { // Not the world's most efficient unconditional true but ... return e_book_query_from_string("(exists \"full_name\")"); } EBookQuery * -OStatement_Base::createTest( const ::rtl::OUString &aColumnName, +OCommonStatement::createTest( const ::rtl::OUString &aColumnName, EBookQueryTest eTest, - const ::rtl::OUString &aMatch, - bool bGeneric ) + const ::rtl::OUString &aMatch ) { - rtl::OString sMatch = rtl::OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 ); - rtl::OString sColumnName = rtl::OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 ); - if ( bGeneric && (aColumnName.equalsAscii("0") || - aColumnName.equalsAscii("1"))) - { - if( aMatch.equals( aColumnName ) ) - return createTrue(); - else - return NULL; - } + ::rtl::OString sMatch = rtl::OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 ); + ::rtl::OString sColumnName = rtl::OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 ); return e_book_query_field_test( e_contact_field_id( sColumnName ), eTest, sMatch ); } // ------------------------------------------------------------------------- -sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) + +::rtl::OUString OCommonStatement::impl_getColumnRefColumnName_throw( const OSQLParseNode& _rColumnRef ) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + ENSURE_OR_THROW( SQL_ISRULE( &_rColumnRef, column_ref ), "internal error: only column_refs supported as LHS" ); + + ::rtl::OUString sColumnName; + switch ( _rColumnRef.count() ) + { + case 3: // SQL_TOKEN_NAME '.' column_val + { + const OSQLParseNode* pPunct = _rColumnRef.getChild( 1 ); + const OSQLParseNode* pColVal = _rColumnRef.getChild( 2 ); + if ( SQL_ISPUNCTUATION( pPunct, "." ) + && ( pColVal->count() == 1 ) + ) + { + sColumnName = pColVal->getChild( 0 )->getTokenValue(); + } + } + break; + + case 1: // column + { + sColumnName = _rColumnRef.getChild( 0 )->getTokenValue(); + } + break; + } + + if ( !sColumnName.getLength() ) + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); + + return sColumnName; +} + +// ------------------------------------------------------------------------- +void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort ) +{ + ENSURE_OR_THROW( _pOrderByClause, "NULL node" ); + ENSURE_OR_THROW( SQL_ISRULE( _pOrderByClause, opt_order_by_clause ), "wrong node type" ); + + _out_rSort.clear(); + + const OSQLParseNode* pOrderList = _pOrderByClause->getByRule( OSQLParseNode::ordering_spec_commalist ); + ENSURE_OR_THROW( pOrderList, "unexpected parse tree structure" ); - executeQuery( sql ); - return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT; + for ( sal_uInt32 i=0; i<pOrderList->count(); ++i ) + { + const OSQLParseNode* pOrderBy = pOrderList->getChild(i); + if ( !pOrderBy || !SQL_ISRULE( pOrderBy, ordering_spec ) ) + continue; + const OSQLParseNode* pColumnRef = pOrderBy->count() == 2 ? pOrderBy->getChild(0) : NULL; + const OSQLParseNode* pAscDesc = pOrderBy->count() == 2 ? pOrderBy->getChild(1) : NULL; + ENSURE_OR_THROW( + ( pColumnRef != NULL ) + && ( pAscDesc != NULL ) + && SQL_ISRULE( pAscDesc, opt_asc_desc ) + && ( pAscDesc->count() < 2 ), + "ordering_spec structure error" ); + + // column name -> column field + if ( !SQL_ISRULE( pColumnRef, column_ref ) ) + m_pConnection->throwGenericSQLException( STR_SORT_BY_COL_ONLY, *this ); + const ::rtl::OUString sColumnName( impl_getColumnRefColumnName_throw( *pColumnRef ) ); + guint nField = evoab::findEvoabField( sColumnName ); + // ascending/descending? + bool bAscending = true; + if ( ( pAscDesc->count() == 1 ) + && SQL_ISTOKEN( pAscDesc->getChild( 0 ), DESC ) + ) + bAscending = false; + + _out_rSort.push_back( FieldSort( nField, bAscending ) ); + } } -EBookQuery *OStatement_Base::whereAnalysis( const OSQLParseNode* parseTree ) throw(SQLException, RuntimeException) +// ------------------------------------------------------------------------- +EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree ) { EBookQuery *pResult = NULL; - if (!parseTree) - return NULL; + ENSURE_OR_THROW( parseTree, "invalid parse tree" ); // Nested brackets if( parseTree->count() == 3 && @@ -226,83 +307,87 @@ EBookQuery *OStatement_Base::whereAnalysis( const OSQLParseNode* parseTree ) thr SQL_ISRULE( parseTree, boolean_term ) ) && parseTree->count() == 3 ) { + ENSURE_OR_THROW( SQL_ISTOKEN( parseTree->getChild( 1 ), OR ) + || SQL_ISTOKEN( parseTree->getChild( 1 ), AND ), + "unexpected search_condition structure" ); + EBookQuery *pArgs[2]; pArgs[0] = whereAnalysis( parseTree->getChild( 0 ) ); pArgs[1] = whereAnalysis( parseTree->getChild( 2 ) ); if( SQL_ISTOKEN( parseTree->getChild( 1 ), OR ) ) - pResult = e_book_query_or( 2, pArgs, TRUE ); - else if( SQL_ISTOKEN( parseTree->getChild( 1 ), AND ) ) - pResult = e_book_query_and( 2, pArgs, TRUE ); + pResult = e_book_query_or( 2, pArgs, TRUE ); else - { - OSL_ASSERT("analyseSQL: Error in Parse Tree"); - e_book_query_unref( pArgs[ 0 ] ); - e_book_query_unref( pArgs[ 1 ] ); - return NULL; - } + pResult = e_book_query_and( 2, pArgs, TRUE ); } // SQL =, != else if( SQL_ISRULE( parseTree, comparison_predicate ) ) { OSQLParseNode *pPrec = parseTree->getChild( 1 ); - if( parseTree->count() != 3 ) + ENSURE_OR_THROW( parseTree->count() == 3, "unexpected comparison_predicate structure" ); + + OSQLParseNode* pLHS = parseTree->getChild( 0 ); + OSQLParseNode* pRHS = parseTree->getChild( 2 ); + + if ( ( !( SQL_ISRULE( pLHS, column_ref ) ) // on the LHS, we accept a column or a constant int value + && ( pLHS->getNodeType() != SQL_NODE_INTNUM ) + ) + || ( ( pRHS->getNodeType() != SQL_NODE_STRING ) // on the RHS, certain literals are acceptable + && ( pRHS->getNodeType() != SQL_NODE_INTNUM ) + && ( pRHS->getNodeType() != SQL_NODE_APPROXNUM ) + && !( SQL_ISTOKEN( pRHS, TRUE ) ) + && !( SQL_ISTOKEN( pRHS, FALSE ) ) + ) + || ( ( pLHS->getNodeType() == SQL_NODE_INTNUM ) // an int on LHS requires an int on RHS + && ( pRHS->getNodeType() != SQL_NODE_INTNUM ) + ) + ) { - OSL_ASSERT("analyseSQL: Error in Parse Tree"); - return NULL; + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); } - if( !( SQL_ISRULE( parseTree->getChild( 0 ), column_ref) || - parseTree->getChild( 2 )->getNodeType() == SQL_NODE_STRING || - parseTree->getChild( 2 )->getNodeType() == SQL_NODE_INTNUM || - parseTree->getChild( 2 )->getNodeType() == SQL_NODE_APPROXNUM || - SQL_ISTOKEN( parseTree->getChild( 2 ), TRUE ) || - SQL_ISTOKEN( parseTree->getChild( 2 ), FALSE ) || - SQL_ISRULE( parseTree->getChild( 2 ), parameter ) || - // odbc date - (SQL_ISRULE( parseTree->getChild( 2 ), set_fct_spec ) && - SQL_ISPUNCTUATION( parseTree->getChild( 2 )->getChild( 0 ), "{" ) ) ) ) - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - - if (pPrec->getNodeType() != SQL_NODE_EQUAL && pPrec->getNodeType() != SQL_NODE_NOTEQUAL) - m_pConnection->throwGenericSQLException(STR_OPERATOR_TOO_COMPLEX,*this); - - rtl::OUString aMatchString; - rtl::OUString aColumnName; - if( SQL_ISRULE( parseTree->getChild( 0 ), column_ref ) ) + if ( ( pPrec->getNodeType() != SQL_NODE_EQUAL ) + && ( pPrec->getNodeType() != SQL_NODE_NOTEQUAL ) + ) { - aColumnName = parseTree->getChild( 0 )->getChild( 0 )->getTokenValue(); - - if( parseTree->getChild( 2 )->isToken() ) - aMatchString = parseTree->getChild( 2 )->getTokenValue(); - else - aMatchString = parseTree->getChild( 2 )->getChild( 0 )->getTokenValue(); + m_pConnection->throwGenericSQLException( STR_OPERATOR_TOO_COMPLEX, *this ); } - else + + // recognize the special "0 = 1" condition + if ( ( pLHS->getNodeType() == SQL_NODE_INTNUM ) + && ( pRHS->getNodeType() == SQL_NODE_INTNUM ) + && ( pPrec->getNodeType() == SQL_NODE_EQUAL ) + ) { - aColumnName = parseTree->getChild( 0 )->getTokenValue(); - aMatchString = parseTree->getChild( 2 )->getTokenValue(); + const sal_Int32 nLHS = pLHS->getTokenValue().toInt64(); + const sal_Int32 nRHS = pRHS->getTokenValue().toInt64(); + return ( nLHS == nRHS ) ? createTrue() : NULL; } - pResult = createTest( aColumnName, E_BOOK_QUERY_IS, aMatchString, true ); + ::rtl::OUString aColumnName( impl_getColumnRefColumnName_throw( *pLHS ) ); + + ::rtl::OUString aMatchString; + if ( pRHS->isToken() ) + aMatchString = pRHS->getTokenValue(); + else + aMatchString = pRHS->getChild( 0 )->getTokenValue(); + + pResult = createTest( aColumnName, E_BOOK_QUERY_IS, aMatchString ); - if (pResult && pPrec->getNodeType() == SQL_NODE_NOTEQUAL) + if ( pResult && ( pPrec->getNodeType() == SQL_NODE_NOTEQUAL ) ) pResult = e_book_query_not( pResult, TRUE ); } // SQL like else if( SQL_ISRULE( parseTree, like_predicate ) ) { - if( parseTree->count() < 4 ) - { - OSL_ASSERT( "analyseSQL: Error in parsing LIKE predicate" ); - return NULL; - } + ENSURE_OR_THROW( parseTree->count() >= 4, "unexpected like_predicate structure" ); if( ! SQL_ISRULE( parseTree->getChild( 0 ), column_ref) ) m_pConnection->throwGenericSQLException(STR_QUERY_INVALID_LIKE_COLUMN,*this); - OSQLParseNode *pColumn = parseTree->getChild( 0 ); // Match Item + ::rtl::OUString aColumnName( impl_getColumnRefColumnName_throw( *parseTree->getChild( 0 ) ) ); + OSQLParseNode *pAtom = parseTree->getChild( parseTree->count() - 2 ); // Match String bool bNotLike = parseTree->count() == 5; @@ -318,62 +403,54 @@ EBookQuery *OStatement_Base::whereAnalysis( const OSQLParseNode* parseTree ) thr const sal_Unicode WILDCARD = '%'; - rtl::OUString aColumnName; rtl::OUString aMatchString; + aMatchString = pAtom->getTokenValue(); - if( SQL_ISRULE( pColumn, column_ref )) + // Determine where '%' character is... + if( aMatchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) ) { - aColumnName = parseTree->getChild(0)->getChild(0)->getTokenValue(); - aMatchString = pAtom->getTokenValue(); - - // Determine where '%' character is... - if( aMatchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) ) - { - // String containing only a '%' and nothing else matches everything - pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, - rtl::OUString::createFromAscii( "" ) ); - } - else if( aMatchString.indexOf( WILDCARD ) == -1 ) - { // Simple string , eg. "to match" "contains in evo" - EVO_TRACE_STRING( "Plain contains '%s'", aMatchString ); - pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString ); - if( pResult && bNotLike ) - pResult = e_book_query_not( pResult, TRUE ); - } - else if( bNotLike ) - { - // We currently can't handle a 'NOT LIKE' when there are '%' - m_pConnection->throwGenericSQLException(STR_QUERY_NOT_LIKE_TOO_COMPLEX,*this); - } - else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) ) - { // One occurance of '%' matches... - if ( aMatchString.indexOf ( WILDCARD ) == 0 ) - pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) ); - else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 ) - pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) ); - else - m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD,*this); - - if( pResult && bNotLike ) - pResult = e_book_query_not( pResult, TRUE ); - } - else if( aMatchString.getLength() >= 3 && - aMatchString.indexOf ( WILDCARD ) == 0 && - aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) { - // one '%' at the start and another at the end - pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) ); - } + // String containing only a '%' and nothing else matches everything + pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, + rtl::OUString::createFromAscii( "" ) ); + } + else if( aMatchString.indexOf( WILDCARD ) == -1 ) + { // Simple string , eg. "to match" "contains in evo" + EVO_TRACE_STRING( "Plain contains '%s'", aMatchString ); + pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString ); + if( pResult && bNotLike ) + pResult = e_book_query_not( pResult, TRUE ); + } + else if( bNotLike ) + { + // We currently can't handle a 'NOT LIKE' when there are '%' + m_pConnection->throwGenericSQLException(STR_QUERY_NOT_LIKE_TOO_COMPLEX,*this); + } + else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) ) + { // One occurance of '%' matches... + if ( aMatchString.indexOf ( WILDCARD ) == 0 ) + pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) ); + else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 ) + pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) ); else - m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD_MANY,*this); + m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD,*this); + + if( pResult && bNotLike ) + pResult = e_book_query_not( pResult, TRUE ); + } + else if( aMatchString.getLength() >= 3 && + aMatchString.indexOf ( WILDCARD ) == 0 && + aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) { + // one '%' at the start and another at the end + pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) ); } else - OSL_ASSERT( "Serious internal error" ); + m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD_MANY,*this); } return pResult; } -rtl::OUString OStatement_Base::getTableName() +rtl::OUString OCommonStatement::getTableName() { ::rtl::OUString aTableName; @@ -386,7 +463,7 @@ rtl::OUString OStatement_Base::getTableName() if( m_aSQLIterator.isTableNode( pAllTableNames->getChild( 0 ) ) ) OSQLParseNode::getTableComponents( pAllTableNames->getChild( 0 ), - aCatalog,aSchema, aTableName ); + aCatalog,aSchema, aTableName,NULL ); else if( SQL_ISRULE( pAllTableNames->getChild( 0 ), table_ref ) ) { @@ -395,238 +472,210 @@ rtl::OUString OStatement_Base::getTableName() { aTableName = OSQLParseNode::getTableRange(pAllTableNames->getChild( 0 )); if( !aTableName.getLength() ) - OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName); + OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName,NULL); } else - OSL_ASSERT( "odd table layout" ); + OSL_ENSURE( false, "odd table layout" ); } else - OSL_ASSERT( "unusual table layout" ); + OSL_ENSURE( false, "unusual table layout" ); } return aTableName; } -EBookQuery *OStatement_Base::parseSql( const rtl::OUString& sql, - rtl::OString &rTable, - bool &bIsWithoutWhere ) - throw ( SQLException, RuntimeException ) +void OCommonStatement::parseSql( const rtl::OUString& sql, QueryData& _out_rQueryData ) { - ::rtl::OUString aErr; + EVO_TRACE_STRING( "parsing %s", sql ); + _out_rQueryData.eFilterType = eFilterOther; + + ::rtl::OUString aErr; m_pParseTree = m_aParser.parseTree( aErr, sql ); m_aSQLIterator.setParseTree( m_pParseTree ); m_aSQLIterator.traverseAll(); - const OSQLTables aTables = m_aSQLIterator.getTables(); - rTable = rtl::OUStringToOString( getTableName(), RTL_TEXTENCODING_UTF8 ); - m_pConnection->setCurrentTableName(getTableName()); - const OSQLParseNode* pParseTree = m_aSQLIterator.getWhereTree(); - if ( pParseTree && SQL_ISRULE( pParseTree, where_clause ) ) - return whereAnalysis( pParseTree->getChild( 1 ) ); - else + _out_rQueryData.sTable = getTableName(); + + // to be sorted? + const OSQLParseNode* pOrderByClause = m_aSQLIterator.getOrderTree(); + if ( pOrderByClause ) { - bIsWithoutWhere = true; - return createTrue(); + #if OSL_DEBUG_LEVEL > 0 + ::rtl::OUString sTreeDebug; + pOrderByClause->showParseTree( sTreeDebug ); + EVO_TRACE_STRING( "found order-by tree:\n%s", sTreeDebug ); + #endif + orderByAnalysis( pOrderByClause, _out_rQueryData.aSortOrder ); } -} - -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - EVO_TRACE_STRING( "NConnection::executeQuery(%s)\n", sql ); - - OEvoabResultSet* pResult = createResultSet(); - Reference< XResultSet > xRS = pResult; - -#ifdef DEBUG - g_message( "Parse SQL '%s'\n", - (const sal_Char *)OUStringToOString( sql, RTL_TEXTENCODING_UTF8 ) ); -#endif - - rtl::OString aTable; - bool bIsWithoutWhere = false; - EBookQuery *pQuery = parseSql( sql, aTable, bIsWithoutWhere ); - -#ifdef DEBUG - char *pSexpr = pQuery ? e_book_query_to_string( pQuery ) : g_strdup( "<map failed>" ); - g_message( "Parsed SQL to sexpr '%s'\n", pSexpr ); - g_free( pSexpr ); -#endif - ::vos::ORef<connectivity::OSQLColumns> xColumns; - if (pQuery) + const OSQLParseNode* pWhereClause = m_aSQLIterator.getWhereTree(); + if ( pWhereClause && SQL_ISRULE( pWhereClause, where_clause ) ) { - pResult->construct( pQuery, aTable, bIsWithoutWhere ); - e_book_query_unref( pQuery ); - xColumns = m_aSQLIterator.getSelectColumns(); - if (!xColumns.isValid()) - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - - OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) pResult->getMetaData().get(); - pMeta->setEvoabFields(xColumns); + #if OSL_DEBUG_LEVEL > 0 + ::rtl::OUString sTreeDebug; + pWhereClause->showParseTree( sTreeDebug ); + EVO_TRACE_STRING( "found where tree:\n%s", sTreeDebug ); + #endif + EBookQuery* pQuery = whereAnalysis( pWhereClause->getChild( 1 ) ); + if ( !pQuery ) + { + _out_rQueryData.eFilterType = eFilterAlwaysFalse; + pQuery = createTrue(); + } + _out_rQueryData.setQuery( pQuery ); + } + else + { + _out_rQueryData.eFilterType = eFilterNone; + _out_rQueryData.setQuery( createTrue() ); } - m_xResultSet = xRS; - - return xRS; -} -// ------------------------------------------------------------------------- -OEvoabResultSet* OStatement_Base::createResultSet() -{ - return new OEvoabResultSet(this,m_pConnection,m_aSQLIterator); } // ------------------------------------------------------------------------- -Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException) +Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); // just return our connection here - return (Reference< XConnection >)m_pConnection; -} -// ------------------------------------------------------------------------- -Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = ::cppu::queryInterface(rType,static_cast< XServiceInfo*> (this)); - if(!aRet.hasValue()) - aRet = OStatement_Base::queryInterface(rType); - 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); - ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this ); - // the return values gives information about how many rows are affected by executing the sql statement - return 0; + return impl_getConnection(); } // ------------------------------------------------------------------------- -Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) +Any SAL_CALL OCommonStatement::getWarnings( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); return makeAny(SQLWarning()); } // ------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) +void SAL_CALL OCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); } // ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const +::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const { - // this properties are define by the service statement - // they must in alphabetic order - Sequence< Property > aProps(10); - 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); + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); } - // ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() +::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper() { - return *const_cast<OStatement_Base*>(this)->getArrayHelper(); + return *const_cast< OCommonStatement* >( this )->getArrayHelper(); } -// ------------------------------------------------------------------------- -sal_Bool OStatement_Base::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 /*nHandle*/, - const Any& /*rValue*/ ) - throw (::com::sun::star::lang::IllegalArgumentException) + +// ----------------------------------------------------------------------------- +void SAL_CALL OCommonStatement::acquire() throw() { - sal_Bool bModified = sal_False; - // here we have to try to convert - return bModified; + OCommonStatement_IBase::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OCommonStatement::release() throw() +{ + relase_ChildImpl(); } + // ------------------------------------------------------------------------- -void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& /*rValue*/) throw (Exception) +QueryData OCommonStatement::impl_getEBookQuery_throw( const ::rtl::OUString& _rSql ) { - // set the value to what ever is nescessary - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } + QueryData aData; + parseSql( _rSql, aData ); + +#ifdef DEBUG + char *pSexpr = aData.getQuery() ? e_book_query_to_string( aData.getQuery() ) : g_strdup( "<map failed>" ); + g_message( "Parsed SQL to sexpr '%s'\n", pSexpr ); + g_free( pSexpr ); +#endif + + if ( !aData.getQuery() ) + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); + + // a postcondition of this method is that we properly determined the SELECT columns + aData.xSelectColumns = m_aSQLIterator.getSelectColumns(); + if ( !aData.xSelectColumns.isValid() ) + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); + + return aData; } + // ------------------------------------------------------------------------- -void OStatement_Base::getFastPropertyValue(Any& /*rValue*/,sal_Int32 nHandle) const +Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const QueryData& _rQueryData ) { - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } + // create result set + OEvoabResultSet* pResult = new OEvoabResultSet( this, m_pConnection ); + Reference< XResultSet > xRS = pResult; + pResult->construct( _rQueryData ); + + // done + m_xResultSet = xRS; + return xRS; } + // ------------------------------------------------------------------------- -IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement"); -// ----------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::acquire() throw() +Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const ::rtl::OUString& _rSql ) { - OStatement_BASE::acquire(); + EVO_TRACE_STRING( "OCommonStatement::impl_executeQuery_throw(%s)\n", _rSql ); + +#ifdef DEBUG + g_message( "Parse SQL '%s'\n", + (const sal_Char *)OUStringToOString( _rSql, RTL_TEXTENCODING_UTF8 ) ); +#endif + + return impl_executeQuery_throw( impl_getEBookQuery_throw( _rSql ) ); } + // ----------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::release() throw() +Reference< XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) throw(RuntimeException) { - OStatement_BASE::release(); + return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); } + +// ============================================================================= +// = OStatement +// ============================================================================= +// ----------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO( OStatement, "com.sun.star.comp.sdbcx.evoab.OStatement", "com.sun.star.sdbc.Statement" ); + +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2( OStatement, OCommonStatement, OStatement_IBase ) + // ----------------------------------------------------------------------------- -void SAL_CALL OStatement::acquire() throw() +IMPLEMENT_FORWARD_XTYPEPROVIDER2( OStatement, OCommonStatement, OStatement_IBase ) + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OStatement::execute( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException) { - OStatement_BASE2::acquire(); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + + Reference< XResultSet > xRS = impl_executeQuery_throw( _sql ); + return xRS.is(); } -// ----------------------------------------------------------------------------- -void SAL_CALL OStatement::release() throw() + +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL OStatement::executeQuery( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException) { - OStatement_BASE2::release(); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + + return impl_executeQuery_throw( _sql ); } + // ----------------------------------------------------------------------------- -Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException) +sal_Int32 SAL_CALL OStatement::executeUpdate( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) { - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this ); + return 0; } -// ----------------------------------------------------------------------------- +} } // namespace ::connectivity::evoab diff --git a/connectivity/source/drivers/evoab2/NStatement.hxx b/connectivity/source/drivers/evoab2/NStatement.hxx index cfab28883bad..ef3b2af4dbcf 100644 --- a/connectivity/source/drivers/evoab2/NStatement.hxx +++ b/connectivity/source/drivers/evoab2/NStatement.hxx @@ -37,52 +37,149 @@ #include <com/sun/star/sdbc/XCloseable.hpp> #include <com/sun/star/sdbc/SQLWarning.hpp> #include <comphelper/proparrhlp.hxx> -#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase2.hxx> #include <comphelper/uno3.hxx> #include "connectivity/CommonTools.hxx" -#ifndef INCLUDED_LIST -#include <list> -#define INCLUDED_LIST -#endif #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/broadcasthelper.hxx> #include "connectivity/sqliterator.hxx" -#ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_ #include "connectivity/sqlparse.hxx" -#endif #include <connectivity/FValue.hxx> #include "OSubComponent.hxx" #include <com/sun/star/util/XCancellable.hpp> #include <cppuhelper/compbase5.hxx> +#include <comphelper/propertycontainer.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> + #include "EApi.h" + +#include <list> + namespace connectivity { namespace evoab { class OEvoabResultSet; class OEvoabConnection; - typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XStatement, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbc::XCloseable> OStatement_BASE; + typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::sdbc::XWarningsSupplier + , ::com::sun::star::sdbc::XCloseable + > OCommonStatement_IBase; + + struct FieldSort + { + sal_Int32 nField; + bool bAscending; + + FieldSort() : nField(0), bAscending( true ) { } + FieldSort( const sal_Int32 _nField, const bool _bAscending ) : nField( _nField ), bAscending( _bAscending ) { } + }; + typedef ::std::vector< FieldSort > SortDescriptor; + + enum QueryFilterType + { + eFilterAlwaysFalse, + eFilterNone, + eFilterOther + }; + + struct QueryData + { + private: + EBookQuery* pQuery; + + public: + ::rtl::OUString sTable; + QueryFilterType eFilterType; + ::vos::ORef< ::connectivity::OSQLColumns > xSelectColumns; + SortDescriptor aSortOrder; + + QueryData() + :pQuery( NULL ) + ,sTable() + ,eFilterType( eFilterOther ) + ,xSelectColumns() + ,aSortOrder() + { + } + + QueryData( const QueryData& _rhs ) + :pQuery( NULL ) + ,sTable() + ,eFilterType( eFilterType ) + ,xSelectColumns() + ,aSortOrder() + { + *this = _rhs; + } + + QueryData& operator=( const QueryData& _rhs ) + { + if ( this == &_rhs ) + return *this; + + setQuery( _rhs.pQuery ); + sTable = _rhs.sTable; + eFilterType = _rhs.eFilterType; + xSelectColumns = _rhs.xSelectColumns; + aSortOrder = _rhs.aSortOrder; + + return *this; + } + + ~QueryData() + { + setQuery( NULL ); + } + + EBookQuery* getQuery() const { return pQuery; } + + void setQuery( EBookQuery* _pQuery ) + { + if ( pQuery ) + e_book_query_unref( pQuery ); + pQuery = _pQuery; + if ( pQuery ) + e_book_query_ref( pQuery ); + } + }; //************************************************************** - //************ Class: OStatement_Base + //************ Class: OCommonStatement // is a base class for the normal statement and for the prepared statement //************************************************************** - class OStatement_Base : public comphelper::OBaseMutex, - public OStatement_BASE, - public ::cppu::OPropertySetHelper, - public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base> + class OCommonStatement; + typedef OSubComponent< OCommonStatement, OCommonStatement_IBase > OStatement_CBase; + class OCommonStatement :public comphelper::OBaseMutex + ,public OCommonStatement_IBase + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement > + ,public OStatement_CBase { - protected: + friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >; + + private: ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created OEvoabResultSet *m_pResultSet; OEvoabConnection *m_pConnection; connectivity::OSQLParser m_aParser; connectivity::OSQLParseTreeIterator m_aSQLIterator; connectivity::OSQLParseNode *m_pParseTree; + + // <properties> + ::rtl::OUString m_aCursorName; + sal_Int32 m_nMaxFieldSize; + sal_Int32 m_nMaxRows; + sal_Int32 m_nQueryTimeOut; + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + sal_Bool m_bEscapeProcessing; + // </properties> + + ::cppu::OBroadcastHelper& rBHelper; + protected: void disposeResultSet(); @@ -91,48 +188,33 @@ namespace connectivity virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle) const; - virtual ~OStatement_Base(); - protected: - /* Driver Internal Methods */ - OEvoabResultSet *createResultSet(); + virtual ~OCommonStatement(); + protected: void reset () throw( ::com::sun::star::sdbc::SQLException); void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); - EBookQuery *parseSql( const ::rtl::OUString& sql, ::rtl::OString &rTable, bool &bIsWithoutWhere ) - throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - EBookQuery *whereAnalysis( const OSQLParseNode* parseTree ) - throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void parseSql( const ::rtl::OUString& sql, QueryData& _out_rQueryData ); + EBookQuery *whereAnalysis( const OSQLParseNode* parseTree ); + void orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort ); rtl::OUString getTableName(); EBookQuery *createTrue(); EBookQuery *createTest( const ::rtl::OUString &aColumnName, EBookQueryTest eTest, - const ::rtl::OUString &aMatch, - bool bGeneric = false ); + const ::rtl::OUString &aMatch ); public: // other methods OEvoabConnection* getOwnConnection() const { return m_pConnection;} - ::cppu::OBroadcastHelper& rBHelper; - OStatement_Base(OEvoabConnection* _pConnection ); - using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + + protected: + OCommonStatement( OEvoabConnection* _pConnection ); // OComponentHelper - virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();} + virtual void SAL_CALL disposing(void); // XInterface virtual void SAL_CALL release() throw(); virtual void SAL_CALL acquire() throw(); @@ -143,46 +225,66 @@ namespace connectivity // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - // XStatement - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + // XWarningsSupplier virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; + protected: + /** will return the EBookQuery representing the stamement's WHERE condition, or throw - class OStatement_BASE2 : public OStatement_Base, - public ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE> + Also, all statement dependent members (such as the parser/iterator) will be inited afterwards. + */ + QueryData + impl_getEBookQuery_throw( const ::rtl::OUString& _rSql ); - { - friend class OSubComponent<OStatement_BASE2, OStatement_BASE>; - public: - OStatement_BASE2(OEvoabConnection* _pConnection ) : OStatement_Base(_pConnection ), - ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){} - // OComponentHelper - virtual void SAL_CALL disposing(void); - // XInterface - virtual void SAL_CALL release() throw(); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > + impl_executeQuery_throw( const ::rtl::OUString& _rSql ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > + impl_executeQuery_throw( const QueryData& _rData ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + impl_getConnection() { return ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >( (::com::sun::star::sdbc::XConnection*)m_pConnection ); } + + ::rtl::OUString + impl_getColumnRefColumnName_throw( const ::connectivity::OSQLParseNode& _rColumnRef ); }; - class OStatement : public OStatement_BASE2, - public ::com::sun::star::lang::XServiceInfo + typedef ::cppu::ImplHelper2 < ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::sdbc::XStatement + > OStatement_IBase; + class OStatement :public OCommonStatement + ,public OStatement_IBase { protected: virtual ~OStatement(){} + public: - // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: - OStatement( OEvoabConnection* _pConnection) : OStatement_BASE2( _pConnection){} - DECLARE_SERVICE_INFO(); + OStatement( OEvoabConnection* _pConnection) + :OCommonStatement( _pConnection) + { + } + // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL acquire() throw(); virtual void SAL_CALL release() throw(); + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; }; } } diff --git a/connectivity/source/drivers/evoab2/NTables.cxx b/connectivity/source/drivers/evoab2/NTables.cxx index 21630ec62a1e..804248435ae6 100644 --- a/connectivity/source/drivers/evoab2/NTables.cxx +++ b/connectivity/source/drivers/evoab2/NTables.cxx @@ -101,7 +101,7 @@ void OEvoabTables::impl_refresh( ) throw(RuntimeException) // ------------------------------------------------------------------------- void OEvoabTables::disposing(void) { - m_xMetaData = NULL; +m_xMetaData.clear(); OCollection::disposing(); } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab2/evoab2.xcu b/connectivity/source/drivers/evoab2/evoab2.xcu new file mode 100755 index 000000000000..ddfc3b070e81 --- /dev/null +++ b/connectivity/source/drivers/evoab2/evoab2.xcu @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--*********************************************************************** + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataAccess.xcu,v $ + * $Revision: 1.27 $ + * + * 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:address:evolution:local" oor:op="replace"> + <prop oor:name="Driver"> + <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">Evolution Local</value> + </prop> + <node oor:name="Features"> + <node oor:name="EscapeDateTime" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + </node> + <node oor:name="sdbc:address:evolution:ldap" oor:op="replace"> + <prop oor:name="Driver"> + <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">Evolution LDAP</value> + </prop> + <node oor:name="Features"> + <node oor:name="EscapeDateTime" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + </node> + <node oor:name="sdbc:address:evolution:groupwise" oor:op="replace"> + <prop oor:name="Driver"> + <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">Groupwise</value> + </prop> + <node oor:name="Features"> + <node oor:name="EscapeDateTime" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> + </node> + </node> + </node> +</oor:component-data> diff --git a/connectivity/source/drivers/evoab2/makefile.mk b/connectivity/source/drivers/evoab2/makefile.mk index 3e59c8ecb442..e9bb9fdc4d70 100644 --- a/connectivity/source/drivers/evoab2/makefile.mk +++ b/connectivity/source/drivers/evoab2/makefile.mk @@ -6,10 +6,6 @@ # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.8 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify @@ -42,18 +38,18 @@ dummy: .ELSE # --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/makefile.pmk .INCLUDE : $(PRJ)$/version.mk +PKGCONFIG_MODULES=gtk+-2.0 +.INCLUDE : pkg_config.mk + CFLAGS+=$(GOBJECT_CFLAGS) # --- Files ------------------------------------- -EXCEPTIONSFILES=\ +SLOFILES=\ $(SLO)$/NDriver.obj \ $(SLO)$/NTable.obj \ $(SLO)$/NColumns.obj \ @@ -66,13 +62,9 @@ EXCEPTIONSFILES=\ $(SLO)$/NServices.obj \ $(SLO)$/NResultSet.obj \ $(SLO)$/NResultSetMetaData.obj \ - $(SLO)$/EApi.obj - -SLOFILES=\ - $(EXCEPTIONSFILES) \ + $(SLO)$/EApi.obj \ $(SLO)$/NDebug.obj - SHL1VERSIONMAP=$(TARGET).map @@ -100,6 +92,15 @@ SHL1STDLIBS+= ifile.lib .ENDIF SHL1STDLIBS+=$(GOBJECT_LIBS) + +SHL1STDLIBS+=$(PKGCONFIG_LIBS:s/ -lpangoxft-1.0//) +# hack for faked SO environment +.IF "$(PKGCONFIG_ROOT)"!="" +SHL1SONAME+=-z nodefs +SHL1NOCHECK=TRUE +.ENDIF # "$(PKGCONFIG_ROOT)"!="" + + SHL1DEPN= SHL1IMPLIB= i$(TARGET) @@ -110,4 +111,4 @@ DEF1NAME= $(SHL1TARGET) .ENDIF # --- Targets ---------------------------------- -.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/target.pmk |