diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-12 16:47:18 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-12 17:20:22 +0100 |
commit | 88d74f35c2ce7968fe3f57f34e25d09374164ecd (patch) | |
tree | 2f7d4065f30b92777c0b1d984fad7e28f3146949 /connectivity | |
parent | f400dac5a846007c9bf7529623732670b73c692e (diff) |
Create Catalog to deal with sdbcx details. (firebird-sdbc)
Change-Id: I521db652157e6b6da79e70f3731b6eddfc2bab1d
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/Library_firebird_sdbc.mk | 1 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Catalog.cxx | 47 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Catalog.hxx | 43 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.cxx | 27 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.hxx | 26 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Driver.cxx | 3 |
6 files changed, 127 insertions, 20 deletions
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk index 066d60ad82aa..577c169e9ef5 100644 --- a/connectivity/Library_firebird_sdbc.mk +++ b/connectivity/Library_firebird_sdbc.mk @@ -38,6 +38,7 @@ $(eval $(call gb_Library_set_componentfile,firebird_sdbc,connectivity/source/dri $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\ connectivity/source/drivers/firebird/Blob \ + connectivity/source/drivers/firebird/Catalog \ connectivity/source/drivers/firebird/Columns \ connectivity/source/drivers/firebird/Connection \ connectivity/source/drivers/firebird/DatabaseMetaData \ diff --git a/connectivity/source/drivers/firebird/Catalog.cxx b/connectivity/source/drivers/firebird/Catalog.cxx new file mode 100644 index 000000000000..552889a1d6e5 --- /dev/null +++ b/connectivity/source/drivers/firebird/Catalog.cxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "Catalog.hxx" + +using namespace ::connectivity::firebird; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::sdbc; + +Catalog::Catalog(const uno::Reference< XConnection >& rConnection): + OCatalog(rConnection), + m_xConnection(rConnection) +{ +} + +//----- OCatalog ------------------------------------------------------------- +void Catalog::refreshTables() +{ + // TODO: implement me. + // Sets m_pTables (OCatalog) +} + +void Catalog::refreshViews() +{ + // TODO: implement me. + // Sets m_pViews (OCatalog) +} + +//----- IRefreshableGroups --------------------------------------------------- +void Catalog::refreshGroups() +{ + // TODO: implement me +} + +//----- IRefreshableUsers ---------------------------------------------------- +void Catalog::refreshUsers() +{ + // TODO: implement me +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/connectivity/source/drivers/firebird/Catalog.hxx b/connectivity/source/drivers/firebird/Catalog.hxx new file mode 100644 index 000000000000..7281b79b8961 --- /dev/null +++ b/connectivity/source/drivers/firebird/Catalog.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef CONNECTIVITY_FIREBIRD_CATALOG_HXX +#define CONNECTIVITY_FIREBIRD_CATALOG_HXX + +#include <connectivity/sdbcx/VCatalog.hxx> + +namespace connectivity +{ + namespace firebird + { + class Catalog: public ::connectivity::sdbcx::OCatalog + { + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + m_xConnection; + + public: + Catalog(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& rConnection); + + // OCatalog + virtual void refreshTables(); + virtual void refreshViews(); + + // IRefreshableGroups + virtual void refreshGroups(); + + // IRefreshableUsers + virtual void refreshUsers(); + }; + } // namespace firebird +} // namespace connectivity + +#endif //CONNECTIVITY_FIREBIRD_CATALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 9dbc87fb6fd8..de795eb221fe 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "Catalog.hxx" #include "Connection.hxx" #include "DatabaseMetaData.hxx" #include "Driver.hxx" @@ -67,6 +68,7 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::uno; const OUString OConnection::sDBLocation( "firebird.fdb" ); @@ -86,7 +88,8 @@ OConnection::OConnection(FirebirdDriver* _pDriver) m_bReadOnly(sal_False), m_aTransactionIsolation(TransactionIsolation::REPEATABLE_READ), m_DBHandler(0), - m_transactionHandle(0) + m_transactionHandle(0), + m_xCatalog(0) { SAL_INFO("connectivity.firebird", "OConnection()."); @@ -762,12 +765,22 @@ void OConnection::clearStatements() m_aStatements.clear(); } -//----- XTablesSupplier ------------------------------------------------------ -uno::Reference< XNameAccess > SAL_CALL OConnection::getTables() - throw (RuntimeException) +uno::Reference< XTablesSupplier > OConnection::createCatalog() { - return new Tables(getMetaData(), - *this, - m_aMutex); + MutexGuard aGuard(m_aMutex); + + // m_xCatalog is a weak reference. Reuse it if it still exists. + Reference< XTablesSupplier > xCatalog = m_xCatalog; + if (xCatalog.is()) + { + return xCatalog; + } + else + { + xCatalog = new Catalog(this); + m_xCatalog = xCatalog; + return m_xCatalog; + } + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index d7a4f37129a0..ca6fae6ccdb2 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -27,7 +27,7 @@ #include <connectivity/CommonTools.hxx> #include <connectivity/OSubComponent.hxx> -#include <cppuhelper/compbase5.hxx> +#include <cppuhelper/compbase4.hxx> #include <cppuhelper/weakref.hxx> #include <map> #include <OTypeInfo.hxx> @@ -49,11 +49,10 @@ namespace connectivity namespace firebird { - typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::document::XDocumentEventListener, + typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::document::XDocumentEventListener, ::com::sun::star::lang::XServiceInfo, ::com::sun::star::sdbc::XConnection, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbcx::XTablesSupplier + ::com::sun::star::sdbc::XWarningsSupplier > OConnection_BASE; class OStatementCommonBase; @@ -109,7 +108,10 @@ namespace connectivity isc_db_handle m_DBHandler; isc_tr_handle m_transactionHandle; - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xEmbeddedStorage; + ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > + m_xEmbeddedStorage; + ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> + m_xCatalog; void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException); @@ -161,13 +163,6 @@ namespace connectivity // css.lang.XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); - // XTablesSupplier - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > - SAL_CALL getTables() - throw(::com::sun::star::uno::RuntimeException); - - - inline ::rtl::OUString getUserName() const { return m_sUser; } inline isc_db_handle& getDBHandle() { return m_DBHandler; } inline FirebirdDriver* getDriver() const { return m_pDriver;} @@ -185,6 +180,13 @@ namespace connectivity ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob> createBlob(ISC_QUAD* pBlobID) throw(::com::sun::star::sdbc::SQLException); + + /** + * Create and/or connect to the sdbcx Catalog. This is completely + * unrelated to the SQL "Catalog". + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > + createCatalog(); }; } } diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index 41c31d266cb6..2b9e65677ddb 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -174,7 +174,8 @@ uno::Reference< XTablesSupplier > SAL_CALL FirebirdDriver::getDataDefinitionByCo const uno::Reference< XConnection >& rConnection) throw(SQLException, RuntimeException) { - return uno::Reference< XTablesSupplier >(rConnection, UNO_QUERY); + OConnection* pConnection = static_cast< OConnection* >(rConnection.get()); + return uno::Reference< XTablesSupplier >(pConnection->createCatalog(), UNO_QUERY); } uno::Reference< XTablesSupplier > SAL_CALL FirebirdDriver::getDataDefinitionByURL( |