[Libreoffice-commits] .: Branch 'feature/mork' - connectivity/Library_mork.mk connectivity/source
David Ostrovsky
davido at kemper.freedesktop.org
Thu Aug 9 13:23:57 PDT 2012
connectivity/Library_mork.mk | 6 +
connectivity/source/drivers/mork/MCatalog.cxx | 111 +++++++++++++++++++++++
connectivity/source/drivers/mork/MCatalog.hxx | 55 +++++++++++
connectivity/source/drivers/mork/MColumns.cxx | 87 ++++++++++++++++++
connectivity/source/drivers/mork/MColumns.hxx | 51 ++++++++++
connectivity/source/drivers/mork/MConnection.cxx | 18 +++
connectivity/source/drivers/mork/MConnection.hxx | 7 +
connectivity/source/drivers/mork/MDriver.cxx | 4
connectivity/source/drivers/mork/MDriver.hxx | 4
connectivity/source/drivers/mork/MStatement.cxx | 11 --
connectivity/source/drivers/mork/MStatement.hxx | 2
connectivity/source/drivers/mork/MTables.cxx | 86 +++++++++++++++++
connectivity/source/drivers/mork/MTables.hxx | 48 +++++++++
13 files changed, 479 insertions(+), 11 deletions(-)
New commits:
commit 8a8e6ace18b88d12a521609db286ddf6f1bc37b0
Author: David Ostrovsky <david at ostrovsky.org>
Date: Thu Aug 9 22:21:16 2012 +0200
mork driver: adding missing stuff
Change-Id: I923cd4d3cbd90315099ab5ceff3761ab3cbdebf9
diff --git a/connectivity/Library_mork.mk b/connectivity/Library_mork.mk
index 7066342..388dd91 100644
--- a/connectivity/Library_mork.mk
+++ b/connectivity/Library_mork.mk
@@ -33,19 +33,23 @@ $(eval $(call gb_Library_use_libraries,mork, \
$(eval $(call gb_Library_use_sdk_api,mork))
$(eval $(call gb_Library_add_exception_objects,mork, \
+ connectivity/source/drivers/mork/MColumns \
connectivity/source/drivers/mork/MNSFolders \
connectivity/source/drivers/mork/MNSINIParser \
connectivity/source/drivers/mork/MNSProfileDiscover \
connectivity/source/drivers/mork/MorkParser \
- connectivity/source/drivers/mork/MDriver \
+ connectivity/source/drivers/mork/MCatalog \
connectivity/source/drivers/mork/MConnection \
connectivity/source/drivers/mork/MDatabaseMetaData \
connectivity/source/drivers/mork/MDatabaseMetaDataHelper \
+ connectivity/source/drivers/mork/MDriver \
connectivity/source/drivers/mork/MStatement \
connectivity/source/drivers/mork/MResultSet \
connectivity/source/drivers/mork/MResultSetMetaData \
connectivity/source/drivers/mork/MPreparedStatement \
connectivity/source/drivers/mork/MServices \
+ connectivity/source/drivers/mork/MTable \
+ connectivity/source/drivers/mork/MTables \
))
# vim: set noet sw=4 ts=4:
diff --git a/connectivity/source/drivers/mork/MCatalog.cxx b/connectivity/source/drivers/mork/MCatalog.cxx
new file mode 100644
index 0000000..005037c
--- /dev/null
+++ b/connectivity/source/drivers/mork/MCatalog.cxx
@@ -0,0 +1,111 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "MCatalog.hxx"
+#include "MConnection.hxx"
+#include "MTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/interfacecontainer.h>
+
+// -------------------------------------------------------------------------
+using namespace connectivity::mork;
+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;
+
+// -------------------------------------------------------------------------
+OCatalog::OCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_xMetaData(m_pConnection->getMetaData( ))
+{
+// osl_incrementInterlockedCount( &m_refCount );
+// refreshTables();
+// refreshViews();
+// refreshGroups();
+// refreshUsers();
+// osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+void OCatalog::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;
+ while(xResult->next())
+ {
+ aName = xRow->getString(3);
+ aVector.push_back(aName);
+ }
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshViews()
+{
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshUsers()
+{
+}
+// -----------------------------------------------------------------------------
+
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pTables || m_pConnection->getForceLoadTables())
+ refreshTables();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pTables;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MCatalog.hxx b/connectivity/source/drivers/mork/MCatalog.hxx
new file mode 100644
index 0000000..e4889fe
--- /dev/null
+++ b/connectivity/source/drivers/mork/MCatalog.hxx
@@ -0,0 +1,55 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _CONNECTIVITY_MOZAB_CATALOG_HXX_
+#define _CONNECTIVITY_MOZAB_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ // please don't name the class the same name as in an other namespaces
+ // some compilers have problems with this task as I noticed on windows
+ class OConnection;
+ class OCatalog : public connectivity::sdbcx::OCatalog
+ {
+ OConnection* 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:
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OCatalog(OConnection* _pCon);
+
+ OConnection* getConnection() const { return m_pConnection; }
+ sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
+ sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_CATALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MColumns.cxx b/connectivity/source/drivers/mork/MColumns.cxx
new file mode 100644
index 0000000..852bb4d
--- /dev/null
+++ b/connectivity/source/drivers/mork/MColumns.cxx
@@ -0,0 +1,87 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "MColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "MTable.hxx"
+#include "MTables.hxx"
+#include "MCatalog.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+
+using namespace ::comphelper;
+
+using namespace connectivity::mork;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+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 OColumns::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)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+
+ OColumn* pRet = new OColumn(_rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ sal_False,sal_False,sal_False,sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MColumns.hxx b/connectivity/source/drivers/mork/MColumns.hxx
new file mode 100644
index 0000000..186f6b5
--- /dev/null
+++ b/connectivity/source/drivers/mork/MColumns.hxx
@@ -0,0 +1,51 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _CONNECTIVITY_MOZAB_COLUMNS_HXX_
+#define _CONNECTIVITY_MOZAB_COLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "MTable.hxx"
+
+namespace connectivity
+{
+ namespace mork
+ {
+ class OColumns : public sdbcx::OCollection
+ {
+ protected:
+ OTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OColumns( OTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector)
+ ,m_pTable(_pTable)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_COLUMNS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx
index 9345d87..08baf7e 100644
--- a/connectivity/source/drivers/mork/MConnection.cxx
+++ b/connectivity/source/drivers/mork/MConnection.cxx
@@ -12,6 +12,7 @@
#include "MConnection.hxx"
#include "MDriver.hxx"
#include "MDatabaseMetaData.hxx"
+#include "MCatalog.hxx"
#include "MPreparedStatement.hxx"
#include "MorkParser.hxx"
@@ -328,6 +329,23 @@ void OConnection::disposing()
}
// -----------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL OConnection::createCatalog()
+{
+ OSL_TRACE("IN OConnection::createCatalog()" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!m_xCatalog.is())
+ {
+ OCatalog *pCat = new OCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ OSL_TRACE( "\tOUT OConnection::createCatalog()" );
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+
+
} } // namespace connectivity::mork
diff --git a/connectivity/source/drivers/mork/MConnection.hxx b/connectivity/source/drivers/mork/MConnection.hxx
index 9f6b862..2967520 100644
--- a/connectivity/source/drivers/mork/MConnection.hxx
+++ b/connectivity/source/drivers/mork/MConnection.hxx
@@ -99,6 +99,13 @@ namespace connectivity
virtual void SAL_CALL clearWarnings() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
static ::rtl::OUString getDriverImplementationName();
+
+ sal_Bool getForceLoadTables() {return true;}
+
+ // Added to enable me to use SQLInterpreter which requires an
+ // XNameAccess i/f to access tables.
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
+
};
}
}
diff --git a/connectivity/source/drivers/mork/MDriver.cxx b/connectivity/source/drivers/mork/MDriver.cxx
index d91d624..04fdc16 100644
--- a/connectivity/source/drivers/mork/MDriver.cxx
+++ b/connectivity/source/drivers/mork/MDriver.cxx
@@ -25,9 +25,11 @@ namespace connectivity
}
MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const context):
- context_(context)
+ context_(context),
+ m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
{
SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
+// css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
m_ProfileAccess = new ProfileAccess();
assert(context.is());
}
diff --git a/connectivity/source/drivers/mork/MDriver.hxx b/connectivity/source/drivers/mork/MDriver.hxx
index 112aa36..722bb92 100644
--- a/connectivity/source/drivers/mork/MDriver.hxx
+++ b/connectivity/source/drivers/mork/MDriver.hxx
@@ -25,6 +25,7 @@
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/weak.hxx"
#include "rtl/ustring.hxx"
@@ -57,6 +58,8 @@ public:
throw(css::uno::RuntimeException);
static css::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()
throw (css::uno::RuntimeException);
+
+ css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > getFactory(){return m_xFactory;}
private:
ProfileAccess* m_ProfileAccess;
@@ -93,6 +96,7 @@ private:
throw (css::uno::RuntimeException);
css::uno::Reference< css::uno::XComponentContext > context_;
+ css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xFactory;
};
} }
diff --git a/connectivity/source/drivers/mork/MStatement.cxx b/connectivity/source/drivers/mork/MStatement.cxx
index 669121f..9b23410 100644
--- a/connectivity/source/drivers/mork/MStatement.cxx
+++ b/connectivity/source/drivers/mork/MStatement.cxx
@@ -76,17 +76,13 @@ OCommonStatement::OCommonStatement(OConnection* _pConnection )
,OCommonStatement_SBASE((::cppu::OWeakObject*)_pConnection, this)
,m_pTable(NULL)
,m_pConnection(_pConnection)
-// ,m_aParser(NULL)//_pConnection->getDriver()->getMSFactory())
- // TODO
+ ,m_aParser(_pConnection->getDriver()->getFactory())
+ ,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) )
,rBHelper(OCommonStatement_IBASE::rBHelper)
{
SAL_INFO("connectivity.mork", "=> OCommonStatement::OCommonStatement()" );
m_xDBMetaData = _pConnection->getMetaData();
-
m_pParseTree = NULL;
-
- //m_pSQLIterator = ( new OSQLParseTreeIterator( _pConnection, _pConnection->getMorkDriver()->getTables(), m_aParser, NULL ) )
-
m_pConnection->acquire();
}
@@ -194,11 +190,10 @@ OCommonStatement::StatementType OCommonStatement::parseSql( const ::rtl::OUStrin
throw ( SQLException, RuntimeException )
{
SAL_INFO("connectivity.mork", "=> OCommonStatement::parseSql()" );
- SAL_WARN("connectivity.mork", "m_aParser is not set!");
::rtl::OUString aErr;
- m_pParseTree = NULL;//m_aParser.parseTree(aErr,sql);
+ m_pParseTree = m_aParser.parseTree(aErr,sql);
#if OSL_DEBUG_LEVEL > 0
{
diff --git a/connectivity/source/drivers/mork/MStatement.hxx b/connectivity/source/drivers/mork/MStatement.hxx
index 212b8e1..8fb3c08 100644
--- a/connectivity/source/drivers/mork/MStatement.hxx
+++ b/connectivity/source/drivers/mork/MStatement.hxx
@@ -82,7 +82,7 @@ namespace connectivity
OValueRow m_aRow;
-// connectivity::OSQLParser m_aParser;
+ connectivity::OSQLParser m_aParser;
::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >
m_pSQLIterator;
diff --git a/connectivity/source/drivers/mork/MTables.cxx b/connectivity/source/drivers/mork/MTables.cxx
new file mode 100644
index 0000000..725f665
--- /dev/null
+++ b/connectivity/source/drivers/mork/MTables.cxx
@@ -0,0 +1,86 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "MTables.hxx"
+#include "MTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "MCatalog.hxx"
+#include "MConnection.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::mork;
+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 dbtools;
+
+sdbcx::ObjectType OTables::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("%"));
+
+ 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
+ {
+ OTable* pRet = new OTable( this, static_cast<OCatalog&>(m_rParent).getConnection(),
+ aName,xRow->getString(4),xRow->getString(5));
+ xRet = pRet;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MTables.hxx b/connectivity/source/drivers/mork/MTables.hxx
new file mode 100644
index 0000000..440f954
--- /dev/null
+++ b/connectivity/source/drivers/mork/MTables.hxx
@@ -0,0 +1,48 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _CONNECTIVITY_MOZAB_TABLES_HXX_
+#define _CONNECTIVITY_MOZAB_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace mork
+ {
+ class OTables : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ // OCatalog* m_pParent;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OTables(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)
+ {}
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_TABLES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list