summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/flat
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/flat')
-rw-r--r--connectivity/source/drivers/flat/ECatalog.cxx75
-rw-r--r--connectivity/source/drivers/flat/EColumns.cxx56
-rw-r--r--connectivity/source/drivers/flat/EConnection.cxx181
-rw-r--r--connectivity/source/drivers/flat/EDatabaseMetaData.cxx267
-rw-r--r--connectivity/source/drivers/flat/EDriver.cxx145
-rw-r--r--connectivity/source/drivers/flat/EPreparedStatement.cxx46
-rw-r--r--connectivity/source/drivers/flat/EResultSet.cxx189
-rw-r--r--connectivity/source/drivers/flat/EStatement.cxx43
-rw-r--r--connectivity/source/drivers/flat/ETable.cxx844
-rw-r--r--connectivity/source/drivers/flat/ETables.cxx62
-rw-r--r--connectivity/source/drivers/flat/Eservices.cxx175
-rw-r--r--connectivity/source/drivers/flat/exports.dxp3
-rw-r--r--connectivity/source/drivers/flat/flat.mxp.map141
-rwxr-xr-xconnectivity/source/drivers/flat/flat.xcu110
-rw-r--r--connectivity/source/drivers/flat/flat.xml33
-rw-r--r--connectivity/source/drivers/flat/makefile.mk107
16 files changed, 2477 insertions, 0 deletions
diff --git a/connectivity/source/drivers/flat/ECatalog.cxx b/connectivity/source/drivers/flat/ECatalog.cxx
new file mode 100644
index 000000000000..2e498cc45b29
--- /dev/null
+++ b/connectivity/source/drivers/flat/ECatalog.cxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * 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 "flat/ECatalog.hxx"
+
+#ifndef _CONNECTIVITY_FLAT_DCONNECTION_HXX_
+#include "flat/EConnection.hxx"
+#endif
+#include "flat/ETables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+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 connectivity::flat;
+// -------------------------------------------------------------------------
+OFlatCatalog::OFlatCatalog(OFlatConnection* _pCon) : file::OFileCatalog(_pCon)
+{
+}
+// -------------------------------------------------------------------------
+void OFlatCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(3));
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OFlatTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/flat/EColumns.cxx b/connectivity/source/drivers/flat/EColumns.cxx
new file mode 100644
index 000000000000..29ac131dd21b
--- /dev/null
+++ b/connectivity/source/drivers/flat/EColumns.cxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * 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 "flat/EColumns.hxx"
+#include "flat/ETable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::flat;
+using namespace connectivity;
+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;
+
+
+sdbcx::ObjectType OFlatColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ OFlatTable* pTable = (OFlatTable*)m_pTable;
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+ OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
+ sdbcx::ObjectType xRet;
+ if(aIter != aCols->get().end())
+ xRet = sdbcx::ObjectType(*aIter,UNO_QUERY);
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/flat/EConnection.cxx b/connectivity/source/drivers/flat/EConnection.cxx
new file mode 100644
index 000000000000..c9cec7b5ee10
--- /dev/null
+++ b/connectivity/source/drivers/flat/EConnection.cxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * 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 "flat/EConnection.hxx"
+#include "flat/EDatabaseMetaData.hxx"
+#include "flat/ECatalog.hxx"
+#ifndef _CONNECTIVITY_FLAT_ODRIVER_HXX_
+#include "flat/EDriver.hxx"
+#endif
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <tools/urlobj.hxx>
+#include "flat/EPreparedStatement.hxx"
+#ifndef _CONNECTIVITY_FLAT_DSTATEMENT_HXX_
+#include "flat/EStatement.hxx"
+#endif
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+
+typedef connectivity::file::OConnection OConnection_B;
+
+//------------------------------------------------------------------------------
+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::lang;
+
+// --------------------------------------------------------------------------------
+OFlatConnection::OFlatConnection(ODriver* _pDriver) : OConnection(_pDriver)
+ ,m_bHeaderLine(sal_True)
+ ,m_cFieldDelimiter(';')
+ ,m_cStringDelimiter('"')
+ ,m_cDecimalDelimiter(',')
+ ,m_cThousandDelimiter('.')
+{
+}
+//-----------------------------------------------------------------------------
+OFlatConnection::~OFlatConnection()
+{
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OFlatConnection, "com.sun.star.sdbc.drivers.flat.Connection", "com.sun.star.sdbc.Connection")
+
+//-----------------------------------------------------------------------------
+void OFlatConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ ::rtl::OUString aExt;
+ const PropertyValue *pBegin = info.getConstArray();
+ const PropertyValue *pEnd = pBegin + info.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!pBegin->Name.compareToAscii("HeaderLine"))
+ OSL_VERIFY( pBegin->Value >>= m_bHeaderLine );
+ else if(!pBegin->Name.compareToAscii("FieldDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cFieldDelimiter = aVal.toChar();
+ }
+ else if(!pBegin->Name.compareToAscii("StringDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cStringDelimiter = aVal.toChar();
+ }
+ else if(!pBegin->Name.compareToAscii("DecimalDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cDecimalDelimiter = aVal.toChar();
+ }
+ else if(!pBegin->Name.compareToAscii("ThousandDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cThousandDelimiter = aVal.toChar();
+ }
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+ OConnection::construct(url,info);
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OFlatConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OFlatDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Reference< XTablesSupplier > OFlatConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ OFlatCatalog *pCat = new OFlatCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OFlatConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+ OFlatStatement* pStmt = new OFlatStatement(this);
+
+ Reference< XStatement > xStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OFlatConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+
+ OFlatPreparedStatement* pStmt = new OFlatPreparedStatement(this);
+ Reference< XPreparedStatement > xStmt = pStmt;
+ pStmt->construct(sql);
+
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OFlatConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+
+
diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
new file mode 100644
index 000000000000..5b01ac3396ef
--- /dev/null
+++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * 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 "flat/EDatabaseMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <tools/urlobj.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace connectivity::flat;
+// using namespace connectivity::file;
+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;
+
+
+
+OFlatDatabaseMetaData::OFlatDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::OFlatDatabaseMetaData" );
+}
+// -------------------------------------------------------------------------
+OFlatDatabaseMetaData::~OFlatDatabaseMetaData()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::~OFlatDatabaseMetaData" );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::impl_getTypeInfo_throw" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR")));
+ aRow.push_back(new ORowSetValueDecorator(DataType::CHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)254));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)65535);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DATE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)10);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIME);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)8);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)19);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::BIT);
+ aRow[3] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC"));
+ aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)20);
+ aRows.push_back(aRow);
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::getColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
+ const ::rtl::OUString* pTabBegin = aTabNames.getConstArray();
+ const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength();
+ for(;pTabBegin != pTabEnd;++pTabBegin)
+ {
+ if(match(tableNamePattern,*pTabBegin,'\0'))
+ {
+ Reference< XColumnsSupplier> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin));
+ aRow[3] = new ORowSetValueDecorator(*pTabBegin);
+
+ Reference< XNameAccess> xColumns = xTable->getColumns();
+ if(!xColumns.is())
+ throw SQLException();
+
+ Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i)
+ {
+ if(match(columnNamePattern,*pBegin,'\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(*pBegin);
+
+ ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin));
+ OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
+ aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
+ aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))));
+ aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))));
+ aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
+ aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))));
+ aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))));
+
+ switch((sal_Int32)aRow[5]->getValue())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)254);
+ break;
+ case DataType::LONGVARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)65535);
+ break;
+ default:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)0);
+ }
+ aRow[17] = new ORowSetValueDecorator(i);
+ switch(sal_Int32(aRow[11]->getValue()))
+ {
+ case ColumnValue::NO_NULLS:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ break;
+ case ColumnValue::NULLABLE:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+ break;
+ default:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString());
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFlatDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::getURL" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:flat:")) + m_pConnection->getURL();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/flat/EDriver.cxx b/connectivity/source/drivers/flat/EDriver.cxx
new file mode 100644
index 000000000000..9aab07bee74f
--- /dev/null
+++ b/connectivity/source/drivers/flat/EDriver.cxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * 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 "flat/EDriver.hxx"
+#include "flat/EConnection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/sequence.hxx>
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+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::lang;
+
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.flat.ODriver");
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::flat::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ODriver(_rxFactory));
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ OFlatConnection* pCon = new OFlatConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return url.compareTo(::rtl::OUString::createFromAscii("sdbc:flat:"),10) == 0;
+}
+// -----------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ Sequence< ::rtl::OUString > aBoolean(2);
+ aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
+ aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Field separator."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text contains headers."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text separator."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Decimal separator."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Thousands separator."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ return ::comphelper::concatSequences(OFileDriver::getPropertyInfo(url,info ),
+ Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()));
+ }
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/flat/EPreparedStatement.cxx b/connectivity/source/drivers/flat/EPreparedStatement.cxx
new file mode 100644
index 000000000000..2ddead6acfc0
--- /dev/null
+++ b/connectivity/source/drivers/flat/EPreparedStatement.cxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_FLAT_EPREPAREDSTATEMENT_HXX_
+#include "flat/EPreparedStatement.hxx"
+#endif
+#include "flat/EResultSet.hxx"
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OFlatPreparedStatement::createResultSet()
+{
+ return new OFlatResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OFlatPreparedStatement,"com.sun.star.sdbc.driver.flat.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
diff --git a/connectivity/source/drivers/flat/EResultSet.cxx b/connectivity/source/drivers/flat/EResultSet.cxx
new file mode 100644
index 000000000000..c4833f310d62
--- /dev/null
+++ b/connectivity/source/drivers/flat/EResultSet.cxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include "flat/EResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+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::container;
+// using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OFlatResultSet::OFlatResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(sal_True)
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFlatResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.flat.ResultSet");
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OFlatResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OFlatResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if(rType == ::getCppuType((const Reference<XDeleteRows>*)0) || rType == ::getCppuType((const Reference<XResultSetUpdate>*)0)
+ || rType == ::getCppuType((const Reference<XRowUpdate>*)0))
+ return Any();
+
+ const Any aRet = OResultSet::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OFlatResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OFlatResultSet::getTypes( ) throw( RuntimeException)
+{
+ Sequence< Type > aTypes = OResultSet::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XDeleteRows>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XResultSetUpdate>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRowUpdate>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ Sequence< Type > aRet(pTypes, aOwnTypes.size());
+ return ::comphelper::concatSequences(aRet,OFlatResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OFlatResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False);
+
+ return relative(rows);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFlatResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException)
+{
+ return (lhs == rhs) ? 0 : 2;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFlatResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ return comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OFlatResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OFlatResultSet::getInfoHelper()
+{
+ return *OFlatResultSet_BASE3::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFlatResultSet::acquire() throw()
+{
+ OFlatResultSet_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFlatResultSet::release() throw()
+{
+ OFlatResultSet_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OFlatResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/flat/EStatement.cxx b/connectivity/source/drivers/flat/EStatement.cxx
new file mode 100644
index 000000000000..e3dfcd686aa7
--- /dev/null
+++ b/connectivity/source/drivers/flat/EStatement.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * 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 "flat/EStatement.hxx"
+#include "flat/EResultSet.hxx"
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OFlatStatement::createResultSet()
+{
+ return new OFlatResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OFlatStatement,"com.sun.star.sdbc.driver.flat.Statement","com.sun.star.sdbc.Statement");
+
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
new file mode 100644
index 000000000000..2d46c3be5bf3
--- /dev/null
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -0,0 +1,844 @@
+/*************************************************************************
+ *
+ * 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 <ctype.h>
+#include "flat/ETable.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <svl/converter.hxx>
+#include "flat/EConnection.hxx"
+#include "flat/EColumns.hxx"
+#include <osl/thread.h>
+#include <tools/config.hxx>
+#include <comphelper/sequence.hxx>
+#include <svl/zforlist.hxx>
+#include <rtl/math.hxx>
+#include <stdio.h> //sprintf
+#include <comphelper/extract.hxx>
+#include <comphelper/numbers.hxx>
+#include "flat/EDriver.hxx"
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <unotools/configmgr.hxx>
+#include <i18npool/mslangid.hxx>
+#include "connectivity/dbconversion.hxx"
+#include <comphelper/types.hxx>
+#include "file/quotedstring.hxx"
+#include <unotools/syslocale.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+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;
+
+// -------------------------------------------------------------------------
+void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::fillColumns" );
+ BOOL bRead = TRUE;
+
+ QuotedTokenizedString aHeaderLine;
+ OFlatConnection* pConnection = (OFlatConnection*)m_pConnection;
+ const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding();
+ const sal_Bool bHasHeaderLine = pConnection->isHeaderLine();
+ if ( bHasHeaderLine )
+ {
+ while(bRead && !aHeaderLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aHeaderLine,nEncoding);
+ }
+ m_nStartRowFilePos = m_pFileStream->Tell();
+ }
+
+ // read first row
+ QuotedTokenizedString aFirstLine;
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding);
+
+ if ( !bHasHeaderLine || !aHeaderLine.Len())
+ {
+ while(bRead && !aFirstLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding);
+ }
+ // use first row as headerline because we need the number of columns
+ aHeaderLine = aFirstLine;
+ }
+ // column count
+ const xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(m_cFieldDelimiter,m_cStringDelimiter);
+
+ if(!m_aColumns.isValid())
+ m_aColumns = new OSQLColumns();
+ else
+ m_aColumns->get().clear();
+
+ m_aTypes.clear();
+ m_aPrecisions.clear();
+ m_aScales.clear();
+ // reserve some space
+ m_aColumns->get().reserve(nFieldCount+1);
+ m_aTypes.reserve(nFieldCount+1);
+ m_aPrecisions.reserve(nFieldCount+1);
+ m_aScales.reserve(nFieldCount+1);
+
+ const sal_Bool bCase = m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale);
+ // read description
+ const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ String aColumnName;
+ ::rtl::OUString aTypeName;
+ ::comphelper::UStringMixEqual aCase(bCase);
+ xub_StrLen nStartPosHeaderLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine2 = 0;
+ for (xub_StrLen i = 0; i < nFieldCount; i++)
+ {
+ if ( bHasHeaderLine )
+ {
+ aHeaderLine.GetTokenSpecial(aColumnName,nStartPosHeaderLine,m_cFieldDelimiter,m_cStringDelimiter);
+ if ( !aColumnName.Len() )
+ {
+ aColumnName = 'C';
+ aColumnName += String::CreateFromInt32(i+1);
+ }
+ }
+ else
+ {
+ // no column name so ...
+ aColumnName = 'C';
+ aColumnName += String::CreateFromInt32(i+1);
+ }
+ sal_Int32 eType;
+ UINT16 nPrecision = 0;
+ UINT16 nScale = 0;
+
+ BOOL bNumeric = FALSE;
+ ULONG nIndex = 0;
+
+ // first without fielddelimiter
+ String aField;
+ aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,m_cFieldDelimiter,'\0');
+ if (aField.Len() == 0 ||
+ (m_cStringDelimiter && m_cStringDelimiter == aField.GetChar(0)))
+ {
+ bNumeric = FALSE;
+ nStartPosFirstLine2 = nStartPosFirstLine;
+ }
+ else
+ {
+ String aField2;
+ if ( m_cStringDelimiter != '\0' )
+ aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter);
+ else
+ aField2 = aField;
+
+ if (aField2.Len() == 0)
+ {
+ bNumeric = FALSE;
+ }
+ else
+ {
+ bNumeric = TRUE;
+ xub_StrLen nDot = 0;
+ xub_StrLen nDecimalDelCount = 0;
+ for (xub_StrLen j = 0; j < aField2.Len(); j++)
+ {
+ const sal_Unicode c = aField2.GetChar(j);
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if ( ( !cDecimalDelimiter || c != cDecimalDelimiter ) &&
+ ( !cThousandDelimiter || c != cThousandDelimiter ) &&
+ !aCharClass.isDigit(aField2,j) &&
+ ( j != 0 || (c != '+' && c != '-' ) ) )
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ if (cDecimalDelimiter && c == cDecimalDelimiter)
+ {
+ nPrecision = 15; // we have an decimal value
+ nScale = 2;
+ ++nDecimalDelCount;
+ } // if (cDecimalDelimiter && c == cDecimalDelimiter)
+ if ( c == '.' )
+ ++nDot;
+ }
+
+ if (nDecimalDelCount > 1 || nDot > 1 ) // if there is more than one dot it isn't a number
+ bNumeric = FALSE;
+ if (bNumeric && cThousandDelimiter)
+ {
+ // Ist der Trenner richtig angegeben?
+ const String aValue = aField2.GetToken(0,cDecimalDelimiter);
+ for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4)
+ {
+ const sal_Unicode c = aValue.GetChar(static_cast<sal_uInt16>(j));
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if (c == cThousandDelimiter && j)
+ continue;
+ else
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ }
+ }
+
+ // jetzt koennte es noch ein Datumsfeld sein
+ if (!bNumeric)
+ {
+ try
+ {
+ nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ }
+
+ sal_Int32 nFlags = 0;
+ if (bNumeric)
+ {
+ if (cDecimalDelimiter)
+ {
+ if(nPrecision)
+ {
+ eType = DataType::DECIMAL;
+ static const ::rtl::OUString s_sDECIMAL(RTL_CONSTASCII_USTRINGPARAM("DECIMAL"));
+ aTypeName = s_sDECIMAL;
+ }
+ else
+ {
+ eType = DataType::DOUBLE;
+ static const ::rtl::OUString s_sDOUBLE(RTL_CONSTASCII_USTRINGPARAM("DOUBLE"));
+ aTypeName = s_sDOUBLE;
+ }
+ }
+ else
+ eType = DataType::INTEGER;
+ nFlags = ColumnSearch::BASIC;
+ }
+ else
+ {
+
+ switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex))
+ {
+ case NUMBERFORMAT_DATE:
+ eType = DataType::DATE;
+ {
+ static const ::rtl::OUString s_sDATE(RTL_CONSTASCII_USTRINGPARAM("DATE"));
+ aTypeName = s_sDATE;
+ }
+ break;
+ case NUMBERFORMAT_DATETIME:
+ eType = DataType::TIMESTAMP;
+ {
+ static const ::rtl::OUString s_sTIMESTAMP(RTL_CONSTASCII_USTRINGPARAM("TIMESTAMP"));
+ aTypeName = s_sTIMESTAMP;
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ eType = DataType::TIME;
+ {
+ static const ::rtl::OUString s_sTIME(RTL_CONSTASCII_USTRINGPARAM("TIME"));
+ aTypeName = s_sTIME;
+ }
+ break;
+ default:
+ eType = DataType::VARCHAR;
+ nPrecision = 0; // nyi: Daten koennen aber laenger sein!
+ nScale = 0;
+ {
+ static const ::rtl::OUString s_sVARCHAR(RTL_CONSTASCII_USTRINGPARAM("VARCHAR"));
+ aTypeName = s_sVARCHAR;
+ }
+ };
+ nFlags |= ColumnSearch::CHAR;
+ }
+
+ // check if the columname already exists
+ String aAlias(aColumnName);
+ OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ sal_Int32 nExprCnt = 0;
+ while(aFind != m_aColumns->get().end())
+ {
+ (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt);
+ aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ }
+
+ sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(),
+ ColumnValue::NULLABLE,
+ nPrecision,
+ nScale,
+ eType,
+ sal_False,
+ sal_False,
+ sal_False,
+ bCase);
+ Reference< XPropertySet> xCol = pColumn;
+ m_aColumns->get().push_back(xCol);
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(nScale);
+ }
+ m_pFileStream->Seek(m_nStartRowFilePos);
+}
+// -------------------------------------------------------------------------
+OFlatTable::OFlatTable(sdbcx::OCollection* _pTables,OFlatConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OFlatTable_BASE(_pTables,_pConnection,_Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_nStartRowFilePos(0)
+ ,m_nRowPos(0)
+ ,m_nMaxRowCount(0)
+ ,m_cStringDelimiter(_pConnection->getStringDelimiter())
+ ,m_cFieldDelimiter(_pConnection->getFieldDelimiter())
+ ,m_bNeedToReadLine(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::OFlatTable" );
+
+}
+// -----------------------------------------------------------------------------
+void OFlatTable::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::construct" );
+ SvtSysLocale aLocale;
+ ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale());
+ Sequence< ::com::sun::star::uno::Any > aArg(1);
+ aArg[0] <<= aAppLocale;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY);
+ m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY);
+ m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier);
+ Reference<XPropertySet> xProp(xSupplier->getNumberFormatSettings(),UNO_QUERY);
+ xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= m_aNullDate;
+
+ INetURLObject aURL;
+ aURL.SetURL(getEntry());
+
+ if(aURL.getExtension() != rtl::OUString(m_pConnection->getExtension()))
+ aURL.setExtension(m_pConnection->getExtension());
+
+ String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+
+ if(!m_pFileStream)
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+
+ if(m_pFileStream)
+ {
+ m_pFileStream->Seek(STREAM_SEEK_TO_END);
+ sal_Int32 nSize = m_pFileStream->Tell();
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ // Buffersize abhaengig von der Filegroesse
+ m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
+ nSize > 100000 ? 16384 :
+ nSize > 10000 ? 4096 : 1024);
+
+ fillColumns(aAppLocale);
+
+ refreshColumns();
+ }
+}
+// -------------------------------------------------------------------------
+String OFlatTable::getEntry()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::getEntry" );
+ ::rtl::OUString sURL;
+ try
+ {
+ Reference< XResultSet > xDir = m_pConnection->getDir()->getStaticResultSet();
+ Reference< XRow> xRow(xDir,UNO_QUERY);
+ ::rtl::OUString sName;
+ ::rtl::OUString sExt;
+
+ INetURLObject aURL;
+ xDir->beforeFirst();
+ static const ::rtl::OUString s_sSeparator(RTL_CONSTASCII_USTRINGPARAM("/"));
+ while(xDir->next())
+ {
+ sName = xRow->getString(1);
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String sUrl = m_pConnection->getURL() + s_sSeparator + sName;
+ aURL.SetSmartURL( sUrl );
+
+ // cut the extension
+ sExt = aURL.getExtension();
+
+ // name and extension have to coincide
+ if ( m_pConnection->matchesExtension( sExt ) )
+ {
+ sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString());
+ if ( sName == m_Name )
+ {
+ Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY );
+ sURL = xContentAccess->queryContentIdentifierString();
+ break;
+ }
+ }
+ }
+ xDir->beforeFirst(); // move back to before first record
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT(0);
+ }
+ return sURL.getStr();
+}
+// -------------------------------------------------------------------------
+void OFlatTable::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::refreshColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TStringVector aVector;
+ aVector.reserve(m_aColumns->get().size());
+
+ for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter)
+ aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OFlatColumns(this,m_aMutex,aVector);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OFlatTable::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::disposing" );
+ OFileTable::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aColumns = NULL;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OFlatTable::getTypes( ) throw(RuntimeException)
+{
+ Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRename>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OFlatTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ Any aRet = OTable_TYPEDEF::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OFlatTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OFlatTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OFlatTable_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+sal_Bool OFlatTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::fetchRow" );
+ *(_rRow->get())[0] = m_nFilePos;
+
+ if (!bRetrieveData)
+ return TRUE;
+ if ( m_bNeedToReadLine )
+ {
+ sal_Int32 nCurrentPos = 0;
+ m_pFileStream->Seek(m_nFilePos);
+ readLine(nCurrentPos);
+ m_bNeedToReadLine = false;
+ }
+
+ OFlatConnection* pConnection = (OFlatConnection*)m_pConnection;
+ const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ // Felder:
+ xub_StrLen nStartPos = 0;
+ String aStr;
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end();
+ const OValueRefVector::Vector::size_type nCount = _rRow->get().size();
+ for (OValueRefVector::Vector::size_type i = 1; aIter != aEnd && i < nCount;
+ ++aIter, i++)
+ {
+ m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,m_cFieldDelimiter,m_cStringDelimiter);
+
+ if (aStr.Len() == 0)
+ (_rRow->get())[i]->setNull();
+ else
+ {
+ // Laengen je nach Datentyp:
+ sal_Int32 nLen,
+ nType = 0;
+ if(bIsTable)
+ {
+ nLen = m_aPrecisions[i-1];
+ nType = m_aTypes[i-1];
+ }
+ else
+ {
+ Reference< XPropertySet> xColumn = *aIter;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ }
+ switch(nType)
+ {
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::TIME:
+ {
+ try
+ {
+ double nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr);
+
+ switch(nType)
+ {
+ case DataType::DATE:
+ *(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,m_aNullDate));
+ break;
+ case DataType::TIMESTAMP:
+ *(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,m_aNullDate));
+ break;
+ default:
+ *(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes));
+ }
+ }
+ catch(Exception&)
+ {
+ (_rRow->get())[i]->setNull();
+ }
+ } break;
+ case DataType::DOUBLE:
+ case DataType::INTEGER:
+ case DataType::DECIMAL: // #99178# OJ
+ case DataType::NUMERIC:
+ {
+
+ String aStrConverted;
+ if ( DataType::INTEGER != nType )
+ {
+ sal_Unicode* pData = aStrConverted.AllocBuffer(aStr.Len());
+ const sal_Unicode* pStart = pData;
+
+ OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER ||
+ !cDecimalDelimiter && nType == DataType::INTEGER,
+ "FalscherTyp");
+
+ // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln:
+ for (xub_StrLen j = 0; j < aStr.Len(); ++j)
+ {
+ const sal_Unicode cChar = aStr.GetChar(j);
+ if (cDecimalDelimiter && cChar == cDecimalDelimiter)
+ *pData++ = '.';
+ //aStrConverted.Append( '.' );
+ else if ( cChar == '.' ) // special case, if decimal seperator isn't '.' we have to put the string after it
+ continue; // #99189# OJ
+ else if (cThousandDelimiter && cChar == cThousandDelimiter)
+ {
+ // weglassen
+ }
+ else
+ *pData++ = cChar;
+ //aStrConverted.Append(cChar);
+ } // for (xub_StrLen j = 0; j < aStr.Len(); ++j)
+ aStrConverted.ReleaseBufferAccess(xub_StrLen(pData - pStart));
+ } // if ( DataType::INTEGER != nType )
+ else
+ {
+ aStrConverted = aStr;
+ if ( cThousandDelimiter )
+ aStrConverted.EraseAllChars(cThousandDelimiter);
+ }
+ const double nVal = ::rtl::math::stringToDouble(aStrConverted,'.',',',NULL,NULL);
+
+ // #99178# OJ
+ if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType )
+ *(_rRow->get())[i] = ::rtl::OUString::valueOf(nVal);
+ else
+ *(_rRow->get())[i] = nVal;
+ } break;
+
+ default:
+ {
+ // Wert als String in Variable der Row uebernehmen
+ *(_rRow->get())[i] = ORowSetValue(aStr);
+ }
+ break;
+ } // switch(nType)
+ (_rRow->get())[i]->setTypeKind(nType);
+ }
+ }
+ return sal_True;
+}
+void OFlatTable::refreshHeader()
+{
+ m_nRowPos = 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::seekRow" );
+ OSL_ENSURE(m_pFileStream,"OFlatTable::seekRow: FileStream is NULL!");
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 0;
+ // run through
+ case IResultSetHelper::NEXT:
+ {
+ ++m_nRowPos;
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::const_iterator aFind = m_aRowPosToFilePos.find(m_nRowPos);
+ m_bNeedToReadLine = aFind != m_aRowPosToFilePos.end();
+ if ( m_bNeedToReadLine )
+ {
+ m_nFilePos = aFind->second->first;
+ nCurPos = aFind->second->second;
+ } // if ( m_bNeedToReadLine )
+ else
+ {
+ if ( m_nRowPos == 1 )
+ m_nFilePos = m_nStartRowFilePos;
+ m_pFileStream->Seek(m_nFilePos);
+ if ( m_pFileStream->IsEof() || !readLine(nCurPos) /*|| !checkHeaderLine()*/)
+ {
+ m_nMaxRowCount = m_nRowPos -1;
+ return sal_False;
+ } // if ( m_pFileStream->IsEof() || !readLine(nCurPos) /*|| !checkHeaderLine()*/)
+
+ TRowPositionsInFile::iterator aPos = m_aFilePosToEndLinePos.insert(TRowPositionsInFile::value_type(m_nFilePos,nCurPos)).first;
+ m_aRowPosToFilePos.insert(::std::map<sal_Int32,TRowPositionsInFile::iterator>::value_type(m_nRowPos,aPos));
+ }
+ }
+
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ if(m_nRowPos > 0)
+ {
+ TRowPositionsInFile::iterator aPositions = m_aRowPosToFilePos[m_nRowPos];
+ m_nFilePos = aPositions->first;
+ nCurPos = aPositions->second;
+ m_bNeedToReadLine = true;
+ }
+ else
+ m_nRowPos = 0;
+
+ break;
+ case IResultSetHelper::LAST:
+ if ( m_nMaxRowCount )
+ {
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::reverse_iterator aLastPos = m_aRowPosToFilePos.rbegin();
+ m_nRowPos = aLastPos->first;
+ m_nFilePos = aLastPos->second->first;
+ nCurPos = aLastPos->second->second;
+
+ //m_pFileStream->Seek(m_nFilePos);
+ m_bNeedToReadLine = true;
+ //if ( m_pFileStream->IsEof() /*|| !checkHeaderLine()*/ || !readLine(nCurPos) )
+ // return sal_False;
+ }
+ else
+ {
+ while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row
+ // now I know all
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::RELATIVE:
+ if(nOffset > 0)
+ {
+ for(sal_Int32 i = 0;i<nOffset;++i)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else if(nOffset < 0)
+ {
+ for(sal_Int32 i = nOffset;i;++i)
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ {
+ if(nOffset < 0)
+ nOffset = m_nRowPos + nOffset;
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::const_iterator aIter = m_aRowPosToFilePos.find(nOffset);
+ if(aIter != m_aRowPosToFilePos.end())
+ {
+ m_nFilePos = aIter->second->first;
+ nCurPos = aIter->second->second;
+ //m_pFileStream->Seek(m_nFilePos);
+ m_bNeedToReadLine = true;
+ //if ( m_pFileStream->IsEof() /*|| !checkHeaderLine()*/ || !readLine(nCurPos) )
+ // return sal_False;
+ }
+ else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table
+ {
+ m_nRowPos = m_nMaxRowCount;
+ return sal_False;
+ }
+ else
+ {
+ aIter = m_aRowPosToFilePos.upper_bound(nOffset);
+ if(aIter == m_aRowPosToFilePos.end())
+ {
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::reverse_iterator aLastPos = m_aRowPosToFilePos.rbegin();
+ m_nRowPos = aLastPos->first;
+ nCurPos = m_nFilePos = aLastPos->second->first;
+ while(m_nRowPos != nOffset)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else
+ {
+ --aIter;
+ m_nRowPos = aIter->first;
+ m_nFilePos = aIter->second->first;
+ nCurPos = aIter->second->second;
+ //m_pFileStream->Seek(m_nFilePos);
+ m_bNeedToReadLine = true;
+ //if ( m_pFileStream->IsEof() /*|| !checkHeaderLine()*/ || !readLine(nCurPos) )
+ // return sal_False;
+ }
+ }
+ }
+
+ break;
+ case IResultSetHelper::BOOKMARK:
+ {
+ TRowPositionsInFile::const_iterator aFind = m_aFilePosToEndLinePos.find(nOffset);
+ m_bNeedToReadLine = aFind != m_aFilePosToEndLinePos.end();
+ if ( m_bNeedToReadLine )
+ {
+ m_nFilePos = aFind->first;
+ nCurPos = aFind->second;
+ }
+ else
+ {
+ m_nFilePos = nOffset;
+ m_pFileStream->Seek(nOffset);
+ if (m_pFileStream->IsEof() || !readLine(nCurPos) )
+ return sal_False;
+ }
+ break;
+ }
+ }
+
+ //nCurPos = m_nFilePos;
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFlatTable::readLine(sal_Int32& _rnCurrentPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::readLine" );
+ const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding();
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,nEncoding);
+ if (m_pFileStream->IsEof())
+ return sal_False;
+
+ QuotedTokenizedString sLine = m_aCurrentLine; // check if the string continues on next line
+ while( (sLine.GetString().GetTokenCount(m_cStringDelimiter) % 2) != 1 )
+ {
+ m_pFileStream->ReadByteStringLine(sLine,nEncoding);
+ if ( !m_pFileStream->IsEof() )
+ {
+ m_aCurrentLine.GetString().Append('\n');
+ m_aCurrentLine.GetString() += sLine.GetString();
+ sLine = m_aCurrentLine;
+ }
+ else
+ break;
+ }
+ _rnCurrentPos = m_pFileStream->Tell();
+ return sal_True;
+}
+
diff --git a/connectivity/source/drivers/flat/ETables.cxx b/connectivity/source/drivers/flat/ETables.cxx
new file mode 100644
index 000000000000..6b795a08957d
--- /dev/null
+++ b/connectivity/source/drivers/flat/ETables.cxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * 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 "flat/ETables.hxx"
+#include "flat/ETable.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 "file/FCatalog.hxx"
+#include "file/FConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace connectivity::flat;
+using namespace connectivity::file;
+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::lang;
+using namespace ::com::sun::star::container;
+namespace starutil = ::com::sun::star::util;
+
+sdbcx::ObjectType OFlatTables::createObject(const ::rtl::OUString& _rName)
+{
+ OFlatTable* pRet = new OFlatTable(this,(OFlatConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
+ _rName,::rtl::OUString::createFromAscii("TABLE"));
+ sdbcx::ObjectType xRet = pRet;
+ pRet->construct();
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/flat/Eservices.cxx b/connectivity/source/drivers/flat/Eservices.cxx
new file mode 100644
index 000000000000..a0445c1ca70f
--- /dev/null
+++ b/connectivity/source/drivers/flat/Eservices.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * 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 "flat/EDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::flat;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+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 ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/flat/exports.dxp b/connectivity/source/drivers/flat/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/flat/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/flat/flat.mxp.map b/connectivity/source/drivers/flat/flat.mxp.map
new file mode 100644
index 000000000000..54a8532f7840
--- /dev/null
+++ b/connectivity/source/drivers/flat/flat.mxp.map
@@ -0,0 +1,141 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___builtin_vec_delete
+___builtin_vec_new
+___check_eh_spec
+___cp_pop_exception
+___cp_push_exception
+___eh_alloc
+___get_eh_context
+___pure_virtual
+___rtti_class
+___rtti_si
+___rtti_user
+___sjthrow
+___start_cp_handler
+___terminate
+_terminate__Fv
+dyld_stub_binding_helper
+rest_world
+save_world
+___eh_rtime_match
+___builtin_new
+___tf9bad_alloc
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_get_per_thread_data
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+___vt_9exception
+_what__C9exception
+__._9bad_alloc
+___vt_9bad_alloc
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+__._Q312connectivity4flat18UStringDescription
+___Q312connectivity4flat18UStringDescriptionPFv_PCc
+_getPropertySetInfo__Q312connectivity4flat14OFlatResultSet
+_release__Q312connectivity4flat14OFlatResultSet
+_acquire__Q312connectivity4flat14OFlatResultSet
+__._Q312connectivity4flat14OFlatResultSet
+__._Q312connectivity4flat14OFlatStatement
+__._Q312connectivity4flat22OFlatPreparedStatement
+__._Q312connectivity4flat10OFlatTable
+_toDouble__FRC10ByteString
+_checkHeaderLine__Q312connectivity4flat10OFlatTable
+_refreshColumns__Q312connectivity4flat10OFlatTable
+_AllocBuffer__Q312connectivity4flat10OFlatTable
+_fillColumns__Q312connectivity4flat10OFlatTable
+_getEntry__Q312connectivity4flat10OFlatTable
+_GetToken__CQ312connectivity4flat11OFlatStringUsUcUc
+_GetTokenCount__CQ312connectivity4flat11OFlatStringUcUc
+_refreshTables__Q312connectivity4flat12OFlatCatalog
+_getPropertySetInfo__Q312connectivity4file26ODatabaseMetaDataResultSet
+_release__Q312connectivity4file26ODatabaseMetaDataResultSet
+_acquire__Q312connectivity4file26ODatabaseMetaDataResultSet
+_getPropertySetInfo__Q312connectivity4file10OResultSet
+_release__Q312connectivity4file10OResultSet
+_acquire__Q312connectivity4file10OResultSet
+_scanParameter__Q312connectivity4file10OResultSetPQ212connectivity13OSQLParseNodeRQ24_STLt6vector2ZPB1ZQ24_STLt9allocator1ZPB1
+_AddParameter__Q312connectivity4file10OResultSetPQ212connectivity13OSQLParseNodeRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star5beans12XPropertySet
+_SetAssignValue__Q312connectivity4file10OResultSetRC6Stringn1UcUl
+_ParseAssignValues__Q312connectivity4file10OResultSetRCQ24_STLt6vector2Z6StringZQ24_STLt9allocator1ZB2PQ212connectivity13OSQLParseNodeUs
+_getUnoTunnelImplementationId__Q312connectivity4file10OResultSet
+_setOrderbyColumn__Q312connectivity4file10OResultSetUsPQ212connectivity13OSQLParseNoden1
+_CreateKeySet__Q312connectivity4file14OFILESortIndex
+___Q312connectivity4file14OFILESortIndexPCQ312connectivity4file8OKeyTypePCUclUs
+_anylizeSQL__Q312connectivity4file10OResultSet
+_GetAssignValues__Q312connectivity4file10OResultSet
+_moveAbsolute__Q312connectivity4file10OResultSetlUc
+_ExecuteRow__Q312connectivity4file10OResultSetQ412connectivity4file10OFileTable12FilePositionlUcn2
+_AddKeyValue__Q312connectivity4file14OFILESortIndexPQ312connectivity4file13OFILEKeyValue
+_GetOrderbyKeyValue__Q312connectivity4file10OResultSetGQ23vost4ORef1ZQ312connectivity4file12OValueVector
+_evaluate__Q312connectivity4file10OResultSet
+_SkipDeleted__Q312connectivity4file10OResultSetQ412connectivity4file10OFileTable12FilePositionlUc
+__._Q312connectivity4file14OFILESortIndex
+_construct__Q312connectivity4file10OResultSet
+_isCount__CQ312connectivity4file10OResultSet
+__._Q312connectivity4file18UStringDescription
+___Q312connectivity4file18UStringDescriptionPFv_PCc
+_disposing__Q312connectivity4file15OStatement_Base
+_acquire__Q312connectivity4file15OStatement_Base
+__._Q312connectivity4file16OStatement_BASE2
+__._Q312connectivity4file10OStatement
+_disposeResultSet__Q312connectivity4file15OStatement_Base
+_getImplementationName_Static__Q312connectivity4file11OFileDriver
+_operate__CQ312connectivity4file8OOp_LIKEPCQ312connectivity4file8OOperandn1
+_operate__CQ312connectivity4file10OOp_ISNULLPCQ312connectivity4file8OOperandn1
+_IsOf__Q312connectivity4file12ONumOperatorPFv_Pv
+_StaticType__Q312connectivity4file12ONumOperator
+_IsOf__Q312connectivity4file11OOp_COMPAREPFv_Pv
+_StaticType__Q312connectivity4file11OOp_COMPARE
+_IsOf__Q312connectivity4file11OOp_NOTLIKEPFv_Pv
+_StaticType__Q312connectivity4file11OOp_NOTLIKE
+_IsOf__Q312connectivity4file8OOp_LIKEPFv_Pv
+_StaticType__Q312connectivity4file8OOp_LIKE
+_IsOf__Q312connectivity4file13OOp_ISNOTNULLPFv_Pv
+_StaticType__Q312connectivity4file13OOp_ISNOTNULL
+_IsOf__Q312connectivity4file10OOp_ISNULLPFv_Pv
+_StaticType__Q312connectivity4file10OOp_ISNULL
+_IsOf__Q312connectivity4file6OOp_ORPFv_Pv
+_StaticType__Q312connectivity4file6OOp_OR
+_IsOf__Q312connectivity4file7OOp_ANDPFv_Pv
+_StaticType__Q312connectivity4file7OOp_AND
+_IsOf__Q312connectivity4file13OBoolOperatorPFv_Pv
+_IsOf__Q312connectivity4file9OOperatorPFv_Pv
+_IsOf__Q312connectivity4file14OOperandResultPFv_Pv
+_IsOf__Q312connectivity4file13OOperandConstPFv_Pv
+_IsOf__Q312connectivity4file13OOperandValuePFv_Pv
+_StaticType__Q312connectivity4file13OOperandValue
+_IsOf__Q312connectivity4file13OOperandParamPFv_Pv
+_IsOf__Q312connectivity4file16OFILEOperandAttrPFv_Pv
+_StaticType__Q312connectivity4file16OFILEOperandAttr
+_IsOf__Q312connectivity4file12OOperandAttrPFv_Pv
+_IsOf__Q312connectivity4file11OOperandRowPFv_Pv
+_StaticType__Q312connectivity4file11OOperandRow
+_IsOf__Q312connectivity4file8OOperandPFv_Pv
+_IsOf__Q312connectivity4file5OCodePFv_Pv
+_StaticType__Q312connectivity4file5OCode
+__._Q312connectivity4file5OCode
+_execute_Operand__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_ISNULL__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_LIKE__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_COMPARE__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/drivers/flat/flat.xcu b/connectivity/source/drivers/flat/flat.xcu
new file mode 100755
index 000000000000..d00d1f98c38c
--- /dev/null
+++ b/connectivity/source/drivers/flat/flat.xcu
@@ -0,0 +1,110 @@
+<?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:flat:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.flat.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Text</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="Extension" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="HeaderLine" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FieldDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>,</value>
+ </prop>
+ </node>
+ <node oor:name="StringDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>"</value>
+ </prop>
+ </node>
+ <node oor:name="DecimalDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>.</value>
+ </prop>
+ </node>
+ <node oor:name="ThousandDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="EnableSQL92Check" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FileSystemBased" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="MediaType" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>text/csv</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/flat/flat.xml b/connectivity/source/drivers/flat/flat.xml
new file mode 100644
index 000000000000..7af53b2c0dda
--- /dev/null
+++ b/connectivity/source/drivers/flat/flat.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>file</module-name>
+ <component-description>
+ <author>Ocke Jannsen</author>
+ <name>com.sun.star.comp.sdbc.flat.ODriver</name>
+ <description>This library implements the database driver for flat file 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>
+ <supported-service>com.sun.star.sdbcx.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>file</runtime-module-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/flat/makefile.mk b/connectivity/source/drivers/flat/makefile.mk
new file mode 100644
index 000000000000..2d1f99f759c7
--- /dev/null
+++ b/connectivity/source/drivers/flat/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# 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=flat
+
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/EResultSet.obj \
+ $(SLO)$/EStatement.obj \
+ $(SLO)$/EPreparedStatement.obj \
+ $(SLO)$/ETable.obj \
+ $(SLO)$/EDatabaseMetaData.obj \
+ $(SLO)$/ECatalog.obj \
+ $(SLO)$/EColumns.obj \
+ $(SLO)$/ETables.obj \
+ $(SLO)$/EConnection.obj \
+ $(SLO)$/Eservices.obj \
+ $(SLO)$/EDriver.obj
+
+EXCEPTIONSFILES=\
+ $(SLO)$/EResultSet.obj \
+ $(SLO)$/EStatement.obj \
+ $(SLO)$/EPreparedStatement.obj \
+ $(SLO)$/ETable.obj \
+ $(SLO)$/EDatabaseMetaData.obj \
+ $(SLO)$/ECatalog.obj \
+ $(SLO)$/EColumns.obj \
+ $(SLO)$/ETables.obj \
+ $(SLO)$/EConnection.obj \
+ $(SLO)$/Eservices.obj \
+ $(SLO)$/EDriver.obj
+
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(TOOLSLIB) \
+ $(SVLLIB) \
+ $(UNOTOOLSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(DBFILELIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(DBFILELIB)" == ""
+SHL1STDLIBS+= ifile.lib
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+