diff options
Diffstat (limited to 'connectivity/source/drivers/kab')
37 files changed, 7202 insertions, 0 deletions
diff --git a/connectivity/source/drivers/kab/KCatalog.cxx b/connectivity/source/drivers/kab/KCatalog.cxx new file mode 100644 index 000000000000..c1309a562154 --- /dev/null +++ b/connectivity/source/drivers/kab/KCatalog.cxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KCatalog.hxx" +#include "KConnection.hxx" +#include "KTables.hxx" + +using namespace connectivity::kab; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::cppu; + +// ------------------------------------------------------------------------- +KabCatalog::KabCatalog(KabConnection* _pCon) + : connectivity::sdbcx::OCatalog(_pCon), + m_pConnection(_pCon), + m_xMetaData(m_pConnection->getMetaData()) +{ +} +// ------------------------------------------------------------------------- +void KabCatalog::refreshTables() +{ + TStringVector aVector; + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")); + Reference< XResultSet > xResult = m_xMetaData->getTables( + Any(), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")), + aTypes); + + if (xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName; + // const ::rtl::OUString& sDot = KabCatalog::getDot(); + + while (xResult->next()) + { + // aName = xRow->getString(2); + // aName += sDot; + aName = xRow->getString(3); + aVector.push_back(aName); + } + } + if (m_pTables) + m_pTables->reFill(aVector); + else + m_pTables = new KabTables(m_xMetaData,*this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void KabCatalog::refreshViews() +{ +} +// ------------------------------------------------------------------------- +void KabCatalog::refreshGroups() +{ +} +// ------------------------------------------------------------------------- +void KabCatalog::refreshUsers() +{ +} +// ------------------------------------------------------------------------- +const ::rtl::OUString& KabCatalog::getDot() +{ + static const ::rtl::OUString sDot = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".")); + return sDot; +} +// ----------------------------------------------------------------------------- + +// XTablesSupplier +Reference< XNameAccess > SAL_CALL KabCatalog::getTables( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(rBHelper.bDisposed); + + try + { + if (!m_pTables) + refreshTables(); + } + catch( const RuntimeException& ) + { + // allowed to leave this method + throw; + } + catch( const Exception& ) + { + // allowed + } + + return m_pTables; +} diff --git a/connectivity/source/drivers/kab/KCatalog.hxx b/connectivity/source/drivers/kab/KCatalog.hxx new file mode 100644 index 000000000000..5129f72b28f9 --- /dev/null +++ b/connectivity/source/drivers/kab/KCatalog.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_CATALOG_HXX_ +#define _CONNECTIVITY_KAB_CATALOG_HXX_ + +#include "connectivity/sdbcx/VCatalog.hxx" + +namespace connectivity +{ + namespace kab + { + class KabConnection; + + class KabCatalog : public connectivity::sdbcx::OCatalog + { + KabConnection* m_pConnection; // used to get the metadata + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier + + public: + KabCatalog(KabConnection* _pCon); + + inline KabConnection* getConnection() const { return m_pConnection; } + + static const ::rtl::OUString& getDot(); + + // implementation of the pure virtual methods + virtual void refreshTables(); + virtual void refreshViews(); + virtual void refreshGroups(); + virtual void refreshUsers(); + + // XTablesSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( + ) throw(::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_KAB_CATALOG_HXX_ diff --git a/connectivity/source/drivers/kab/KColumns.cxx b/connectivity/source/drivers/kab/KColumns.cxx new file mode 100644 index 000000000000..4adcbe304c82 --- /dev/null +++ b/connectivity/source/drivers/kab/KColumns.cxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KColumns.hxx" +#include "KTable.hxx" +#include "KTables.hxx" +#include "KCatalog.hxx" +#include "connectivity/sdbcx/VColumn.hxx" + +using namespace connectivity::kab; +using namespace connectivity::sdbcx; +using namespace connectivity; +using namespace ::comphelper; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +sdbcx::ObjectType KabColumns::createObject(const ::rtl::OUString& _rName) +{ + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns( + Any(), + m_pTable->getSchema(), + m_pTable->getTableName(), + _rName); + + sdbcx::ObjectType xRet = NULL; + if (xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + + while (xResult->next()) + { + if (xRow->getString(4) == _rName) + { + OColumn* pRet = new OColumn( + _rName, + xRow->getString(6), + xRow->getString(13), + xRow->getString(12), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False, + sal_False, + sal_False, + sal_True); + xRet = pRet; + break; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +void KabColumns::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshColumns(); +} +// ------------------------------------------------------------------------- +KabColumns::KabColumns( KabTable* _pTable, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector) + : sdbcx::OCollection(*_pTable, sal_True, _rMutex, _rVector), + m_pTable(_pTable) +{ +} diff --git a/connectivity/source/drivers/kab/KColumns.hxx b/connectivity/source/drivers/kab/KColumns.hxx new file mode 100644 index 000000000000..76ce272ed902 --- /dev/null +++ b/connectivity/source/drivers/kab/KColumns.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_COLUMNS_HXX_ +#define _CONNECTIVITY_KAB_COLUMNS_HXX_ + +#include "KTable.hxx" +#include "connectivity/sdbcx/VCollection.hxx" + +namespace connectivity +{ + namespace kab + { + class KabColumns : public sdbcx::OCollection + { + protected: + KabTable* m_pTable; + + virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + + public: + KabColumns( KabTable* _pTable, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector); + }; + } +} + +#endif // _CONNECTIVITY_KAB_COLUMNS_HXX_ diff --git a/connectivity/source/drivers/kab/KConnection.cxx b/connectivity/source/drivers/kab/KConnection.cxx new file mode 100644 index 000000000000..32e047748983 --- /dev/null +++ b/connectivity/source/drivers/kab/KConnection.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KConnection.hxx" +#include "KDatabaseMetaData.hxx" +#include "KStatement.hxx" +#include "KPreparedStatement.hxx" +#include "KDriver.hxx" +#include "KCatalog.hxx" +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/TransactionIsolation.hpp> +#include <shell/kde_headers.h> + +using namespace connectivity::kab; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; + +IMPLEMENT_SERVICE_INFO(KabConnection, "com.sun.star.sdbc.drivers.KabConnection", "com.sun.star.sdbc.Connection") +//----------------------------------------------------------------------------- +KabConnection::KabConnection(KabDriver* _pDriver) + : OMetaConnection_BASE(m_aMutex), + OSubComponent<KabConnection, KabConnection_BASE>((::cppu::OWeakObject*)_pDriver, this), + m_xMetaData(NULL), + m_pAddressBook(NULL), + m_pDriver(_pDriver) +{ + m_pDriver->acquire(); +} +//----------------------------------------------------------------------------- +KabConnection::~KabConnection() +{ + if (!isClosed()) + close(); + + m_pDriver->release(); + m_pDriver = NULL; +} +//----------------------------------------------------------------------------- +void SAL_CALL KabConnection::release() throw() +{ + relase_ChildImpl(); +} +// ----------------------------------------------------------------------------- +void KabConnection::construct(const ::rtl::OUString&, const Sequence< PropertyValue >&) throw(SQLException) +{ + osl_incrementInterlockedCount( &m_refCount ); + + // create a KDE address book object + m_pAddressBook = KABC::StdAddressBook::self(); + m_pAddressBook->setAutomaticSave(false); +// perharps we should analyze the URL to know whether the addressbook is local, over LDAP, etc... +// perharps we should get some user and password information from "info" properties + + osl_decrementInterlockedCount( &m_refCount ); +} +// XServiceInfo +// -------------------------------------------------------------------------------- +Reference< XStatement > SAL_CALL KabConnection::createStatement( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // create a statement + // the statement can only be executed once + Reference< XStatement > xReturn = new KabStatement(this); + m_aStatements.push_back(WeakReferenceHelper(xReturn)); + return xReturn; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL KabConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // create a statement + // the statement can only be executed more than once + Reference< XPreparedStatement > xReturn = new KabPreparedStatement(this, _sSql); + m_aStatements.push_back(WeakReferenceHelper(xReturn)); + return xReturn; +} +// -------------------------------------------------------------------------------- +Reference< XPreparedStatement > SAL_CALL KabConnection::prepareCall( const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // not implemented yet :-) a task to do + return NULL; +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + // when you need to transform SQL92 to you driver specific you can do it here + + return _sSql; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::setAutoCommit( sal_Bool ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + // here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL KabConnection::getAutoCommit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + // you have to distinguish which if you are in autocommit mode or not + // at normal case true should be fine here + + return sal_True; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::commit( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // when you database does support transactions you should commit here +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::rollback( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // same as commit but for the other case +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL KabConnection::isClosed( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + // just simple -> we are closed when we are disposed, that means someone called dispose(); (XComponent) + return KabConnection_BASE::rBHelper.bDisposed; +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL KabConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // here we have to create the class with biggest interface + // The answer is 42 :-) + Reference< XDatabaseMetaData > xMetaData = m_xMetaData; + if (!xMetaData.is()) + { + xMetaData = new KabDatabaseMetaData(this); // need the connection because it can return it + m_xMetaData = xMetaData; + } + + return xMetaData; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::setReadOnly( sal_Bool ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // set you connection to readonly +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL KabConnection::isReadOnly( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // return if your connection to readonly + return sal_False; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::setCatalog( const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // if your database doesn't work with catalogs you go to next method otherwise you kjnow what to do +} +// -------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabConnection::getCatalog( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + + // return your current catalog + return ::rtl::OUString(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::setTransactionIsolation( sal_Int32 ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // set your isolation level + // please have a look at @see com.sun.star.sdbc.TransactionIsolation +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + + // please have a look at @see com.sun.star.sdbc.TransactionIsolation + return TransactionIsolation::NONE; +} +// -------------------------------------------------------------------------------- +Reference< ::com::sun::star::container::XNameAccess > SAL_CALL KabConnection::getTypeMap( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + + // if your driver has special database types you can return it here + + return NULL; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& ) throw(SQLException, RuntimeException) +{ + // the other way around +} +// -------------------------------------------------------------------------------- +// XCloseable +void SAL_CALL KabConnection::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabConnection_BASE::rBHelper.bDisposed); + } + dispose(); +} +// -------------------------------------------------------------------------------- +// XWarningsSupplier +Any SAL_CALL KabConnection::getWarnings( ) throw(SQLException, RuntimeException) +{ + // when you collected some warnings -> return it + return Any(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabConnection::clearWarnings( ) throw(SQLException, RuntimeException) +{ + // you should clear your collected warnings here +} +//------------------------------------------------------------------------------ +void KabConnection::disposing() +{ + // we noticed that we should be destroied in near future so we have to dispose our statements + ::osl::MutexGuard aGuard(m_aMutex); + + for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_aStatements.clear(); + + if (m_pAddressBook != NULL) + { + m_pAddressBook->close(); + m_pAddressBook = NULL; + } + + m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>(); + + dispose_ChildImpl(); + KabConnection_BASE::disposing(); +} +// ----------------------------------------------------------------------------- +Reference< XTablesSupplier > SAL_CALL KabConnection::createCatalog() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + Reference< XTablesSupplier > xTab = m_xCatalog; + if (!m_xCatalog.is()) + { + KabCatalog *pCat = new KabCatalog(this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} +// ----------------------------------------------------------------------------- +::KABC::AddressBook* KabConnection::getAddressBook() const +{ + return m_pAddressBook; +} +// ----------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL createKabConnection( void* _pDriver ) +{ + KabConnection* pConnection = new KabConnection( static_cast< KabDriver* >( _pDriver ) ); + // by definition, the pointer crossing library boundaries as void ptr is acquired once + pConnection->acquire(); + return pConnection; +} diff --git a/connectivity/source/drivers/kab/KConnection.hxx b/connectivity/source/drivers/kab/KConnection.hxx new file mode 100644 index 000000000000..c7a9fcc82b11 --- /dev/null +++ b/connectivity/source/drivers/kab/KConnection.hxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_CONNECTION_HXX_ +#define _CONNECTIVITY_KAB_CONNECTION_HXX_ + +#include <map> +#include "OSubComponent.hxx" +#include "connectivity/CommonTools.hxx" +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdbc/SQLWarning.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <comphelper/broadcasthelper.hxx> +#include <cppuhelper/compbase3.hxx> + +namespace KABC +{ + class StdAddressBook; + class AddressBook; +} + +namespace connectivity +{ + namespace kab + { + + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::lang::XServiceInfo + > OMetaConnection_BASE; + + class KabStatement_Base; + class KabDriver; + class KabDatabaseMetaData; + + typedef OMetaConnection_BASE KabConnection_BASE; // implements basics and text encoding + typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray; + + class KabConnection : public comphelper::OBaseMutex, + public KabConnection_BASE, + public OSubComponent<KabConnection, KabConnection_BASE> + { + friend class OSubComponent<KabConnection, KabConnection_BASE>; + + protected: + //==================================================================== + // Data attributes + //==================================================================== + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + OWeakRefArray m_aStatements; // vector containing a list of all the Statement objects + // for this Connection + + ::KABC::StdAddressBook* m_pAddressBook; // the address book + KabDriver* m_pDriver; // pointer to the owning driver object + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> + m_xCatalog; // needed for the SQL interpreter + + public: + virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException); + + KabConnection(KabDriver* _pDriver); + virtual ~KabConnection(); + + void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + + // XInterface + virtual void SAL_CALL release() throw(); + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XConnection + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( 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::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) 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); + + // 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); + + // needed for the SQL interpreter + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog(); + + // accessors + inline KabDriver* getDriver() const { return m_pDriver;} + ::KABC::AddressBook* getAddressBook() const; + }; + } +} + +#endif // _CONNECTIVITY_KAB_CONNECTION_HXX_ diff --git a/connectivity/source/drivers/kab/KDEInit.cxx b/connectivity/source/drivers/kab/KDEInit.cxx new file mode 100644 index 000000000000..86098c1b8866 --- /dev/null +++ b/connectivity/source/drivers/kab/KDEInit.cxx @@ -0,0 +1,155 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "KDEInit.h" +#include <osl/diagnose.h> +#include <osl/process.h> +#include <shell/kde_headers.h> + +namespace connectivity +{ + namespace kab + { + // =============================================================== + // = KDEInit + // =============================================================== + class KDEInit + { + private: + /// KDE application if we own it + static KApplication* s_pKApplication; + static bool s_bDidInsertCatalogue; + + public: + static void Init(); + static void Shutdown(); + }; + + // --------------------------------------------------------------- + KApplication* KDEInit::s_pKApplication = NULL; + bool KDEInit::s_bDidInsertCatalogue = false; + + // --------------------------------------------------------------- + void KDEInit::Init() + { + // TODO: All this is not thread-safe + + // we create a KDE application only if it is not already done + if (KApplication::kApplication() == NULL) + { + OSL_ENSURE(s_pKApplication == NULL, "KDEInit::Init: inconsistency in the application pointers!"); + + char *kabargs[1] = {(char*)"libkab1"}; + KCmdLineArgs::init(1, kabargs, "KAddressBook", *kabargs, "Address Book driver", KAB_DRIVER_VERSION); + + s_pKApplication = new KApplication(false, false); + } + + // set language + rtl_Locale *pProcessLocale; + osl_getProcessLocale(&pProcessLocale); + // sal_Unicode and QChar are (currently) both 16 bits characters + QString aLanguage( + (const QChar *) pProcessLocale->Language->buffer, + (int) pProcessLocale->Language->length); + KGlobal::locale()->setLanguage(aLanguage); + + // load KDE address book's localized messages + KGlobal::locale()->insertCatalogue("kaddressbook"); + s_bDidInsertCatalogue = true; + } + + // --------------------------------------------------------------- + void KDEInit::Shutdown() + { + if ( s_bDidInsertCatalogue ) + // this guard is necessary, since KDE 3.3 seems to crash if we remove a catalogue + // which we did not previously insert + KGlobal::locale()->removeCatalogue("kaddressbook"); + + if ( s_pKApplication != NULL ) + { + delete s_pKApplication; + s_pKApplication = NULL; + } + } + } +} + +// ======================================================================= +namespace +{ + double normalizeVersion( unsigned int major, unsigned int minor ) + { + return major + 1.0 * minor / 1000; + } +} + +// ----------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL initKApplication() +{ + ::connectivity::kab::KDEInit::Init(); +} + +// ----------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL shutdownKApplication() +{ + ::connectivity::kab::KDEInit::Shutdown(); +} +// ----------------------------------------------------------------------- +/** checks whether the KDE version on the system we're running at is supported + by the driver + + Has to be called before any other code from this library, in particular, + it has to be called before initKApplication() + + If this function returns <code>0</code>, then no other code from this library + has to be called, else the results are unpredictable. + + @return + <ul><li><code>0</code> if the KDE version is supportednon</li> + <li>a negative value if the version is too old</li> + <li>a positive value if the version is too new to know whether it works with this driver</li> + </ul> + + #i60062# / 2006-01-06 / frank.schoenheit@sun.com +*/ +extern "C" SAL_DLLPUBLIC_EXPORT int SAL_CALL matchKDEVersion() +{ + double nMinVersion = normalizeVersion( MIN_KDE_VERSION_MAJOR, MIN_KDE_VERSION_MINOR ); + double nCurVersion = normalizeVersion( ::KDE::versionMajor(), ::KDE::versionMinor() ); + double nMaxVersion = normalizeVersion( MAX_KDE_VERSION_MAJOR, MAX_KDE_VERSION_MINOR ); + + if ( nCurVersion < nMinVersion ) + return -1; + if ( nCurVersion > nMaxVersion ) + return 1; + + return 0; +} diff --git a/connectivity/source/drivers/kab/KDEInit.h b/connectivity/source/drivers/kab/KDEInit.h new file mode 100644 index 000000000000..8e401a05e8d6 --- /dev/null +++ b/connectivity/source/drivers/kab/KDEInit.h @@ -0,0 +1,44 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CONNECTIVITY_KAB_KDEINIT_H +#define CONNECTIVITY_KAB_KDEINIT_H + +// the address book driver's version +#define KAB_DRIVER_VERSION "0.2" +#define KAB_DRIVER_VERSION_MAJOR 0 +#define KAB_DRIVER_VERSION_MINOR 2 + +// the minimum KDE version which is required at runtime +#define MIN_KDE_VERSION_MAJOR 3 +#define MIN_KDE_VERSION_MINOR 2 + +#define MAX_KDE_VERSION_MAJOR 3 +#define MAX_KDE_VERSION_MINOR 6 + + +#endif // CONNECTIVITY_KAB_KDEINIT_H diff --git a/connectivity/source/drivers/kab/KDatabaseMetaData.cxx b/connectivity/source/drivers/kab/KDatabaseMetaData.cxx new file mode 100644 index 000000000000..b972f362b45a --- /dev/null +++ b/connectivity/source/drivers/kab/KDatabaseMetaData.cxx @@ -0,0 +1,1080 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KDatabaseMetaData.hxx" +#include "kfields.hxx" +#include "KDEInit.h" +#include <shell/kde_headers.h> +#include "FDatabaseMetaDataResultSet.hxx" +#include "OTypeInfo.hxx" +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/TransactionIsolation.hpp> + +using namespace connectivity::kab; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; + +KabDatabaseMetaData::KabDatabaseMetaData(KabConnection* _pCon) + : m_xConnection(_pCon), + m_bUseCatalog(sal_True) +{ + OSL_ENSURE(_pCon,"KabDatabaseMetaData::KabDatabaseMetaData: No connection set!"); + + osl_incrementInterlockedCount( &m_refCount ); + m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable()); + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +KabDatabaseMetaData::~KabDatabaseMetaData() +{ +} +// ------------------------------------------------------------------------- +const ::rtl::OUString & KabDatabaseMetaData::getAddressBookTableName() +{ + static const ::rtl::OUString aAddressBookTableName + (::rtl::OUString::createFromAscii( i18n("Address Book") )); + + return aAddressBookTableName; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + if (m_bUseCatalog) + { // do some special here for you database + } + + return aVal; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException) +{ + // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement, + // currently, the resultset/statement implementations can cope with one table only + sal_Int32 nValue = 1; + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + if (m_bUseCatalog) + { + } + return aVal; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException) +{ + // normally this is " + ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("\""); + return aVal; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aVal; + return aVal; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException) +{ + sal_Bool bValue = sal_False; + if (m_bUseCatalog) + { + } + return bValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) +{ + return sal_True; // should be supported at least +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) +{ + // for the moment, we have read-only addresses, but this might change in the future + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsConvert( sal_Int32, sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + // if someday we support more than the default address book, + // this method should return the URL which was used to create it + ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:address:kab:"); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("kab"); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue = ::rtl::OUString::createFromAscii(KAB_DRIVER_VERSION); + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) +{ + return KAB_DRIVER_VERSION_MAJOR; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) +{ + return TransactionIsolation::NONE; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) +{ + return KAB_DRIVER_VERSION_MINOR; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aValue; + return aValue; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabDatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) +{ + sal_Int32 nValue = 0; // 0 means no limit + return nValue; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException) +{ + switch (setType) + { + case ResultSetType::FORWARD_ONLY: + case ResultSetType::SCROLL_INSENSITIVE: + return sal_True; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 ) throw(SQLException, RuntimeException) +{ + switch (setType) + { + case ResultSetType::FORWARD_ONLY: + case ResultSetType::SCROLL_INSENSITIVE: + return sal_True; + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::updatesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::deletesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::insertsAreDetected( sal_Int32 ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL KabDatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException) +{ + return (Reference< XConnection >) m_xConnection.get(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) +{ + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); + Reference< XResultSet > xRef = pResult; + + static ODatabaseMetaDataResultSet::ORows aRows; + static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE")); + + if (aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow(2); + aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = new ORowSetValueDecorator(aTable); + aRows.push_back(aRow); + } + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) +{ + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); + Reference< XResultSet > xRef = pResult; + + static ODatabaseMetaDataResultSet::ORows aRows; + if (aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow(19); + + aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR")); + aRow[2] = new ORowSetValueDecorator(DataType::CHAR); + aRow[3] = new ORowSetValueDecorator((sal_Int32) 254); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[7] = new ORowSetValueDecorator((sal_Int32) ColumnValue::NULLABLE); + aRow[8] = ODatabaseMetaDataResultSet::get1Value(); + aRow[9] = new ORowSetValueDecorator((sal_Int32) ColumnSearch::CHAR); + aRow[10] = ODatabaseMetaDataResultSet::get1Value(); + aRow[11] = ODatabaseMetaDataResultSet::get0Value(); + aRow[12] = ODatabaseMetaDataResultSet::get0Value(); + aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[14] = ODatabaseMetaDataResultSet::get0Value(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRow[16] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[17] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[18] = new ORowSetValueDecorator((sal_Int32) 10); + aRows.push_back(aRow); +// Much more types might appear in KDE address books +// To be completed + } + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs ); +} +// ----------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getColumnPrivileges( + const Any&, const ::rtl::OUString&, const ::rtl::OUString&, + const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getColumns( + const Any&, + const ::rtl::OUString&, + const ::rtl::OUString& tableNamePattern, + const ::rtl::OUString& columnNamePattern) throw(SQLException, RuntimeException) +{ + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); + Reference< XResultSet > xRef = pResult; + + ODatabaseMetaDataResultSet::ORows aRows; + + if (match(tableNamePattern, getAddressBookTableName(), '\0')) + { + ODatabaseMetaDataResultSet::ORow aRow(19); + + aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[3] = new ORowSetValueDecorator(getAddressBookTableName()); + aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[9] = ODatabaseMetaDataResultSet::get0Value(); + aRow[10] = new ORowSetValueDecorator((sal_Int32) 10); + aRow[11] = ODatabaseMetaDataResultSet::get1Value(); + aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[16] = new ORowSetValueDecorator((sal_Int32) 254); + aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES")); + + sal_Int32 nPosition = 1; + QString aQtName; + ::rtl::OUString sName; + + aQtName = ::KABC::Addressee::revisionLabel(); + sName = (const sal_Unicode *) aQtName.ucs2(); + if (match(columnNamePattern, sName, '\0')) + { + aRow[4] = new ORowSetValueDecorator(sName); + aRow[5] = new ORowSetValueDecorator(DataType::TIMESTAMP); + aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); + aRow[17] = new ORowSetValueDecorator(nPosition++); + aRows.push_back(aRow); + } + + ::KABC::Field::List aFields = ::KABC::Field::allFields(); + ::KABC::Field::List::iterator aField; + + for ( aField = aFields.begin(); + aField != aFields.end(); + ++aField, ++nPosition) + { + aQtName = (*aField)->label(); + sName = (const sal_Unicode *) aQtName.ucs2(); + if (match(columnNamePattern, sName, '\0')) + { + aRow[4] = new ORowSetValueDecorator(sName); + aRow[5] = new ORowSetValueDecorator(DataType::CHAR); + aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR")); + aRow[7] = new ORowSetValueDecorator((sal_Int32) 256); +// Might be VARCHAR and not CHAR[256]... + aRow[17] = new ORowSetValueDecorator(nPosition); + aRows.push_back(aRow); + } + } + } + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTables( + const Any&, + const ::rtl::OUString&, + const ::rtl::OUString&, + const Sequence< ::rtl::OUString >& types) throw(SQLException, RuntimeException) +{ + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables); + Reference< XResultSet > xRef = pResult; + + // check whether we have tables in the requested types + // for the moment, we answer only the "TABLE" table type + // when no types are given at all, we return all the tables + static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE")); + sal_Bool bTableFound = sal_False; + const ::rtl::OUString* p = types.getConstArray(), + * pEnd = p + types.getLength(); + + if (p == pEnd) + { + bTableFound = sal_True; + } + else while (p < pEnd) + { + if (match(*p, aTable, '\0')) + { + bTableFound = sal_True; + break; + } + p++; + } + if (!bTableFound) + return xRef; + + static ODatabaseMetaDataResultSet::ORows aRows; + + if (aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow(6); + + aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[3] = new ORowSetValueDecorator(getAddressBookTableName()); + aRow[4] = new ORowSetValueDecorator(aTable); + aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRows.push_back(aRow); + } + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getProcedureColumns( + const Any&, const ::rtl::OUString&, + const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getProcedures( + const Any&, const ::rtl::OUString&, + const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getVersionColumns( + const Any&, const ::rtl::OUString&, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) +{ + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns); + + Reference< XResultSet > xRef = pResult; + + ODatabaseMetaDataResultSet::ORows aRows; + + if (table == getAddressBookTableName()) + { + ODatabaseMetaDataResultSet::ORow aRow( 9 ); + QString aQtName = ::KABC::Addressee::revisionLabel(); + ::rtl::OUString sName = (const sal_Unicode *) aQtName.ucs2(); + + aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue(); + + aRow[2] = new ORowSetValueDecorator(sName); + aRow[3] = new ORowSetValueDecorator(DataType::TIMESTAMP); + aRow[4] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); + + aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[7] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue(); + + aRows.push_back(aRow); + } + pResult->setRows(aRows); + return xRef; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getExportedKeys( + const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getImportedKeys( + const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getPrimaryKeys( + const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getIndexInfo( + const Any&, const ::rtl::OUString&, const ::rtl::OUString&, + sal_Bool, sal_Bool ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getBestRowIdentifier( + const Any&, const ::rtl::OUString&, const ::rtl::OUString&, sal_Int32, + sal_Bool ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTablePrivileges( + const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getCrossReference( + const Any&, const ::rtl::OUString&, + const ::rtl::OUString&, const Any&, + const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference ); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getUDTs( const Any&, const ::rtl::OUString&, const ::rtl::OUString&, const Sequence< sal_Int32 >& ) throw(SQLException, RuntimeException) +{ + OSL_ENSURE(0,"Not implemented yet!"); + throw SQLException(); +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/kab/KDatabaseMetaData.hxx b/connectivity/source/drivers/kab/KDatabaseMetaData.hxx new file mode 100644 index 000000000000..2c56869fcb6d --- /dev/null +++ b/connectivity/source/drivers/kab/KDatabaseMetaData.hxx @@ -0,0 +1,213 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_DATABASEMETADATA_HXX_ +#define _CONNECTIVITY_KAB_DATABASEMETADATA_HXX_ + +#include "KConnection.hxx" +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> +#include <cppuhelper/implbase1.hxx> + +namespace connectivity +{ + namespace kab + { + //************************************************************** + //************ Class: KabDatabaseMetaData + //************************************************************** + + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData> KabDatabaseMetaData_BASE; + + class KabDatabaseMetaData : public KabDatabaseMetaData_BASE + { + ::com::sun::star::uno::Reference< KabConnection > m_xConnection; + sal_Bool m_bUseCatalog; + + public: + + inline KabConnection* getOwnConnection() const { return m_xConnection.get(); } + + KabDatabaseMetaData(KabConnection* _pCon); + static const ::rtl::OUString & getAddressBookTableName(); + virtual ~KabDatabaseMetaData(); + + // this interface is really BIG + // XDatabaseMetaData + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) 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); + }; + } +} + +#endif // _CONNECTIVITY_KAB_DATABASEMETADATA_HXX_ diff --git a/connectivity/source/drivers/kab/KDriver.cxx b/connectivity/source/drivers/kab/KDriver.cxx new file mode 100644 index 000000000000..72753f10662a --- /dev/null +++ b/connectivity/source/drivers/kab/KDriver.cxx @@ -0,0 +1,473 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KDriver.hxx" +#include "KDEInit.h" +#include "KConnection.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/lang/NullPointerException.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +/** === end UNO includes === **/ +#include <rtl/ustrbuf.hxx> +#include <tools/diagnose_ex.h> +#include "resource/kab_res.hrc" +#include "resource/sharedresources.hxx" + +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdb; +using namespace com::sun::star::frame; +using namespace connectivity::kab; + +// ======================================================================= +// = KabImplModule +// ======================================================================= +// -------------------------------------------------------------------------------- +KabImplModule::KabImplModule( const Reference< XMultiServiceFactory >& _rxFactory ) + :m_xORB(_rxFactory) + ,m_bAttemptedLoadModule(false) + ,m_bAttemptedInitialize(false) + ,m_hConnectorModule(NULL) + ,m_pConnectionFactoryFunc(NULL) + ,m_pApplicationInitFunc(NULL) + ,m_pApplicationShutdownFunc(NULL) + ,m_pKDEVersionCheckFunc(NULL) +{ + if ( !m_xORB.is() ) + throw NullPointerException(); +} + +// -------------------------------------------------------------------------------- +bool KabImplModule::isKDEPresent() +{ + if ( !impl_loadModule() ) + return false; + + return true; +} + +// -------------------------------------------------------------------------------- +KabImplModule::KDEVersionType KabImplModule::matchKDEVersion() +{ + OSL_PRECOND( m_pKDEVersionCheckFunc, "KabImplModule::matchKDEVersion: module not loaded!" ); + + int nVersionInfo = (*m_pKDEVersionCheckFunc)(); + if ( nVersionInfo < 0 ) + return eTooOld; + if ( nVersionInfo > 0 ) + return eToNew; + return eSupported; +} + +// -------------------------------------------------------------------------------- +namespace +{ + template< typename FUNCTION > + void lcl_getFunctionFromModuleOrUnload( oslModule& _rModule, const sal_Char* _pAsciiSymbolName, FUNCTION& _rFunction ) + { + _rFunction = NULL; + if ( _rModule ) + { + // + const ::rtl::OUString sSymbolName = ::rtl::OUString::createFromAscii( _pAsciiSymbolName ); + _rFunction = (FUNCTION)( osl_getSymbol( _rModule, sSymbolName.pData ) ); + + if ( !_rFunction ) + { // did not find the symbol + OSL_ENSURE( false, ::rtl::OString( "lcl_getFunctionFromModuleOrUnload: could not find the symbol " ) + ::rtl::OString( _pAsciiSymbolName ) ); + osl_unloadModule( _rModule ); + _rModule = NULL; + } + } + } +} + +// -------------------------------------------------------------------------------- +extern "C" { void SAL_CALL thisModule() {} } + +bool KabImplModule::impl_loadModule() +{ + if ( m_bAttemptedLoadModule ) + return ( m_hConnectorModule != NULL ); + m_bAttemptedLoadModule = true; + + OSL_ENSURE( !m_hConnectorModule && !m_pConnectionFactoryFunc && !m_pApplicationInitFunc && !m_pApplicationShutdownFunc && !m_pKDEVersionCheckFunc, + "KabImplModule::impl_loadModule: inconsistence: inconsistency (never attempted load before, but some values already set)!"); + + const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii( SAL_MODULENAME( "kabdrv1" ) ); + m_hConnectorModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, SAL_LOADMODULE_NOW ); // LAZY! #i61335# + OSL_ENSURE( m_hConnectorModule, "KabImplModule::impl_loadModule: could not load the implementation library!" ); + if ( !m_hConnectorModule ) + return false; + + lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "createKabConnection", m_pConnectionFactoryFunc ); + lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "initKApplication", m_pApplicationInitFunc ); + lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "shutdownKApplication", m_pApplicationShutdownFunc ); + lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "matchKDEVersion", m_pKDEVersionCheckFunc ); + + if ( !m_hConnectorModule ) + // one of the symbols did not exist + throw RuntimeException(); + + return true; +} + +// -------------------------------------------------------------------------------- +void KabImplModule::impl_unloadModule() +{ + OSL_PRECOND( m_hConnectorModule != NULL, "KabImplModule::impl_unloadModule: no module!" ); + + osl_unloadModule( m_hConnectorModule ); + m_hConnectorModule = NULL; + + m_pConnectionFactoryFunc = NULL; + m_pApplicationInitFunc = NULL; + m_pApplicationShutdownFunc = NULL; + m_pKDEVersionCheckFunc = NULL; + + m_bAttemptedLoadModule = false; +} + +// -------------------------------------------------------------------------------- +void KabImplModule::init() +{ + if ( !impl_loadModule() ) + impl_throwNoKdeException(); + + // if we're not running on a supported version, throw + KabImplModule::KDEVersionType eKDEVersion = matchKDEVersion(); + + if ( eKDEVersion == eTooOld ) + impl_throwKdeTooOldException(); + + if ( ( eKDEVersion == eToNew ) && !impl_doAllowNewKDEVersion() ) + impl_throwKdeTooNewException(); + + if ( !m_bAttemptedInitialize ) + { + m_bAttemptedInitialize = true; + (*m_pApplicationInitFunc)(); + } +} + +// -------------------------------------------------------------------------------- +bool KabImplModule::impl_doAllowNewKDEVersion() +{ + try + { + Reference< XMultiServiceFactory > xConfigProvider( + m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ), + UNO_QUERY_THROW ); + Sequence< Any > aCreationArgs(1); + aCreationArgs[0] <<= PropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), + 0, + makeAny( KabDriver::impl_getConfigurationSettingsPath() ), + PropertyState_DIRECT_VALUE ); + Reference< XPropertySet > xSettings( xConfigProvider->createInstanceWithArguments( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ), + aCreationArgs ), + UNO_QUERY_THROW ); + + sal_Bool bDisableCheck = sal_False; + xSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableKDEMaximumVersionCheck" ) ) ) >>= bDisableCheck; + + return bDisableCheck != sal_False; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return false; +} + +// -------------------------------------------------------------------------------- +void KabImplModule::impl_throwNoKdeException() +{ + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceString( + STR_NO_KDE_INST + ) ); + impl_throwGenericSQLException( sError ); +} + +// -------------------------------------------------------------------------------- +void KabImplModule::impl_throwKdeTooOldException() +{ + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( + STR_KDE_VERSION_TOO_OLD, + "$major$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MAJOR), + "$minor$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MINOR) + ) ); + impl_throwGenericSQLException( sError ); +} + +// -------------------------------------------------------------------------------- +void KabImplModule::impl_throwGenericSQLException( const ::rtl::OUString& _rMessage ) +{ + SQLException aError; + aError.Message = _rMessage; + aError.SQLState = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ); + aError.ErrorCode = 0; + throw aError; +} + +// -------------------------------------------------------------------------------- +void KabImplModule::impl_throwKdeTooNewException() +{ + ::connectivity::SharedResources aResources; + + SQLException aError; + aError.Message = aResources.getResourceStringWithSubstitution( + STR_KDE_VERSION_TOO_NEW, + "$major$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MAJOR), + "$minor$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MINOR) + ); + aError.SQLState = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ); + aError.ErrorCode = 0; + + SQLContext aDetails; + ::rtl::OUStringBuffer aMessage; + aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) ); + + aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" ); + aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" ); + + aMessage.appendAscii( " Dim configNode as Object\n" ); + aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" ); + aMessage.append( KabDriver::impl_getConfigurationSettingsPath() ); + aMessage.appendAscii( "\", true )\n" ); + + aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" ); + aMessage.appendAscii( " configNode.commitChanges\n" ); + aMessage.appendAscii( "End Sub\n" ); + + aDetails.Message = aMessage.makeStringAndClear(); + + aError.NextException <<= aDetails; + + throw aError; +} + +// -------------------------------------------------------------------------------- +KabConnection* KabImplModule::createConnection( KabDriver* _pDriver ) const +{ + OSL_PRECOND( m_hConnectorModule, "KabImplModule::createConnection: not initialized!" ); + + void* pUntypedConnection = (*m_pConnectionFactoryFunc)( _pDriver ); + if ( !pUntypedConnection ) + throw RuntimeException(); + + return static_cast< KabConnection* >( pUntypedConnection ); +} + +// -------------------------------------------------------------------------------- +void KabImplModule::shutdown() +{ + if ( !m_hConnectorModule ) + return; + + (*m_pApplicationShutdownFunc)(); + m_bAttemptedInitialize = false; + + impl_unloadModule(); +} + +// ======================================================================= +// = KabDriver +// ======================================================================= +KabDriver::KabDriver( + const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) + : KDriver_BASE(m_aMutex), + m_xMSFactory(_rxFactory), + m_aImplModule(_rxFactory) +{ + if ( !m_xMSFactory.is() ) + throw NullPointerException(); + + osl_incrementInterlockedCount( &m_refCount ); + try + { + Reference< XDesktop > xDesktop( + m_xMSFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), + UNO_QUERY_THROW ); + xDesktop->addTerminateListener( this ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + osl_decrementInterlockedCount( &m_refCount ); +} +// -------------------------------------------------------------------------------- +void KabDriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + // when driver will be destroied so all our connections have to be destroied as well + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + Reference< XComponent > xComp(i->get(), UNO_QUERY); + if (xComp.is()) + xComp->dispose(); + } + m_xConnections.clear(); + + WeakComponentImplHelperBase::disposing(); +} +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString KabDriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii( impl_getAsciiImplementationName() ); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > KabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + // which service is supported + // for more information @see com.sun.star.sdbc.Driver + Sequence< ::rtl::OUString > aSNS( 1 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + + return aSNS; +} +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL KabDriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} +//------------------------------------------------------------------ +sal_Bool SAL_CALL KabDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); + + while (pSupported != pEnd && !pSupported->equals(_rServiceName)) + ++pSupported; + return pSupported != pEnd; +} +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL KabDriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL KabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + m_aImplModule.init(); + + // create a new connection with the given properties and append it to our vector + KabConnection* pConnection = m_aImplModule.createConnection( this ); + OSL_POSTCOND( pConnection, "KabDriver::connect: no connection has been created by the factory!" ); + + // by definition, the factory function returned an object which was acquired once + Reference< XConnection > xConnection = pConnection; + pConnection->release(); + + // late constructor call which can throw exception and allows a correct dtor call when so + pConnection->construct( url, info ); + + // remember it + m_xConnections.push_back( WeakReferenceHelper( *pConnection ) ); + + return xConnection; +} +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL KabDriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + if ( !m_aImplModule.isKDEPresent() ) + return sal_False; + + // here we have to look whether we support this URL format + return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:address:kab:"), 16)); +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL KabDriver::getPropertyInfo( const ::rtl::OUString&, const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException) +{ + // if you have something special to say, return it here :-) + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDriver::getMajorVersion( ) throw(RuntimeException) +{ + return KAB_DRIVER_VERSION_MAJOR; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabDriver::getMinorVersion( ) throw(RuntimeException) +{ + return KAB_DRIVER_VERSION_MINOR; +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabDriver::queryTermination( const EventObject& ) throw (TerminationVetoException, RuntimeException) +{ + // nothing to do, nothing to veto +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabDriver::notifyTermination( const EventObject& ) throw (RuntimeException) +{ + m_aImplModule.shutdown(); +} +// -------------------------------------------------------------------------------- +void SAL_CALL KabDriver::disposing( const EventObject& ) throw (RuntimeException) +{ + // not interested in (this is the disposing of the desktop, if any) +} +// -------------------------------------------------------------------------------- +const sal_Char* KabDriver::impl_getAsciiImplementationName() +{ + return "com.sun.star.comp.sdbc.kab.Driver"; + // this name is referenced in the configuration and in the kab.xml + // Please be careful when changing it. +} +// -------------------------------------------------------------------------------- +::rtl::OUString KabDriver::impl_getConfigurationSettingsPath() +{ + ::rtl::OUStringBuffer aPath; + aPath.appendAscii( "/org.openoffice.Office.DataAccess/DriverSettings/" ); + aPath.appendAscii( "com.sun.star.comp.sdbc.kab.Driver" ); + return aPath.makeStringAndClear(); +} +// -------------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL KabDriver::Create( const Reference< XMultiServiceFactory >& _rxFactory ) throw( Exception ) +{ + return *(new KabDriver(_rxFactory)); +} + diff --git a/connectivity/source/drivers/kab/KDriver.hxx b/connectivity/source/drivers/kab/KDriver.hxx new file mode 100644 index 000000000000..5bceb27efdec --- /dev/null +++ b/connectivity/source/drivers/kab/KDriver.hxx @@ -0,0 +1,223 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_DRIVER_HXX_ +#define _CONNECTIVITY_KAB_DRIVER_HXX_ + +/** === begin UNO includes === **/ +#include <com/sun/star/sdbc/XDriver.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +/** === end UNO includes === **/ +#include <cppuhelper/compbase3.hxx> +#include <osl/module.h> + +namespace connectivity +{ + namespace kab + { + class KabConnection; + class KabDriver; + + typedef void* (SAL_CALL * ConnectionFactoryFunction)( void* _pDriver ); + typedef void (SAL_CALL * ApplicationInitFunction)( void ); + typedef void (SAL_CALL * ApplicationShutdownFunction)( void ); + typedef int (SAL_CALL * KDEVersionCheckFunction)( void ); + + typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray; + + // =============================================================== + // = KabImplModule + // =============================================================== + class KabImplModule + { + private: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xORB; + + /// Did we already attempt to load the module and to retrieve the symbols? + bool m_bAttemptedLoadModule; + /// Did we already check the KDE version and initialize the impl module (or at least attempted to)? + bool m_bAttemptedInitialize; + + oslModule m_hConnectorModule; + ConnectionFactoryFunction m_pConnectionFactoryFunc; + ApplicationInitFunction m_pApplicationInitFunc; + ApplicationShutdownFunction m_pApplicationShutdownFunc; + KDEVersionCheckFunction m_pKDEVersionCheckFunc; + + public: + KabImplModule( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); + + /** determines whether there is a KDE present in the environment + */ + bool isKDEPresent(); + + enum KDEVersionType + { + eTooOld, + eSupported, + eToNew + }; + /** checks whether the KDE version we're running against is supported + @precond + the module is loaded, i.e impl_loadModule has successfully been called + */ + KDEVersionType matchKDEVersion(); + + /** initializes the implementation module. + + @raises ::com::sun::star::uno::RuntimeException + if the module could be loaded, but required symbols are missing + @raises ::com::sun::star::sdbc::SQLException + if the KDE version we're running against is not supported, or no KDE was found at all + */ + void init(); + + /** shuts down the impl module (and the KDE application, if we own it) + */ + void shutdown(); + + /** creates a new connection + @precond + <member>init</member> has been called before + @raises ::com::sun::star::uno::RuntimeException + if no connection object could be created (which is a severe error, normally impossible) + */ + KabConnection* createConnection( KabDriver* _pDriver ) const; + + private: + /** loads the implementation module and retrieves the needed symbols + + Save against being called multiple times. + + @return <TRUE/> if the module could be loaded successfully. + + @raises ::com::sun::star::uno::RuntimeException + if the module could be loaded, but required symbols are missing + */ + bool impl_loadModule(); + + /** unloads the implementation module, and resets all function pointers to <NULL/> + @precond m_hConnectorModule is not <NULL/> + */ + void impl_unloadModule(); + + /** throws an SQLException saying than no KDE installation was found + */ + void impl_throwNoKdeException(); + + /** throws an SQLException saying that the found KDE version is too old + */ + void impl_throwKdeTooOldException(); + + /** throws an SQLException saying that the found KDE version is too new + */ + void impl_throwKdeTooNewException(); + + /** throws a generic SQL exception with SQLState S1000 and error code 0 + */ + void impl_throwGenericSQLException( const ::rtl::OUString& _rMessage ); + + /** determines whether it's allowed to run on a too-new (not confirmed to work) version + */ + bool impl_doAllowNewKDEVersion(); + }; + + // =============================================================== + // = KabDriver + // =============================================================== + typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::frame::XTerminateListener > KDriver_BASE; + class KabDriver : public KDriver_BASE + { + protected: + ::osl::Mutex m_aMutex; // mutex is need to control member access + OWeakRefArray m_xConnections; // vector containing a list of all the + // KabConnection objects for this Driver + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > + m_xMSFactory; // the multi-service factory + KabImplModule m_aImplModule; + + public: + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); + + // XServiceInfo - static versions + static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException); + + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& + getMSFactory() const { return m_xMSFactory; } + + /** returns the driver's implementation name (being pure ASCII) for reference in various places + */ + static const sal_Char* impl_getAsciiImplementationName(); + + /** returns the path of our configuration settings + */ + static ::rtl::OUString impl_getConfigurationSettingsPath(); + + protected: + KabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); + + // OComponentHelper + virtual void SAL_CALL disposing(void); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XDriver + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMajorVersion() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getMinorVersion() throw(::com::sun::star::uno::RuntimeException); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + private: + /** shuts down the library which contains the real implementations + + This method is safe against being called multiple times + + @precond our mutex is locked + */ + void impl_shutdownImplementationModule(); + }; + } + +} + +#endif // _CONNECTIVITY_KAB_DRIVER_HXX_ diff --git a/connectivity/source/drivers/kab/KPreparedStatement.cxx b/connectivity/source/drivers/kab/KPreparedStatement.cxx new file mode 100644 index 000000000000..02bdd32ef90b --- /dev/null +++ b/connectivity/source/drivers/kab/KPreparedStatement.cxx @@ -0,0 +1,390 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KPreparedStatement.hxx" +#include "propertyids.hxx" +#include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> +#include "resource/kab_res.hrc" +#include "resource/sharedresources.hxx" + +using namespace connectivity::kab; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::util; + +IMPLEMENT_SERVICE_INFO(KabPreparedStatement, "com.sun.star.sdbc.drivers.KabPreparedStatement", "com.sun.star.sdbc.PreparedStatement"); +// ------------------------------------------------------------------------- +void KabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams) throw(SQLException) +{ + if ( !m_aParameterRow.isValid() ) + m_aParameterRow = new OValueVector(); + + if (nParams < 1) + ::dbtools::throwInvalidIndexException(*(KabPreparedStatement *) this,Any()); + + if (nParams >= (sal_Int32) (m_aParameterRow->get()).size()) + (m_aParameterRow->get()).resize(nParams); +} +// ------------------------------------------------------------------------- +void KabPreparedStatement::setKabFields() const throw(SQLException) +{ + ::vos::ORef<connectivity::OSQLColumns> xColumns; // selected columns + + xColumns = m_aSQLIterator.getSelectColumns(); + if (!xColumns.isValid()) + { + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceString( + STR_INVALID_COLUMN_SELECTION + ) ); + ::dbtools::throwGenericSQLException(sError,NULL); + } + m_xMetaData->setKabFields(xColumns); +} +// ------------------------------------------------------------------------- +void KabPreparedStatement::resetParameters() const throw(SQLException) +{ + m_nParameterIndex = 0; +} +// ------------------------------------------------------------------------- +void KabPreparedStatement::getNextParameter(::rtl::OUString &rParameter) const throw(SQLException) +{ + if (m_nParameterIndex >= (sal_Int32) (m_aParameterRow->get()).size()) + { + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceString( + STR_INVALID_PARA_COUNT + ) ); + ::dbtools::throwGenericSQLException(sError,*(KabPreparedStatement *) this); + } // if (m_nParameterIndex >= (sal_Int32) (*m_aParameterRow).size()) + + rParameter = (m_aParameterRow->get())[m_nParameterIndex]; + + m_nParameterIndex++; +} +// ------------------------------------------------------------------------- +KabPreparedStatement::KabPreparedStatement( + KabConnection* _pConnection, + const ::rtl::OUString& sql) + : KabPreparedStatement_BASE(_pConnection), + m_sSqlStatement(sql), + m_bPrepared(sal_False), + m_nParameterIndex(0), + m_aParameterRow() +{ +} +// ------------------------------------------------------------------------- +KabPreparedStatement::~KabPreparedStatement() +{ +} +// ------------------------------------------------------------------------- +void KabPreparedStatement::disposing() +{ + KabPreparedStatement_BASE::disposing(); + + if (m_aParameterRow.isValid()) + { + m_aParameterRow->get().clear(); + m_aParameterRow = NULL; + } +} +// ------------------------------------------------------------------------- +Reference< XResultSetMetaData > SAL_CALL KabPreparedStatement::getMetaData() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + if (!m_xMetaData.is()) + { + m_xMetaData = new KabResultSetMetaData(getOwnConnection()); + setKabFields(); + } + Reference< XResultSetMetaData > xMetaData = m_xMetaData.get(); + return xMetaData; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::close() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + // Reset last warning message + try { + clearWarnings (); + KabCommonStatement::close(); + } + catch (SQLException &) { + // If we get an error, ignore + } + + // Remove this Statement object from the Connection object's + // list +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabPreparedStatement::execute() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + Reference< XResultSet> xRS = KabCommonStatement::executeQuery(m_sSqlStatement); + + return xRS.is(); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabPreparedStatement::executeUpdate() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + // same as in statement with the difference that this statement also can contain parameter + return 0; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL KabPreparedStatement::getConnection() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + return (Reference< XConnection >) m_pConnection; +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabPreparedStatement::executeQuery() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + Reference< XResultSet > rs = KabCommonStatement::executeQuery(m_sSqlStatement); + + return rs; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + checkAndResizeParameters(parameterIndex); + + (m_aParameterRow->get())[parameterIndex - 1].setNull(); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setObjectNull", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setBoolean", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setByte", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setShort", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setInt", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setFloat(sal_Int32, float) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setFloat", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setDouble(sal_Int32, double) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setDouble", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setString(sal_Int32 parameterIndex, const ::rtl::OUString &x) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + checkAndResizeParameters(parameterIndex); + + (m_aParameterRow->get())[parameterIndex - 1] = x; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setBytes", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setDate(sal_Int32, const Date&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setDate", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setTime(sal_Int32, const Time&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setTime", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setTimestamp", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setBinaryStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setBinaryStream", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setCharacterStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setCharacterStream", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setObject(sal_Int32 parameterIndex, const Any& x) throw(SQLException, RuntimeException) +{ + if(!::dbtools::implSetObject(this,parameterIndex,x)) + { + throw SQLException(); + } +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setObjectWithInfo(sal_Int32, const Any&, sal_Int32, sal_Int32) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setObjectWithInfo", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setRef(sal_Int32, const Reference< XRef >&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setRef", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setBlob(sal_Int32, const Reference< XBlob >&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setBlob", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setClob(sal_Int32, const Reference< XClob >&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setClob", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::setArray(sal_Int32, const Reference< XArray >&) throw(SQLException, RuntimeException) +{ + + + +::dbtools::throwFunctionNotSupportedException("setArray", NULL); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabPreparedStatement::clearParameters() throw(SQLException, RuntimeException) +{ +::dbtools::throwFunctionNotSupportedException("clearParameters", NULL); +} +// ------------------------------------------------------------------------- +void KabPreparedStatement::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: + KabCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue); + } +} diff --git a/connectivity/source/drivers/kab/KPreparedStatement.hxx b/connectivity/source/drivers/kab/KPreparedStatement.hxx new file mode 100644 index 000000000000..779bdf22e620 --- /dev/null +++ b/connectivity/source/drivers/kab/KPreparedStatement.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_PREPAREDSTATEMENT_HXX_ +#define _CONNECTIVITY_KAB_PREPAREDSTATEMENT_HXX_ + +#include "KStatement.hxx" +#include "KResultSetMetaData.hxx" +#include <connectivity/FValue.hxx> +#include <com/sun/star/sdbc/XParameters.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <cppuhelper/implbase4.hxx> + +namespace connectivity +{ + namespace kab + { + + class OBoundParam; + typedef ::cppu::ImplInheritanceHelper4< KabCommonStatement, + ::com::sun::star::sdbc::XPreparedStatement, + ::com::sun::star::sdbc::XParameters, + ::com::sun::star::sdbc::XResultSetMetaDataSupplier, + ::com::sun::star::lang::XServiceInfo> KabPreparedStatement_BASE; + + class KabPreparedStatement : public KabPreparedStatement_BASE + { + protected: + ::rtl::OUString m_sSqlStatement; + ::rtl::Reference< KabResultSetMetaData > + m_xMetaData; + sal_Bool m_bPrepared; + mutable sal_Int32 m_nParameterIndex; + OValueRow m_aParameterRow; + + void checkAndResizeParameters(sal_Int32 nParams) throw(::com::sun::star::sdbc::SQLException); + void setKabFields() const throw(::com::sun::star::sdbc::SQLException); + + protected: + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); + + virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException); + virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException); + virtual ~KabPreparedStatement(); + + public: + DECLARE_SERVICE_INFO(); + KabPreparedStatement(KabConnection* _pConnection, const ::rtl::OUString& sql); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XPreparedStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL execute( ) 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); + + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearParameters( ) 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); + + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_KAB_PREPAREDSTATEMENT_HXX_ diff --git a/connectivity/source/drivers/kab/KResultSet.cxx b/connectivity/source/drivers/kab/KResultSet.cxx new file mode 100644 index 000000000000..22df0c4854c5 --- /dev/null +++ b/connectivity/source/drivers/kab/KResultSet.cxx @@ -0,0 +1,987 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KResultSet.hxx" +#include "KResultSetMetaData.hxx" +#include "KConnection.hxx" +#include "kcondition.hxx" +#include "korder.hxx" +#include "kfields.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/sdbcx/CompareBookmark.hpp> +#include "TConnection.hxx" +#include <connectivity/dbexception.hxx> +#include "resource/kab_res.hrc" +#include "resource/sharedresources.hxx" + +using namespace connectivity::kab; +using namespace cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::io; +using namespace com::sun::star::util; + +IMPLEMENT_SERVICE_INFO(KabResultSet, "com.sun.star.sdbc.drivers.KabResultSet", "com.sun.star.sdbc.ResultSet"); +// ------------------------------------------------------------------------- +KabResultSet::KabResultSet(KabCommonStatement* pStmt) + : KabResultSet_BASE(m_aMutex), + OPropertySetHelper(KabResultSet_BASE::rBHelper), + m_xStatement(pStmt), + m_xMetaData(NULL), + m_aKabAddressees(), + m_nRowPos(-1), + m_bWasNull(sal_True) +{ +} +// ------------------------------------------------------------------------- +KabResultSet::~KabResultSet() +{ +} +// ------------------------------------------------------------------------- +void KabResultSet::allKabAddressees() +{ + KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get()); + KABC::AddressBook* pAddressBook = pConnection->getAddressBook(); + + m_aKabAddressees = pAddressBook->allAddressees(); +} +// ------------------------------------------------------------------------- +void KabResultSet::someKabAddressees(const KabCondition *pCondition) +{ + KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get()); + KABC::AddressBook* pAddressBook = pConnection->getAddressBook(); + + KABC::AddressBook::Iterator iterator; + + for (iterator = pAddressBook->begin(); + iterator != pAddressBook->end(); + ++iterator) + { + if (pCondition->eval(*iterator)) + m_aKabAddressees.push_back(*iterator); + } +} +// ------------------------------------------------------------------------- +void KabResultSet::sortKabAddressees(const KabOrder *pOrder) +{ + // We do not use class KAddresseeList, which has a sorting algorithm in it, because + // it uses templates. It would expand to more or less the same code as the one + // which follows, but it would need not be called in a much less convenient way. + + KABC::Addressee::List::Iterator + begin = m_aKabAddressees.begin(), + end = m_aKabAddressees.end(), + iterator; + + // Bubble sort. Feel free to implement a better algorithm. + while (begin != end) + { + end--; + for (iterator = begin; iterator != end; ++iterator) + { + if (pOrder->compare(*iterator, *end) > 0) + qSwap(*iterator, *end); + } + } +} +// ------------------------------------------------------------------------- +void KabResultSet::disposing() +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + +m_xStatement.clear(); +m_xMetaData.clear(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL KabResultSet::queryInterface(const Type & rType) throw(RuntimeException) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + if (!aRet.hasValue()) + aRet = KabResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::acquire() throw() +{ + KabResultSet_BASE::acquire(); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::release() throw() +{ + KabResultSet_BASE::release(); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL KabResultSet::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)); + + return comphelper::concatSequences(aTypes.getTypes(), KabResultSet_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL KabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSet::findColumn(const ::rtl::OUString& columnName) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + // find the first column with the name columnName + Reference< XResultSetMetaData > xMeta = getMetaData(); + sal_Int32 nLen = xMeta->getColumnCount(); + + for (sal_Int32 i = 1; i <= nLen; ++i) + if (xMeta->isCaseSensitive(i) ? + columnName == xMeta->getColumnName(i) : + columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) + return i; + + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( + STR_INVALID_COLUMNNAME, + "$columnname$",columnName + ) ); + ::dbtools::throwGenericSQLException(sError,NULL); + + // Unreachable: + OSL_ASSERT(false); + return 0; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSet::getString(sal_Int32 columnIndex) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + ::rtl::OUString aRet; + sal_Int32 nAddressees = m_aKabAddressees.size(); + ::KABC::Field::List aFields = ::KABC::Field::allFields(); + + if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is()) + { + sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex); + QString aQtName; + + switch (nFieldNumber) + { + case KAB_FIELD_REVISION: +// trigger an exception here +m_bWasNull = true; +return aRet; + default: + aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->value(m_aKabAddressees[m_nRowPos]); + } +// KDE address book currently does not use NULL values. +// But it might do it someday + if (!aQtName.isNull()) + { + m_bWasNull = false; + aRet = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + return aRet; + } + } +// Trigger an exception ? + m_bWasNull = true; + return aRet; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::getBoolean(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getBoolean", NULL); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int8 SAL_CALL KabResultSet::getByte(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getByte", NULL); + + sal_Int8 nRet = 0; + return nRet; +} +// ------------------------------------------------------------------------- +sal_Int16 SAL_CALL KabResultSet::getShort(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getShort", NULL); + + sal_Int16 nRet = 0; + return nRet; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSet::getInt(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getInt", NULL); + + sal_Int32 nRet = 0; + return nRet; +} +// ------------------------------------------------------------------------- +sal_Int64 SAL_CALL KabResultSet::getLong(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getLong", NULL); + + return sal_Int64(); +} +// ------------------------------------------------------------------------- +float SAL_CALL KabResultSet::getFloat(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getFloat", NULL); + + float nVal(0); + return nVal; +} +// ------------------------------------------------------------------------- +double SAL_CALL KabResultSet::getDouble(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getDouble", NULL); + + double nRet = 0; + return nRet; +} +// ------------------------------------------------------------------------- +Sequence< sal_Int8 > SAL_CALL KabResultSet::getBytes(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("", NULL); + + return Sequence< sal_Int8 >(); +} +// ------------------------------------------------------------------------- +Date SAL_CALL KabResultSet::getDate(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getDate", NULL); + + Date aRet; + return aRet; +} +// ------------------------------------------------------------------------- +Time SAL_CALL KabResultSet::getTime(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getTime", NULL); + + Time nRet; + return nRet; +} +// ------------------------------------------------------------------------- +DateTime SAL_CALL KabResultSet::getTimestamp(sal_Int32 columnIndex) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + DateTime nRet; + sal_Int32 nAddressees = m_aKabAddressees.size(); + + if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is()) + { + KabResultSetMetaData *pMeta = static_cast<KabResultSetMetaData *>(m_xMetaData.get()); + sal_Int32 nFieldNumber = pMeta->fieldAtColumn(columnIndex); + + if (nFieldNumber == KAB_FIELD_REVISION) + { + QDateTime nRevision(m_aKabAddressees[m_nRowPos].revision()); + + if (!nRevision.isNull()) + { + m_bWasNull = false; + nRet.Year = nRevision.date().year(); + nRet.Month = nRevision.date().month(); + nRet.Day = nRevision.date().day(); + nRet.Hours = nRevision.time().hour(); + nRet.Minutes = nRevision.time().minute(); + nRet.Seconds = nRevision.time().second(); + nRet.HundredthSeconds = nRevision.time().msec() / 10; + return nRet; + } + } + else { + ; + } +// trigger an exception here + } +// Trigger an exception ? + m_bWasNull = true; + return nRet; +} +// ------------------------------------------------------------------------- +Reference< XInputStream > SAL_CALL KabResultSet::getBinaryStream(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getBinaryStream", NULL); + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XInputStream > SAL_CALL KabResultSet::getCharacterStream(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getCharacterStream", NULL); + + return NULL; +} +// ------------------------------------------------------------------------- +Any SAL_CALL KabResultSet::getObject(sal_Int32, const Reference< ::com::sun::star::container::XNameAccess >&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getObject", NULL); + + return Any(); +} +// ------------------------------------------------------------------------- +Reference< XRef > SAL_CALL KabResultSet::getRef(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getRef", NULL); + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XBlob > SAL_CALL KabResultSet::getBlob(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getBlob", NULL); + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XClob > SAL_CALL KabResultSet::getClob(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getClob", NULL); + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XArray > SAL_CALL KabResultSet::getArray(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + +::dbtools::throwFunctionNotSupportedException("getArray", NULL); + + return NULL; +} +// ------------------------------------------------------------------------- +Reference< XResultSetMetaData > SAL_CALL KabResultSet::getMetaData() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + if (!m_xMetaData.is()) + m_xMetaData = new KabResultSetMetaData(m_xStatement->getOwnConnection()); + + Reference< XResultSetMetaData > xMetaData = m_xMetaData.get(); + return xMetaData; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::isBeforeFirst() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + if (m_nRowPos == -1) + return sal_True; + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::isAfterLast() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nAddressees = m_aKabAddressees.size(); + if (m_nRowPos == nAddressees) + return sal_True; + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::isFirst() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + if (m_nRowPos == 0) + return sal_True; + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::isLast() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nAddressees = m_aKabAddressees.size(); + if (m_nRowPos == nAddressees - 1) + return sal_True; + + return sal_False; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::beforeFirst() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + // move before the first row + m_nRowPos = -1; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::afterLast() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + // move after the last row + sal_Int32 nAddressees = m_aKabAddressees.size(); + m_nRowPos = nAddressees; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::close() throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + } + dispose(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::first() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nAddressees = m_aKabAddressees.size(); + if (nAddressees == 0) + return sal_False; + + m_nRowPos = 0; + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::last() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nAddressees = m_aKabAddressees.size(); + if (nAddressees == 0) + return sal_False; + + m_nRowPos = nAddressees - 1; + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSet::getRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return m_nRowPos; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::absolute(sal_Int32 row) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nAddressees = m_aKabAddressees.size(); + if (row <= -1 || + row >= nAddressees) + return sal_False; + + m_nRowPos = row; + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::relative(sal_Int32 row) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return absolute(m_nRowPos + row); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::next() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return absolute(m_nRowPos + 1); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::previous() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return absolute(m_nRowPos - 1); +} +// ------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL KabResultSet::getStatement() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + Reference< XStatement > xStatement = m_xStatement.get(); + return xStatement; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::rowDeleted() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::rowInserted() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::rowUpdated() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::wasNull() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return m_bWasNull; +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::cancel() throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::clearWarnings() throw(SQLException, RuntimeException) +{ +} +// ------------------------------------------------------------------------- +Any SAL_CALL KabResultSet::getWarnings() throw(SQLException, RuntimeException) +{ + return Any(); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::insertRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + // you only have to implement this if you want to insert new rows +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + // only when you allow updates +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::deleteRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::cancelRowUpdates() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::moveToInsertRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + // only when you allow inserts +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::moveToCurrentRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateNull(sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException) +{ + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + ::osl::MutexGuard aGuard( m_aMutex ); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException) +{ + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + ::osl::MutexGuard aGuard( m_aMutex ); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ----------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateFloat(sal_Int32, float) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateDouble(sal_Int32, double) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateString(sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateDate(sal_Int32, const Date&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateTime(sal_Int32, const Time&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateBinaryStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateCharacterStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::refreshRow() throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateObject(sal_Int32, const Any&) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabResultSet::updateNumericObject(sal_Int32, const Any&, sal_Int32) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); +} +// ------------------------------------------------------------------------- +// XRowLocate +Any SAL_CALL KabResultSet::getBookmark() throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nAddressees = m_aKabAddressees.size(); + + if (m_nRowPos != -1 && m_nRowPos != nAddressees) + { + QString aQtName = m_aKabAddressees[m_nRowPos].uid(); + ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + return makeAny(sUniqueIdentifier); + } + return Any(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + ::rtl::OUString sBookmark = comphelper::getString(bookmark); + sal_Int32 nAddressees = m_aKabAddressees.size(); + + for (sal_Int32 nRow = 0; nRow < nAddressees; nRow++) + { + QString aQtName = m_aKabAddressees[nRow].uid(); + ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + + if (sUniqueIdentifier == sBookmark) + { + m_nRowPos = nRow; + return sal_True; + } + } + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + sal_Int32 nRowSave = m_nRowPos; + + if (moveToBookmark(bookmark)) + { + sal_Int32 nAddressees = m_aKabAddressees.size(); + + m_nRowPos += rows; + + if (-1 < m_nRowPos && m_nRowPos < nAddressees) + return sal_True; + } + + m_nRowPos = nRowSave; + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSet::compareBookmarks(const Any& firstItem, const Any& secondItem) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + ::rtl::OUString sFirst = comphelper::getString(firstItem); + ::rtl::OUString sSecond = comphelper::getString(secondItem); + + if (sFirst < sSecond) + return CompareBookmark::LESS; + if (sFirst > sSecond) + return CompareBookmark::GREATER; + return CompareBookmark::EQUAL; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + ::rtl::OUString sBookmark = comphelper::getString(bookmark); + + return sBookmark.hashCode(); +} +// ------------------------------------------------------------------------- +// XDeleteRows +Sequence< sal_Int32 > SAL_CALL KabResultSet::deleteRows(const Sequence< Any >&) throw( SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabResultSet_BASE::rBHelper.bDisposed); + + return Sequence< sal_Int32 >(); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper* KabResultSet::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); +} +// ------------------------------------------------------------------------- +IPropertyArrayHelper & KabResultSet::getInfoHelper() +{ + return *static_cast<KabResultSet*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool KabResultSet::convertFastPropertyValue( + Any &, + Any &, + sal_Int32 nHandle, + const Any& ) + 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 KabResultSet::setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const Any& ) + 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 KabResultSet::getFastPropertyValue( + Any& _rValue, + sal_Int32 nHandle) const +{ + switch (nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + _rValue <<= (sal_Bool)sal_False; + break; + case PROPERTY_ID_CURSORNAME: + case PROPERTY_ID_RESULTSETCONCURRENCY: + case PROPERTY_ID_RESULTSETTYPE: + case PROPERTY_ID_FETCHDIRECTION: + case PROPERTY_ID_FETCHSIZE: + ; + } +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/kab/KResultSet.hxx b/connectivity/source/drivers/kab/KResultSet.hxx new file mode 100644 index 000000000000..9cabb48980be --- /dev/null +++ b/connectivity/source/drivers/kab/KResultSet.hxx @@ -0,0 +1,224 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_RESULTSET_HXX_ +#define _CONNECTIVITY_KAB_RESULTSET_HXX_ + +#include "KStatement.hxx" +#include "KResultSetMetaData.hxx" +#include <shell/kde_headers.h> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#include <com/sun/star/sdbcx/XRowLocate.hpp> +#include <com/sun/star/sdbcx/XDeleteRows.hpp> +#include <cppuhelper/compbase12.hxx> + +namespace connectivity +{ + namespace kab + { + /* + ** KabResultSet + */ + typedef ::cppu::WeakComponentImplHelper12< ::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::XResultSetUpdate, + ::com::sun::star::sdbc::XRowUpdate, + ::com::sun::star::sdbcx::XRowLocate, + ::com::sun::star::sdbcx::XDeleteRows, + ::com::sun::star::sdbc::XCloseable, + ::com::sun::star::sdbc::XColumnLocate, + ::com::sun::star::lang::XServiceInfo> KabResultSet_BASE; + + class KabResultSet : public comphelper::OBaseMutex, + public KabResultSet_BASE, + public ::cppu::OPropertySetHelper, + public comphelper::OPropertyArrayUsageHelper<KabResultSet> + { + protected: + ::rtl::Reference< KabCommonStatement > m_xStatement; // the statement that has created this result set + ::rtl::Reference< KabResultSetMetaData > m_xMetaData; // the description of the columns in this result set + ::KABC::Addressee::List m_aKabAddressees; // address book entries matching the query + sal_Int32 m_nRowPos; // the current row within the result set + sal_Bool m_bWasNull; // last entry retrieved from this result set was NULL + + // 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 ~KabResultSet(); + + public: + DECLARE_SERVICE_INFO(); + + KabResultSet(KabCommonStatement *pStmt); + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *() + { + return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(KabResultSet_BASE*) this); + } + + void allKabAddressees(); + void someKabAddressees(const class KabCondition *pCondition); + void sortKabAddressees(const class KabOrder *pOrder); + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(void); + + // 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 + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // XResultSet + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XResultSetMetaDataSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XCancellable + virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); + + // XCloseable + virtual void SAL_CALL close( ) 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); + + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XRowLocate + virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& firstItem, const ::com::sun::star::uno::Any& secondItem ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // XDeleteRows + virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_KAB_RESULTSET_HXX_ diff --git a/connectivity/source/drivers/kab/KResultSetMetaData.cxx b/connectivity/source/drivers/kab/KResultSetMetaData.cxx new file mode 100644 index 000000000000..c36b166b2a73 --- /dev/null +++ b/connectivity/source/drivers/kab/KResultSetMetaData.cxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KResultSetMetaData.hxx" +#include "kfields.hxx" +#include "KDatabaseMetaData.hxx" +#include <com/sun/star/sdbc/DataType.hpp> + +using namespace connectivity::kab; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::sdbc; + +KabResultSetMetaData::KabResultSetMetaData(KabConnection* _pConnection) + : m_pConnection(_pConnection), + m_aKabFields() +{ +} +// ------------------------------------------------------------------------- +KabResultSetMetaData::~KabResultSetMetaData() +{ +} +// ------------------------------------------------------------------------- +void KabResultSetMetaData::setKabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException) +{ + OSQLColumns::Vector::const_iterator aIter; + static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name")); + + for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter) + { + ::rtl::OUString aFieldName; + sal_uInt32 nFieldNumber; + + (*aIter)->getPropertyValue(aName) >>= aFieldName; + nFieldNumber = findKabField(aFieldName); + m_aKabFields.push_back(nFieldNumber); + } +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException) +{ + return m_aKabFields[column - 1] < KAB_DATA_FIELDS? 20: 50; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException) +{ + return m_aKabFields[column - 1] == KAB_FIELD_REVISION? DataType::TIMESTAMP: DataType::CHAR; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException) +{ + return m_aKabFields.size(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException) +{ + sal_uInt32 nFieldNumber = m_aKabFields[column - 1]; + ::KABC::Field::List aFields = ::KABC::Field::allFields(); + QString aQtName; + + switch (nFieldNumber) + { + case KAB_FIELD_REVISION: + aQtName = KABC::Addressee::revisionLabel(); + break; + default: + aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->label(); + } + ::rtl::OUString aName((const sal_Unicode *) aQtName.ucs2()); + + return aName; +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException) +{ + return KabDatabaseMetaData::getAddressBookTableName(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException) +{ + return 0; +} +// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSetMetaData::getScale(sal_Int32) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return 0; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException) +{ + return (sal_Int32) sal_True; +// KDE address book currently does not use NULL values. +// But it might do it someday +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_True; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException) +{ + return sal_False; +} +// ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/kab/KResultSetMetaData.hxx b/connectivity/source/drivers/kab/KResultSetMetaData.hxx new file mode 100644 index 000000000000..2ee6ababa91a --- /dev/null +++ b/connectivity/source/drivers/kab/KResultSetMetaData.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_ +#define _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_ + +#include "KConnection.hxx" +#include <connectivity/CommonTools.hxx> +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#include <cppuhelper/implbase1.hxx> +#include <vos/ref.hxx> + +namespace connectivity +{ + namespace kab + { + /* + ** KabResultSetMetaData + */ + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> KabResultSetMetaData_BASE; + + class KabResultSetMetaData : public KabResultSetMetaData_BASE + { + KabConnection* m_pConnection; + ::std::vector<sal_Int32> m_aKabFields; // for each selected column, contains the number + // of the corresponding KAddressBook field + + protected: + virtual ~KabResultSetMetaData(); + + public: + KabResultSetMetaData(KabConnection* _pConnection); + + // avoid ambigous cast error from the compiler + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + void setKabFields( + const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(::com::sun::star::sdbc::SQLException); + inline sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const + { return m_aKabFields[columnIndex - 1]; } + + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_ diff --git a/connectivity/source/drivers/kab/KServices.cxx b/connectivity/source/drivers/kab/KServices.cxx new file mode 100644 index 000000000000..6b7a1a39a667 --- /dev/null +++ b/connectivity/source/drivers/kab/KServices.cxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KDriver.hxx" +#include <cppuhelper/factory.hxx> + +using namespace connectivity::kab; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames, + rtl_ModuleCount* _pTemp + ); + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment ** + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void*) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + KabDriver::getImplementationName_Static(), + KabDriver::getSupportedServiceNames_Static(), + &KabDriver::Create, + ::cppu::createSingleFactory) + ; + + if (aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + + diff --git a/connectivity/source/drivers/kab/KStatement.cxx b/connectivity/source/drivers/kab/KStatement.cxx new file mode 100644 index 000000000000..f0069fc6875e --- /dev/null +++ b/connectivity/source/drivers/kab/KStatement.cxx @@ -0,0 +1,584 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KStatement.hxx" +#include "KConnection.hxx" +#include "KDriver.hxx" +#include "KResultSet.hxx" +#include "KResultSetMetaData.hxx" +#include "kcondition.hxx" +#include "korder.hxx" +#include "TConnection.hxx" +#include <connectivity/dbexception.hxx> +#include "resource/kab_res.hrc" +#include "resource/sharedresources.hxx" + + +#if OSL_DEBUG_LEVEL > 0 +# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr()) +#else /* OSL_DEBUG_LEVEL */ +# define OUtoCStr( x ) ("dummy") +#endif /* OSL_DEBUG_LEVEL */ + +using namespace connectivity::kab; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::beans; +using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; +using namespace com::sun::star::container; +using namespace com::sun::star::io; +using namespace com::sun::star::util; + +namespace +{ + void lcl_throwError(sal_uInt16 _nErrorId) + { + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceString(_nErrorId) ); + ::dbtools::throwGenericSQLException(sError,NULL); + } +} + +IMPLEMENT_SERVICE_INFO(KabStatement, "com.sun.star.sdbc.drivers.KabStatement", "com.sun.star.sdbc.Statement"); +//------------------------------------------------------------------------------ +KabCommonStatement::KabCommonStatement(KabConnection* _pConnection ) + : KabCommonStatement_BASE(m_aMutex), + OPropertySetHelper(KabCommonStatement_BASE::rBHelper), + m_aParser(_pConnection->getDriver()->getMSFactory()), + m_aSQLIterator(_pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ), + m_pParseTree(NULL), + m_pConnection(_pConnection), + rBHelper(KabCommonStatement_BASE::rBHelper) +{ + m_pConnection->acquire(); +} +// ----------------------------------------------------------------------------- +KabCommonStatement::~KabCommonStatement() +{ +} +// ----------------------------------------------------------------------------- +void KabCommonStatement::disposing() +{ + KabCommonStatement_BASE::disposing(); +} +// ----------------------------------------------------------------------------- +void KabCommonStatement::resetParameters() const throw(::com::sun::star::sdbc::SQLException) +{ + lcl_throwError(STR_PARA_ONLY_PREPARED); +} +// ----------------------------------------------------------------------------- +void KabCommonStatement::getNextParameter(::rtl::OUString &) const throw(::com::sun::star::sdbc::SQLException) +{ + lcl_throwError(STR_PARA_ONLY_PREPARED); +} +// ----------------------------------------------------------------------------- +KabCondition *KabCommonStatement::analyseWhereClause(const OSQLParseNode *pParseNode) const throw(SQLException) +{ + if (pParseNode->count() == 3) + { + const OSQLParseNode *pLeft = pParseNode->getChild(0), + *pMiddle = pParseNode->getChild(1), + *pRight = pParseNode->getChild(2); + + // WHERE ( ... ) ? + if (SQL_ISPUNCTUATION(pLeft, "(") && SQL_ISPUNCTUATION(pRight, ")")) + { + return analyseWhereClause(pMiddle); + } + else if (SQL_ISRULE(pParseNode, comparison_predicate)) + { + if (pLeft->isToken() && pRight->isToken()) + { + switch (pMiddle->getNodeType()) + { + case SQL_NODE_EQUAL: + // WHERE 0 = 1 + return new KabConditionConstant(pLeft->getTokenValue() == pRight->getTokenValue()); + + case SQL_NODE_NOTEQUAL: + // WHERE 0 <> 1 + // (might not be correct SQL... don't care, handling anyway) + return new KabConditionConstant(pLeft->getTokenValue() != pRight->getTokenValue()); + + default: + break; + } + } + else if (SQL_ISRULE(pLeft, column_ref)) + { + ::rtl::OUString sColumnName, + sTableRange; + + m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange); + + if (pRight->isToken() || SQL_ISRULE(pRight, parameter)) + { + ::rtl::OUString sMatchString; + + if (pRight->isToken()) // WHERE Name = 'Doe' + sMatchString = pRight->getTokenValue(); + else if (SQL_ISRULE(pRight, parameter)) // WHERE Name = ? + getNextParameter(sMatchString); + + switch (pMiddle->getNodeType()) + { + case SQL_NODE_EQUAL: + // WHERE Name = 'Smith' + return new KabConditionEqual(sColumnName, sMatchString); + + case SQL_NODE_NOTEQUAL: + // WHERE Name <> 'Jones' + return new KabConditionDifferent(sColumnName, sMatchString); + + default: + break; + } + } + } + } + else if (SQL_ISRULE(pParseNode, search_condition)) + { + if (SQL_ISTOKEN(pMiddle, OR)) + { + // WHERE Name = 'Smith' OR Name = 'Jones' + return new KabConditionOr( + analyseWhereClause(pLeft), + analyseWhereClause(pRight)); + } + } + else if (SQL_ISRULE(pParseNode, boolean_term)) + { + if (SQL_ISTOKEN(pMiddle, AND)) + { + // WHERE Name = 'Smith' AND "Given Name" = 'Peter' + return new KabConditionAnd( + analyseWhereClause(pLeft), + analyseWhereClause(pRight)); + } + } + } + else if (SQL_ISRULE(pParseNode, test_for_null) || SQL_ISRULE(pParseNode, like_predicate)) + { + const OSQLParseNode *pLeft = pParseNode->getChild(0); + const OSQLParseNode* pPart2 = pParseNode->getChild(1); + const OSQLParseNode *pMiddleLeft = pPart2->getChild(0), + *pMiddleRight = pPart2->getChild(1), + *pRight = pPart2->getChild(2); + + if (SQL_ISRULE(pParseNode, test_for_null)) + { + if (SQL_ISRULE(pLeft, column_ref) && + SQL_ISTOKEN(pMiddleLeft, IS) && + SQL_ISTOKEN(pRight, NULL)) + { + ::rtl::OUString sColumnName, + sTableRange; + + m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange); + + if (SQL_ISTOKEN(pMiddleRight, NOT)) + { + // WHERE "Mobile Phone" IS NOT NULL + return new KabConditionNotNull(sColumnName); + } + else + { + // WHERE "Mobile Phone" IS NULL + return new KabConditionNull(sColumnName); + } + } + } + else if (SQL_ISRULE(pParseNode, like_predicate)) + { + if (SQL_ISRULE(pLeft, column_ref)) + { + ::rtl::OUString sColumnName, + sTableRange; + + m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange); + + if (pMiddleRight->isToken() || SQL_ISRULE(pMiddleRight, parameter)) + { + ::rtl::OUString sMatchString; + + if (pMiddleRight->isToken()) // WHERE Name LIKE 'Sm%' + sMatchString = pMiddleRight->getTokenValue(); + else if (SQL_ISRULE(pMiddleRight, parameter)) // WHERE Name LIKE ? + getNextParameter(sMatchString); + + return new KabConditionSimilar(sColumnName, sMatchString); + } + } + } + } + + lcl_throwError(STR_QUERY_TOO_COMPLEX); + + // Unreachable: + OSL_ASSERT(false); + return 0; +} +// ----------------------------------------------------------------------------- +KabOrder *KabCommonStatement::analyseOrderByClause(const OSQLParseNode *pParseNode) const throw(SQLException) +{ + if (SQL_ISRULE(pParseNode, ordering_spec_commalist)) + { + KabComplexOrder *list = new KabComplexOrder(); + sal_uInt32 n = pParseNode->count(); + + // Iterate through the ordering columns + for (sal_uInt32 i = 0; i < n; i++) + { + list->addOrder + (analyseOrderByClause(pParseNode->getChild(i))); + } + + return list; + } + else if (SQL_ISRULE(pParseNode, ordering_spec)) + { + if (pParseNode->count() == 2) + { + OSQLParseNode* pColumnRef = pParseNode->getChild(0); + OSQLParseNode* pAscendingDescending = pParseNode->getChild(1); + + if (SQL_ISRULE(pColumnRef, column_ref)) + { + if (pColumnRef->count() == 3) + pColumnRef = pColumnRef->getChild(2); + + if (pColumnRef->count() == 1) + { + ::rtl::OUString sColumnName = + pColumnRef->getChild(0)->getTokenValue(); + sal_Bool bAscending = + SQL_ISTOKEN(pAscendingDescending, DESC)? + sal_False: + sal_True; + + return new KabSimpleOrder(sColumnName, bAscending); + } + } + } + } + lcl_throwError(STR_QUERY_TOO_COMPLEX); + // Unreachable: + OSL_ASSERT(false); + return 0; +} +//------------------------------------------------------------------------------ +sal_Bool KabCommonStatement::isTableKnown(KabResultSet *pResult) const +{ + // can handle requests like SELECT * FROM addresses addresses + // but cannot handle requests like SELECT * FROM addresses persons + if (m_aSQLIterator.getTables().size() != 1) + return sal_False; + + if (m_aSQLIterator.getTables().begin()->first != pResult->getMetaData()->getTableName(0)) + return sal_False; + + return sal_True; +} +//------------------------------------------------------------------------------ +void KabCommonStatement::setKabFields(KabResultSet *pResult) const throw(SQLException) +{ + ::vos::ORef<connectivity::OSQLColumns> xColumns; // selected columns + KabResultSetMetaData *pMeta; // meta information - holds the list of KAddressBook fields + + xColumns = m_aSQLIterator.getSelectColumns(); + if (!xColumns.isValid()) + { + lcl_throwError(STR_INVALID_COLUMN_SELECTION); + } + pMeta = static_cast<KabResultSetMetaData *>(pResult->getMetaData().get()); + pMeta->setKabFields(xColumns); +} +// ------------------------------------------------------------------------- +void KabCommonStatement::selectAddressees(KabResultSet *pResult) const throw(SQLException) +{ + const OSQLParseNode *pParseNode; + KabCondition *pCondition; + + pParseNode = m_aSQLIterator.getWhereTree(); + if (pParseNode != NULL) + { + if (SQL_ISRULE(pParseNode, where_clause)) + { + resetParameters(); + pParseNode = pParseNode->getChild(1); + pCondition = analyseWhereClause(pParseNode); + if (pCondition->isAlwaysTrue()) + pResult->allKabAddressees(); + else if (!pCondition->isAlwaysFalse()) + pResult->someKabAddressees(pCondition); + delete pCondition; + return; + } + } + + // no WHERE clause: get all rows + pResult->allKabAddressees(); +} +// ------------------------------------------------------------------------- +void KabCommonStatement::sortAddressees(KabResultSet *pResult) const throw(SQLException) +{ + const OSQLParseNode *pParseNode; + KabOrder *pOrder; + + pParseNode = m_aSQLIterator.getOrderTree(); + if (pParseNode != NULL) + { + if (SQL_ISRULE(pParseNode, opt_order_by_clause)) + { + pParseNode = pParseNode->getChild(2); + pOrder = analyseOrderByClause(pParseNode); + pResult->sortKabAddressees(pOrder); + delete pOrder; + } + } +} +//----------------------------------------------------------------------------- +Any SAL_CALL KabCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = KabCommonStatement_BASE::queryInterface(rType); + if (!aRet.hasValue()) + aRet = OPropertySetHelper::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL KabCommonStatement::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(),KabCommonStatement_BASE::getTypes()); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabCommonStatement::cancel( ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + // cancel the current sql statement +} +// ------------------------------------------------------------------------- +void SAL_CALL KabCommonStatement::close( ) throw(SQLException, RuntimeException) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + } + dispose(); +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL KabCommonStatement::execute( + const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + Reference< XResultSet > xRS = executeQuery(sql); + + return xRS.is(); +} +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL KabCommonStatement::executeQuery( + const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + +OSL_TRACE("KDE Address book - SQL Request: %s", OUtoCStr(sql)); + + KabResultSet* pResult = new KabResultSet(this); + Reference< XResultSet > xRS = pResult; + ::rtl::OUString aErr; + + m_pParseTree = m_aParser.parseTree(aErr, sql); + if (m_pParseTree == NULL) + throw SQLException(aErr, *this, aErr, 0, Any()); + + m_aSQLIterator.setParseTree(m_pParseTree); + m_aSQLIterator.traverseAll(); + switch (m_aSQLIterator.getStatementType()) + { + case SQL_STATEMENT_SELECT: + if (isTableKnown(pResult)) // FROM which table ? + { + setKabFields(pResult); // SELECT which columns ? + selectAddressees(pResult); // WHERE which condition ? + sortAddressees(pResult); // ORDER BY which columns ? +// To be continued: DISTINCT +// etc... + } + break; + + default: +// To be continued: UPDATE +// DELETE +// etc... + lcl_throwError(STR_QUERY_TOO_COMPLEX); + } + + return xRS; +} +// ------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL KabCommonStatement::getConnection( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + // just return our connection here + return (Reference< XConnection >) m_pConnection; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL KabCommonStatement::executeUpdate( const ::rtl::OUString& ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + // the return values gives information about how many rows are affected by executing the sql statement + return 0; +} +// ------------------------------------------------------------------------- +Any SAL_CALL KabCommonStatement::getWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + return makeAny(m_aLastWarning); +} +// ------------------------------------------------------------------------- +void SAL_CALL KabCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); + + m_aLastWarning = SQLWarning(); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper* KabCommonStatement::createArrayHelper( ) const +{ + // this properties are defined by the service statement + // they must be 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); +} +// ------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper & KabCommonStatement::getInfoHelper() +{ + return *const_cast<KabCommonStatement*>(this)->getArrayHelper(); +} +// ------------------------------------------------------------------------- +sal_Bool KabCommonStatement::convertFastPropertyValue( + Any &, + Any &, + sal_Int32, + const Any&) throw (::com::sun::star::lang::IllegalArgumentException) +{ + sal_Bool bConverted = sal_False; + // here we have to try to convert + return bConverted; +} +// ------------------------------------------------------------------------- +void KabCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any&) throw (Exception) +{ + // set the value to whatever 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: + ; + } +} +// ------------------------------------------------------------------------- +void KabCommonStatement::getFastPropertyValue(Any&,sal_Int32 nHandle) const +{ + 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: + ; + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL KabCommonStatement::acquire() throw() +{ + KabCommonStatement_BASE::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL KabCommonStatement::release() throw() +{ + KabCommonStatement_BASE::release(); +} +// ----------------------------------------------------------------------------- +Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL KabCommonStatement::getPropertySetInfo( ) throw(RuntimeException) +{ + return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); +} +// ----------------------------------------------------------------------------- +KabStatement::KabStatement(KabConnection* _pConnection) + : KabStatement_BASE(_pConnection) +{ +} diff --git a/connectivity/source/drivers/kab/KStatement.hxx b/connectivity/source/drivers/kab/KStatement.hxx new file mode 100644 index 000000000000..710647b10380 --- /dev/null +++ b/connectivity/source/drivers/kab/KStatement.hxx @@ -0,0 +1,172 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_STATEMENT_HXX_ +#define _CONNECTIVITY_KAB_STATEMENT_HXX_ + +#include "KConnection.hxx" +#include <list> +#include "connectivity/sqliterator.hxx" +#ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_ +#include "connectivity/sqlparse.hxx" +#endif +#include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/implbase1.hxx> +#include <comphelper/proparrhlp.hxx> + +namespace connectivity +{ + namespace kab + { + typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement, + ::com::sun::star::sdbc::XWarningsSupplier, + ::com::sun::star::util::XCancellable, + ::com::sun::star::sdbc::XCloseable> KabCommonStatement_BASE; + + //************************************************************** + // Class KabCommonStatement + // is a base class for the normal statement and for the prepared statement + //************************************************************** + class KabCommonStatement : public comphelper::OBaseMutex, + public KabCommonStatement_BASE, + public ::cppu::OPropertySetHelper, + public comphelper::OPropertyArrayUsageHelper<KabCommonStatement> + + { + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; + + protected: + ::std::list< ::rtl::OUString> m_aBatchList; + connectivity::OSQLParser m_aParser; + connectivity::OSQLParseTreeIterator m_aSQLIterator; + connectivity::OSQLParseNode* m_pParseTree; + KabConnection* m_pConnection; // The owning Connection object + + protected: + class KabCondition *analyseWhereClause( + const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException); + class KabOrder *analyseOrderByClause( + const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException); + sal_Bool isTableKnown(class KabResultSet *pResult) const; + void setKabFields(class KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); + void selectAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); + void sortAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException); + + // 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; + + virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException); + virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException); + virtual ~KabCommonStatement(); + + public: + ::cppu::OBroadcastHelper& rBHelper; + + KabCommonStatement(KabConnection *_pConnection); + using KabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XInterface + virtual void SAL_CALL release() throw(); + virtual void SAL_CALL acquire() throw(); + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType + ) throw(::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( + ) throw(::com::sun::star::uno::RuntimeException); + + // 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); + + // XCancellable + virtual void SAL_CALL cancel( + ) throw(::com::sun::star::uno::RuntimeException); + + // XCloseable + virtual void SAL_CALL close( + ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + // other methods + inline KabConnection* getOwnConnection() const { return m_pConnection; } + }; + + //************************************************************** + // Class KabStatement + //************************************************************** + typedef ::cppu::ImplInheritanceHelper1< + KabCommonStatement, ::com::sun::star::lang::XServiceInfo > KabStatement_BASE; + + class KabStatement : public KabStatement_BASE + { + protected: + virtual ~KabStatement() { } + + public: + KabStatement(KabConnection* _pConnection); + DECLARE_SERVICE_INFO(); + }; + } +} + +#endif // _CONNECTIVITY_KAB_STATEMENT_HXX_ diff --git a/connectivity/source/drivers/kab/KTable.cxx b/connectivity/source/drivers/kab/KTable.cxx new file mode 100644 index 000000000000..916edcf9bda2 --- /dev/null +++ b/connectivity/source/drivers/kab/KTable.cxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KTable.hxx" +#include "KTables.hxx" +#include "KColumns.hxx" +#include "KCatalog.hxx" + +using namespace connectivity::kab; +using namespace connectivity; +using namespace ::comphelper; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +KabTable::KabTable( sdbcx::OCollection* _pTables, KabConnection* _pConnection) + : KabTable_TYPEDEF(_pTables, sal_True), + m_pConnection(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +KabTable::KabTable( sdbcx::OCollection* _pTables, + KabConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : KabTable_TYPEDEF(_pTables,sal_True, + _Name, + _Type, + _Description, + _SchemaName, + _CatalogName), + m_pConnection(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +void KabTable::refreshColumns() +{ + TStringVector aVector; + + if (!isNew()) + { + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns( + Any(), + m_SchemaName, + m_Name, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"))); + + if (xResult.is()) + { + Reference< XRow > xRow(xResult, UNO_QUERY); + while (xResult->next()) + aVector.push_back(xRow->getString(4)); + } + } + + if (m_pColumns) + m_pColumns->reFill(aVector); + else + m_pColumns = new KabColumns(this,m_aMutex,aVector); +} diff --git a/connectivity/source/drivers/kab/KTable.hxx b/connectivity/source/drivers/kab/KTable.hxx new file mode 100644 index 000000000000..eca7b9fb78b1 --- /dev/null +++ b/connectivity/source/drivers/kab/KTable.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_TABLE_HXX_ +#define _CONNECTIVITY_KAB_TABLE_HXX_ + +#include "KConnection.hxx" +#include "connectivity/sdbcx/VTable.hxx" + +namespace connectivity +{ + namespace kab + { + typedef connectivity::sdbcx::OTable KabTable_TYPEDEF; + + ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp); + + class KabTable : public KabTable_TYPEDEF + { + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + KabConnection* m_pConnection; + + public: + KabTable( sdbcx::OCollection* _pTables, KabConnection* _pConnection); + KabTable( sdbcx::OCollection* _pTables, + KabConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description = ::rtl::OUString(), + const ::rtl::OUString& _SchemaName = ::rtl::OUString(), + const ::rtl::OUString& _CatalogName = ::rtl::OUString() + ); + + KabConnection* getConnection() { return m_pConnection;} + + virtual void refreshColumns(); + + ::rtl::OUString getTableName() const { return m_Name; } + ::rtl::OUString getSchema() const { return m_SchemaName; } + }; + } +} + +#endif // _CONNECTIVITY_KAB_TABLE_HXX_ diff --git a/connectivity/source/drivers/kab/KTables.cxx b/connectivity/source/drivers/kab/KTables.cxx new file mode 100644 index 000000000000..418f7a1dd676 --- /dev/null +++ b/connectivity/source/drivers/kab/KTables.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "KTables.hxx" +#include "KTable.hxx" +#include "KCatalog.hxx" +#include "KConnection.hxx" +#include <comphelper/types.hxx> + +using namespace connectivity::kab; +using namespace connectivity; +using namespace ::comphelper; +using namespace ::cppu; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +sdbcx::ObjectType KabTables::createObject(const ::rtl::OUString& _rName) +{ + ::rtl::OUString aName,aSchema; + aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")); + aName = _rName; + + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")); + ::rtl::OUString sEmpty; + + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), aSchema, aName, aTypes); + + sdbcx::ObjectType xRet = NULL; + if (xResult.is()) + { + Reference< XRow > xRow(xResult, UNO_QUERY); + if (xResult->next()) // there can be only one table with this name + { + KabTable* pRet = new KabTable( + this, + static_cast<KabCatalog&>(m_rParent).getConnection(), + aName, + xRow->getString(4), + xRow->getString(5), + sEmpty); + xRet = pRet; + } + } + ::comphelper::disposeComponent(xResult); + + return xRet; +} +// ------------------------------------------------------------------------- +void KabTables::impl_refresh( ) throw(RuntimeException) +{ + static_cast<KabCatalog&>(m_rParent).refreshTables(); +} +// ------------------------------------------------------------------------- +void KabTables::disposing(void) +{ +m_xMetaData.clear(); + OCollection::disposing(); +} diff --git a/connectivity/source/drivers/kab/KTables.hxx b/connectivity/source/drivers/kab/KTables.hxx new file mode 100644 index 000000000000..aaa06002751b --- /dev/null +++ b/connectivity/source/drivers/kab/KTables.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_TABLES_HXX_ +#define _CONNECTIVITY_KAB_TABLES_HXX_ + +#include "connectivity/sdbcx/VCollection.hxx" +#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> + +namespace connectivity +{ + namespace kab + { + class KabTables : public sdbcx::OCollection + { + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; + + protected: + virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); + virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); + + public: + KabTables( + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData, + ::cppu::OWeakObject& _rParent, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector) + : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector), + m_xMetaData(_rMetaData) + { } + + virtual void SAL_CALL disposing(void); + }; + } +} + +#endif // _CONNECTIVITY_KAB_TABLES_HXX_ diff --git a/connectivity/source/drivers/kab/exports.dxp b/connectivity/source/drivers/kab/exports.dxp new file mode 100644 index 000000000000..f0e1c69934bc --- /dev/null +++ b/connectivity/source/drivers/kab/exports.dxp @@ -0,0 +1,2 @@ +component_getImplementationEnvironment +component_getFactory diff --git a/connectivity/source/drivers/kab/kab.xcu b/connectivity/source/drivers/kab/kab.xcu new file mode 100755 index 000000000000..d350014a3017 --- /dev/null +++ b/connectivity/source/drivers/kab/kab.xcu @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--*********************************************************************** + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************ --> +<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <node oor:name="Installed"> + <node oor:name="sdbc:address:kab" oor:op="replace"> + <prop oor:name="Driver"> + <value>com.sun.star.comp.sdbc.kab.Driver</value> + </prop> + <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> + <value xml:lang="en-US">KDE Address Book</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/kab/kab.xml b/connectivity/source/drivers/kab/kab.xml new file mode 100644 index 000000000000..4992d6fba096 --- /dev/null +++ b/connectivity/source/drivers/kab/kab.xml @@ -0,0 +1,79 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> kab1 </module-name> + <component-description> + <Author>Eric Bischoff</Author> + <Name>com.sun.star.comp.sdbc.kab.Driver</Name> + <description>This library implements the database driver for KDE address book formats.</description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language>c++</language> + <status value="final"/> + <supported-service>com.sun.star.sdbc.Driver</supported-service> + <service-dependency> ... </service-dependency> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <project-build-dependency> vos </project-build-dependency> + + <runtime-module-dependency> cppuhelper </runtime-module-dependency> + <runtime-module-dependency> cppu1 </runtime-module-dependency> + <runtime-module-dependency> sal1 </runtime-module-dependency> + <runtime-module-dependency> vos </runtime-module-dependency> + + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.util.XCancellable </type> + <type> com.sun.star.util.XNumberFormatter </type> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.uno.XComponentContext </type> + <type> com.sun.star.beans.PropertyAttribute </type> + <type> com.sun.star.beans.XPropertyState </type> + <type> com.sun.star.beans.XPropertySet </type> + <type> com.sun.star.beans.PropertyValue </type> + <type> com.sun.star.beans.XMultiPropertySet </type> + <type> com.sun.star.beans.XFastPropertySet </type> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.XSingleComponentFactory </type> + <type> com.sun.star.lang.EventObject </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.lang.IllegalArgumentException </type> + <type> com.sun.star.lang.DisposedException </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XUnoTunnel </type> + <type> com.sun.star.java.XJavaThreadRegister_11 </type> + <type> com.sun.star.java.XJavaVM </type> + <type> com.sun.star.sdbc.FetchDirection </type> + <type> com.sun.star.sdbc.XConnection </type> + <type> com.sun.star.sdbc.XStatement </type> + <type> com.sun.star.sdbc.XResultSet </type> + <type> com.sun.star.sdbc.XResultSetMetaDataSupplier</type> + <type> com.sun.star.sdbc.XColumnLocate </type> + <type> com.sun.star.sdbc.XResultSetUpdate </type> + <type> com.sun.star.sdbc.XWarningsSupplier </type> + <type> com.sun.star.sdbc.XRowUpdate </type> + <type> com.sun.star.sdbc.XMultipleResults </type> + <type> com.sun.star.sdbc.XBatchExecution </type> + <type> com.sun.star.sdbc.XPreparedBatchExecution </type> + <type> com.sun.star.sdbc.XParameters </type> + <type> com.sun.star.sdbc.XOutParameters </type> + <type> com.sun.star.sdbc.DriverPropertyInfo </type> + <type> com.sun.star.sdbc.SQLWarning </type> + <type> com.sun.star.sdbc.XRow </type> + <type> com.sun.star.sdbc.ColumnSearch </type> + <type> com.sun.star.sdbc.ColumnValue </type> + <type> com.sun.star.sdbc.DataType </type> + <type> com.sun.star.sdbc.XDriver </type> + <type> com.sun.star.sdbc.TransactionIsolation </type> + <type> com.sun.star.sdbc.ResultSetType </type> + <type> com.sun.star.sdbc.ResultSetConcurrency </type> + <type> com.sun.star.sdbcx.XRowLocate </type> + <type> com.sun.star.sdbcx.XDeleteRows </type> + <type> com.sun.star.sdbcx.CompareBookmark </type> + <type> com.sun.star.sdb.XColumnUpdate </type> + <type> com.sun.star.sdb.XColumn </type> +</module-description> diff --git a/connectivity/source/drivers/kab/kab1.component b/connectivity/source/drivers/kab/kab1.component new file mode 100644 index 000000000000..77227501d36c --- /dev/null +++ b/connectivity/source/drivers/kab/kab1.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.sdbc.kab.Driver"> + <service name="com.sun.star.sdbc.Driver"/> + </implementation> +</component> diff --git a/connectivity/source/drivers/kab/kabdrv.map b/connectivity/source/drivers/kab/kabdrv.map new file mode 100644 index 000000000000..5de866f2e52f --- /dev/null +++ b/connectivity/source/drivers/kab/kabdrv.map @@ -0,0 +1,9 @@ +UDK_3_0_0 { + global: + createKabConnection; + initKApplication; + shutdownKApplication; + matchKDEVersion; + local: + *; +}; diff --git a/connectivity/source/drivers/kab/kcondition.cxx b/connectivity/source/drivers/kab/kcondition.cxx new file mode 100644 index 000000000000..c99905678242 --- /dev/null +++ b/connectivity/source/drivers/kab/kcondition.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "kcondition.hxx" +#include "kfields.hxx" +#include "connectivity/CommonTools.hxx" + +using namespace ::connectivity::kab; +using namespace ::com::sun::star::sdbc; +// ----------------------------------------------------------------------------- +KabCondition::~KabCondition() +{ +} +// ----------------------------------------------------------------------------- +KabConditionConstant::KabConditionConstant(const sal_Bool bValue) + : KabCondition(), + m_bValue(bValue) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionConstant::isAlwaysTrue() const +{ + return m_bValue; +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionConstant::isAlwaysFalse() const +{ + return !m_bValue; +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionConstant::eval(const ::KABC::Addressee &) const +{ + return m_bValue; +} +// ----------------------------------------------------------------------------- +KabConditionColumn::KabConditionColumn(const ::rtl::OUString &sColumnName) throw(SQLException) + : KabCondition(), + m_nFieldNumber(findKabField(sColumnName)) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionColumn::isAlwaysTrue() const +{ + // Sometimes true, sometimes false + return sal_False; +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionColumn::isAlwaysFalse() const +{ + // Sometimes true, sometimes false + return sal_False; +} +// ----------------------------------------------------------------------------- +KabConditionNull::KabConditionNull(const ::rtl::OUString &sColumnName) throw(SQLException) + : KabConditionColumn(sColumnName) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionNull::eval(const ::KABC::Addressee &aAddressee) const +{ + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); + + return aQtName.isNull(); +// KDE address book currently does not use NULL values. +// But it might do it someday +} +// ----------------------------------------------------------------------------- +KabConditionNotNull::KabConditionNotNull(const ::rtl::OUString &sColumnName) throw(SQLException) + : KabConditionColumn(sColumnName) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionNotNull::eval(const ::KABC::Addressee &aAddressee) const +{ + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); + + return !aQtName.isNull(); +// KDE address book currently does not use NULL values. +// But it might do it someday +} +// ----------------------------------------------------------------------------- +KabConditionCompare::KabConditionCompare(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException) + : KabConditionColumn(sColumnName), + m_sMatchString(sMatchString) +{ +} +// ----------------------------------------------------------------------------- +KabConditionEqual::KabConditionEqual(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException) + : KabConditionCompare(sColumnName, sMatchString) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionEqual::eval(const ::KABC::Addressee &aAddressee) const +{ + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); +// Timestamps should not be compared according to their string value +// The syntax for such queries should be like +// {ts '2004-03-29 12:55:00.000000'} +// They should also support operators like '<' or '>=' + + if (aQtName.isNull()) return sal_False; + + ::rtl::OUString sValue((const sal_Unicode *) aQtName.ucs2()); + return sValue == m_sMatchString; +} +// ----------------------------------------------------------------------------- +KabConditionDifferent::KabConditionDifferent(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException) + : KabConditionCompare(sColumnName, sMatchString) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionDifferent::eval(const ::KABC::Addressee &aAddressee) const +{ + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); + + if (aQtName.isNull()) return sal_False; + + ::rtl::OUString sValue((const sal_Unicode *) aQtName.ucs2()); + return sValue != m_sMatchString; +} +// ----------------------------------------------------------------------------- +KabConditionSimilar::KabConditionSimilar(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException) + : KabConditionCompare(sColumnName, sMatchString) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionSimilar::eval(const ::KABC::Addressee &aAddressee) const +{ + QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber); + + if (aQtName.isNull()) return sal_False; + + ::rtl::OUString sValue((const sal_Unicode *) aQtName.ucs2()); + return match(m_sMatchString, sValue, '\0'); +} +// ----------------------------------------------------------------------------- +KabConditionBoolean::KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight) + : KabCondition(), + m_pLeft(pLeft), + m_pRight(pRight) +{ +} +// ----------------------------------------------------------------------------- +KabConditionBoolean::~KabConditionBoolean() +{ + delete m_pLeft; + delete m_pRight; +} +// ----------------------------------------------------------------------------- +KabConditionOr::KabConditionOr(KabCondition *pLeft, KabCondition *pRight) + : KabConditionBoolean(pLeft, pRight) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionOr::isAlwaysTrue() const +{ + return m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue(); +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionOr::isAlwaysFalse() const +{ + return m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse(); +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionOr::eval(const ::KABC::Addressee &aAddressee) const +{ + // We avoid evaluating terms as much as we can + if (m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue()) return sal_True; + if (m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse()) return sal_False; + + if (m_pLeft->eval(aAddressee)) return sal_True; + if (m_pRight->eval(aAddressee)) return sal_True; + + return sal_False; +} +// ----------------------------------------------------------------------------- +KabConditionAnd::KabConditionAnd(KabCondition *pLeft, KabCondition *pRight) + : KabConditionBoolean(pLeft, pRight) +{ +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionAnd::isAlwaysTrue() const +{ + return m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue(); +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionAnd::isAlwaysFalse() const +{ + return m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse(); +} +// ----------------------------------------------------------------------------- +sal_Bool KabConditionAnd::eval(const ::KABC::Addressee &aAddressee) const +{ + // We avoid evaluating terms as much as we can + if (m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse()) return sal_False; + if (m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue()) return sal_True; + + if (!m_pLeft->eval(aAddressee)) return sal_False; + if (!m_pRight->eval(aAddressee)) return sal_False; + + return sal_True; +} diff --git a/connectivity/source/drivers/kab/kcondition.hxx b/connectivity/source/drivers/kab/kcondition.hxx new file mode 100644 index 000000000000..26bc530a9960 --- /dev/null +++ b/connectivity/source/drivers/kab/kcondition.hxx @@ -0,0 +1,162 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_CONDITION_HXX_ +#define _CONNECTIVITY_KAB_CONDITION_HXX_ + +#ifndef _COMPHELPER_TYPES_H_ +#include <comphelper/types.hxx> +#endif +#include <shell/kde_headers.h> +#include <connectivity/dbexception.hxx> + +namespace connectivity +{ + namespace kab + { +// ----------------------------------------------------------------------------- +class KabCondition +{ + public: + virtual ~KabCondition(); + virtual sal_Bool isAlwaysTrue() const = 0; + virtual sal_Bool isAlwaysFalse() const = 0; + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const = 0; +}; +// ----------------------------------------------------------------------------- +class KabConditionConstant : public KabCondition +{ + protected: + sal_Bool m_bValue; + + public: + KabConditionConstant(const sal_Bool bValue); + virtual sal_Bool isAlwaysTrue() const; + virtual sal_Bool isAlwaysFalse() const; + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionColumn : public KabCondition +{ + protected: + sal_Int32 m_nFieldNumber; + + QString value(const ::KABC::Addressee &aAddressee) const; + + public: + KabConditionColumn( + const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException); + virtual sal_Bool isAlwaysTrue() const; + virtual sal_Bool isAlwaysFalse() const; +}; +// ----------------------------------------------------------------------------- +class KabConditionNull : public KabConditionColumn +{ + public: + KabConditionNull( + const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException); + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionNotNull : public KabConditionColumn +{ + public: + KabConditionNotNull( + const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException); + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionCompare : public KabConditionColumn +{ + protected: + const ::rtl::OUString m_sMatchString; + + public: + KabConditionCompare( + const ::rtl::OUString &sColumnName, + const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); +}; +// ----------------------------------------------------------------------------- +class KabConditionEqual : public KabConditionCompare +{ + public: + KabConditionEqual( + const ::rtl::OUString &sColumnName, + const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionDifferent : public KabConditionCompare +{ + public: + KabConditionDifferent( + const ::rtl::OUString &sColumnName, + const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionSimilar : public KabConditionCompare +{ + public: + KabConditionSimilar( + const ::rtl::OUString &sColumnName, + const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException); + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionBoolean : public KabCondition +{ + protected: + KabCondition *m_pLeft, *m_pRight; + + public: + KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight); + virtual ~KabConditionBoolean(); +}; +// ----------------------------------------------------------------------------- +class KabConditionOr : public KabConditionBoolean +{ + public: + KabConditionOr(KabCondition *pLeft, KabCondition *pRight); + virtual sal_Bool isAlwaysTrue() const; + virtual sal_Bool isAlwaysFalse() const; + virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const; +}; +// ----------------------------------------------------------------------------- +class KabConditionAnd : public KabConditionBoolean +{ + public: + KabConditionAnd(KabCondition *pLeft, KabCondition *pRight); + virtual sal_Bool isAlwaysTrue() const; + virtual sal_Bool isAlwaysFalse() const; + virtual sal_Bool eval(const ::KABC::Addressee &addressee) const; +}; +// ----------------------------------------------------------------------------- + } +} + +#endif // _CONNECTIVITY_KAB_CONDITION_HXX_ diff --git a/connectivity/source/drivers/kab/kfields.cxx b/connectivity/source/drivers/kab/kfields.cxx new file mode 100644 index 000000000000..e2ff003d98b0 --- /dev/null +++ b/connectivity/source/drivers/kab/kfields.cxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "kfields.hxx" +#include "resource/common_res.hrc" +#include "resource/sharedresources.hxx" + +using namespace ::connectivity::kab; +using namespace ::com::sun::star::sdbc; + +namespace connectivity +{ + namespace kab + { +// ----------------------------------------------------------------------------- +// return the value of a KDE address book field, given an addressee and a field number +QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber) +{ + switch (nFieldNumber) + { + case KAB_FIELD_REVISION: + return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss"); + default: + ::KABC::Field::List aFields = ::KABC::Field::allFields(); + return aFields[nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee); + } +} +// ------------------------------------------------------------------------------ +// search the KDE address book field number of a given column name +sal_uInt32 findKabField(const ::rtl::OUString& columnName) throw(SQLException) +{ + QString aQtName; + ::rtl::OUString aName; + + aQtName = KABC::Addressee::revisionLabel(); + aName = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + if (columnName == aName) + return KAB_FIELD_REVISION; + + ::KABC::Field::List aFields = ::KABC::Field::allFields(); + ::KABC::Field::List::iterator aField; + sal_uInt32 nResult; + + for ( aField = aFields.begin(), nResult = KAB_DATA_FIELDS; + aField != aFields.end(); + ++aField, ++nResult) + { + aQtName = (*aField)->label(); + aName = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2()); + + if (columnName == aName) + return nResult; + } + + ::connectivity::SharedResources aResources; + const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( + STR_INVALID_COLUMNNAME, + "$columnname$",columnName + ) ); + ::dbtools::throwGenericSQLException(sError,NULL); + // Unreachable: + OSL_ASSERT(false); + return 0; +} +// ------------------------------------------------------------------------------ + } +} diff --git a/connectivity/source/drivers/kab/kfields.hxx b/connectivity/source/drivers/kab/kfields.hxx new file mode 100644 index 000000000000..ed5688d5b064 --- /dev/null +++ b/connectivity/source/drivers/kab/kfields.hxx @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_FIELDS_HXX_ +#define _CONNECTIVITY_KAB_FIELDS_HXX_ + +#include <shell/kde_headers.h> +#include <connectivity/dbexception.hxx> +#include <rtl/ustring.hxx> + +#define KAB_FIELD_REVISION 0 +#define KAB_DATA_FIELDS 1 + +namespace connectivity +{ + namespace kab + { + QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber); + sal_uInt32 findKabField(const ::rtl::OUString& columnName) throw(::com::sun::star::sdbc::SQLException); + } +} + +#endif diff --git a/connectivity/source/drivers/kab/korder.cxx b/connectivity/source/drivers/kab/korder.cxx new file mode 100644 index 000000000000..0df6b66babf6 --- /dev/null +++ b/connectivity/source/drivers/kab/korder.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" + +#include "korder.hxx" +#include "kfields.hxx" + +using namespace ::connectivity::kab; + +KabOrder::~KabOrder() +{ +} +// ----------------------------------------------------------------------------- +KabSimpleOrder::KabSimpleOrder(::rtl::OUString &sColumnName, sal_Bool bAscending) + : KabOrder(), + m_nFieldNumber(findKabField(sColumnName)), + m_bAscending(bAscending) +{ +} +// ----------------------------------------------------------------------------- +sal_Int32 KabSimpleOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const +{ + sal_Int32 result; + + result = QString::compare( + valueOfKabField(aAddressee1, m_nFieldNumber), + valueOfKabField(aAddressee2, m_nFieldNumber)); +// Timestamps should be compared differently than with their string value + + if (!m_bAscending) result = -result; + + return result; +} +// ----------------------------------------------------------------------------- +KabComplexOrder::KabComplexOrder() + : KabOrder(), + m_aOrders() +{ +} +// ----------------------------------------------------------------------------- +KabComplexOrder::~KabComplexOrder() +{ + for (sal_uInt32 i = 0; i < m_aOrders.size(); i++) + delete m_aOrders[i]; +} +// ----------------------------------------------------------------------------- +void KabComplexOrder::addOrder(KabOrder *pOrder) +{ + m_aOrders.push_back(pOrder); +} +// ----------------------------------------------------------------------------- +sal_Int32 KabComplexOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const +{ + for (sal_uInt32 i = 0; i < m_aOrders.size(); i++) + { + const KabOrder *pOrder = m_aOrders[i]; + sal_Int32 result = pOrder->compare(aAddressee1, aAddressee2); + + if (result) return result; + } + return 0; +} diff --git a/connectivity/source/drivers/kab/korder.hxx b/connectivity/source/drivers/kab/korder.hxx new file mode 100644 index 000000000000..6c88f9e3ab9f --- /dev/null +++ b/connectivity/source/drivers/kab/korder.hxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_KAB_ORDER_HXX_ +#define _CONNECTIVITY_KAB_ORDER_HXX_ + +#include "rtl/ustring.hxx" +#include <shell/kde_headers.h> + +#include <vector> + +namespace connectivity +{ + namespace kab + { + class KabOrder + { + public: + virtual ~KabOrder(); + + virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const = 0; + }; + + class KabSimpleOrder : public KabOrder + { + sal_Int32 m_nFieldNumber; + sal_Bool m_bAscending; + + QString value(const ::KABC::Addressee &aAddressee) const; + public: + KabSimpleOrder(::rtl::OUString &sColumnName, sal_Bool bAscending); + + virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const; + }; + + class KabComplexOrder : public KabOrder + { + ::std::vector<KabOrder *> m_aOrders; + + public: + KabComplexOrder(); + virtual ~KabComplexOrder(); + + void addOrder(KabOrder *pOrder); + virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const; + }; + } +} + +#endif diff --git a/connectivity/source/drivers/kab/makefile.mk b/connectivity/source/drivers/kab/makefile.mk new file mode 100644 index 000000000000..c085cddb2d3b --- /dev/null +++ b/connectivity/source/drivers/kab/makefile.mk @@ -0,0 +1,148 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=kab +TARGET2=$(TARGET)drv + +ENABLE_EXCEPTIONS=TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ---------------------------------- + +.INCLUDE : $(PRJ)$/makefile.pmk +.INCLUDE : $(PRJ)$/version.mk + +.IF "$(GUI)" == "UNX" +.IF "$(ENABLE_KAB)" == "TRUE" + +CFLAGS+=$(KDE_CFLAGS) + +.IF "$(KDE_ROOT)"!="" +EXTRALIBPATHS+=-L$(KDE_ROOT)$/lib +.IF "$(OS)$(CPU)" == "LINUXX" +EXTRALIBPATHS+=-L$(KDE_ROOT)$/lib64 +.ENDIF +.ENDIF + +# === KAB base library ========================== + +# --- Files ------------------------------------- + +SLOFILES= \ + $(SLO)$/KDriver.obj \ + $(SLO)$/KServices.obj + +DEPOBJFILES= \ + $(SLO2FILES) + +# --- Library ----------------------------------- + +SHL1VERSIONMAP=$(SOLARENV)/src/component.map + +SHL1TARGET= $(TARGET)$(KAB_MAJOR) +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(DBTOOLSLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) + +# === KAB impl library ========================== + +# --- Files ------------------------------------- + +SLO2FILES=\ + $(SLO)$/KColumns.obj \ + $(SLO)$/KTable.obj \ + $(SLO)$/KTables.obj \ + $(SLO)$/KCatalog.obj \ + $(SLO)$/KResultSet.obj \ + $(SLO)$/KStatement.obj \ + $(SLO)$/KPreparedStatement.obj \ + $(SLO)$/KDatabaseMetaData.obj \ + $(SLO)$/KConnection.obj \ + $(SLO)$/KResultSetMetaData.obj \ + $(SLO)$/kcondition.obj \ + $(SLO)$/korder.obj \ + $(SLO)$/kfields.obj \ + $(SLO)$/KDEInit.obj + +KAB_LIB=$(KDE_LIBS) -lkabc + +# --- Library ----------------------------------- + +SHL2VERSIONMAP=$(TARGET2).map + +SHL2TARGET= $(TARGET2)$(KAB_MAJOR) +SHL2OBJS=$(SLO2FILES) +SHL2STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(DBTOOLSLIB) \ + $(COMPHELPERLIB) \ + $(KAB_LIB) + +SHL2DEPN= +SHL2IMPLIB= i$(TARGET2) + +SHL2DEF= $(MISC)$/$(SHL2TARGET).def + +DEF2NAME= $(SHL2TARGET) + +# --- Targets ----------------------------------- +.ELSE # "$(ENABLE_KAB)" == "TRUE" +dummy: + @echo KDE Addressbook disabled - nothing to build +.ENDIF + +.ELSE # "$(GUI)" == "UNX" +dummy: + @echo "Nothing to build for GUI $(GUI)" +.ENDIF + +.INCLUDE : $(PRJ)$/target.pmk + + +ALLTAR : $(MISC)/kab1.component + +$(MISC)/kab1.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + kab1.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt kab1.component |