summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/file
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/file')
-rw-r--r--connectivity/source/drivers/file/FCatalog.cxx121
-rw-r--r--connectivity/source/drivers/file/FColumns.cxx93
-rw-r--r--connectivity/source/drivers/file/FConnection.cxx461
-rw-r--r--connectivity/source/drivers/file/FDatabaseMetaData.cxx1223
-rw-r--r--connectivity/source/drivers/file/FDateFunctions.cxx289
-rw-r--r--connectivity/source/drivers/file/FDriver.cxx285
-rw-r--r--connectivity/source/drivers/file/FNoException.cxx131
-rw-r--r--connectivity/source/drivers/file/FNumericFunctions.cxx249
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx633
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx1896
-rw-r--r--connectivity/source/drivers/file/FResultSetMetaData.cxx219
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx860
-rw-r--r--connectivity/source/drivers/file/FStringFunctions.cxx267
-rw-r--r--connectivity/source/drivers/file/FTable.cxx257
-rw-r--r--connectivity/source/drivers/file/FTables.cxx83
-rw-r--r--connectivity/source/drivers/file/fanalyzer.cxx322
-rw-r--r--connectivity/source/drivers/file/fcode.cxx519
-rw-r--r--connectivity/source/drivers/file/fcomp.cxx920
-rw-r--r--connectivity/source/drivers/file/file.xml32
-rw-r--r--connectivity/source/drivers/file/makefile.mk108
-rw-r--r--connectivity/source/drivers/file/quotedstring.cxx164
21 files changed, 9132 insertions, 0 deletions
diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx
new file mode 100644
index 000000000000..7ef176353082
--- /dev/null
+++ b/connectivity/source/drivers/file/FCatalog.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * 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 "file/FCatalog.hxx"
+#include "file/FConnection.hxx"
+#include "file/FTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <rtl/logfile.hxx>
+
+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::file;
+// -------------------------------------------------------------------------
+OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::OFileCatalog" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OFileCatalog::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
+m_xMetaData.clear();
+ OFileCatalog_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFileCatalog::buildName(const Reference< XRow >& _xRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::buildName" );
+ return _xRow->getString(3);
+}
+// -------------------------------------------------------------------------
+void OFileCatalog::refreshTables()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::refreshTables" );
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+ fillNames(xResult,aVector);
+
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::queryInterface" );
+ if( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XViewsSupplier>*)0))
+ return Any();
+
+
+ typedef sdbcx::OCatalog OFileCatalog_BASE;
+ return OFileCatalog_BASE::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OFileCatalog::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::getTypes" );
+ typedef sdbcx::OCatalog OFileCatalog_BASE;
+
+ Sequence< Type > aTypes = OFileCatalog_BASE::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<XGroupsSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XViewsSupplier>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ const Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/file/FColumns.cxx b/connectivity/source/drivers/file/FColumns.cxx
new file mode 100644
index 000000000000..7c70d4c4372d
--- /dev/null
+++ b/connectivity/source/drivers/file/FColumns.cxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * 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 "file/FColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "file/FTable.hxx"
+#include <comphelper/property.hxx>
+
+using namespace connectivity::file;
+using namespace connectivity;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sdbcx::OColumn* pRet = new sdbcx::OColumn(_rName,
+ xRow->getString(6),
+ xRow->getString(13),
+ xRow->getInt(11),
+ xRow->getInt(7),
+ xRow->getInt(9),
+ xRow->getInt(5),
+ sal_False,
+ sal_False,
+ sal_False,
+ m_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx
new file mode 100644
index 000000000000..de145407188a
--- /dev/null
+++ b/connectivity/source/drivers/file/FConnection.cxx
@@ -0,0 +1,461 @@
+/*************************************************************************
+ *
+ * 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 <cppuhelper/typeprovider.hxx>
+#include "file/FConnection.hxx"
+#include "file/FDatabaseMetaData.hxx"
+#include "file/FDriver.hxx"
+#include "file/FStatement.hxx"
+#include "file/FPreparedStatement.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#include <tools/urlobj.hxx>
+#include "file/FCatalog.hxx"
+#include <unotools/pathoptions.hxx>
+#include <ucbhelper/content.hxx>
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/dbexception.hxx>
+#include <osl/thread.h>
+#include <osl/nlsupport.h>
+#include "resource/file_res.hrc"
+
+using namespace connectivity::file;
+using namespace dbtools;
+//------------------------------------------------------------------------------
+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::ucb;
+using namespace ::ucbhelper;
+using rtl::OUString;
+typedef connectivity::OMetaConnection OConnection_BASE;
+// --------------------------------------------------------------------------------
+OConnection::OConnection(OFileDriver* _pDriver)
+ : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+ ,m_pDriver(_pDriver)
+ ,m_bClosed(sal_False)
+ ,m_bShowDeleted(sal_False)
+ ,m_bCaseSensitiveExtension( sal_True )
+ ,m_bCheckSQL92(sal_False)
+ ,m_bDefaultTextEncoding(false)
+{
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+ if(!isClosed( ))
+ close();
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+
+//-----------------------------------------------------------------------------
+sal_Bool OConnection::matchesExtension( const String& _rExt ) const
+{
+ if ( isCaseSensitveExtension() )
+ return ( getExtension() == _rExt );
+
+ String sMyExtension( getExtension() );
+ sMyExtension.ToLowerAscii();
+ String sExt( _rExt );
+ sExt.ToLowerAscii();
+
+ return sMyExtension == sExt;
+}
+
+//-----------------------------------------------------------------------------
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ ::rtl::OUString aExt;
+ const PropertyValue *pIter = info.getConstArray();
+ const PropertyValue *pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(0 == pIter->Name.compareToAscii("Extension"))
+ OSL_VERIFY( pIter->Value >>= aExt );
+ else if(0 == pIter->Name.compareToAscii("CharSet"))
+ {
+ ::rtl::OUString sIanaName;
+ OSL_VERIFY( pIter->Value >>= sIanaName );
+
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA());
+ if (aLookup != aLookupIanaName.end())
+ m_nTextEncoding = (*aLookup).getEncoding();
+ else
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+ }
+ else if (0 == pIter->Name.compareToAscii("ShowDeleted"))
+ {
+ OSL_VERIFY( pIter->Value >>= m_bShowDeleted );
+ }
+ else if (0 == pIter->Name.compareToAscii("EnableSQL92Check"))
+ {
+ pIter->Value >>= m_bCheckSQL92;
+ }
+ } // for(;pIter != pEnd;++pIter)
+
+ {
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
+
+ String aFileName = aDSN;
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ {
+ SvtPathOptions aPathOptions;
+ aFileName = aPathOptions.SubstituteVariable(aFileName);
+ }
+
+ aURL.SetSmartURL(aFileName);
+
+ setURL(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ }
+
+ if ( m_nTextEncoding == RTL_TEXTENCODING_DONTKNOW )
+ {
+ //m_nTextEncoding = osl_getTextEncodingFromLocale(NULL);
+ m_nTextEncoding = osl_getThreadTextEncoding();
+ m_bDefaultTextEncoding = true;
+ }
+
+ if ( aExt.getLength() )
+ m_aFilenameExtension = aExt;
+
+ try
+ {
+ ::ucbhelper::Content aFile;
+ try
+ {
+ aFile = ::ucbhelper::Content(getURL(),Reference< XCommandEnvironment >());
+ }
+ catch(ContentCreationException& e)
+ {
+ throwUrlNotValid(getURL(),e.Message);
+ }
+
+ // set fields to fetch
+ Sequence< OUString > aProps(1);
+ OUString* pProps = aProps.getArray();
+ pProps[ 0 ] = OUString::createFromAscii( "Title" );
+
+ try
+ {
+ if (aFile.isFolder())
+ {
+ m_xDir = aFile.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
+ m_xContent = aFile.get();
+ }
+ else if (aFile.isDocument())
+ {
+ Reference<XContent> xParent(Reference<XChild>(aFile.get(),UNO_QUERY)->getParent(),UNO_QUERY);
+ Reference<XContentIdentifier> xIdent = xParent->getIdentifier();
+ m_xContent = xParent;
+
+ ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >());
+ m_xDir = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
+ }
+ else
+ {
+ OSL_ENSURE(0,"OConnection::construct: ::ucbhelper::Content isn't a folde nor a document! How that?!");
+ throw SQLException();
+ }
+ }
+ catch(Exception& e) // a execption is thrown when no file exists
+ {
+ throwUrlNotValid(getURL(),e.Message);
+ }
+ if(!m_xDir.is() || !m_xContent.is())
+ throwUrlNotValid(getURL(),::rtl::OUString());
+
+ if (m_aFilenameExtension.Search('*') != STRING_NOTFOUND || m_aFilenameExtension.Search('?') != STRING_NOTFOUND)
+ throw SQLException();
+ }
+ catch(const Exception&)
+ {
+ osl_decrementInterlockedCount( &m_refCount );
+ throw;
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.file.Connection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XStatement > xReturn = new OStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OPreparedStatement* pStmt = new OPreparedStatement(this);
+ Reference< XPreparedStatement > xHoldAlive = pStmt;
+ pStmt->construct(sql);
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return pStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ return sql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ m_bAutoCommit = autoCommit;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ return m_bAutoCommit;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
+{
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ m_bReadOnly = readOnly;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ return m_bReadOnly;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(SQLException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XConnection::setCatalog", *this );
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XConnection::setTransactionIsolation", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// --------------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTypeMap( const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OConnection_BASE::disposing();
+
+ m_bClosed = sal_True;
+m_xDir.clear();
+m_xContent.clear();
+ m_xCatalog = WeakReference< XTablesSupplier>();
+
+ dispose_ChildImpl();
+}
+//------------------------------------------------------------------------------
+Reference< XTablesSupplier > OConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ xTab = new OFileCatalog(this);
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+Reference< XDynamicResultSet > OConnection::getDir() const
+{
+ Reference<XDynamicResultSet> xContent;
+ Sequence< ::rtl::OUString > aProps(1);
+ ::rtl::OUString* pProps = aProps.getArray();
+ pProps[ 0 ] = ::rtl::OUString::createFromAscii( "Title" );
+ try
+ {
+ Reference<XContentIdentifier> xIdent = getContent()->getIdentifier();
+ ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >());
+ xContent = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
+ }
+ catch(Exception&)
+ {
+ }
+ return xContent;
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OConnection::getSomething( const Sequence< sal_Int8 >& rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : (sal_Int64)0;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OConnection::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();
+}
+// -----------------------------------------------------------------------------
+void OConnection::throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage)
+{
+ SQLException aError;
+ aError.Message = getResources().getResourceStringWithSubstitution(
+ STR_NO_VALID_FILE_URL,
+ "$URL$", _rsUrl
+ );
+
+ aError.SQLState = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
+ aError.ErrorCode = 0;
+ aError.Context = static_cast< XConnection* >(this);
+ if (_rsMessage.getLength())
+ aError.NextException <<= SQLException(_rsMessage, aError.Context, ::rtl::OUString(), 0, Any());
+
+ throw aError;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
new file mode 100644
index 000000000000..24fcb06833fa
--- /dev/null
+++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
@@ -0,0 +1,1223 @@
+/*************************************************************************
+ *
+ * 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 "file/FDatabaseMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/ucb/SearchRecursion.hpp>
+#include <com/sun/star/ucb/SearchCommandArgument.hpp>
+#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <tools/urlobj.hxx>
+#include "file/FDriver.hxx"
+#include "file/FTable.hxx"
+#include <comphelper/extract.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+
+using namespace com::sun::star::ucb;
+using namespace connectivity::file;
+using namespace connectivity;
+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::lang;
+using namespace com::sun::star::container;
+
+DBG_NAME( file_ODatabaseMetaData )
+ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
+ ,m_pConnection(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ODatabaseMetaData" );
+ DBG_CTOR( file_ODatabaseMetaData, NULL );
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+ DBG_DTOR( file_ODatabaseMetaData, NULL );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getTypeInfo_throw" );
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTypeInfo );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getCatalogSeparator_throw" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*tableNamePattern*/,
+ const ::rtl::OUString& /*columnNamePattern*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getColumns" );
+ OSL_ENSURE(0,"Should be overloaded!");
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns );
+}
+
+// -------------------------------------------------------------------------
+namespace
+{
+ sal_Int16 isCaseSensitiveParentFolder( const String& _rFolderOrDoc, const String& _rDocName )
+ {
+ sal_Int16 nIsCS = 1;
+ try
+ {
+ // first get the real content for the URL
+ INetURLObject aContentURL( _rFolderOrDoc );
+ ::ucbhelper::Content aContent1;
+ {
+ ::ucbhelper::Content aFolderOrDoc( _rFolderOrDoc, Reference< XCommandEnvironment >() );
+ if ( aFolderOrDoc.isDocument() )
+ aContent1 = aFolderOrDoc;
+ else
+ {
+ aContentURL = INetURLObject( _rFolderOrDoc, INetURLObject::WAS_ENCODED );
+ aContentURL.Append( _rDocName );
+ aContent1 = ::ucbhelper::Content( aContentURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() );
+ }
+ }
+
+ // get two extensions which differ by case only
+ String sExtension1 = aContentURL.getExtension();
+ String sExtension2( sExtension1 );
+ sExtension2.ToLowerAscii();
+ if ( sExtension2 == sExtension1 )
+ // the extension was already in lower case
+ sExtension2.ToUpperAscii();
+
+ // the complete URL for the second extension
+ INetURLObject aURL2( aContentURL );
+ if ( sExtension2.Len() )
+ aURL2.SetExtension( sExtension2 );
+ if ( aURL2.GetMainURL(INetURLObject::NO_DECODE) == aContentURL.GetMainURL(INetURLObject::NO_DECODE) )
+ return -1;
+
+ // the second context
+ sal_Bool bCanAccess = sal_False;
+ ::ucbhelper::Content aContent2;
+ try
+ {
+ aContent2 = ::ucbhelper::Content( aURL2.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() );
+ bCanAccess = aContent2.isDocument();
+ }
+ catch( const Exception& )
+ {
+ }
+
+ if ( bCanAccess )
+ {
+ // here we have two contents whose URLs differ by case only.
+ // Now let's check if both really refer to the same object ....
+ Reference< XContent > xContent1 = aContent1.get();
+ Reference< XContent > xContent2 = aContent2.get();
+ OSL_ENSURE( xContent1.is() && xContent2.is(), "isCaseSensitiveParentFolder: invalid content interfaces!" );
+ if ( xContent1.is() && xContent2.is() )
+ {
+ Reference< XContentIdentifier > xID1 = xContent1->getIdentifier();
+ Reference< XContentIdentifier > xID2 = xContent2->getIdentifier();
+ OSL_ENSURE( xID1.is() && xID2.is(), "isCaseSensitiveParentFolder: invalid ID interfaces!" );
+ if ( xID1.is() && xID2.is() )
+ {
+ // get a generic content provider
+ ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
+ Reference< XContentProvider > xProvider;
+ if ( pBroker )
+ xProvider = pBroker->getContentProviderInterface();
+ OSL_ENSURE( xProvider.is(), "isCaseSensitiveParentFolder: invalid content broker!" );
+ if ( xProvider.is() )
+ {
+ if ( 0 == xProvider->compareContentIds( xID1, xID2 ) )
+ // finally, we know that the folder is not case-sensitive ....
+ nIsCS = 0;
+ }
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "isCaseSensitiveParentFolder: caught an unexpected exception!" );
+ }
+
+ return nIsCS;
+ }
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTables" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTables );
+ Reference< XResultSet > xRef = pResult;
+
+ // check if any type is given
+ // when no types are given then we have to return all tables e.g. TABLE
+
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ sal_Bool bTableFound = sal_True;
+ sal_Int32 nLength = types.getLength();
+ if(nLength)
+ {
+ bTableFound = sal_False;
+
+ const ::rtl::OUString* pBegin = types.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + nLength;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(*pBegin == aTable)
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ }
+ }
+ if(!bTableFound)
+ return xRef;
+
+ Reference<XDynamicResultSet> xContent = m_pConnection->getDir();
+ Reference < XSortedDynamicResultSetFactory > xSRSFac(
+ m_pConnection->getDriver()->getFactory()->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SortedDynamicResultSetFactory") ), UNO_QUERY );
+
+ Sequence< NumberedSortingInfo > aSortInfo( 1 );
+ NumberedSortingInfo* pInfo = aSortInfo.getArray();
+ pInfo[ 0 ].ColumnIndex = 1;
+ pInfo[ 0 ].Ascending = sal_True;
+
+ Reference < XAnyCompareFactory > xFactory;
+ Reference< XDynamicResultSet > xDynamicResultSet;
+ xDynamicResultSet = xSRSFac->createSortedDynamicResultSet( xContent, aSortInfo, xFactory );
+ Reference<XResultSet> xResultSet = xDynamicResultSet->getStaticResultSet();
+
+ Reference<XRow> xRow(xResultSet,UNO_QUERY);
+
+ String aFilenameExtension = m_pConnection->getExtension();
+ String sThisContentExtension;
+ ODatabaseMetaDataResultSet::ORows aRows;
+ // scan the directory for tables
+ ::rtl::OUString aName;
+ INetURLObject aURL;
+ xResultSet->beforeFirst();
+
+ sal_Bool bKnowCaseSensivity = sal_False;
+ sal_Bool bCaseSensitiveDir = sal_True;
+ sal_Bool bCheckEnabled = m_pConnection->isCheckEnabled();
+
+ while(xResultSet->next())
+ {
+ aName = xRow->getString(1);
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String sUrl = m_pConnection->getURL() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + aName;
+ aURL.SetSmartURL( sUrl );
+ sThisContentExtension = aURL.getExtension();
+
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+ aRow.reserve(6);
+ sal_Bool bNewRow = sal_False;
+
+ if ( !bKnowCaseSensivity )
+ {
+ bKnowCaseSensivity = sal_True;
+ sal_Int16 nCase = isCaseSensitiveParentFolder( m_pConnection->getURL(), aURL.getName() );
+ switch( nCase )
+ {
+ case 1:
+ bCaseSensitiveDir = sal_True;
+ break;
+ case -1:
+ bKnowCaseSensivity = sal_False;
+ /** run through */
+ case 0:
+ bCaseSensitiveDir = sal_False;
+ }
+ if ( bKnowCaseSensivity )
+ {
+ m_pConnection->setCaseSensitiveExtension( bCaseSensitiveDir, OConnection::GrantAccess() );
+ if ( !bCaseSensitiveDir )
+ aFilenameExtension.ToLowerAscii();
+ }
+ }
+
+ if (aFilenameExtension.Len())
+ {
+ if ( !bCaseSensitiveDir )
+ sThisContentExtension.ToLowerAscii();
+
+ if ( sThisContentExtension == aFilenameExtension )
+ {
+ aName = aName.replaceAt(aName.getLength()-(aFilenameExtension.Len()+1),aFilenameExtension.Len()+1,::rtl::OUString());
+ sal_Unicode nChar = aName.toChar();
+ if ( match(tableNamePattern,aName.getStr(),'\0') && ( !bCheckEnabled || ( bCheckEnabled && ((nChar < '0' || nChar > '9')))) )
+ {
+ aRow.push_back(new ORowSetValueDecorator(aName));
+ bNewRow = sal_True;
+ }
+ }
+ }
+ else // no extension, filter myself
+ {
+ sal_Bool bErg = sal_False;
+ do
+ {
+ if (!aURL.getExtension().getLength())
+ {
+ sal_Unicode nChar = aURL.getBase().getStr()[0];
+ if(match(tableNamePattern,aURL.getBase().getStr(),'\0') && ( !bCheckEnabled || ( bCheckEnabled && ((nChar < '0' || nChar > '9')))) )
+ {
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString(aURL.getBase())));
+ bNewRow = sal_True;
+ }
+ break;
+ }
+ else if ( ( bErg = xResultSet->next() ) != sal_False )
+ {
+ aName = xRow->getString(1);
+ aURL.SetSmartURL(aName);
+ }
+ } while (bErg);
+ }
+ if(bNewRow)
+ {
+ aRow.push_back(new ORowSetValueDecorator(aTable));
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+
+ aRows.push_back(aRow);
+ }
+ }
+
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxBinaryLiteralLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxRowSize" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxCatalogNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxCharLiteralLength" );
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInIndex" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxCursorNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxConnections" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInTable" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getMaxStatements_throw" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxTableNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getMaxTablesInSelect_throw" );
+ return 1;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTablePrivileges" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
+ Reference< XResultSet > xRef = pResult;
+ ODatabaseMetaDataResultSet::ORows aRows;
+
+
+ Reference< XTablesSupplier > xTabSup = m_pConnection->createCatalog();
+ if( xTabSup.is())
+ {
+ Reference< XNameAccess> xNames = xTabSup->getTables();
+ Sequence< ::rtl::OUString > aNames = xNames->getElementNames();
+ const ::rtl::OUString* pBegin = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(match(tableNamePattern,pBegin->getStr(),'\0'))
+ {
+ static ODatabaseMetaDataResultSet::ORow aRow(8);
+
+ aRow[2] = new ORowSetValueDecorator(*pBegin);
+ aRow[6] = ODatabaseMetaDataResultSet::getSelectValue();
+ aRow[7] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ aRows.push_back(aRow);
+
+ Reference< XPropertySet> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(*pBegin));
+ if(xTable.is())
+ {
+ Reference<XUnoTunnel> xTunnel(xTable,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OFileTable* pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()) );
+ if(pTable)
+ {
+ if(!pTable->isReadOnly())
+ {
+ aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
+ aRows.push_back(aRow);
+ if(!m_pConnection->showDeleted())
+ {
+ aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue();
+ aRows.push_back(aRow);
+ }
+ aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getCreateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getReadValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getAlterValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getDropValue();
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::doesMaxRowSizeIncludeBlobs" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesLowerCaseQuotedIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesLowerCaseIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesMixedCaseIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesUpperCaseQuotedIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesUpperCaseIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxIndexLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsNonNullableColumns" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getCatalogTerm" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getIdentifierQuoteString_throw" );
+ static const ::rtl::OUString sQuote = ::rtl::OUString::createFromAscii("\"");
+ return sQuote;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getExtraNameCharacters" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsDifferentTableCorrelationNames" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_isCatalogAtStart_throw" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::dataDefinitionIgnoredInTransactions" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::dataDefinitionCausesTransactionCommit" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsDataManipulationTransactionsOnly" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsPositionedDelete" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsPositionedUpdate" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenStatementsAcrossRollback" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenStatementsAcrossCommit" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenCursorsAcrossCommit" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenCursorsAcrossRollback" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTransactionIsolationLevel" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsANSI92FullSQL" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsANSI92EntryLevelSQL" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsIntegrityEnhancementFacility" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSchemasInIndexDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCatalogsInIndexDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOuterJoins" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTableTypes" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTableTypes );
+ 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("TABLE")));
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxStatementLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxProcedureNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxSchemaNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTransactions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::allProceduresAreCallable" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsStoredProcedures" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSelectForUpdate" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::allTablesAreSelectable" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::isReadOnly" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::usesLocalFiles" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::usesLocalFilePerTable" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTypeConversion" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullPlusNonNullIsNull" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsColumnAliasing" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTableCorrelationNames" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsConvert" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsExpressionsInOrderBy" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsGroupBy" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsGroupByBeyondSelect" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsGroupByUnrelated" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMultipleTransactions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMultipleResultSets" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsLikeEscapeClause" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOrderByUnrelated" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsUnion" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsUnionAll" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMixedCaseIdentifiers" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedAtEnd" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedAtStart" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedHigh" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedLow" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSchemasInProcedureCalls" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCatalogsInProcedureCalls" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCorrelatedSubqueries" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInComparisons" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInExists" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInIns" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInQuantifieds" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsANSI92IntermediateSQL" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getURL" );
+ static const ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:file:");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getUserName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverVersion" );
+ return ::rtl::OUString::valueOf((sal_Int32)1);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDatabaseProductVersion" );
+ return ::rtl::OUString::valueOf((sal_Int32)0);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDatabaseProductName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getProcedureTerm" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSchemaTerm" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverMajorVersion" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDefaultTransactionIsolation" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverMinorVersion" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSQLKeywords" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSearchStringEscape" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getStringFunctions" );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UCASE,LCASE,ASCII,LENGTH,OCTET_LENGTH,CHAR_LENGTH,CHARACTER_LENGTH,CHAR,CONCAT,LOCATE,SUBSTRING,LTRIM,RTRIM,SPACE,REPLACE,REPEAT,INSERT,LEFT,RIGHT"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTimeDateFunctions" );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DAYOFWEEK,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,CURDATE,CURTIME,NOW"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSystemFunctions" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getNumericFunctions" );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ABS,SIGN,MOD,FLOOR,CEILING,ROUND,EXP,LN,LOG,LOG10,POWER,SQRT,PI,COS,SIN,TAN,ACOS,ASIN,ATAN,ATAN2,DEGREES,RADIANS"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsExtendedSQLGrammar" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCoreSQLGrammar" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMinimumSQLGrammar" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsFullOuterJoins" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsLimitedOuterJoins" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInGroupBy" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInOrderBy" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInSelect" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxUserNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsResultSetType" );
+ switch(setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ return sal_True;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ case ResultSetType::SCROLL_SENSITIVE:
+ break;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsResultSetConcurrency" );
+ switch(setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ return sal_True;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ case ResultSetType::SCROLL_SENSITIVE:
+ break;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ownUpdatesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ownDeletesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ownInsertsAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::othersUpdatesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::othersDeletesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::othersInsertsAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::updatesAreDetected" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::deletesAreDetected" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::insertsAreDetected" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsBatchUpdates" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getUDTs" );
+ return NULL;
+}
+
+
diff --git a/connectivity/source/drivers/file/FDateFunctions.cxx b/connectivity/source/drivers/file/FDateFunctions.cxx
new file mode 100644
index 000000000000..69330bf0c168
--- /dev/null
+++ b/connectivity/source/drivers/file/FDateFunctions.cxx
@@ -0,0 +1,289 @@
+/*************************************************************************
+ *
+ * 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 "file/FDateFunctions.hxx"
+#include <tools/date.hxx>
+#include <tools/time.hxx>
+#include <tools/datetime.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+//------------------------------------------------------------------
+ORowSetValue OOp_DayOfWeek::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ sal_Int32 nRet = 0;
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ DayOfWeek eDayOfWeek = aDate.GetDayOfWeek();
+ switch(eDayOfWeek)
+ {
+ case MONDAY:
+ nRet = 2;
+ break;
+ case TUESDAY:
+ nRet = 3;
+ break;
+ case WEDNESDAY:
+ nRet = 4;
+ break;
+ case THURSDAY:
+ nRet = 5;
+ break;
+ case FRIDAY:
+ nRet = 6;
+ break;
+ case SATURDAY:
+ nRet = 7;
+ break;
+ case SUNDAY:
+ nRet = 1;
+ break;
+ default:
+ OSL_ENSURE(0,"Error in enum values for date");
+ }
+ return nRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_DayOfMonth::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ return static_cast<sal_Int16>(aD.Day);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_DayOfYear::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ return static_cast<sal_Int16>(aDate.GetDayOfYear());
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Month::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ return static_cast<sal_Int16>(aD.Month);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_DayName::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet;
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ DayOfWeek eDayOfWeek = aDate.GetDayOfWeek();
+ switch(eDayOfWeek)
+ {
+ case MONDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Monday"));
+ break;
+ case TUESDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tuesday"));
+ break;
+ case WEDNESDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Wednesday"));
+ break;
+ case THURSDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Thursday"));
+ break;
+ case FRIDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Friday"));
+ break;
+ case SATURDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Saturday"));
+ break;
+ case SUNDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sunday"));
+ break;
+ default:
+ OSL_ENSURE(0,"Error in enum values for date");
+ }
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_MonthName::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet;
+ ::com::sun::star::util::Date aD = lhs;
+ switch(aD.Month)
+ {
+ case 1:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("January"));
+ break;
+ case 2:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("February"));
+ break;
+ case 3:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("March"));
+ break;
+ case 4:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("April"));
+ break;
+ case 5:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("May"));
+ break;
+ case 6:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("June"));
+ break;
+ case 7:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("July"));
+ break;
+ case 8:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("August"));
+ break;
+ case 9:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("September"));
+ break;
+ case 10:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("October"));
+ break;
+ case 11:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("November"));
+ break;
+ case 12:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("December"));
+ break;
+ }
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Quarter::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ sal_Int32 nRet = 1;
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ if ( aD.Month >= 4 && aD.Month < 7 )
+ nRet = 2;
+ else if ( aD.Month >= 7 && aD.Month < 10 )
+ nRet = 3;
+ else if ( aD.Month >= 10 && aD.Month <= 12 )
+ nRet = 4;
+ return nRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Week::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( lhs.empty() || lhs.size() > 2 )
+ return ORowSetValue();
+
+ size_t nSize = lhs.size();
+
+ ::com::sun::star::util::Date aD = lhs[nSize-1];
+ Date aDate(aD.Day,aD.Month,aD.Year);
+
+ sal_Int16 nStartDay = SUNDAY;
+ if ( nSize == 2 && !lhs[0].isNull() )
+ nStartDay = lhs[0];
+
+ return static_cast<sal_Int16>(aDate.GetWeekOfYear(static_cast<DayOfWeek>(nStartDay)));
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Year::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ return static_cast<sal_Int16>(aD.Year);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Hour::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Time aT = lhs;
+ return static_cast<sal_Int16>(aT.Hours);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Minute::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Time aT = lhs;
+ return static_cast<sal_Int16>(aT.Minutes);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Second::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Time aT = lhs;
+ return static_cast<sal_Int16>(aT.Seconds);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_CurDate::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( !lhs.empty() )
+ return ORowSetValue();
+
+ Date aCurDate;
+ return ::com::sun::star::util::Date(aCurDate.GetDay(),aCurDate.GetMonth(),aCurDate.GetYear());
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_CurTime::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( !lhs.empty() )
+ return ORowSetValue();
+
+ Time aCurTime;
+ return ::com::sun::star::util::Time(aCurTime.Get100Sec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour());
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Now::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( !lhs.empty() )
+ return ORowSetValue();
+
+ DateTime aCurTime;
+ return ::com::sun::star::util::DateTime(aCurTime.Get100Sec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour(),
+ aCurTime.GetDay(),aCurTime.GetMonth(),aCurTime.GetYear());
+}
+//------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx
new file mode 100644
index 000000000000..d0d952e9bab6
--- /dev/null
+++ b/connectivity/source/drivers/file/FDriver.cxx
@@ -0,0 +1,285 @@
+/*************************************************************************
+ *
+ * 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 "file/FDriver.hxx"
+#include "file/FConnection.hxx"
+#include "file/fcode.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/types.hxx>
+#include "connectivity/dbexception.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include <rtl/logfile.hxx>
+
+
+using namespace connectivity::file;
+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;
+// --------------------------------------------------------------------------------
+OFileDriver::OFileDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : ODriver_BASE(m_aMutex)
+ ,m_xFactory(_rxFactory)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::OFileDriver" );
+}
+// --------------------------------------------------------------------------------
+void OFileDriver::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ ODriver_BASE::disposing();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OFileDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdbc.driver.file.Driver");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OFileDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver");
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFileDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL OFileDriver::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;
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OFileDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OFileDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::connect" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODriver_BASE::rBHelper.bDisposed);
+
+ OConnection* pCon = new OConnection(this);
+ Reference< XConnection > xCon = pCon;
+ pCon->construct(url,info);
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OFileDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::acceptsURL" );
+ return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:file:"),10));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getPropertyInfo" );
+ 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("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension of the file format."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".*"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Display inactive records."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EnableSQL92Check"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Use SQL92 naming constraints."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseRelativePath"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Handle the connection url as relative path."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The URL of the database document which is used to create an absolute path."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
+ } // if ( acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( ! acceptsURL(url) )
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFileDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getMajorVersion" );
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFileDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getMinorVersion" );
+ return 0;
+}
+// --------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------
+// XDataDefinitionSupplier
+Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getDataDefinitionByConnection" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODriver_BASE::rBHelper.bDisposed);
+
+ Reference< XTablesSupplier > xTab = NULL;
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelImplementationId()) );
+ OConnection* pConnection = NULL;
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection)
+ {
+ pConnection = pSearchConnection;
+ break;
+ }
+ }
+
+ if(pConnection)
+ xTab = pConnection->createCatalog();
+ }
+ return xTab;
+}
+
+// --------------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getDataDefinitionByURL" );
+ if ( ! acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+ return getDataDefinitionByConnection(connect(url,info));
+}
+// -----------------------------------------------------------------------------
+void OOperandParam::describe(const Reference< XPropertySet>& rColumn, ::vos::ORef<connectivity::OSQLColumns> rParameterColumns)
+{
+ // den alten namen beibehalten
+
+ OSL_ENSURE(getRowPos() < rParameterColumns->get().size(),"Invalid index for orderkey values!");
+
+ Reference< XPropertySet> xColumn = (rParameterColumns->get())[getRowPos()];
+
+ try
+ {
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)));
+ }
+ catch(const Exception&)
+ {
+ }
+
+ m_eDBType = ::comphelper::getINT32(rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+}
+// -----------------------------------------------------------------------------
+OOperandAttr::OOperandAttr(sal_uInt16 _nPos,const Reference< XPropertySet>& _xColumn)
+ : OOperandRow(_nPos,::comphelper::getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ , m_xColumn(_xColumn)
+{
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx
new file mode 100644
index 000000000000..4bf0a2e37a1b
--- /dev/null
+++ b/connectivity/source/drivers/file/FNoException.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * 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 "file/FCatalog.hxx"
+#include "file/fcomp.hxx"
+#include "file/fanalyzer.hxx"
+#include "file/FResultSet.hxx"
+#include "file/FPreparedStatement.hxx"
+#include <connectivity/FValue.hxx>
+#include <tools/debug.hxx>
+#include "TKeyValue.hxx"
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+// -----------------------------------------------------------------------------
+void OFileCatalog::refreshViews()
+{}
+void OFileCatalog::refreshGroups()
+{}
+void OFileCatalog::refreshUsers()
+{
+}
+// -----------------------------------------------------------------------------
+OPredicateInterpreter::~OPredicateInterpreter()
+{
+ while(!m_aStack.empty())
+ {
+ delete m_aStack.top();
+ m_aStack.pop();
+ }
+ // m_aStack.clear();
+}
+// -----------------------------------------------------------------------------
+void OPredicateCompiler::Clean()
+{
+ for(OCodeList::reverse_iterator aIter = m_aCodeList.rbegin(); aIter != m_aCodeList.rend();++aIter)
+ {
+ delete *aIter;
+ }
+ m_aCodeList.clear();
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::clean()
+{
+ m_aCompiler->Clean();
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::bindParameterRow(OValueRefRow& _pRow)
+{
+ OCodeList& rCodeList = m_aCompiler->m_aCodeList;
+ for(OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end();++aIter)
+ {
+ OOperandParam* pParam = PTR_CAST(OOperandParam,(*aIter));
+ if ( pParam )
+ pParam->bindValue(_pRow);
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::scanParameter" );
+ DBG_ASSERT(pParseNode != NULL,"OResultSet: interner Fehler: ungueltiger ParseNode");
+
+ // Parameter Name-Regel gefunden?
+ if (SQL_ISRULE(pParseNode,parameter))
+ {
+ DBG_ASSERT(pParseNode->count() >= 1,"OResultSet: Parse Tree fehlerhaft");
+ DBG_ASSERT(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Parse Tree fehlerhaft");
+
+ _rParaNodes.push_back(pParseNode);
+ // Weiterer Abstieg nicht erforderlich
+ return;
+ }
+
+ // Weiter absteigen im Parse Tree
+ for (UINT32 i = 0; i < pParseNode->count(); i++)
+ scanParameter(pParseNode->getChild(i),_rParaNodes);
+}
+// -----------------------------------------------------------------------------
+OKeyValue* OResultSet::GetOrderbyKeyValue(OValueRefRow& _rRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::GetOrderbyKeyValue" );
+ UINT32 nBookmarkValue = Abs((sal_Int32)(_rRow->get())[0]->getValue());
+
+ OKeyValue* pKeyValue = OKeyValue::createKeyValue((UINT32)nBookmarkValue);
+
+ ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin();
+ for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter)
+ {
+ OSL_ENSURE(*aIter < static_cast<sal_Int32>(_rRow->get().size()),"Invalid index for orderkey values!");
+ pKeyValue->pushKey(new ORowSetValueDecorator((_rRow->get())[*aIter]->getValue()));
+ }
+
+ return pKeyValue;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
+
+
diff --git a/connectivity/source/drivers/file/FNumericFunctions.cxx b/connectivity/source/drivers/file/FNumericFunctions.cxx
new file mode 100644
index 000000000000..ea5848132ecb
--- /dev/null
+++ b/connectivity/source/drivers/file/FNumericFunctions.cxx
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * 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 <cmath>
+#include "file/FNumericFunctions.hxx"
+#include <rtl/math.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+//------------------------------------------------------------------
+ORowSetValue OOp_Abs::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal(lhs);
+ if ( nVal < 0 )
+ nVal *= -1.0;
+ return fabs(nVal);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Sign::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ sal_Int32 nRet = 0;
+ double nVal(lhs);
+ if ( nVal < 0 )
+ nRet = -1;
+ else if ( nVal > 0 )
+ nRet = 1;
+
+ return nRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Mod::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ if ( lhs.isNull() || rhs.isNull() )
+ return ORowSetValue();
+
+ return fmod((double)lhs,(double)rhs);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Floor::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return floor((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal(lhs);
+ return ceil(nVal);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Round::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( lhs.empty() || lhs.size() > 2 )
+ return ORowSetValue();
+
+ size_t nSize = lhs.size();
+ double nVal = lhs[nSize-1];
+
+ sal_Int32 nDec = 0;
+ if ( nSize == 2 && !lhs[0].isNull() )
+ nDec = lhs[0];
+ return ::rtl::math::round(nVal,nDec);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Exp::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal(lhs);
+ return exp(nVal);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Ln::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 )
+ return lhs;
+
+ double nVal(lhs);
+ nVal = log(nVal);
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Log::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( lhs.empty() || lhs.size() > 2 )
+ return ORowSetValue();
+ size_t nSize = lhs.size();
+ double nVal = log( (double)lhs[nSize-1] );
+
+
+ if ( nSize == 2 && !lhs[0].isNull() )
+ nVal /= log((double)lhs[0]);
+
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Log10::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 )
+ return lhs;
+
+ double nVal = log((double)lhs);
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ nVal /= log(10.0);
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Pow::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ return pow((double)lhs,(double)rhs);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal = sqrt((double)lhs);
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Pi::operate(const ::std::vector<ORowSetValue>& /*lhs*/) const
+{
+ return 3.141592653589793116;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Cos::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return cos((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Sin::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return sin((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Tan::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return tan((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ACos::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return acos((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ASin::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return asin((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ATan::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return atan((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ATan2::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ return atan2((double)lhs,(double)rhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nLhs = lhs;
+ return nLhs*180*(1.0/3.141592653589793116);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Radians::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nLhs = lhs;
+ return nLhs*3.141592653589793116*(1.0/180.0);
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
new file mode 100644
index 000000000000..080b2a592aef
--- /dev/null
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -0,0 +1,633 @@
+/*************************************************************************
+ *
+ * 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 <stdio.h>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <osl/diagnose.h>
+#include "file/FPreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "file/FResultSetMetaData.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbconversion.hxx"
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "connectivity/PColumn.hxx"
+#include "diagnose_ex.h"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <tools/debug.hxx>
+#include "resource/file_res.hrc"
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace comphelper;
+using namespace ::dbtools;
+using namespace connectivity::file;
+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;
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+DBG_NAME( file_OPreparedStatement )
+// -------------------------------------------------------------------------
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection)
+ : OStatement_BASE2( _pConnection )
+ ,m_pResultSet(NULL)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::OPreparedStatement" );
+ DBG_CTOR( file_OPreparedStatement, NULL );
+}
+
+// -------------------------------------------------------------------------
+OPreparedStatement::~OPreparedStatement()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::~OPreparedStatement" );
+ DBG_DTOR( file_OPreparedStatement, NULL );
+}
+
+// -------------------------------------------------------------------------
+void OPreparedStatement::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ clearMyResultSet();
+ OStatement_BASE2::disposing();
+
+ if(m_pResultSet)
+ {
+ m_pResultSet->release();
+ m_pResultSet = NULL;
+ }
+
+ m_xParamColumns = NULL;
+ m_xMetaData.clear();
+ if(m_aParameterRow.isValid())
+ {
+ m_aParameterRow->get().clear();
+ m_aParameterRow = NULL;
+ }
+
+
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::construct" );
+ OStatement_Base::construct(sql);
+
+ m_aParameterRow = new OValueRefVector();
+ m_aParameterRow->get().push_back(new ORowSetValueDecorator(sal_Int32(0)) );
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+
+ if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT )
+ m_xParamColumns = m_aSQLIterator.getParameters();
+ else
+ {
+ m_xParamColumns = new OSQLColumns();
+ // describe all parameters need for the resultset
+ describeParameter();
+ }
+
+ OValueRefRow aTemp;
+ OResultSet::setBoundedColumns(m_aEvaluateRow,aTemp,m_xParamColumns,xNames,sal_False,m_xDBMetaData,m_aColMapping);
+
+ m_pResultSet = createResultSet();
+ m_pResultSet->acquire();
+ m_xResultSet = Reference<XResultSet>(m_pResultSet);
+ initializeResultSet(m_pResultSet);
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::queryInterface" );
+ Any aRet = OStatement_BASE2::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
+ static_cast< XPreparedStatement*>(this),
+ static_cast< XParameters*>(this),
+ static_cast< XResultSetMetaDataSupplier*>(this));
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getTypes" );
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getMetaData" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::close" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ clearMyResultSet();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::execute" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ initResultSet();
+
+ return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::executeUpdate" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ initResultSet();
+
+ return m_pResultSet ? m_pResultSet->getRowCountResult() : sal_Int32(0);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setString" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getConnection" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::executeQuery" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return initResultSet();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBoolean" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setByte" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setDate" );
+ setParameter(parameterIndex,DBTypeConversion::toDouble(aData));
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setTime" );
+ setParameter(parameterIndex,DBTypeConversion::toDouble(aVal));
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setTimestamp" );
+ setParameter(parameterIndex,DBTypeConversion::toDouble(aVal));
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setDouble" );
+ setParameter(parameterIndex,x);
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setFloat" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setInt" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setLong" );
+ throwFeatureNotImplementedException( "XParameters::setLong", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setNull" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkAndResizeParameters(parameterIndex);
+
+ if ( m_aAssignValues.isValid() )
+ (m_aAssignValues->get())[m_aParameterIndexes[parameterIndex]]->setNull();
+ else
+ (m_aParameterRow->get())[parameterIndex]->setNull();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setClob" );
+ throwFeatureNotImplementedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBlob" );
+ throwFeatureNotImplementedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setArray" );
+ throwFeatureNotImplementedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setRef" );
+ throwFeatureNotImplementedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObjectWithInfo" );
+ switch(sqlType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ setString(parameterIndex,::comphelper::getString(x));
+ break;
+ default:
+ ::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale);
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObjectNull" );
+ setNull(parameterIndex,sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObject" );
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ // setObject (parameterIndex, x, sqlType, 0);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setShort" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBytes" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setCharacterStream" );
+ setBinaryStream(parameterIndex,x,length );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBinaryStream" );
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ setParameter(parameterIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::clearParameters" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ m_aParameterRow->get().clear();
+ m_aParameterRow->get().push_back(new ORowSetValueDecorator(sal_Int32(0)) );
+}
+// -------------------------------------------------------------------------
+OResultSet* OPreparedStatement::createResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::createResultSet" );
+ return new OResultSet(this,m_aSQLIterator);
+}
+// -----------------------------------------------------------------------------
+Reference<XResultSet> OPreparedStatement::initResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::initResultSet" );
+ m_pResultSet->clear();
+ Reference<XResultSet> xRs(m_pResultSet);
+
+ // check if we got enough paramters
+ if ( (m_aParameterRow.isValid() && ( m_aParameterRow->get().size() -1 ) < m_xParamColumns->get().size()) ||
+ (m_xParamColumns.isValid() && !m_aParameterRow.isValid() && !m_aParameterRow->get().empty()) )
+ m_pConnection->throwGenericSQLException(STR_INVALID_PARA_COUNT,*this);
+
+ m_pResultSet->OpenImpl();
+ m_pResultSet->setMetaData(getMetaData());
+
+ return xRs;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::checkAndResizeParameters" );
+ ::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ if ( m_aAssignValues.isValid() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) )
+ throwInvalidIndexException(*this);
+ else if ( static_cast<sal_Int32>((m_aParameterRow->get()).size()) <= parameterIndex )
+ {
+ sal_Int32 i = m_aParameterRow->get().size();
+ (m_aParameterRow->get()).resize(parameterIndex+1);
+ for ( ;i <= parameterIndex+1; ++i )
+ {
+ if ( !(m_aParameterRow->get())[i].isValid() )
+ (m_aParameterRow->get())[i] = new ORowSetValueDecorator;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setParameter" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkAndResizeParameters(parameterIndex);
+
+ if(m_aAssignValues.isValid())
+ *(m_aAssignValues->get())[m_aParameterIndexes[parameterIndex]] = x;
+ else
+ *((m_aParameterRow->get())[parameterIndex]) = x;
+}
+// -----------------------------------------------------------------------------
+UINT32 OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::AddParameter" );
+ OSL_UNUSED( pParameter );
+ OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter");
+ OSL_ENSURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree");
+#if OSL_DEBUG_LEVEL > 0
+ OSQLParseNode * pMark = pParameter->getChild(0);
+ OSL_UNUSED( pMark );
+#endif
+
+ ::rtl::OUString sParameterName;
+ // Parameter-Column aufsetzen:
+ sal_Int32 eType = DataType::VARCHAR;
+ UINT32 nPrecision = 255;
+ sal_Int32 nScale = 0;
+ sal_Int32 nNullable = ColumnValue::NULLABLE;
+
+ if (_xCol.is())
+ {
+ // Typ, Precision, Scale ... der angegebenen Column verwenden,
+ // denn dieser Column wird der Wert zugewiesen bzw. mit dieser
+ // Column wird der Wert verglichen.
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= eType;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nPrecision;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNullable;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName;
+ }
+
+ Reference<XPropertySet> xParaColumn = new connectivity::parse::OParseColumn(sParameterName
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,nNullable
+ ,nPrecision
+ ,nScale
+ ,eType
+ ,sal_False
+ ,sal_False
+ ,m_aSQLIterator.isCaseSensitive());
+ m_xParamColumns->get().push_back(xParaColumn);
+ return m_xParamColumns->get().size();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::describeColumn" );
+ Reference<XPropertySet> xProp;
+ if(SQL_ISRULE(_pNode,column_ref))
+ {
+ ::rtl::OUString sColumnName,sTableRange;
+ m_aSQLIterator.getColumnRange(_pNode,sColumnName,sTableRange);
+ if ( sColumnName.getLength() )
+ {
+ Reference<XNameAccess> xNameAccess = _xTable->getColumns();
+ if(xNameAccess->hasByName(sColumnName))
+ xNameAccess->getByName(sColumnName) >>= xProp;
+ AddParameter(_pParameter,xProp);
+ }
+ }
+ // else
+ // AddParameter(_pParameter,xProp);
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::describeParameter()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::describeParameter" );
+ ::std::vector< OSQLParseNode*> aParseNodes;
+ scanParameter(m_pParseTree,aParseNodes);
+ if ( !aParseNodes.empty() )
+ {
+ // m_xParamColumns = new OSQLColumns();
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+ if( !xTabs.empty() )
+ {
+ OSQLTable xTable = xTabs.begin()->second;
+ ::std::vector< OSQLParseNode*>::const_iterator aIter = aParseNodes.begin();
+ for (;aIter != aParseNodes.end();++aIter )
+ {
+ describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::initializeResultSet(OResultSet* _pResult)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::initializeResultSet" );
+ OStatement_Base::initializeResultSet(_pResult);
+
+ m_pResultSet->setParameterColumns(m_xParamColumns);
+ m_pResultSet->setParameterRow(m_aParameterRow);
+
+ // Parameter substituieren (AssignValues und Kriterien):
+ if (!m_xParamColumns->get().empty())
+ {
+ // Zunaechst AssignValues
+ USHORT nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an
+
+ // Nach zu substituierenden Parametern suchen:
+ size_t nCount = m_aAssignValues.isValid() ? m_aAssignValues->get().size() : 1; // 1 ist wichtig fuer die Kriterien
+ for (size_t j = 1; j < nCount; j++)
+ {
+ UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j);
+ if (nParameter == SQL_NO_PARAMETER)
+ continue; // dieser AssignValue ist kein Parameter
+
+ ++nParaCount; // ab hier ist der Parameter gueltig
+ // Parameter ersetzen. Wenn Parameter nicht verfuegbar,
+ // Value auf NULL setzen.
+ // (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter];
+ }
+
+ if (m_aParameterRow.isValid() && (m_xParamColumns->get().size()+1) != m_aParameterRow->get().size() )
+ {
+ sal_Int32 i = m_aParameterRow->get().size();
+ sal_Int32 nParamColumns = m_xParamColumns->get().size()+1;
+ m_aParameterRow->get().resize(nParamColumns);
+ for ( ;i < nParamColumns; ++i )
+ {
+ if ( !(m_aParameterRow->get())[i].isValid() )
+ (m_aParameterRow->get())[i] = new ORowSetValueDecorator;
+ }
+ //m_aParameterRow->resize(m_xParamColumns->size()+1);
+ }
+ if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->get().size() )
+ {
+
+ m_pSQLAnalyzer->bindParameterRow(m_aParameterRow);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::parseParamterElem" );
+ Reference<XPropertySet> xCol;
+ m_xColNames->getByName(_sColumnName) >>= xCol;
+ sal_Int32 nParameter = -1;
+ if(m_xParamColumns.isValid())
+ {
+ OSQLColumns::Vector::const_iterator aIter = find(m_xParamColumns->get().begin(),m_xParamColumns->get().end(),_sColumnName,::comphelper::UStringMixEqual(m_pTable->isCaseSensitive()));
+ if(aIter != m_xParamColumns->get().end())
+ nParameter = m_xParamColumns->get().size() - (m_xParamColumns->get().end() - aIter) + 1;// +1 because the rows start at 1
+ }
+ if(nParameter == -1)
+ nParameter = AddParameter(pRow_Value_Constructor_Elem,xCol);
+ // Nr. des Parameters in der Variablen merken:
+ SetAssignValue(_sColumnName, String(), TRUE, nParameter);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
new file mode 100644
index 000000000000..265084be697f
--- /dev/null
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -0,0 +1,1896 @@
+/*************************************************************************
+ *
+ * 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 <limits> // included here to prevent problems if compiling with C52
+
+#ifdef GCC
+#include <iostream>
+#endif
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "file/FResultSet.hxx"
+#include "file/FResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/property.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include "connectivity/dbconversion.hxx"
+#include "connectivity/dbtools.hxx"
+#include <cppuhelper/propshlp.hxx>
+#include <iterator>
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+
+#include <algorithm>
+#include <comphelper/extract.hxx>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/types.hxx>
+#include "resource/file_res.hrc"
+#include "resource/sharedresources.hxx"
+#include <rtl/logfile.hxx>
+
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace dbtools;
+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;
+
+// Maximale Anzahl von Rows, die mit ORDER BY sortiert durchlaufen werden koennen:
+#if defined (WIN)
+#define MAX_KEYSET_SIZE 0x3ff0 // Etwas weniger als ein Segment, damit
+ // noch Platz fuer Memory Debug-Informationen
+#else
+#define MAX_KEYSET_SIZE 0x40000 // 256K
+#endif
+
+namespace
+{
+ void lcl_throwError(sal_uInt16 _nErrorId,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xContext)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(_nErrorId);
+ ::dbtools::throwGenericSQLException(sMessage ,_xContext);
+ }
+}
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet");
+DBG_NAME( file_OResultSet )
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer(OResultSet_BASE::rBHelper)
+ ,m_aAssignValues(NULL)
+ ,m_pEvaluationKeySet(NULL)
+ ,m_aSkipDeletedSet(this)
+ ,m_pFileSet(NULL)
+ ,m_pSortIndex(NULL)
+ ,m_pTable(NULL)
+ ,m_pParseTree(pStmt->getParseTree())
+ ,m_pSQLAnalyzer(NULL)
+ ,m_aSQLIterator(_aSQLIterator)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ ,m_xStatement(*pStmt)
+ ,m_xMetaData(NULL)
+ ,m_xDBMetaData(pStmt->getOwnConnection()->getMetaData())
+ ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
+ ,m_nRowPos(-1)
+ ,m_nFilePos(0)
+ ,m_nLastVisitedPos(-1)
+ ,m_nRowCountResult(-1)
+ ,m_nCurrentPosition(0)
+ ,m_nColumnCount(0)
+ ,m_bWasNull(sal_False)
+ ,m_bEOF(sal_False)
+ ,m_bLastRecord(sal_False)
+ ,m_bInserted(sal_False)
+ ,m_bRowUpdated(sal_False)
+ ,m_bRowInserted(sal_False)
+ ,m_bRowDeleted(sal_False)
+ ,m_bShowDeleted(pStmt->getOwnConnection()->showDeleted())
+ ,m_bIsCount(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" );
+ DBG_CTOR( file_OResultSet, NULL );
+ osl_incrementInterlockedCount( &m_refCount );
+ m_bIsCount = (m_pParseTree &&
+ m_pParseTree->count() > 2 &&
+ SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
+ m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
+ );
+
+ m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
+ construct();
+ m_aSkipDeletedSet.SetDeleted(m_bShowDeleted);
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+// -------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::~OResultSet" );
+ osl_incrementInterlockedCount( &m_refCount );
+ disposing();
+ DBG_DTOR( file_OResultSet, NULL );
+}
+// -------------------------------------------------------------------------
+void OResultSet::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::construct" );
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+}
+// -------------------------------------------------------------------------
+void OResultSet::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_xStatement.clear();
+ m_xMetaData.clear();
+ m_pParseTree = NULL;
+ m_xColNames.clear();
+ m_xColumns = NULL;
+ m_xParamColumns = NULL;
+ m_xColsIdx.clear();
+
+ Reference<XComponent> xComp = m_pTable;
+ if ( xComp.is() )
+ xComp->removeEventListener(this);
+ if(m_pTable)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+ clear();
+}
+// -----------------------------------------------------------------------------
+void OResultSet::clear()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clear" );
+ m_pFileSet = NULL;
+ DELETEZ(m_pSortIndex);
+
+ if(m_aInsertRow.isValid())
+ m_aInsertRow->get().clear();
+
+ m_aSkipDeletedSet.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" );
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTypes" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& OResultSet::getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getValue" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ //columnIndex = mapColumn(columnIndex);
+ checkIndex(columnIndex );
+
+
+ m_bWasNull = (m_aSelectRow->get())[columnIndex]->getValue().isNull();
+ return *(m_aSelectRow->get())[columnIndex];
+}
+// -----------------------------------------------------------------------------
+void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::checkIndex" );
+ if ( columnIndex <= 0
+ // || columnIndex > (sal_Int32)m_xColumns->size()
+ || columnIndex >= m_nColumnCount )
+ ::dbtools::throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getByte" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDouble" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getFloat" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInt" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row");
+
+ return m_aSkipDeletedSet.getMappedPosition((m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getLong" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getArray" );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getClob" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBlob" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRef" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
+ return getValue(columnIndex).makeAny();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getShort" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getString" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == sal_Int32(m_pFileSet->get().size());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == sal_Int32(m_pFileSet->get().size() - 1);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(first())
+ previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(last())
+ next();
+ m_bEOF = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::close" );
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::first" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::last" );
+ // here I know definitely that I stand on the last record
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE,row,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::relative" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE,row,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::previous" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getStatement" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bRowDeleted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bRowInserted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bRowUpdated;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == -1;
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::evaluate()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::evaluate" );
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::evaluate: Analyzer isn't set!");
+ sal_Bool bRet = sal_True;
+ while(!m_pSQLAnalyzer->evaluateRestriction())
+ {
+ if(m_pEvaluationKeySet)
+ {
+ if(m_aEvaluateIter == m_pEvaluationKeySet->end())
+ return sal_False;
+ bRet = m_pTable->seekRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),m_nRowPos);
+ ++m_aEvaluateIter;
+ }
+ else
+ bRet = m_pTable->seekRow(IResultSetHelper::NEXT,1,m_nRowPos);
+ if(bRet)
+ {
+ if(m_pEvaluationKeySet)
+ {
+ bRet = m_pTable->fetchRow(m_aEvaluateRow,m_pTable->getTableColumns().getBody(),sal_True,sal_True);
+ evaluate();
+
+ }
+ else
+ bRet = m_pTable->fetchRow(m_aRow,m_xColumns.getBody(),sal_False,sal_True);
+ }
+ }
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::next" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancel" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" );
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" );
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_bInserted || !m_pTable)
+ throwFunctionSequenceException(*this);
+
+ // we know that we append new rows at the end
+ // so we have to know where the end is
+ m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_False);
+ m_bRowInserted = m_pTable->InsertRow(m_aInsertRow.getBody(), TRUE,m_xColsIdx);
+ if(m_bRowInserted && m_pFileSet.isValid())
+ {
+ sal_Int32 nPos = (m_aInsertRow->get())[0]->getValue();
+ m_pFileSet->get().push_back(nPos);
+ *(m_aInsertRow->get())[0] = sal_Int32(m_pFileSet->get().size());
+ clearInsertRow();
+
+ m_aSkipDeletedSet.insertNewPosition((m_aRow->get())[0]->getValue());
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(!m_pTable || m_pTable->isReadOnly())
+ lcl_throwError(STR_TABLE_READONLY,*this);
+
+ m_bRowUpdated = m_pTable->UpdateRow(m_aInsertRow.getBody(), m_aRow,m_xColsIdx);
+ *(m_aInsertRow->get())[0] = (sal_Int32)(m_aRow->get())[0]->getValue();
+
+ clearInsertRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pTable || m_pTable->isReadOnly())
+ lcl_throwError(STR_TABLE_READONLY,*this);
+ if (m_bShowDeleted)
+ lcl_throwError(STR_DELETE_ROW,*this);
+ if(m_aRow->isDeleted())
+ lcl_throwError(STR_ROW_ALREADY_DELETED,*this);
+
+ sal_Int32 nPos = (sal_Int32)(m_aRow->get())[0]->getValue();
+ m_bRowDeleted = m_pTable->DeleteRow(m_xColumns.getBody());
+ if(m_bRowDeleted && m_pFileSet.isValid())
+ {
+ m_aRow->setDeleted(sal_True);
+ // don't touch the m_pFileSet member here
+ m_aSkipDeletedSet.deletePosition(nPos);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bInserted = sal_False;
+ m_bRowUpdated = sal_False;
+ m_bRowInserted = sal_False;
+ m_bRowDeleted = sal_False;
+
+ if(m_aInsertRow.isValid())
+ {
+ OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1;
+ for(;aIter != m_aInsertRow->get().end();++aIter)
+ {
+ (*aIter)->setBound(sal_False);
+ (*aIter)->setNull();
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(!m_pTable || m_pTable->isReadOnly())
+ lcl_throwError(STR_TABLE_READONLY,*this);
+
+ m_bInserted = sal_True;
+
+ OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1;
+ for(;aIter != m_aInsertRow->get().end();++aIter)
+ {
+ (*aIter)->setBound(sal_False);
+ (*aIter)->setNull();
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" );
+}
+// -------------------------------------------------------------------------
+void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ checkIndex(columnIndex );
+ columnIndex = mapColumn(columnIndex);
+
+ (m_aInsertRow->get())[columnIndex]->setBound(sal_True);
+ *(m_aInsertRow->get())[columnIndex] = x;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNull" );
+ ORowSetValue aEmpty;
+ updateValue(columnIndex,aEmpty);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateByte" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateShort" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateInt" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateLong" );
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this );
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateString" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDate" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTime" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateValue(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" );
+ updateBinaryStream(columnIndex,x,length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateObject" );
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" );
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" );
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" );
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------
+BOOL OResultSet::ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition,
+ INT32 nFirstOffset,
+ BOOL bEvaluate,
+ BOOL bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::ExecuteRow" );
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::ExecuteRow: Analyzer isn't set!");
+
+ // Fuer weitere Fetch-Operationen werden diese Angaben ggf. veraendert ...
+ IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition;
+ INT32 nOffset = nFirstOffset;
+
+ const OSQLColumns & rTableCols = m_pTable->getTableColumns().getBody();
+ BOOL bHasRestriction = m_pSQLAnalyzer->hasRestriction();
+again:
+
+ // protect from reading over the end when someboby is inserting while we are reading
+ // this method works only for dBase at the moment !!!!
+ if (eCursorPosition == IResultSetHelper::NEXT && m_nFilePos == m_nLastVisitedPos)
+ {
+ return sal_False;
+ }
+
+ if (!m_pTable || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
+ {
+ return sal_False;
+ }
+
+ if (!bEvaluate) // Laeuft keine Auswertung, dann nur Ergebniszeile fuellen
+ {
+ m_pTable->fetchRow(m_aRow,rTableCols, sal_True,bRetrieveData);
+ }
+ else
+ {
+ m_pTable->fetchRow(m_aEvaluateRow, rTableCols, sal_True,bRetrieveData || bHasRestriction);
+
+ if ( (!m_bShowDeleted && m_aEvaluateRow->isDeleted())
+ || (bHasRestriction && //!bShowDeleted && m_aEvaluateRow->isDeleted() ||// keine Anzeige von geloeschten Saetzen
+ !m_pSQLAnalyzer->evaluateRestriction())) // Auswerten der Bedingungen
+ { // naechsten Satz auswerten
+ // aktuelle Zeile loeschen im Keyset
+ if (m_pEvaluationKeySet)
+ {
+ ++m_aEvaluateIter;
+ if (m_pEvaluationKeySet->end() != m_aEvaluateIter)
+ nOffset = (*m_aEvaluateIter);
+ else
+ {
+ return sal_False;
+ }
+ }
+ else if (m_pFileSet.isValid())
+ {
+ OSL_ENSURE(//!m_pFileSet->IsFrozen() &&
+ eCursorPosition == IResultSetHelper::NEXT, "Falsche CursorPosition!");
+ eCursorPosition = IResultSetHelper::NEXT;
+ nOffset = 1;
+ }
+ else if (eCursorPosition == IResultSetHelper::FIRST ||
+ eCursorPosition == IResultSetHelper::NEXT ||
+ eCursorPosition == IResultSetHelper::ABSOLUTE)
+ {
+ eCursorPosition = IResultSetHelper::NEXT;
+ nOffset = 1;
+ }
+ else if (eCursorPosition == IResultSetHelper::LAST ||
+ eCursorPosition == IResultSetHelper::PRIOR)
+ {
+ eCursorPosition = IResultSetHelper::PRIOR;
+ nOffset = 1;
+ }
+ else if (eCursorPosition == IResultSetHelper::RELATIVE)
+ {
+ eCursorPosition = (nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR;
+ }
+ else
+ {
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ return sal_False;
+ }
+ // Nochmal probieren ...
+ goto again;
+ }
+ }
+
+ // Evaluate darf nur gesetzt sein,
+ // wenn der Keyset weiter aufgebaut werden soll
+ if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && !isCount() &&
+ (m_pFileSet.isValid() || m_pSortIndex) && bEvaluate)
+ {
+ if (m_pSortIndex)
+ {
+ OKeyValue* pKeyValue = GetOrderbyKeyValue(m_aEvaluateRow);
+ m_pSortIndex->AddKeyValue(pKeyValue);
+ }
+ else if (m_pFileSet.isValid())
+ {
+ // OSL_ENSURE(!m_pFileSet->IsFrozen() , "Falsche CursorPosition!");
+ sal_uInt32 nBookmarkValue = Abs((sal_Int32)(m_aEvaluateRow->get())[0]->getValue());
+ m_pFileSet->get().push_back(nBookmarkValue);
+ }
+ }
+ else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE)
+ {
+ sal_Bool bOK = sal_True;
+ if (bEvaluate)
+ {
+ // jetzt die eigentliche Ergebniszeile Lesen
+ bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,TRUE);
+ }
+
+ if (bOK)
+ {
+ // Nur die zu aendernden Werte uebergeben:
+ if(!m_pTable->UpdateRow(m_aAssignValues.getBody(),m_aEvaluateRow,m_xColsIdx))
+ return sal_False;
+ }
+ }
+ else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_DELETE)
+ {
+ sal_Bool bOK = sal_True;
+ if (bEvaluate)
+ {
+ bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,TRUE);
+ }
+ if (bOK)
+ {
+ if(!m_pTable->DeleteRow(m_xColumns.getBody()))
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+//-------------------------------------------------------------------
+BOOL OResultSet::Move(IResultSetHelper::Movement eCursorPosition, INT32 nOffset, BOOL bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::Move" );
+
+//IgnoreDeletedRows:
+//
+ INT32 nTempPos = m_nRowPos;
+ // exclusiver zugriff auf die Tabelle
+ // NAMESPACE_VOS(OGuard)* pGuard = m_pTable->Lock();
+
+ if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT &&
+ !isCount())
+ {
+ if (!m_pFileSet.isValid()) // kein Index verfuegbar
+ {
+ // Normales FETCH
+ ExecuteRow(eCursorPosition,nOffset,FALSE,bRetrieveData);
+
+ // now set the bookmark for outside this is the logical pos and not the file pos
+ *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
+ }
+ else
+ {
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nRowPos;
+ break;
+ case IResultSetHelper::PRIOR:
+ if (m_nRowPos >= 0)
+ --m_nRowPos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ // OSL_ENSURE(IsRowCountFinal(), "Fehler im Keyset!"); // muss eingefroren sein, sonst Fehler beim SQLCursor
+ m_nRowPos = m_pFileSet->get().size() - 1;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nRowPos += nOffset;
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ if ( m_nRowPos == (nOffset -1) )
+ return sal_True;
+ m_nRowPos = nOffset -1;
+ break;
+ }
+
+ // OffRange?
+ // Der FileCursor ist ausserhalb des gueltigen Bereichs, wenn
+ // a.) m_nRowPos < 1
+ // b.) Ein KeySet besteht und m_nRowPos > m_pFileSet->size()
+ if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= (INT32)m_pFileSet->get().size() )) // && m_pFileSet->IsFrozen()
+ {
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ goto Error;
+ }
+ else
+ {
+ if (m_nRowPos < (INT32)m_pFileSet->get().size())
+ {
+ // Fetch ueber Index
+ ExecuteRow(IResultSetHelper::BOOKMARK,(m_pFileSet->get())[m_nRowPos],FALSE,bRetrieveData);
+
+ // now set the bookmark for outside
+ *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
+ if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
+ {
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ }
+ }
+ else // Index muss weiter aufgebaut werden
+ {
+ // Zunaechst auf die letzte bekannte Zeile setzen
+ if (!m_pFileSet->get().empty())
+ {
+ m_aFileSetIter = m_pFileSet->get().end()-1;
+ // m_pFileSet->SeekPos(m_pFileSet->size()-1);
+ m_pTable->seekRow(IResultSetHelper::BOOKMARK, *m_aFileSetIter, m_nFilePos);
+ }
+ sal_Bool bOK = sal_True;
+ // Ermitteln der Anzahl weiterer Fetches
+ while (bOK && m_nRowPos >= (INT32)m_pFileSet->get().size())
+ {
+ if (m_pEvaluationKeySet)
+ {
+ if (m_nRowPos >= (INT32)m_pEvaluationKeySet->size())
+ return sal_False;
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ else if (m_nRowPos == 0)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+ bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,TRUE, bRetrieveData);
+ }
+ else
+ {
+ ++m_aEvaluateIter;
+ bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,TRUE, bRetrieveData);
+ }
+ }
+ else
+ bOK = ExecuteRow(IResultSetHelper::NEXT,1,TRUE, FALSE);//bRetrieveData);
+ }
+
+ if (bOK)
+ {
+ // jetzt nochmal die Ergebnisse lesen
+ m_pTable->fetchRow(m_aRow, m_pTable->getTableColumns().getBody(), sal_True,bRetrieveData);
+
+ // now set the bookmark for outside
+ *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
+
+ if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
+ {
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ }
+ }
+ else if (!m_pFileSet->isFrozen()) // keinen gueltigen Satz gefunden
+ {
+ //m_pFileSet->Freeze();
+ m_pFileSet->setFrozen();
+
+ // DELETEZ(m_pEvaluationKeySet);
+ m_pEvaluationKeySet = NULL;
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ goto Error;
+ }
+ }
+ }
+ }
+ }
+ else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && isCount())
+ {
+ // Fetch des COUNT(*)
+ switch (eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nRowPos;
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ m_nRowPos = 0;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nRowPos += nOffset;
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ m_nRowPos = nOffset - 1;
+ break;
+ }
+
+ if (m_nRowPos == 0)
+ {
+ // COUNT(*) in Ergebnisrow packen
+ // (muss die erste und einzige Variable in der Row sein)
+ if (m_aRow->get().size() >= 2)
+ {
+ *(m_aRow->get())[1] = m_nRowCountResult;
+ *(m_aRow->get())[0] = sal_Int32(1);
+ (m_aRow->get())[1]->setBound(sal_True);
+ (m_aSelectRow->get())[1] = (m_aRow->get())[1];
+ }
+ }
+ else
+ {
+ m_bEOF = sal_True;
+ m_nRowPos = 1;
+ return sal_False;
+ }
+ }
+ else
+ // Fetch nur bei SELECT moeglich!
+ return sal_False;
+
+ return sal_True;
+
+Error:
+ // steht der Cursor vor dem ersten Satz
+ // dann wird die position beibehalten
+ if (nTempPos == -1)
+ m_nRowPos = nTempPos;
+ else
+ {
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::PRIOR:
+ case IResultSetHelper::FIRST:
+ m_nRowPos = -1;
+ break;
+ case IResultSetHelper::LAST:
+ case IResultSetHelper::NEXT:
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::RELATIVE:
+ if (nOffset > 0)
+ m_nRowPos = m_pFileSet.isValid() ? (sal_Int32)m_pFileSet->get().size() : -1;
+ else if (nOffset < 0)
+ m_nRowPos = -1;
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_nRowPos = nTempPos; // vorherige Position
+ }
+ }
+ // delete pGuard;
+ // rMode = (!bShowDeleted && aStatus.IsSuccessful() && m_aRow->isDeleted()) ? // keine Anzeige von geloeschten Saetzen
+ // OCursor::SQL_MOD_INVALID : OCursor::SQL_MOD_NONE;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void OResultSet::sortRows()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::sortRows" );
+ if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber.size() == 1)
+ {
+ // Ist nur ein Feld fuer die Sortierung angegeben
+ // Und diese Feld ist indiziert, dann den Index ausnutzen
+ Reference<XIndexesSupplier> xIndexSup;
+ m_pTable->queryInterface(::getCppuType((const Reference<XIndexesSupplier>*)0)) >>= xIndexSup;
+ // Reference<XIndexesSupplier> xIndexSup(m_pTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexes;
+ if(xIndexSup.is())
+ {
+ xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
+ Reference<XPropertySet> xColProp;
+ if(m_aOrderbyColumnNumber[0] < xIndexes->getCount())
+ {
+ xColProp.set(xIndexes->getByIndex(m_aOrderbyColumnNumber[0]),UNO_QUERY);
+ // iterate through the indexes to find the matching column
+ const sal_Int32 nCount = xIndexes->getCount();
+ for(sal_Int32 i=0; i < nCount;++i)
+ {
+ Reference<XColumnsSupplier> xIndex(xIndexes->getByIndex(i),UNO_QUERY);
+ Reference<XNameAccess> xIndexCols = xIndex->getColumns();
+ if(xIndexCols->hasByName(comphelper::getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))))
+ {
+ m_pFileSet = new OKeySet();
+
+ if(fillIndexValues(xIndex))
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
+ ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
+ for (::std::vector<sal_Int16>::size_type i=0;aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
+ {
+ OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
+ switch ((*(m_aRow->get().begin()+*aOrderByIter))->getValue().getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ eKeyType[i] = SQL_ORDERBYKEY_STRING;
+ break;
+
+ case DataType::OTHER:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BIT:
+ eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
+ break;
+
+ // Andere Typen sind nicht implementiert (und damit immer FALSE)
+ default:
+ eKeyType[i] = SQL_ORDERBYKEY_NONE;
+ OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert");
+ break;
+ }
+ (m_aEvaluateRow->get())[*aOrderByIter]->setBound(sal_True);
+ }
+
+ m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
+
+ if (m_pEvaluationKeySet)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+
+ while (m_aEvaluateIter != m_pEvaluationKeySet->end())
+ {
+ ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),TRUE);
+ ++m_aEvaluateIter;
+ }
+ }
+ else
+ {
+ while (ExecuteRow(IResultSetHelper::NEXT,1,TRUE))
+ {
+ }
+ }
+
+ // Sortiertes Keyset erzeugen
+ // DELETEZ(m_pEvaluationKeySet);
+ m_pEvaluationKeySet = NULL;
+ m_pFileSet = NULL;
+ m_pFileSet = m_pSortIndex->CreateKeySet();
+ // if(!bDistinct)
+ // SetRowCount(pFileSet->count());
+ DELETEZ(m_pSortIndex);
+ // Nun kann ueber den Index sortiert zugegriffen werden.
+}
+
+
+// -------------------------------------------------------------------------
+BOOL OResultSet::OpenImpl()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OpenImpl" );
+ OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!");
+ if(!m_pTable)
+ {
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+ if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is())
+ lcl_throwError(STR_QUERY_TOO_COMPLEX,*this);
+
+ if ( xTabs.size() > 1 || m_aSQLIterator.hasErrors() )
+ lcl_throwError(STR_QUERY_MORE_TABLES,*this);
+
+ OSQLTable xTable = xTabs.begin()->second;
+ m_xColumns = m_aSQLIterator.getSelectColumns();
+
+ m_xColNames = xTable->getColumns();
+ m_xColsIdx.set(m_xColNames,UNO_QUERY);
+ doTableSpecials(xTable);
+ Reference<XComponent> xComp(xTable,UNO_QUERY);
+ if(xComp.is())
+ xComp->addEventListener(this);
+ }
+
+ m_pTable->refreshHeader();
+
+ sal_Int32 nColumnCount = m_xColsIdx->getCount();
+
+ initializeRow(m_aRow,nColumnCount);
+ initializeRow(m_aEvaluateRow,nColumnCount);
+ initializeRow(m_aInsertRow,nColumnCount);
+
+
+ m_nResultSetConcurrency = (m_pTable->isReadOnly() || isCount()) ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
+
+ // Neuen Index aufbauen:
+ m_pFileSet = NULL;
+ // DELETEZ(m_pEvaluationKeySet);
+
+ // An den Anfang positionieren
+ m_nRowPos = -1;
+ m_nFilePos = 0;
+ m_nRowCountResult = -1;
+
+ // exclusiver zugriff auf die Tabelle
+ // NAMESPACE_VOS(OGuard)* pGuard = pTable->Lock();
+ m_nLastVisitedPos = m_pTable->getCurrentLastPos();
+
+ switch(m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ if(isCount())
+ {
+ if(m_xColumns->get().size() > 1)
+ lcl_throwError(STR_QUERY_COMPLEX_COUNT,*this);
+
+ m_nRowCountResult = 0;
+ // Vorlaeufig einfach ueber alle Datensaetze iterieren und
+ // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen):
+ {
+ sal_Bool bOK = sal_True;
+ if (m_pEvaluationKeySet)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+
+ }
+ while (bOK)
+ {
+ if (m_pEvaluationKeySet)
+ ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),TRUE);
+ else
+ bOK = ExecuteRow(IResultSetHelper::NEXT,1,TRUE);
+
+ if (bOK)
+ {
+ m_nRowCountResult++;
+ if(m_pEvaluationKeySet)
+ {
+ ++m_aEvaluateIter;
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+ }
+ }
+ }
+
+ // Ergebnis von COUNT(*) in m_nRowCountResult merken.
+ // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser
+ // Anfrage = 1!
+ m_pEvaluationKeySet = NULL;
+ // DELETEZ(m_pEvaluationKeySet);
+ }
+ }
+ else
+ {
+ BOOL bDistinct = FALSE;
+ BOOL bWasSorted = FALSE;
+ OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
+ ::std::vector<sal_Int32> aOrderbyColumnNumberSave;
+ ::std::vector<TAscendingOrder> aOrderbyAscendingSave;
+
+ if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT )
+ {
+ // Sort on all columns, saving original order for later
+ if(IsSorted())
+ {
+ aOrderbyColumnNumberSave = m_aOrderbyColumnNumber;// .assign(m_aOrderbyColumnNumber.begin(), m_aOrderbyColumnNumber.end());
+ m_aOrderbyColumnNumber.clear();
+ aOrderbyAscendingSave.assign(m_aOrderbyAscending.begin(), m_aOrderbyAscending.end());
+ bWasSorted = TRUE;
+ }
+
+ // the first column is the bookmark column
+ ::std::vector<sal_Int32>::iterator aColStart = (m_aColMapping.begin()+1);
+ ::std::copy(aColStart, m_aColMapping.end(),::std::back_inserter(m_aOrderbyColumnNumber));
+// m_aOrderbyColumnNumber.assign(aColStart, m_aColMapping.end());
+ m_aOrderbyAscending.assign(m_aColMapping.size()-1, SQL_ASC);
+ bDistinct = TRUE;
+ }
+
+ if (IsSorted())
+ sortRows();
+
+ if (!m_pFileSet.isValid())
+ {
+ m_pFileSet = new OKeySet();
+
+ if (!m_pSQLAnalyzer->hasRestriction())
+ // jetzt kann das Keyset schon gefuellt werden!
+ // Aber Achtung: es wird davon ausgegangen, das die FilePositionen als Folge 1..n
+ // abgelegt werden!
+ {
+ if ( m_nLastVisitedPos > 0)
+ m_pFileSet->get().reserve( m_nLastVisitedPos );
+ for (sal_Int32 i = 0; i < m_nLastVisitedPos; i++)
+ m_pFileSet->get().push_back(i + 1);
+ }
+ }
+ OSL_ENSURE(m_pFileSet.isValid(),"Kein KeySet vorhanden! :-(");
+
+ if(bDistinct && m_pFileSet.isValid()) // sicher ist sicher
+ {
+ OValueRow aSearchRow = new OValueVector(m_aRow->get().size());
+ OValueRefVector::Vector::iterator aRowIter = m_aRow->get().begin();
+ OValueVector::Vector::iterator aSearchIter = aSearchRow->get().begin();
+ for ( ++aRowIter,++aSearchIter; // the first column is the bookmark column
+ aRowIter != m_aRow->get().end();
+ ++aRowIter,++aSearchIter)
+ aSearchIter->setBound((*aRowIter)->isBound());
+
+ size_t nMaxRow = m_pFileSet->get().size();
+
+ if (nMaxRow)
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ INT32 nFound=0;
+ #endif
+ INT32 nPos;
+ INT32 nKey;
+
+ for( size_t j = nMaxRow-1; j > 0; --j)
+ {
+ nPos = (m_pFileSet->get())[j];
+ ExecuteRow(IResultSetHelper::BOOKMARK,nPos,FALSE);
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ { // copy row values
+ OValueRefVector::Vector::iterator copyFrom = m_aSelectRow->get().begin();
+ OValueVector::Vector::iterator copyTo = aSearchRow->get().begin();
+ for ( ++copyFrom,++copyTo; // the first column is the bookmark column
+ copyFrom != m_aSelectRow->get().end();
+ ++copyFrom,++copyTo)
+ *copyTo = *(*copyFrom);
+ // *aSearchRow = *m_aRow;
+ }
+
+ // compare with next row
+ nKey = (m_pFileSet->get())[j-1];
+ ExecuteRow(IResultSetHelper::BOOKMARK,nKey,FALSE);
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ OValueRefVector::Vector::iterator loopInRow = m_aSelectRow->get().begin();
+ OValueVector::Vector::iterator existentInSearchRow = aSearchRow->get().begin();
+ for ( ++loopInRow,++existentInSearchRow; // the first column is the bookmark column
+ loopInRow != m_aSelectRow->get().end();
+ ++loopInRow,++existentInSearchRow)
+ {
+ if ( (*loopInRow)->isBound() && !( *(*loopInRow) == *existentInSearchRow) )
+ break;
+ }
+
+ if(loopInRow == m_aSelectRow->get().end())
+ (m_pFileSet->get())[j] = 0; // Rows match -- Mark for deletion by setting key to 0
+ #if OSL_DEBUG_LEVEL > 1
+ else
+ nFound++;
+ #endif
+ }
+
+ m_pFileSet->get().erase(::std::remove_if(m_pFileSet->get().begin(),m_pFileSet->get().end(),
+ ::std::bind2nd(::std::equal_to<sal_Int32>(),0))
+ ,m_pFileSet->get().end());
+
+ if (bWasSorted)
+ {
+ // Re-sort on original requested order
+ m_aOrderbyColumnNumber = aOrderbyColumnNumberSave;
+ m_aOrderbyAscending.assign(aOrderbyAscendingSave.begin(), aOrderbyAscendingSave.end());
+
+ TIntVector aEvaluationKeySet(m_pFileSet->get());
+ m_pEvaluationKeySet = &aEvaluationKeySet;
+ sortRows();
+ }
+ else
+ {
+ m_aOrderbyColumnNumber.clear();
+ m_aOrderbyAscending.clear();
+ ::std::sort(m_pFileSet->get().begin(),m_pFileSet->get().end());
+ }
+ }
+ // SetRowCount(m_pFileSet->count());
+ }
+ }
+ } break;
+
+ case SQL_STATEMENT_UPDATE:
+ case SQL_STATEMENT_DELETE:
+ // waehrend der Bearbeitung die Anzahl der bearbeiteten Rows zaehlen:
+ m_nRowCountResult = 0;
+ // Vorlaeufig einfach ueber alle Datensaetze iterieren und
+ // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen):
+ {
+
+ sal_Bool bOK = sal_True;
+ if (m_pEvaluationKeySet)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+
+ }
+ while (bOK)
+ {
+ if (m_pEvaluationKeySet)
+ ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),TRUE);
+ else
+ bOK = ExecuteRow(IResultSetHelper::NEXT,1,TRUE);
+
+ if (bOK)
+ {
+ m_nRowCountResult++;
+ if(m_pEvaluationKeySet)
+ {
+ ++m_aEvaluateIter;
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+ }
+ }
+ }
+
+ // Ergebnis von COUNT(*) in nRowCountResult merken.
+ // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser
+ // Anfrage = 1!
+ // DELETEZ(m_pEvaluationKeySet);
+ m_pEvaluationKeySet = NULL;
+ }
+ // SetRowCount(1);
+ break;
+ case SQL_STATEMENT_INSERT:
+ m_nRowCountResult = 0;
+
+ OSL_ENSURE(m_aAssignValues.isValid(),"No assign values set!");
+ if(!m_pTable->InsertRow(m_aAssignValues.getBody(), TRUE,m_xColsIdx))
+ {
+ m_nFilePos = 0;
+ return sal_False;
+ }
+
+ m_nRowCountResult = 1;
+ break;
+ default:
+ OSL_ENSURE( false, "OResultSet::OpenImpl: unsupported statement type!" );
+ break;
+ }
+
+ // FilePos zuruecksetzen
+ m_nFilePos = 0;
+
+ return sal_True;
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::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 OResultSet::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : 0;
+}
+// -----------------------------------------------------------------------------
+void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
+ const OValueRefRow& _rSelectRow,
+ const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,
+ const Reference<XIndexAccess>& _xNames,
+ sal_Bool _bSetColumnMapping,
+ const Reference<XDatabaseMetaData>& _xMetaData,
+ ::std::vector<sal_Int32>& _rColMapping)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::setBoundedColumns" );
+ ::comphelper::UStringMixEqual aCase(_xMetaData->storesMixedCaseQuotedIdentifiers());
+
+ Reference<XPropertySet> xTableColumn;
+ ::rtl::OUString sTableColumnName, sSelectColumnRealName;
+
+ const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
+ const ::rtl::OUString sType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE);
+
+ typedef ::std::map<OSQLColumns::Vector::iterator,sal_Bool> IterMap;
+ IterMap aSelectIters;
+ OValueRefVector::Vector::iterator aRowIter = _rRow->get().begin()+1;
+ for (sal_Int32 i=0; // the first column is the bookmark column
+ aRowIter != _rRow->get().end();
+ ++i, ++aRowIter
+ )
+ {
+ (*aRowIter)->setBound(sal_False);
+ try
+ {
+ // get the table column and it's name
+ _xNames->getByIndex(i) >>= xTableColumn;
+ OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
+ if (xTableColumn.is())
+ xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
+ else
+ sTableColumnName = ::rtl::OUString();
+
+ // look if we have such a select column
+ // TODO: would like to have a O(log n) search here ...
+ for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
+ aIter != _rxColumns->get().end();
+ ++aIter
+ )
+ {
+ if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
+ (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
+ else
+ (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
+
+ if ( aCase(sTableColumnName, sSelectColumnRealName) && !(*aRowIter)->isBound() && aSelectIters.end() == aSelectIters.find(aIter) )
+ {
+ aSelectIters.insert(IterMap::value_type(aIter,sal_True));
+ if(_bSetColumnMapping)
+ {
+ sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
+ // the getXXX methods are 1-based ...
+ sal_Int32 nTableColumnPos = i + 1;
+ // get first table column is the bookmark column ...
+ _rColMapping[nSelectColumnPos] = nTableColumnPos;
+ (_rSelectRow->get())[nSelectColumnPos] = *aRowIter;
+ }
+
+ (*aRowIter)->setBound(sal_True);
+ sal_Int32 nType = DataType::OTHER;
+ if (xTableColumn.is())
+ xTableColumn->getPropertyValue(sType) >>= nType;
+ (*aRowIter)->setTypeKind(nType);
+
+ break;
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(sal_False, "OResultSet::setBoundedColumns: caught an Exception!");
+ }
+ }
+ // in this case we got more select columns as columns exist in the table
+ if ( _bSetColumnMapping && aSelectIters.size() != _rColMapping.size() )
+ {
+ Reference<XNameAccess> xNameAccess(_xNames,UNO_QUERY);
+ Sequence< ::rtl::OUString > aSelectColumns = xNameAccess->getElementNames();
+
+ for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
+ aIter != _rxColumns->get().end();
+ ++aIter
+ )
+ {
+ if ( aSelectIters.end() == aSelectIters.find(aIter) )
+ {
+ if ( (*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName) )
+ (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
+ else
+ (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
+
+ if ( xNameAccess->hasByName( sSelectColumnRealName ) )
+ {
+ aSelectIters.insert(IterMap::value_type(aIter,sal_True));
+ sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
+ const ::rtl::OUString* pBegin = aSelectColumns.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aSelectColumns.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i)
+ {
+ if ( aCase(*pBegin, sSelectColumnRealName) )
+ {
+ // the getXXX methods are 1-based ...
+ sal_Int32 nTableColumnPos = i + 1;
+ // get first table column is the bookmark column ...
+ _rColMapping[nSelectColumnPos] = nTableColumnPos;
+ (_rSelectRow->get())[nSelectColumnPos] = (_rRow->get())[nTableColumnPos];
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" );
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void OResultSet::doTableSpecials(const OSQLTable& _xTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::doTableSpecials" );
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(_xTable,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ m_pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()) );
+ if(m_pTable)
+ m_pTable->acquire();
+ }
+}
+// -----------------------------------------------------------------------------
+void OResultSet::clearInsertRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearInsertRow" );
+ m_aRow->setDeleted(sal_False); // set to false here because this is the new row
+ OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin();
+ const OValueRefVector::Vector::iterator aEnd = m_aInsertRow->get().end();
+ for(sal_Int32 nPos = 0;aIter != aEnd;++aIter,++nPos)
+ {
+ ORowSetValueDecoratorRef& rValue = (*aIter);
+ if ( rValue->isBound() )
+ {
+ (m_aRow->get())[nPos]->setValue( (*aIter)->getValue() );
+ }
+ rValue->setBound(nPos == 0);
+ rValue->setModified(sal_False);
+ rValue->setNull();
+ }
+}
+// -----------------------------------------------------------------------------
+void OResultSet::initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::initializeRow" );
+ if(!_rRow.isValid())
+ {
+ _rRow = new OValueRefVector(_nColumnCount);
+ (_rRow->get())[0]->setBound(sal_True);
+ ::std::for_each(_rRow->get().begin()+1,_rRow->get().end(),TSetRefBound(sal_False));
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::fillIndexValues" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::move" );
+ return Move(_eCursorPosition,_nOffset,_bRetrieveData);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OResultSet::getDriverPos() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDriverPos" );
+ return (m_aRow->get())[0]->getValue();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::deletedVisible() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deletedVisible" );
+ return m_bShowDeleted;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::isRowDeleted() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isRowDeleted" );
+ return m_aRow->isDeleted();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::disposing( const EventObject& Source ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
+ // Reference<XInterface> xInt = m_pTable;
+ Reference<XPropertySet> xProp = m_pTable;
+ if(m_pTable && Source.Source == xProp)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx
new file mode 100644
index 000000000000..3e3befaa2430
--- /dev/null
+++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * 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 "file/FResultSetMetaData.hxx"
+#include "file/FTable.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace dbtools;
+using namespace connectivity::file;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::OResultSetMetaData(const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,const ::rtl::OUString& _aTableName,OFileTable* _pTable)
+ :m_aTableName(_aTableName)
+ ,m_xColumns(_rxColumns)
+ ,m_pTable(_pTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::OResultSetMetaData" );
+}
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::~OResultSetMetaData()
+{
+ m_xColumns = NULL;
+}
+// -----------------------------------------------------------------------------
+void OResultSetMetaData::checkColumnIndex(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::checkColumnIndex" );
+ if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
+ throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnDisplaySize" );
+ return getPrecision(column);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnType" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnCount" );
+ return (m_xColumns->get()).size();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isCaseSensitive" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getSchemaName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnName" );
+ checkColumnIndex(column);
+
+ Any aName((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
+ return aName.hasValue() ? getString(aName) : getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getTableName" );
+ return m_aTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getCatalogName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnTypeName" );
+ checkColumnIndex(column);
+ return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnLabel" );
+ return getColumnName(column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnServiceName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isCurrency" );
+ checkColumnIndex(column);
+ return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*setCatalogcolumn*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isAutoIncrement" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSigned" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getPrecision" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getScale" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isNullable" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSearchable" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isReadOnly" );
+ checkColumnIndex(column);
+ return m_pTable->isReadOnly() || (
+ (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
+ ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isDefinitelyWritable" );
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isWritable" );
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
new file mode 100644
index 000000000000..acc2059f15c7
--- /dev/null
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -0,0 +1,860 @@
+/*************************************************************************
+ *
+ * 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 <osl/diagnose.h>
+#include "file/FStatement.hxx"
+#include "file/FConnection.hxx"
+#include "file/FDriver.hxx"
+#include "file/FResultSet.hxx"
+#include <comphelper/property.hxx>
+#include <comphelper/uno3.hxx>
+#include <osl/thread.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include "connectivity/dbexception.hxx"
+#include "resource/file_res.hrc"
+#include <algorithm>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+#define THROW_SQL(x) \
+ OTools::ThrowException(x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
+
+namespace connectivity
+{
+ namespace file
+ {
+
+//------------------------------------------------------------------------------
+using namespace dbtools;
+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;
+DBG_NAME( file_OStatement_Base )
+
+//------------------------------------------------------------------------------
+OStatement_Base::OStatement_Base(OConnection* _pConnection )
+ :OStatement_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer(OStatement_BASE::rBHelper)
+ ,m_xDBMetaData(_pConnection->getMetaData())
+ ,m_aParser(_pConnection->getDriver()->getFactory())
+ ,m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL )
+ ,m_pConnection(_pConnection)
+ ,m_pParseTree(NULL)
+ ,m_pSQLAnalyzer(NULL)
+ ,m_pEvaluationKeySet(NULL)
+ ,m_pTable(NULL)
+ ,m_nMaxFieldSize(0)
+ ,m_nMaxRows(0)
+ ,m_nQueryTimeOut(0)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::FORWARD_ONLY)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ ,m_bEscapeProcessing(sal_True)
+ ,rBHelper(OStatement_BASE::rBHelper)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::OStatement_Base" );
+ DBG_CTOR( file_OStatement_Base, NULL );
+
+ m_pConnection->acquire();
+
+ sal_Int32 nAttrib = 0;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), PROPERTY_ID_CURSORNAME, nAttrib,&m_aCursorName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), PROPERTY_ID_MAXFIELDSIZE, nAttrib,&m_nMaxFieldSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), PROPERTY_ID_MAXROWS, nAttrib,&m_nMaxRows, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), PROPERTY_ID_QUERYTIMEOUT, nAttrib,&m_nQueryTimeOut, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, nAttrib,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, nAttrib,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, nAttrib,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),PROPERTY_ID_ESCAPEPROCESSING, nAttrib,&m_bEscapeProcessing,::getCppuBooleanType());
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, nAttrib,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+OStatement_Base::~OStatement_Base()
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ disposing();
+ delete m_pSQLAnalyzer;
+
+ DBG_DTOR( file_OStatement_Base, NULL );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::disposeResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::disposeResultSet" );
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet = Reference< XResultSet>();
+}
+//------------------------------------------------------------------------------
+void OStatement_BASE2::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ disposeResultSet();
+
+ if(m_pSQLAnalyzer)
+ m_pSQLAnalyzer->dispose();
+
+ if(m_aRow.isValid())
+ {
+ m_aRow->get().clear();
+ m_aRow = NULL;
+ }
+
+ m_aSQLIterator.dispose();
+
+ if(m_pTable)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+
+ if (m_pConnection)
+ {
+ m_pConnection->release();
+ m_pConnection = NULL;
+ }
+
+ dispose_ChildImpl();
+
+ if ( m_pParseTree )
+ {
+ delete m_pParseTree;
+ m_pParseTree = NULL;
+ }
+
+ OStatement_Base::disposing();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::acquire() throw()
+{
+ OStatement_BASE::acquire();
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OStatement_BASE2::release() throw()
+{
+ relase_ChildImpl();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::queryInterface" );
+ const Any aRet = OStatement_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getTypes" );
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::cancel" );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::close" );
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void OStatement_Base::reset() throw (SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::reset" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ clearWarnings ();
+
+ if (m_xResultSet.get().is())
+ clearMyResultSet();
+}
+//--------------------------------------------------------------------
+// clearMyResultSet
+// If a ResultSet was created for this Statement, close it
+//--------------------------------------------------------------------
+
+void OStatement_Base::clearMyResultSet () throw (SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::clearMyResultSet " );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ Reference<XCloseable> xCloseable;
+ if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
+ xCloseable->close();
+ }
+ catch( const DisposedException& ) { }
+
+ m_xResultSet = Reference< XResultSet>();
+}
+//--------------------------------------------------------------------
+// setWarning
+// Sets the warning
+//--------------------------------------------------------------------
+
+void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::setWarning " );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = ex;
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getWarnings" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::clearWarnings" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::createArrayHelper" );
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getInfoHelper" );
+ return *const_cast<OStatement_Base*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+OResultSet* OStatement::createResultSet()
+{
+ return new OResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbc.driver.file.Statement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ executeQuery(sql);
+
+ return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OStatement::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ construct(sql);
+ Reference< XResultSet > xRS;
+ OResultSet* pResult = createResultSet();
+ xRS = pResult;
+ initializeResultSet(pResult);
+ m_xResultSet = Reference<XResultSet>(pResult);
+
+ pResult->OpenImpl();
+
+ return xRS;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStatement::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ construct(sql);
+ OResultSet* pResult = createResultSet();
+ Reference< XResultSet > xRS = pResult;
+ initializeResultSet(pResult);
+ pResult->OpenImpl();
+
+ return pResult->getRowCountResult();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::disposing" );
+ if(m_aEvaluateRow.isValid())
+ {
+ m_aEvaluateRow->get().clear();
+ m_aEvaluateRow = NULL;
+ }
+ delete m_pEvaluationKeySet;
+ OStatement_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getPropertySetInfo" );
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OStatement_XStatement::queryInterface( rType);
+ return aRet.hasValue() ? aRet : OStatement_BASE2::queryInterface( rType);
+}
+// -----------------------------------------------------------------------------
+OSQLAnalyzer* OStatement_Base::createAnalyzer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::createAnalyzer" );
+ return new OSQLAnalyzer(m_pConnection);
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::anylizeSQL()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::anylizeSQL" );
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::anylizeSQL: Analyzer isn't set!");
+ // start analysing the statement
+ m_pSQLAnalyzer->setOrigColumns(m_xColNames);
+ m_pSQLAnalyzer->start(m_pParseTree);
+
+ const OSQLParseNode* pOrderbyClause = m_aSQLIterator.getOrderTree();
+ if(pOrderbyClause)
+ {
+ OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree");
+
+ for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++)
+ {
+ OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0);
+ if(!SQL_ISRULE(pColumnRef,column_ref))
+ {
+ throw SQLException();
+ }
+ OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1);
+ setOrderbyColumn(pColumnRef,pAscendingDescending);
+ }
+ }
+}
+//------------------------------------------------------------------
+void OStatement_Base::setOrderbyColumn( OSQLParseNode* pColumnRef,
+ OSQLParseNode* pAscendingDescending)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::setOrderbyColumn" );
+ ::rtl::OUString aColumnName;
+ if (pColumnRef->count() == 1)
+ aColumnName = pColumnRef->getChild(0)->getTokenValue();
+ else if (pColumnRef->count() == 3)
+ {
+ // Nur die Table Range-Variable darf hier vorkommen:
+// if (!(pColumnRef->getChild(0)->getTokenValue() == aTableRange))
+// {
+// aStatus.Set(SQL_STAT_ERROR,
+// String::CreateFromAscii("S1000"),
+// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_INVALID_RANGE_VAR))),
+// 0, String() );
+ // return;
+ // }
+ pColumnRef->getChild(2)->parseNodeToStr( aColumnName, getOwnConnection(), NULL, sal_False, sal_False );
+ }
+ else
+ {
+ // aStatus.SetStatementTooComplex();
+ throw SQLException();
+ }
+
+ Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY);
+ if(!xColLocate.is())
+ return;
+ // Alles geprueft und wir haben den Namen der Column.
+ // Die wievielte Column ist das?
+ try
+ {
+ m_aOrderbyColumnNumber.push_back(xColLocate->findColumn(aColumnName));
+ }
+ catch(Exception)
+ {
+ ::vos::ORef<OSQLColumns> aSelectColumns = m_aSQLIterator.getSelectColumns();
+ ::comphelper::UStringMixEqual aCase;
+ OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),aColumnName,aCase);
+ if ( aFind == aSelectColumns->get().end() )
+ throw SQLException();
+ m_aOrderbyColumnNumber.push_back((aFind - aSelectColumns->get().begin()) + 1);
+ }
+
+ // Ascending or Descending?
+ m_aOrderbyAscending.push_back((SQL_ISTOKEN(pAscendingDescending,DESC)) ? SQL_DESC : SQL_ASC);
+}
+
+// -----------------------------------------------------------------------------
+void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::construct" );
+ ::rtl::OUString aErr;
+ m_pParseTree = m_aParser.parseTree(aErr,sql);
+ if(m_pParseTree)
+ {
+ m_aSQLIterator.setParseTree(m_pParseTree);
+ m_aSQLIterator.traverseAll();
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+
+ // sanity checks
+ if ( xTabs.empty() )
+ // no tables -> nothing to operate on -> error
+ m_pConnection->throwGenericSQLException(STR_QUERY_NO_TABLE,*this);
+
+ if ( xTabs.size() > 1 || m_aSQLIterator.hasErrors() )
+ // more than one table -> can't operate on them -> error
+ m_pConnection->throwGenericSQLException(STR_QUERY_MORE_TABLES,*this);
+
+ if ( (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT) && m_aSQLIterator.getSelectColumns()->get().empty() )
+ // SELECT statement without columns -> error
+ m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this);
+
+ switch(m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_CREATE_TABLE:
+ case SQL_STATEMENT_ODBC_CALL:
+ case SQL_STATEMENT_UNKNOWN:
+ m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this);
+ break;
+ default:
+ break;
+ }
+
+ // at this moment we support only one table per select statement
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ if(m_pTable)
+ m_pTable->release();
+ m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()));
+ if(m_pTable)
+ m_pTable->acquire();
+ }
+ OSL_ENSURE(m_pTable,"No table!");
+ if ( m_pTable )
+ m_xColNames = m_pTable->getColumns();
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ // set the binding of the resultrow
+ m_aRow = new OValueRefVector(xNames->getCount());
+ (m_aRow->get())[0]->setBound(sal_True);
+ ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetRefBound(sal_False));
+
+ // set the binding of the resultrow
+ m_aEvaluateRow = new OValueRefVector(xNames->getCount());
+
+ (m_aEvaluateRow->get())[0]->setBound(sal_True);
+ ::std::for_each(m_aEvaluateRow->get().begin()+1,m_aEvaluateRow->get().end(),TSetRefBound(sal_False));
+
+ // set the select row
+ m_aSelectRow = new OValueRefVector(m_aSQLIterator.getSelectColumns()->get().size());
+ ::std::for_each(m_aSelectRow->get().begin(),m_aSelectRow->get().end(),TSetRefBound(sal_True));
+
+ // create the column mapping
+ createColumnMapping();
+
+ m_pSQLAnalyzer = createAnalyzer();
+
+ Reference<XIndexesSupplier> xIndexSup(xTunnel,UNO_QUERY);
+ if(xIndexSup.is())
+ m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes());
+
+ anylizeSQL();
+ }
+ else
+ throw SQLException(aErr,*this,::rtl::OUString(),0,Any());
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::createColumnMapping()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::createColumnMapping" );
+ // initialize the column index map (mapping select columns to table columns)
+ ::vos::ORef<connectivity::OSQLColumns> xColumns = m_aSQLIterator.getSelectColumns();
+ m_aColMapping.resize(xColumns->get().size() + 1);
+ for (sal_Int32 i=0; i<(sal_Int32)m_aColMapping.size(); ++i)
+ m_aColMapping[i] = i;
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ // now check which columns are bound
+ OResultSet::setBoundedColumns(m_aRow,m_aSelectRow,xColumns,xNames,sal_True,m_xDBMetaData,m_aColMapping);
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::initializeResultSet(OResultSet* _pResult)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::initializeResultSet" );
+ GetAssignValues();
+
+ _pResult->setSqlAnalyzer(m_pSQLAnalyzer);
+ _pResult->setOrderByColumns(m_aOrderbyColumnNumber);
+ _pResult->setOrderByAscending(m_aOrderbyAscending);
+ _pResult->setBindingRow(m_aRow);
+ _pResult->setColumnMapping(m_aColMapping);
+ _pResult->setEvaluationRow(m_aEvaluateRow);
+ _pResult->setAssignValues(m_aAssignValues);
+ _pResult->setSelectRow(m_aSelectRow);
+
+ m_pSQLAnalyzer->bindSelectRow(m_aRow);
+ m_pEvaluationKeySet = m_pSQLAnalyzer->bindEvaluationRow(m_aEvaluateRow); // Werte im Code des Compilers setzen
+ _pResult->setEvaluationKeySet(m_pEvaluationKeySet);
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::GetAssignValues()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::GetAssignValues" );
+ if (m_pParseTree == NULL)
+ {
+ ::dbtools::throwFunctionSequenceException(*this);
+ return;
+ }
+
+ if (SQL_ISRULE(m_pParseTree,select_statement))
+ // Keine zu setzenden Werte bei SELECT
+ return;
+ else if (SQL_ISRULE(m_pParseTree,insert_statement))
+ {
+ // Row fuer die zu setzenden Werte anlegen (Referenz durch new)
+ if(m_aAssignValues.isValid())
+ m_aAssignValues->get().clear();
+ sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount();
+ m_aAssignValues = new OAssignValues(nCount);
+ // unbound all
+ ::std::for_each(m_aAssignValues->get().begin()+1,m_aAssignValues->get().end(),TSetRefBound(sal_False));
+
+ m_aParameterIndexes.resize(nCount+1,SQL_NO_PARAMETER);
+
+ // Liste der Columns-Namen, die in der column_commalist vorkommen (mit ; getrennt):
+ ::std::vector<String> aColumnNameList;
+
+ OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pOptColumnCommalist = m_pParseTree->getChild(3);
+ OSL_ENSURE(pOptColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(SQL_ISRULE(pOptColumnCommalist,opt_column_commalist),"OResultSet: Fehler im Parse Tree");
+ if (pOptColumnCommalist->count() == 0)
+ {
+ const Sequence< ::rtl::OUString>& aNames = m_xColNames->getElementNames();
+ const ::rtl::OUString* pBegin = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
+ for (; pBegin != pEnd; ++pBegin)
+ aColumnNameList.push_back(*pBegin);
+ }
+ else
+ {
+ OSL_ENSURE(pOptColumnCommalist->count() == 3,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pColumnCommalist = pOptColumnCommalist->getChild(1);
+ OSL_ENSURE(pColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(SQL_ISRULE(pColumnCommalist,column_commalist),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pColumnCommalist->count() > 0,"OResultSet: Fehler im Parse Tree");
+
+ // Alle Columns in der column_commalist ...
+ for (sal_uInt32 i = 0; i < pColumnCommalist->count(); i++)
+ {
+ OSQLParseNode * pCol = pColumnCommalist->getChild(i);
+ OSL_ENSURE(pCol != NULL,"OResultSet: Fehler im Parse Tree");
+ aColumnNameList.push_back(pCol->getTokenValue());
+ }
+ }
+ if ( aColumnNameList.empty() )
+ throwFunctionSequenceException(*this);
+
+ // Werte ...
+ OSQLParseNode * pValuesOrQuerySpec = m_pParseTree->getChild(4);
+ OSL_ENSURE(pValuesOrQuerySpec != NULL,"OResultSet: pValuesOrQuerySpec darf nicht NULL sein!");
+ OSL_ENSURE(SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec),"OResultSet: ! SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec)");
+ OSL_ENSURE(pValuesOrQuerySpec->count() > 0,"OResultSet: pValuesOrQuerySpec->count() <= 0");
+
+ // nur "VALUES" ist erlaubt ...
+ if (! SQL_ISTOKEN(pValuesOrQuerySpec->getChild(0),VALUES))
+ throwFunctionSequenceException(*this);
+
+ OSL_ENSURE(pValuesOrQuerySpec->count() == 4,"OResultSet: pValuesOrQuerySpec->count() != 4");
+
+ // Liste von Werten
+ OSQLParseNode * pInsertAtomCommalist = pValuesOrQuerySpec->getChild(2);
+ OSL_ENSURE(pInsertAtomCommalist != NULL,"OResultSet: pInsertAtomCommalist darf nicht NULL sein!");
+ OSL_ENSURE(pInsertAtomCommalist->count() > 0,"OResultSet: pInsertAtomCommalist <= 0");
+
+ String aColumnName;
+ OSQLParseNode * pRow_Value_Const;
+ xub_StrLen nIndex=0;
+ for (sal_uInt32 i = 0; i < pInsertAtomCommalist->count(); i++)
+ {
+ pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor
+ OSL_ENSURE(pRow_Value_Const != NULL,"OResultSet: pRow_Value_Const darf nicht NULL sein!");
+ if(SQL_ISRULE(pRow_Value_Const,parameter))
+ {
+ ParseAssignValues(aColumnNameList,pRow_Value_Const,nIndex++); // kann nur ein Columnname vorhanden sein pro Schleife
+ }
+ else if(pRow_Value_Const->isToken())
+ ParseAssignValues(aColumnNameList,pRow_Value_Const,static_cast<xub_StrLen>(i));
+ else
+ {
+ if(pRow_Value_Const->count() == aColumnNameList.size())
+ {
+ for (sal_uInt32 j = 0; j < pRow_Value_Const->count(); ++j)
+ ParseAssignValues(aColumnNameList,pRow_Value_Const->getChild(j),nIndex++);
+ }
+ else
+ throwFunctionSequenceException(*this);
+ }
+ }
+ }
+ else if (SQL_ISRULE(m_pParseTree,update_statement_searched))
+ {
+ if(m_aAssignValues.isValid())
+ m_aAssignValues->get().clear();
+ sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount();
+ m_aAssignValues = new OAssignValues(nCount);
+ // unbound all
+ ::std::for_each(m_aAssignValues->get().begin()+1,m_aAssignValues->get().end(),TSetRefBound(sal_False));
+
+ m_aParameterIndexes.resize(nCount+1,SQL_NO_PARAMETER);
+
+ OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pAssignmentCommalist = m_pParseTree->getChild(3);
+ OSL_ENSURE(pAssignmentCommalist != NULL,"OResultSet: pAssignmentCommalist == NULL");
+ OSL_ENSURE(SQL_ISRULE(pAssignmentCommalist,assignment_commalist),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pAssignmentCommalist->count() > 0,"OResultSet: pAssignmentCommalist->count() <= 0");
+
+ // Alle Zuweisungen (Kommaliste) bearbeiten ...
+ ::std::vector< String> aList(1);
+ for (sal_uInt32 i = 0; i < pAssignmentCommalist->count(); i++)
+ {
+ OSQLParseNode * pAssignment = pAssignmentCommalist->getChild(i);
+ OSL_ENSURE(pAssignment != NULL,"OResultSet: pAssignment == NULL");
+ OSL_ENSURE(SQL_ISRULE(pAssignment,assignment),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pAssignment->count() == 3,"OResultSet: pAssignment->count() != 3");
+
+ OSQLParseNode * pCol = pAssignment->getChild(0);
+ OSL_ENSURE(pCol != NULL,"OResultSet: pCol == NULL");
+
+ OSQLParseNode * pComp = pAssignment->getChild(1);
+ OSL_ENSURE(pComp != NULL,"OResultSet: pComp == NULL");
+ OSL_ENSURE(pComp->getNodeType() == SQL_NODE_EQUAL,"OResultSet: pComp->getNodeType() != SQL_NODE_COMPARISON");
+ if (pComp->getTokenValue().toChar() != '=')
+ {
+ // aStatus.SetInvalidStatement();
+ throwFunctionSequenceException(*this);
+ }
+
+ OSQLParseNode * pVal = pAssignment->getChild(2);
+ OSL_ENSURE(pVal != NULL,"OResultSet: pVal == NULL");
+ aList[0] = pCol->getTokenValue();
+ ParseAssignValues(aList,pVal,0);
+ }
+
+ }
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::ParseAssignValues(const ::std::vector< String>& aColumnNameList,OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::ParseAssignValues" );
+ OSL_ENSURE(nIndex <= aColumnNameList.size(),"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()");
+ String aColumnName(aColumnNameList[nIndex]);
+ OSL_ENSURE(aColumnName.Len() > 0,"OResultSet: Column-Name nicht gefunden");
+ OSL_ENSURE(pRow_Value_Constructor_Elem != NULL,"OResultSet: pRow_Value_Constructor_Elem darf nicht NULL sein!");
+
+ if (pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_STRING ||
+ pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_INTNUM ||
+ pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_APPROXNUM)
+ {
+ // Wert setzen:
+ SetAssignValue(aColumnName, pRow_Value_Constructor_Elem->getTokenValue());
+ }
+ else if (SQL_ISTOKEN(pRow_Value_Constructor_Elem,NULL))
+ {
+ // NULL setzen
+ SetAssignValue(aColumnName, String(), TRUE);
+ }
+ else if (SQL_ISRULE(pRow_Value_Constructor_Elem,parameter))
+ parseParamterElem(aColumnName,pRow_Value_Constructor_Elem);
+ else
+ {
+ // aStatus.SetStatementTooComplex();
+ throwFunctionSequenceException(*this);
+ }
+}
+//------------------------------------------------------------------
+void OStatement_Base::SetAssignValue(const String& aColumnName,
+ const String& aValue,
+ BOOL bSetNull,
+ UINT32 nParameter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::SetAssignValue" );
+ Reference<XPropertySet> xCol;
+ m_xColNames->getByName(aColumnName) >>= xCol;
+ sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY)->findColumn(aColumnName);
+ // Kommt diese Column ueberhaupt in der Datei vor?
+
+ if (!xCol.is())
+ {
+ // Diese Column gibt es nicht!
+// aStatus.Set(SQL_STAT_ERROR,
+// String::CreateFromAscii("S0022"),
+// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_COLUMN_NOT_FOUND))),
+// 0, String() );
+ throwFunctionSequenceException(*this);
+ }
+
+ // Value an die Row mit den zuzuweisenden Werten binden:
+ // const ODbVariantRef& xValue = (*aAssignValues)[pFileColumn->GetId()];
+
+ // Alles geprueft und wir haben den Namen der Column.
+ // Jetzt eine Value allozieren, den Wert setzen und die Value an die Row binden.
+ if (bSetNull)
+ (m_aAssignValues->get())[nId]->setNull();
+ else
+ {
+ switch (::comphelper::getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ {
+ // Kriterium je nach Typ als String oder double in die Variable packen ...
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ *(m_aAssignValues->get())[nId] = ORowSetValue(aValue);
+ // Zeichensatz ist bereits konvertiert, da ja das gesamte Statement konvertiert wurde
+ break;
+
+ case DataType::BIT:
+ {
+ if (aValue.EqualsIgnoreCaseAscii("TRUE") || aValue.GetChar(0) == '1')
+ *(m_aAssignValues->get())[nId] = sal_True;
+ else if (aValue.EqualsIgnoreCaseAscii("FALSE") || aValue.GetChar(0) == '0')
+ *(m_aAssignValues->get())[nId] = sal_False;
+ else
+ {
+ // aStatus.Set(SQL_STAT_ERROR); // nyi: genauer!
+ throwFunctionSequenceException(*this);
+ }
+ }
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ {
+ *(m_aAssignValues->get())[nId] = ORowSetValue(aValue); // .ToDouble
+// try
+// {
+// double n = xValue->toDouble();
+// xValue->setDouble(n);
+// }
+// catch ( ... )
+// {
+// aStatus.SetDriverNotCapableError();
+// }
+ } break;
+ default:
+ throwFunctionSequenceException(*this);
+ }
+ }
+
+ // Parameter-Nr. merken (als User Data)
+ // SQL_NO_PARAMETER = kein Parameter.
+ m_aAssignValues->setParameterIndex(nId,nParameter);
+ if(nParameter != SQL_NO_PARAMETER)
+ m_aParameterIndexes[nParameter] = nId;
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::parseParamterElem(const String& /*_sColumnName*/,OSQLParseNode* /*pRow_Value_Constructor_Elem*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::parseParamterElem" );
+ // do nothing here
+}
+// =============================================================================
+ } // namespace file
+// =============================================================================
+}// namespace connectivity
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FStringFunctions.cxx b/connectivity/source/drivers/file/FStringFunctions.cxx
new file mode 100644
index 000000000000..0ef8fcb99b1d
--- /dev/null
+++ b/connectivity/source/drivers/file/FStringFunctions.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 "file/FStringFunctions.hxx"
+#include <rtl/ustrbuf.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+//------------------------------------------------------------------
+ORowSetValue OOp_Upper::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Upper::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ return lhs.getString().toAsciiUpperCase();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Lower::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Lower::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ return lhs.getString().toAsciiLowerCase();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Ascii::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Ascii::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+ ::rtl::OString sStr(::rtl::OUStringToOString(lhs,RTL_TEXTENCODING_ASCII_US));
+ sal_Int32 nAscii = sStr.toChar();
+ return nAscii;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_CharLength::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_CharLength::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ return lhs.getString().getLength();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Char::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Char::operate" );
+ if ( lhs.empty() )
+ return ORowSetValue();
+
+ ::rtl::OUString sRet;
+ ::std::vector<ORowSetValue>::const_reverse_iterator aIter = lhs.rbegin();
+ ::std::vector<ORowSetValue>::const_reverse_iterator aEnd = lhs.rend();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( !aIter->isNull() )
+ {
+ sal_Char c = static_cast<sal_Char>(static_cast<sal_Int32>(*aIter));
+
+ sRet += ::rtl::OUString(&c,1,RTL_TEXTENCODING_ASCII_US);
+ }
+ }
+
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Concat::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Concat::operate" );
+ if ( lhs.empty() )
+ return ORowSetValue();
+
+ ::rtl::OUStringBuffer sRet;
+ ::std::vector<ORowSetValue>::const_reverse_iterator aIter = lhs.rbegin();
+ ::std::vector<ORowSetValue>::const_reverse_iterator aEnd = lhs.rend();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->isNull() )
+ return ORowSetValue();
+
+ sRet.append(aIter->operator ::rtl::OUString());
+ }
+
+ return sRet.makeStringAndClear();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Locate::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Locate::operate" );
+ ::std::vector<ORowSetValue>::const_iterator aIter = lhs.begin();
+ ::std::vector<ORowSetValue>::const_iterator aEnd = lhs.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->isNull() )
+ return ORowSetValue();
+ }
+ if ( lhs.size() == 2 )
+ return ::rtl::OUString::valueOf(lhs[0].getString().indexOf(lhs[1].getString())+1);
+
+ else if ( lhs.size() != 3 )
+ return ORowSetValue();
+
+ return lhs[1].getString().indexOf(lhs[2].getString(),lhs[0]) + 1;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_SubString::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_SubString::operate" );
+ ::std::vector<ORowSetValue>::const_iterator aIter = lhs.begin();
+ ::std::vector<ORowSetValue>::const_iterator aEnd = lhs.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->isNull() )
+ return ORowSetValue();
+ }
+ if ( lhs.size() == 2 && static_cast<sal_Int32>(lhs[0]) >= sal_Int32(0) )
+ return lhs[1].getString().copy(static_cast<sal_Int32>(lhs[0])-1);
+
+ else if ( lhs.size() != 3 || static_cast<sal_Int32>(lhs[1]) < sal_Int32(0))
+ return ORowSetValue();
+
+ return lhs[2].getString().copy(static_cast<sal_Int32>(lhs[1])-1,lhs[0]);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_LTrim::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_LTrim::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet = lhs;
+ ::rtl::OUString sNew = sRet.trim();
+ return sRet.copy(sRet.indexOf(sNew));
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_RTrim::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_RTrim::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet = lhs;
+ ::rtl::OUString sNew = sRet.trim();
+ return sRet.copy(0,sRet.lastIndexOf(sNew.getStr()[sNew.getLength()-1])+1);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Space::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Space::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ const sal_Char c = ' ';
+ ::rtl::OUStringBuffer sRet;
+ sal_Int32 nCount = lhs;
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ sRet.appendAscii(&c,1);
+ }
+ return sRet.makeStringAndClear();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Replace::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Replace::operate" );
+ if ( lhs.size() != 3 )
+ return ORowSetValue();
+
+ ::rtl::OUString sStr = lhs[2];
+ ::rtl::OUString sFrom = lhs[1];
+ ::rtl::OUString sTo = lhs[0];
+ sal_Int32 nIndexOf = sStr.indexOf(sFrom);
+ while( nIndexOf != -1 )
+ {
+ sStr = sStr.replaceAt(nIndexOf,sFrom.getLength(),sTo);
+ nIndexOf = sStr.indexOf(sFrom,nIndexOf + sTo.getLength());
+ }
+
+ return sStr;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Repeat::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Repeat::operate" );
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet;
+ sal_Int32 nCount = rhs;
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ sRet += lhs;
+ }
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Insert::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Insert::operate" );
+ if ( lhs.size() != 4 )
+ return ORowSetValue();
+
+ ::rtl::OUString sStr = lhs[3];
+
+ sal_Int32 nStart = static_cast<sal_Int32>(lhs[2]);
+ if ( nStart < 1 )
+ nStart = 1;
+ return sStr.replaceAt(nStart-1,static_cast<sal_Int32>(lhs[1]),lhs[0]);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Left::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Left::operate" );
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet = lhs;
+ sal_Int32 nCount = rhs;
+ if ( nCount < 0 )
+ return ORowSetValue();
+ return sRet.copy(0,nCount);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Right::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Right::operate" );
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ sal_Int32 nCount = rhs;
+ ::rtl::OUString sRet = lhs;
+ if ( nCount < 0 || nCount >= sRet.getLength() )
+ return ORowSetValue();
+
+ return sRet.copy(sRet.getLength()-nCount,nCount);
+}
+
diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx
new file mode 100644
index 000000000000..7bc28fd35b64
--- /dev/null
+++ b/connectivity/source/drivers/file/FTable.cxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * 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 <stdio.h>
+#include "file/FTable.hxx"
+#include "file/FColumns.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <unotools/ucbstreamhelper.hxx>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+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;
+
+DBG_NAME( file_OFileTable )
+OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection)
+: OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers())
+ ,m_pConnection(_pConnection)
+ ,m_pFileStream(NULL)
+ ,m_nFilePos(0)
+ ,m_pBuffer(NULL)
+ ,m_nBufferSize(0)
+ ,m_bWriteable(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::OFileTable" );
+ DBG_CTOR( file_OFileTable, NULL );
+ construct();
+ TStringVector aVector;
+ // m_pColumns = new OColumns(this,m_aMutex,aVector);
+ m_aColumns = new OSQLColumns();
+}
+// -------------------------------------------------------------------------
+OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers(),
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pConnection(_pConnection)
+ ,m_pFileStream(NULL)
+ ,m_nFilePos(0)
+ ,m_pBuffer(NULL)
+ ,m_nBufferSize(0)
+ ,m_bWriteable(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::OFileTable" );
+ DBG_CTOR( file_OFileTable, NULL );
+ m_aColumns = new OSQLColumns();
+ construct();
+ // refreshColumns();
+}
+// -------------------------------------------------------------------------
+OFileTable::~OFileTable( )
+{
+ DBG_DTOR( file_OFileTable, NULL );
+}
+// -------------------------------------------------------------------------
+void OFileTable::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshColumns" );
+ TStringVector aVector;
+ Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(),
+ m_SchemaName,m_Name,::rtl::OUString::createFromAscii("%"));
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(4));
+ }
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OColumns(this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OFileTable::refreshKeys()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshKeys" );
+}
+// -------------------------------------------------------------------------
+void OFileTable::refreshIndexes()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshIndexes" );
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OFileTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::queryInterface" );
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ return OTable_TYPEDEF::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OFileTable::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::disposing" );
+ OTable::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ FileClose();
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OFileTable::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::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 OFileTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -----------------------------------------------------------------------------
+void OFileTable::FileClose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::FileClose" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if (m_pFileStream && m_pFileStream->IsWritable())
+ m_pFileStream->Flush();
+
+ delete m_pFileStream;
+ m_pFileStream = NULL;
+
+ if (m_pBuffer)
+ {
+ delete[] m_pBuffer;
+ m_pBuffer = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFileTable::acquire() throw()
+{
+ OTable_TYPEDEF::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFileTable::release() throw()
+{
+ OTable_TYPEDEF::release();
+}
+// -----------------------------------------------------------------------------
+BOOL OFileTable::InsertRow(OValueRefVector& /*rRow*/, BOOL /*bFlush*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::InsertRow" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+BOOL OFileTable::DeleteRow(const OSQLColumns& /*_rCols*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::DeleteRow" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+BOOL OFileTable::UpdateRow(OValueRefVector& /*rRow*/, OValueRefRow& /*pOrgRow*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::UpdateRow" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void OFileTable::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& /*descriptor*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::addColumn" );
+ OSL_ENSURE( false, "OFileTable::addColumn: not implemented!" );
+}
+// -----------------------------------------------------------------------------
+void OFileTable::dropColumn(sal_Int32 /*_nPos*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::dropColumn" );
+ OSL_ENSURE( false, "OFileTable::addColumn: not implemented!" );
+}
+
+// -----------------------------------------------------------------------------
+SvStream* OFileTable::createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::createStream_simpleError" );
+ utl::UcbLockBytesHandler* p_null_dummy=NULL;
+ SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, (_eOpenMode & STREAM_NOCREATE) == STREAM_NOCREATE ,p_null_dummy);
+ if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode()))
+ {
+ delete pReturn;
+ pReturn = NULL;
+ }
+ return pReturn;
+}
+
+// -----------------------------------------------------------------------------
+void OFileTable::refreshHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshHeader" );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/file/FTables.cxx b/connectivity/source/drivers/file/FTables.cxx
new file mode 100644
index 000000000000..7ac21ef50668
--- /dev/null
+++ b/connectivity/source/drivers/file/FTables.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * 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 "file/FTables.hxx"
+#include "file/FTable.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"
+#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
+#include "file/FConnection.hxx"
+#endif
+//#ifndef _CONNECTIVITY_FILE_OEMPTYCOLLECTION_HXX_
+//#include "file/FEmptyCollection.hxx"
+//#endif
+
+using namespace connectivity;
+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;
+
+namespace starutil = ::com::sun::star::util;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& /*_rName*/)
+{
+ return sdbcx::ObjectType();
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OFileCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+//------------------------------------------------------------------
+Any SAL_CALL OTables::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XColumnLocate>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0) ||
+ rType == ::getCppuType((const Reference<XAppend>*)0) ||
+ rType == ::getCppuType((const Reference<XDrop>*)0))
+ return Any();
+
+ typedef sdbcx::OCollection OTables_BASE;
+ return OTables_BASE::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx
new file mode 100644
index 000000000000..7abf10191f21
--- /dev/null
+++ b/connectivity/source/drivers/file/fanalyzer.cxx
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * 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 "file/fanalyzer.hxx"
+#include "connectivity/sqlparse.hxx"
+#include <osl/diagnose.h>
+#include <tools/debug.hxx>
+#include <comphelper/extract.hxx>
+#include "connectivity/sqlnode.hxx"
+#include "connectivity/dbexception.hxx"
+#include "file/FConnection.hxx"
+#include "resource/file_res.hrc"
+
+using namespace ::connectivity;
+using namespace ::connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+DBG_NAME( file_OSQLAnalyzer )
+//------------------------------------------------------------------
+OSQLAnalyzer::OSQLAnalyzer(OConnection* _pConnection)
+ :m_pConnection(_pConnection)
+ ,m_bHasSelectionCode(sal_False)
+ ,m_bSelectionFirstTime(sal_True)
+{
+ DBG_CTOR( file_OSQLAnalyzer, NULL );
+ m_aCompiler = new OPredicateCompiler(this);
+ m_aInterpreter = new OPredicateInterpreter(m_aCompiler);
+}
+
+// -----------------------------------------------------------------------------
+OSQLAnalyzer::~OSQLAnalyzer()
+{
+ DBG_DTOR( file_OSQLAnalyzer, NULL );
+}
+
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::setIndexes(const Reference< XNameAccess>& _xIndexes)
+{
+ m_aCompiler->m_xIndexes = _xIndexes;
+}
+//------------------------------------------------------------------
+void OSQLAnalyzer::start(OSQLParseNode* pSQLParseNode)
+{
+ if (SQL_ISRULE(pSQLParseNode,select_statement))
+ {
+ DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ // check that we don't use anything other than count(*) as function
+ OSQLParseNode* pSelection = pSQLParseNode->getChild(2);
+ if ( SQL_ISRULE(pSelection,scalar_exp_commalist) )
+ {
+ for (sal_uInt32 i = 0; i < pSelection->count(); i++)
+ {
+ OSQLParseNode *pColumnRef = pSelection->getChild(i)->getChild(0);
+ if ( ( SQL_ISRULE(pColumnRef,set_fct_spec) && pColumnRef->count() == 4 )
+ || SQL_ISRULE(pColumnRef,char_value_fct)
+ || SQL_ISRULE(pColumnRef,char_substring_fct)
+ || SQL_ISRULE(pColumnRef,position_exp)
+ || SQL_ISRULE(pColumnRef,fold)
+ || SQL_ISRULE(pColumnRef,length_exp)
+ || SQL_ISRULE(pColumnRef,num_value_exp)
+ || SQL_ISRULE(pColumnRef,term)
+ || SQL_ISRULE(pColumnRef,factor)
+ || SQL_ISRULE(pColumnRef,set_fct_spec) )
+ {
+ ::vos::ORef<OPredicateCompiler> pCompiler = new OPredicateCompiler(this);
+ pCompiler->setOrigColumns(m_aCompiler->getOrigColumns());
+ ::vos::ORef<OPredicateInterpreter> pInterpreter = new OPredicateInterpreter(pCompiler);
+ pCompiler->execute( pColumnRef );
+ m_aSelectionEvaluations.push_back( TPredicates(pCompiler,pInterpreter) );
+ }
+ else if ( ( SQL_ISRULE(pColumnRef,general_set_fct) && pColumnRef->count() != 4 ) )
+ {
+ m_pConnection->throwGenericSQLException(STR_QUERY_COMPLEX_COUNT,NULL);
+ }
+ else
+ m_aSelectionEvaluations.push_back( TPredicates() );
+ }
+ }
+ }
+
+ m_aCompiler->start(pSQLParseNode);
+}
+
+//------------------------------------------------------------------
+void OSQLAnalyzer::bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow,OEvaluateSetList& _rEvaluateSetList)
+{
+ // Zaehlen, wieviele Kriterien
+ // wenn nur ein Kriterium, und das entsprechende Feld ist indiziert
+ // dann wird der Index verwendet
+
+ OEvaluateSet* pEvaluateSet = NULL;
+
+ for (OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end(); ++aIter)
+ {
+ OOperandAttr* pAttr = PTR_CAST(OOperandAttr,(*aIter));
+ if (pAttr)
+ {
+ if (pAttr->isIndexed() && !m_aCompiler->hasORCondition())
+ {
+ OCode* pCode1 = *(aIter + 1);
+ OCode* pCode2 = *(aIter + 2);
+
+ if (PTR_CAST(OOperand,pCode1))
+ pEvaluateSet = pAttr->preProcess(PTR_CAST(OBoolOperator,pCode2), PTR_CAST(OOperand,pCode1));
+ else
+ pEvaluateSet = pAttr->preProcess(PTR_CAST(OBoolOperator,pCode1));
+ }
+
+ if (pEvaluateSet)
+ {
+ _rEvaluateSetList.push_back(pEvaluateSet);
+ pEvaluateSet = NULL;
+ }
+ pAttr->bindValue(_pRow);
+ }
+ }
+}
+//------------------------------------------------------------------
+void OSQLAnalyzer::bindSelectRow(const OValueRefRow& _pRow)
+{
+ // first the select part
+ OEvaluateSetList aEvaluateSetList;
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter)
+ {
+ if ( aIter->first.isValid() )
+ bindRow( aIter->first->m_aCodeList,_pRow,aEvaluateSetList);
+ }
+}
+//------------------------------------------------------------------
+::std::vector<sal_Int32>* OSQLAnalyzer::bindEvaluationRow(OValueRefRow& _pRow)
+{
+ OEvaluateSetList aEvaluateSetList;
+ bindRow( m_aCompiler->m_aCodeList,_pRow,aEvaluateSetList);
+
+ ::std::vector<sal_Int32>* pKeySet = NULL;
+ OEvaluateSet* pEvaluateSet = NULL;
+
+ // Keyset erzeugen mit kleinster Liste
+ if(!aEvaluateSetList.empty())
+ {
+ // welche Liste hat den kleinsten count ?
+ OEvaluateSetList::iterator i = aEvaluateSetList.begin();
+ pEvaluateSet = *(i);
+ for(++i; i != aEvaluateSetList.end();++i)
+ {
+ OEvaluateSet* pEvaluateSetComp = (*i);
+ for(OEvaluateSet::reverse_iterator j = pEvaluateSet->rbegin(); j != pEvaluateSet->rend(); ++j)
+ {
+ if (pEvaluateSetComp->find(j->second) != pEvaluateSetComp->end())
+ pEvaluateSet->erase(j->second);
+ }
+ }
+ pKeySet = new ::std::vector<sal_Int32>(pEvaluateSet->size());
+ sal_Int32 k=0;
+ for(OEvaluateSet::iterator j = pEvaluateSet->begin(); j != pEvaluateSet->end(); ++j,++k)
+ {
+ (*pKeySet)[k] = j->second;
+ }
+
+ // alle loeschen
+ for(i = aEvaluateSetList.begin(); i != aEvaluateSetList.end();++i)
+ delete (*i);
+ }
+
+ return pKeySet;
+}
+
+//------------------------------------------------------------------
+void OSQLAnalyzer::describeParam(::vos::ORef<OSQLColumns> rParameterColumns)
+{
+ OCodeList& rCodeList = m_aCompiler->m_aCodeList;
+ OCodeStack aCodeStack;
+
+ if (!rCodeList.size())
+ return; // kein Praedikat
+ if (!rParameterColumns->get().size())
+ return; // keine Parameter
+
+ // Anlegen von Columns, die eine genauere Beschreibung fuer die enthalten
+ ::vos::ORef<OSQLColumns> aNewParamColumns = new OSQLColumns(*rParameterColumns);
+
+
+ // Anlegen einer Testzeile, wird benoetigt um die Parameter zu beschreiben
+ OValueRefRow aParameterRow = new OValueRefVector(rParameterColumns->get().size());
+ bindParameterRow(aParameterRow);
+
+ OValueRefRow aTestRow = new OValueRefVector(Reference< XIndexAccess>(m_aCompiler->getOrigColumns(),UNO_QUERY)->getCount());
+ delete bindEvaluationRow(aTestRow); // Binden der Attribute an die Values
+
+ for(OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end(); ++aIter)
+ {
+ OOperand* pOperand = PTR_CAST(OOperand,(*aIter));
+ OOperator* pOperator = PTR_CAST(OOperator,(*aIter));
+ if (pOperand)
+ aCodeStack.push(pOperand);
+ else
+ {
+ if (pOperator->getRequestedOperands() == 2) // bei zwei Operatoren ist es moeglich
+ { // einen Parameter weiter zu spezifizieren
+ OOperandParam *pParam = PTR_CAST(OOperandParam,aCodeStack.top());
+ if (pParam) // Anpassen des ParameterTyps, wenn der linke Operand ein Attribut ist
+ {
+ OOperandAttr *pLeft = PTR_CAST(OOperandAttr,*(rCodeList.end() - 2));
+ if (pLeft)
+ {
+ Reference< XPropertySet> xCol;
+ Reference< XIndexAccess>(m_aCompiler->getOrigColumns(),UNO_QUERY)->getByIndex(pLeft->getRowPos()) >>= xCol;
+ OSL_ENSURE(xCol.is(), "Ungueltige Struktur");
+ pParam->describe(xCol, aNewParamColumns);
+ }
+ }
+ }
+ pOperator->Exec(aCodeStack);
+ }
+ }
+ OOperand* pOperand = aCodeStack.top();
+ aCodeStack.pop();
+
+ OSL_ENSURE(aCodeStack.size() == 0, "StackFehler");
+ OSL_ENSURE(pOperand, "StackFehler");
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+ else
+ OSL_ENSURE(0,"Illegal here!");
+
+ rParameterColumns = aNewParamColumns;
+ // m_aCompiler->setParameterColumns(rParameterColumns);
+}
+
+// -----------------------------------------------------------------------------
+OOperandAttr* OSQLAnalyzer::createOperandAttr(sal_Int32 _nPos,
+ const Reference< XPropertySet>& _xCol,
+ const Reference< XNameAccess>& /*_xIndexes*/)
+{
+ return new OOperandAttr(static_cast<sal_uInt16>(_nPos),_xCol);
+}
+// -----------------------------------------------------------------------------
+BOOL OSQLAnalyzer::hasRestriction() const
+{
+ return m_aCompiler->hasCode();
+}
+// -----------------------------------------------------------------------------
+BOOL OSQLAnalyzer::hasFunctions() const
+{
+ if ( m_bSelectionFirstTime )
+ {
+ m_bSelectionFirstTime = sal_False;
+ for ( ::std::vector< TPredicates >::const_iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end() && !m_bHasSelectionCode ;++aIter)
+ {
+ if ( aIter->first.isValid() )
+ m_bHasSelectionCode = aIter->first->hasCode();
+ }
+ }
+ return m_bHasSelectionCode;;
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::setSelectionEvaluationResult(OValueRefRow& _pRow,const ::std::vector<sal_Int32>& _rColumnMapping)
+{
+ sal_Int32 nPos = 1;
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter,++nPos)
+ {
+ if ( aIter->second.isValid() )
+ {
+ sal_Int32 map = nPos;
+ // the first column (index 0) is for convenience only. The first real select column is no 1.
+ if ( (nPos > 0) && (nPos < static_cast<sal_Int32>(_rColumnMapping.size())) )
+ map = _rColumnMapping[nPos];
+ aIter->second->startSelection((_pRow->get())[map]);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::dispose()
+{
+ m_aCompiler->dispose();
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter)
+ {
+ if ( aIter->first.isValid() )
+ aIter->first->dispose();
+ }
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::setOrigColumns(const OFileColumns& rCols)
+{
+ m_aCompiler->setOrigColumns(rCols);
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter)
+ {
+ if ( aIter->first.isValid() )
+ aIter->first->setOrigColumns(rCols);
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx
new file mode 100644
index 000000000000..9d4e1644d370
--- /dev/null
+++ b/connectivity/source/drivers/file/fcode.cxx
@@ -0,0 +1,519 @@
+/*************************************************************************
+ *
+ * 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 "file/fcode.hxx"
+#include <osl/diagnose.h>
+#include "connectivity/sqlparse.hxx"
+#include <i18npool/mslangid.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include "TConnection.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::file;
+//using namespace ::com::sun::star::uno;
+//using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+//using namespace ::com::sun::star::container;
+//using namespace ::com::sun::star::beans;
+//using namespace ::com::sun::star::sdbcx;
+
+TYPEINIT0(OCode);
+TYPEINIT1(OOperand, OCode);
+TYPEINIT1(OOperandRow, OOperand);
+TYPEINIT1(OOperandAttr, OOperandRow);
+TYPEINIT1(OOperandParam, OOperandRow);
+TYPEINIT1(OOperandValue, OOperand);
+TYPEINIT1(OOperandConst, OOperandValue);
+TYPEINIT1(OOperandResult, OOperandValue);
+TYPEINIT1(OStopOperand, OOperandValue);
+
+TYPEINIT1(OOperator, OCode);
+TYPEINIT1(OBoolOperator,OOperator);
+TYPEINIT1(OOp_NOT, OBoolOperator);
+TYPEINIT1(OOp_AND, OBoolOperator);
+TYPEINIT1(OOp_OR, OBoolOperator);
+TYPEINIT1(OOp_ISNULL, OBoolOperator);
+TYPEINIT1(OOp_ISNOTNULL, OOp_ISNULL);
+TYPEINIT1(OOp_LIKE, OBoolOperator);
+TYPEINIT1(OOp_NOTLIKE, OOp_LIKE);
+TYPEINIT1(OOp_COMPARE, OBoolOperator);
+TYPEINIT1(ONumOperator, OOperator);
+TYPEINIT1(ONthOperator, OOperator);
+TYPEINIT1(OBinaryOperator, OOperator);
+TYPEINIT1(OUnaryOperator, OOperator);
+
+//------------------------------------------------------------------
+DBG_NAME(OCode )
+OCode::OCode()
+{
+ DBG_CTOR(OCode ,NULL);
+}
+// -----------------------------------------------------------------------------
+OCode::~OCode()
+{
+ DBG_DTOR(OCode,NULL);
+}
+
+//------------------------------------------------------------------
+OEvaluateSet* OOperand::preProcess(OBoolOperator* /*pOp*/, OOperand* /*pRight*/)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+OOperandRow::OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType)
+ : OOperand(_rType)
+ , m_nRowPos(_nPos)
+{}
+//------------------------------------------------------------------
+void OOperandRow::bindValue(const OValueRefRow& _pRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandRow::OOperandRow" );
+ OSL_ENSURE(_pRow.isValid(),"NO EMPTY row allowed!");
+ m_pRow = _pRow;
+ OSL_ENSURE(m_pRow.isValid() && m_nRowPos < m_pRow->get().size(),"Invalid RowPos is >= vector.size()");
+ (m_pRow->get())[m_nRowPos]->setBound(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OOperandRow::setValue(const ORowSetValue& _rVal)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandRow::setValue" );
+ OSL_ENSURE(m_pRow.isValid() && m_nRowPos < m_pRow->get().size(),"Invalid RowPos is >= vector.size()");
+ (*(m_pRow->get())[m_nRowPos]) = _rVal;
+}
+//------------------------------------------------------------------
+const ORowSetValue& OOperandRow::getValue() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandRow::getValue" );
+ OSL_ENSURE(m_pRow.isValid() && m_nRowPos < m_pRow->get().size(),"Invalid RowPos is >= vector.size()");
+ return (m_pRow->get())[m_nRowPos]->getValue();
+}
+
+// -----------------------------------------------------------------------------
+void OOperandValue::setValue(const ORowSetValue& _rVal)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandValue::setValue" );
+ m_aValue = _rVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool OOperandAttr::isIndexed() const
+{
+ return sal_False;
+}
+//------------------------------------------------------------------
+OOperandParam::OOperandParam(OSQLParseNode* pNode, sal_Int32 _nPos)
+ : OOperandRow(static_cast<sal_uInt16>(_nPos), DataType::VARCHAR) // Standard-Typ
+{
+ OSL_ENSURE(SQL_ISRULE(pNode,parameter),"Argument ist kein Parameter");
+ OSL_ENSURE(pNode->count() > 0,"Fehler im Parse Tree");
+ OSQLParseNode *pMark = pNode->getChild(0);
+
+ String aParameterName;
+ if (SQL_ISPUNCTUATION(pMark,"?"))
+ aParameterName = '?';
+ else if (SQL_ISPUNCTUATION(pMark,":"))
+ aParameterName = pNode->getChild(1)->getTokenValue();
+ else
+ {
+ OSL_ASSERT("Fehler im Parse Tree");
+ }
+
+ // Parameter-Column aufsetzen mit defult typ, kann zu einem spaeteren Zeitpunkt ueber DescribeParameter
+ // genauer spezifiziert werden
+
+ // Identitaet merken (hier eigentlich nicht erforderlich, aber aus
+ // Symmetriegruenden ...)
+
+ // todo
+ // OColumn* pColumn = new OFILEColumn(aParameterName,eDBType,255,0,SQL_FLAGS_NULLALLOWED);
+ // rParamColumns->AddColumn(pColumn);
+
+ // der Wert wird erst kurz vor der Auswertung gesetzt
+}
+
+
+//------------------------------------------------------------------
+const ORowSetValue& OOperandValue::getValue() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandValue::getValue" );
+ return m_aValue;
+}
+
+//------------------------------------------------------------------
+OOperandConst::OOperandConst(const OSQLParseNode& rColumnRef, const rtl::OUString& aStrValue)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandConst::OOperandConst" );
+ switch (rColumnRef.getNodeType())
+ {
+ case SQL_NODE_STRING:
+ m_aValue = aStrValue;
+ m_eDBType = DataType::VARCHAR;
+ m_aValue.setBound(sal_True);
+ return;
+ case SQL_NODE_INTNUM:
+ case SQL_NODE_APPROXNUM:
+ {
+ m_aValue = aStrValue.toDouble();
+ m_eDBType = DataType::DOUBLE;
+ m_aValue.setBound(sal_True);
+ return;
+ }
+ default:
+ break;
+ }
+
+ if (SQL_ISTOKEN(&rColumnRef,TRUE))
+ {
+ m_aValue = 1.0;
+ m_eDBType = DataType::BIT;
+ }
+ else if (SQL_ISTOKEN(&rColumnRef,FALSE))
+ {
+ m_aValue = 0.0;
+ m_eDBType = DataType::BIT;
+ }
+ else
+ {
+ OSL_ASSERT("Parse Error");
+ }
+ m_aValue.setBound(sal_True);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Implementation of the operators
+
+//------------------------------------------------------------------
+sal_uInt16 OOperator::getRequestedOperands() const {return 2;}
+
+//------------------------------------------------------------------
+sal_Bool OBoolOperator::operate(const OOperand*, const OOperand*) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OBoolOperator::operate" );
+ return sal_False;
+}
+
+
+//------------------------------------------------------------------
+void OBoolOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OBoolOperator::Exec" );
+ OOperand *pRight = rCodeStack.top();
+ rCodeStack.pop();
+ OOperand *pLeft = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pLeft, pRight)));
+ if (IS_TYPE(OOperandResult,pLeft))
+ delete pLeft;
+ if (IS_TYPE(OOperandResult,pRight))
+ delete pRight;
+}
+//------------------------------------------------------------------
+sal_Bool OOp_NOT::operate(const OOperand* pLeft, const OOperand* ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_AND::operate" );
+ return !pLeft->isValid();
+}
+//------------------------------------------------------------------
+void OOp_NOT::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::Exec" );
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pOperand)));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+//------------------------------------------------------------------
+sal_uInt16 OOp_NOT::getRequestedOperands() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_NOT::getRequestedOperands" );
+ return 1;
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_AND::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_AND::operate" );
+ return pLeft->isValid() && pRight->isValid();
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_OR::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_OR::operate" );
+ return pLeft->isValid() || pRight->isValid();
+}
+
+//------------------------------------------------------------------
+sal_uInt16 OOp_ISNULL::getRequestedOperands() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::getRequestedOperands" );
+ return 1;
+}
+
+//------------------------------------------------------------------
+void OOp_ISNULL::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::Exec" );
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pOperand)));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_ISNULL::operate(const OOperand* pOperand, const OOperand*) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::operate" );
+ return pOperand->getValue().isNull();
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_ISNOTNULL::operate(const OOperand* pOperand, const OOperand*) const
+{
+ return !OOp_ISNULL::operate(pOperand);
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_LIKE::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::operate" );
+ sal_Bool bMatch;
+ ORowSetValue aLH(pLeft->getValue());
+ ORowSetValue aRH(pRight->getValue());
+
+ if (aLH.isNull() || aRH.isNull())
+ bMatch = sal_False;
+ else
+ {
+ bMatch = match(aRH.getString(), aLH.getString(), cEscape);
+ }
+ return bMatch;
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_NOTLIKE::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_NOTLIKE::operate" );
+ return !OOp_LIKE::operate(pLeft, pRight);
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_COMPARE::operate" );
+ ORowSetValue aLH(pLeft->getValue());
+ ORowSetValue aRH(pRight->getValue());
+
+ if (aLH.isNull() || aRH.isNull()) // if (!aLH.getValue() || !aRH.getValue())
+ return sal_False;
+
+ sal_Bool bResult = sal_False;
+ sal_Int32 eDBType = pLeft->getDBType();
+
+ // Vergleich (je nach Datentyp):
+ switch (eDBType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ {
+ rtl::OUString sLH = aLH, sRH = aRH;
+ INT32 nRes = rtl_ustr_compareIgnoreAsciiCase_WithLength
+ (
+ sLH.pData->buffer,
+ sLH.pData->length,
+ sRH.pData->buffer,
+ sRH.pData->length );
+ switch(aPredicateType)
+ {
+ case SQLFilterOperator::EQUAL: bResult = (nRes == 0); break;
+ case SQLFilterOperator::NOT_EQUAL: bResult = (nRes != 0); break;
+ case SQLFilterOperator::LESS: bResult = (nRes < 0); break;
+ case SQLFilterOperator::LESS_EQUAL: bResult = (nRes <= 0); break;
+ case SQLFilterOperator::GREATER: bResult = (nRes > 0); break;
+ case SQLFilterOperator::GREATER_EQUAL: bResult = (nRes >= 0); break;
+ default: bResult = sal_False;
+ }
+ } break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::BIT:
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::TIME:
+ {
+ double n = aLH ,m = aRH;
+
+ switch (aPredicateType)
+ {
+ case SQLFilterOperator::EQUAL: bResult = (n == m); break;
+ case SQLFilterOperator::LIKE: bResult = (n == m); break;
+ case SQLFilterOperator::NOT_EQUAL: bResult = (n != m); break;
+ case SQLFilterOperator::NOT_LIKE: bResult = (n != m); break;
+ case SQLFilterOperator::LESS: bResult = (n < m); break;
+ case SQLFilterOperator::LESS_EQUAL: bResult = (n <= m); break;
+ case SQLFilterOperator::GREATER: bResult = (n > m); break;
+ case SQLFilterOperator::GREATER_EQUAL: bResult = (n >= m); break;
+ default: bResult = sal_False;
+ }
+ } break;
+ default:
+ bResult = aLH == aRH;
+ }
+ return bResult;
+}
+
+//------------------------------------------------------------------
+void ONumOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ONumOperator::Exec" );
+
+ OOperand *pRight = rCodeStack.top();
+ rCodeStack.pop();
+ OOperand *pLeft = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultNUM(operate(pLeft->getValue(), pRight->getValue())));
+ if (IS_TYPE(OOperandResult,pLeft))
+ delete pLeft;
+ if (IS_TYPE(OOperandResult,pRight))
+ delete pRight;
+}
+//------------------------------------------------------------------
+double OOp_ADD::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ADD::operate" );
+ return fLeft + fRight;
+}
+
+//------------------------------------------------------------------
+double OOp_SUB::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_SUB::operate" );
+ return fLeft - fRight;
+}
+
+//------------------------------------------------------------------
+double OOp_MUL::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_MUL::operate" );
+ return fLeft * fRight;
+}
+
+//------------------------------------------------------------------
+double OOp_DIV::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_DIV::operate" );
+ return fLeft / fRight;
+}
+// -----------------------------------------------------------------------------
+OEvaluateSet* OOperandAttr::preProcess(OBoolOperator* /*pOp*/, OOperand* /*pRight*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandAttr::preProcess" );
+ return NULL;
+}
+//------------------------------------------------------------------
+void ONthOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ONthOperator::Exec" );
+ ::std::vector<ORowSetValue> aValues;
+ ::std::vector<OOperand*> aOperands;
+ OOperand* pOperand;
+ do
+ {
+ OSL_ENSURE(!rCodeStack.empty(),"Stack must be none empty!");
+ pOperand = rCodeStack.top();
+ rCodeStack.pop();
+ if ( !IS_TYPE(OStopOperand,pOperand) )
+ aValues.push_back( pOperand->getValue() );
+ aOperands.push_back( pOperand );
+ }
+ while ( !IS_TYPE(OStopOperand,pOperand) );
+
+ rCodeStack.push(new OOperandResult(operate(aValues)));
+
+ ::std::vector<OOperand*>::iterator aIter = aOperands.begin();
+ ::std::vector<OOperand*>::iterator aEnd = aOperands.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if (IS_TYPE(OOperandResult,*aIter))
+ delete *aIter;
+ }
+}
+//------------------------------------------------------------------
+void OBinaryOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OBinaryOperator::Exec" );
+ OOperand *pRight = rCodeStack.top();
+ rCodeStack.pop();
+ OOperand *pLeft = rCodeStack.top();
+ rCodeStack.pop();
+
+ if ( !rCodeStack.empty() && IS_TYPE(OStopOperand,rCodeStack.top()) )
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResult(operate(pLeft->getValue(),pRight->getValue())));
+ if (IS_TYPE(OOperandResult,pRight))
+ delete pRight;
+ if (IS_TYPE(OOperandResult,pLeft))
+ delete pLeft;
+}
+//------------------------------------------------------------------
+void OUnaryOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OUnaryOperator::Exec" );
+ OSL_ENSURE(!rCodeStack.empty(),"Stack is empty!");
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResult(operate(pOperand->getValue())));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+// -----------------------------------------------------------------------------
+sal_uInt16 OUnaryOperator::getRequestedOperands() const {return 1;}
+
+
+
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
new file mode 100644
index 000000000000..9cf9874dbf10
--- /dev/null
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -0,0 +1,920 @@
+/*************************************************************************
+ *
+ * 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 "file/fcomp.hxx"
+#include <tools/debug.hxx>
+#include "TConnection.hxx"
+#include "connectivity/sqlparse.hxx"
+#include "file/fanalyzer.hxx"
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbconversion.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include "resource/file_res.hrc"
+#include "file/FStringFunctions.hxx"
+#include "file/FDateFunctions.hxx"
+#include "file/FNumericFunctions.hxx"
+#include "file/FConnection.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+
+using namespace connectivity;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdb;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+
+DBG_NAME(OPredicateCompiler)
+//------------------------------------------------------------------
+OPredicateCompiler::OPredicateCompiler(OSQLAnalyzer* pAnalyzer)//,OCursor& rCurs)
+ // : m_rCursor(rCurs)
+ : m_pAnalyzer(pAnalyzer)
+ , m_nParamCounter(0)
+ , m_bORCondition(FALSE)
+{
+ DBG_CTOR(OPredicateCompiler,NULL);
+}
+
+//------------------------------------------------------------------
+OPredicateCompiler::~OPredicateCompiler()
+{
+ Clean();
+ DBG_DTOR(OPredicateCompiler,NULL);
+}
+// -----------------------------------------------------------------------------
+void OPredicateCompiler::dispose()
+{
+ Clean();
+ m_orgColumns = NULL;
+m_xIndexes.clear();
+}
+//------------------------------------------------------------------
+// inline OCursor& OPredicateCompiler::Cursor() const {return m_rCursor;}
+//------------------------------------------------------------------
+void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode)
+{
+ if (!pSQLParseNode)
+ return;
+
+ m_nParamCounter = 0;
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf WHERE-Klausel setzen:
+ OSQLParseNode * pWhereClause = NULL;
+ OSQLParseNode * pOrderbyClause = NULL;
+
+ if (SQL_ISRULE(pSQLParseNode,select_statement))
+ {
+ DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ OSQLParseNode * pTableExp = pSQLParseNode->getChild(3);
+ DBG_ASSERT(pTableExp != NULL,"Fehler im Parse Tree");
+ DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp)," Fehler im Parse Tree");
+ DBG_ASSERT(pTableExp->count() == 5,"Fehler im Parse Tree");
+
+ // check that we don't use anything other than count(*) as function
+ OSQLParseNode* pSelection = pSQLParseNode->getChild(2);
+ if ( SQL_ISRULE(pSelection,scalar_exp_commalist) )
+ {
+ for (sal_uInt32 i = 0; i < pSelection->count(); i++)
+ {
+ OSQLParseNode *pColumnRef = pSelection->getChild(i)->getChild(0);
+ if ( SQL_ISRULE(pColumnRef,general_set_fct) && pColumnRef->count() != 4 )
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_COMPLEX_COUNT,NULL);
+ }
+ }
+ }
+
+
+ pWhereClause = pTableExp->getChild(1);
+ pOrderbyClause = pTableExp->getChild(4);
+ }
+ else if (SQL_ISRULE(pSQLParseNode,update_statement_searched))
+ {
+ DBG_ASSERT(pSQLParseNode->count() == 5,"OFILECursor: Fehler im Parse Tree");
+ pWhereClause = pSQLParseNode->getChild(4);
+ }
+ else if (SQL_ISRULE(pSQLParseNode,delete_statement_searched))
+ {
+ DBG_ASSERT(pSQLParseNode->count() == 4,"Fehler im Parse Tree");
+ pWhereClause = pSQLParseNode->getChild(3);
+ }
+ else
+ // Anderes Statement. Keine Selektionskriterien.
+ return;
+
+ if (SQL_ISRULE(pWhereClause,where_clause))
+ {
+ // Wenn es aber eine where_clause ist, dann darf sie nicht leer sein:
+ DBG_ASSERT(pWhereClause->count() == 2,"OFILECursor: Fehler im Parse Tree");
+
+ OSQLParseNode * pComparisonPredicate = pWhereClause->getChild(1);
+ DBG_ASSERT(pComparisonPredicate != NULL,"OFILECursor: Fehler im Parse Tree");
+
+ execute( pComparisonPredicate );
+ }
+ else
+ {
+ // Die Where Clause ist meistens optional, d. h. es koennte sich auch
+ // um "optional_where_clause" handeln.
+ DBG_ASSERT(SQL_ISRULE(pWhereClause,opt_where_clause),"OPredicateCompiler: Fehler im Parse Tree");
+ }
+}
+
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute(OSQLParseNode* pPredicateNode)
+{
+ OOperand* pOperand = NULL;
+ if (pPredicateNode->count() == 3 && // Ausdruck is geklammert
+ SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pPredicateNode->getChild(2),")"))
+ {
+ execute(pPredicateNode->getChild(1));
+ }
+ else if ((SQL_ISRULE(pPredicateNode,search_condition) || (SQL_ISRULE(pPredicateNode,boolean_term)))
+ && // AND/OR-Verknuepfung:
+ pPredicateNode->count() == 3)
+ {
+ execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
+ execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
+
+ if (SQL_ISTOKEN(pPredicateNode->getChild(1),OR)) // OR-Operator
+ {
+ m_aCodeList.push_back(new OOp_OR());
+ m_bORCondition = sal_True;
+ }
+ else if (SQL_ISTOKEN(pPredicateNode->getChild(1),AND)) // AND-Operator
+ m_aCodeList.push_back(new OOp_AND());
+ else
+ {
+ DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree");
+ }
+ }
+ else if (SQL_ISRULE(pPredicateNode,boolean_factor))
+ {
+ execute(pPredicateNode->getChild(1));
+ m_aCodeList.push_back(new OOp_NOT());
+ }
+ else if (SQL_ISRULE(pPredicateNode,comparison_predicate))
+ {
+ execute_COMPARE(pPredicateNode);
+ }
+ else if (SQL_ISRULE(pPredicateNode,like_predicate))
+ {
+ execute_LIKE(pPredicateNode);
+ }
+ else if (SQL_ISRULE(pPredicateNode,between_predicate))
+ {
+ execute_BETWEEN(pPredicateNode);
+ }
+ else if (SQL_ISRULE(pPredicateNode,test_for_null))
+ {
+ execute_ISNULL(pPredicateNode);
+ }
+ else if(SQL_ISRULE(pPredicateNode,num_value_exp))
+ {
+ execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
+ execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
+ if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"+"))
+ {
+ m_aCodeList.push_back(new OOp_ADD());
+ }
+ else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"-"))
+ m_aCodeList.push_back(new OOp_SUB());
+ else
+ {
+ DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree num_value_exp");
+ }
+ }
+ else if(SQL_ISRULE(pPredicateNode,term))
+ {
+ execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
+ execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
+ if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"*"))
+ {
+ m_aCodeList.push_back(new OOp_MUL());
+ }
+ else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"/"))
+ m_aCodeList.push_back(new OOp_DIV());
+ else
+ {
+ DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree num_value_exp");
+ }
+ }
+ else
+ pOperand = execute_Operand(pPredicateNode); // jetzt werden nur einfache Operanden verarbeitet
+
+ return pOperand;
+}
+
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_COMPARE(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() == 3,"OFILECursor: Fehler im Parse Tree");
+
+ if ( !(SQL_ISRULE(pPredicateNode->getChild(0),column_ref) ||
+ pPredicateNode->getChild(2)->getNodeType() == SQL_NODE_STRING ||
+ pPredicateNode->getChild(2)->getNodeType() == SQL_NODE_INTNUM ||
+ pPredicateNode->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM ||
+ SQL_ISTOKEN(pPredicateNode->getChild(2),TRUE) ||
+ SQL_ISTOKEN(pPredicateNode->getChild(2),FALSE) ||
+ SQL_ISRULE(pPredicateNode->getChild(2),parameter) ||
+ // odbc date
+ SQL_ISRULE(pPredicateNode->getChild(2),set_fct_spec) ||
+ SQL_ISRULE(pPredicateNode->getChild(2),position_exp) ||
+ SQL_ISRULE(pPredicateNode->getChild(2),char_substring_fct) ||
+ // upper, lower etc.
+ SQL_ISRULE(pPredicateNode->getChild(2),fold)) )
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL);
+ return NULL;
+ }
+
+ sal_Int32 ePredicateType( SQLFilterOperator::EQUAL );
+ OSQLParseNode *pPrec = pPredicateNode->getChild(1);
+
+ if (pPrec->getNodeType() == SQL_NODE_EQUAL)
+ ePredicateType = SQLFilterOperator::EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL)
+ ePredicateType = SQLFilterOperator::NOT_EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_LESS)
+ ePredicateType = SQLFilterOperator::LESS;
+ else if (pPrec->getNodeType() == SQL_NODE_LESSEQ)
+ ePredicateType = SQLFilterOperator::LESS_EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_GREATEQ)
+ ePredicateType = SQLFilterOperator::GREATER_EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_GREAT)
+ ePredicateType = SQLFilterOperator::GREATER;
+ else
+ OSL_ENSURE( false, "OPredicateCompiler::execute_COMPARE: unexpected node type!" );
+
+ execute(pPredicateNode->getChild(0));
+ execute(pPredicateNode->getChild(2));
+ m_aCodeList.push_back( new OOp_COMPARE(ePredicateType) );
+
+ return NULL;
+}
+
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_LIKE(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ sal_Int32 ePredicateType;
+ sal_Unicode cEscape = L'\0';
+ if (pPredicateNode->count() == 5)
+ ePredicateType = SQLFilterOperator::NOT_LIKE;
+ else
+ ePredicateType = SQLFilterOperator::LIKE;
+
+ OSQLParseNode* pAtom = pPredicateNode->getChild(pPredicateNode->count()-2);
+ OSQLParseNode* pOptEscape = pPredicateNode->getChild(pPredicateNode->count()-1);
+
+ if (!(pAtom->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(pAtom,parameter)))
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL);
+ }
+ if (pOptEscape->count() != 0)
+ {
+ if (pOptEscape->count() != 2)
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL);
+ }
+ OSQLParseNode *pEscNode = pOptEscape->getChild(1);
+ if (pEscNode->getNodeType() != SQL_NODE_STRING)
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL);
+ }
+ else
+ cEscape = pEscNode->getTokenValue().toChar();
+ }
+
+ execute(pPredicateNode->getChild(0));
+ execute(pAtom);
+
+ OBoolOperator* pOperator = (ePredicateType == SQLFilterOperator::LIKE)
+ ? new OOp_LIKE(cEscape)
+ : new OOp_NOTLIKE(cEscape);
+ m_aCodeList.push_back(pOperator);
+
+ return NULL;
+}
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_BETWEEN(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() == 6,"OFILECursor: Fehler im Parse Tree");
+
+ OSQLParseNode* pColumn = pPredicateNode->getChild(0);
+ OSQLParseNode* p1stValue = pPredicateNode->getChild(3);
+ OSQLParseNode* p2ndtValue = pPredicateNode->getChild(5);
+
+ if (
+ !(p1stValue->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(p1stValue,parameter))
+ && !(p2ndtValue->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(p2ndtValue,parameter))
+ )
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_BETWEEN,NULL);
+ }
+
+ sal_Bool bNot = SQL_ISTOKEN(pPredicateNode->getChild(1),NOT);
+
+ OOperand* pColumnOp = execute(pColumn);
+ OOperand* pOb1 = execute(p1stValue);
+ OBoolOperator* pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::LESS_EQUAL : SQLFilterOperator::GREATER);
+ m_aCodeList.push_back(pOperator);
+
+ execute(pColumn);
+ OOperand* pOb2 = execute(p2ndtValue);
+ pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::GREATER_EQUAL : SQLFilterOperator::LESS);
+ m_aCodeList.push_back(pOperator);
+
+ if ( pColumnOp && pOb1 && pOb2 )
+ {
+ switch(pColumnOp->getDBType())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ pOb1->setValue(pOb1->getValue().getString());
+ pOb2->setValue(pOb2->getValue().getString());
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ pOb1->setValue((double)pOb1->getValue());
+ pOb2->setValue((double)pOb2->getValue());
+ break;
+ case DataType::FLOAT:
+ pOb1->setValue((float)pOb1->getValue());
+ pOb2->setValue((float)pOb2->getValue());
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ pOb1->setValue((double)pOb1->getValue());
+ pOb2->setValue((double)pOb2->getValue());
+ break;
+ case DataType::DATE:
+ pOb1->setValue((Date)pOb1->getValue());
+ pOb2->setValue((Date)pOb2->getValue());
+ break;
+ case DataType::TIME:
+ pOb1->setValue((Time)pOb1->getValue());
+ pOb2->setValue((Time)pOb2->getValue());
+ break;
+ case DataType::TIMESTAMP:
+ pOb1->setValue((DateTime)pOb1->getValue());
+ pOb2->setValue((DateTime)pOb2->getValue());
+ break;
+ }
+ }
+
+
+
+ OBoolOperator* pBoolOp = NULL;
+ if ( bNot )
+ pBoolOp = new OOp_OR();
+ else
+ pBoolOp = new OOp_AND();
+ m_aCodeList.push_back(pBoolOp);
+
+ return NULL;
+}
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_ISNULL(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() >= 3,"OFILECursor: Fehler im Parse Tree");
+ DBG_ASSERT(SQL_ISTOKEN(pPredicateNode->getChild(1),IS),"OFILECursor: Fehler im Parse Tree");
+
+ sal_Int32 ePredicateType;
+ if (SQL_ISTOKEN(pPredicateNode->getChild(2),NOT))
+ ePredicateType = SQLFilterOperator::NOT_SQLNULL;
+ else
+ ePredicateType = SQLFilterOperator::SQLNULL;
+
+ execute(pPredicateNode->getChild(0));
+ OBoolOperator* pOperator = (ePredicateType == SQLFilterOperator::SQLNULL) ?
+ new OOp_ISNULL() : new OOp_ISNOTNULL();
+ m_aCodeList.push_back(pOperator);
+
+ return NULL;
+}
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ OOperand* pOperand = NULL;
+
+ if (SQL_ISRULE(pPredicateNode,column_ref))
+ {
+ ::rtl::OUString aColumnName;
+ if (pPredicateNode->count() == 1)
+ {
+ aColumnName = pPredicateNode->getChild(0)->getTokenValue();
+ }
+ else if (pPredicateNode->count() == 3)
+ {
+ ::rtl::OUString aTableName = pPredicateNode->getChild(0)->getTokenValue();
+ if(SQL_ISRULE(pPredicateNode->getChild(2),column_val))
+ aColumnName = pPredicateNode->getChild(2)->getChild(0)->getTokenValue();
+ else
+ aColumnName = pPredicateNode->getChild(2)->getTokenValue();
+ }
+
+ if(!m_orgColumns->hasByName(aColumnName))
+ {
+ const ::rtl::OUString sError( m_pAnalyzer->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", aColumnName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, NULL );
+ }
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xCol;
+ try
+ {
+ if (m_orgColumns->getByName(aColumnName) >>= xCol)
+ {
+ pOperand = m_pAnalyzer->createOperandAttr(Reference< XColumnLocate>(m_orgColumns,UNO_QUERY)->findColumn(aColumnName),xCol,m_xIndexes);
+ }
+ else
+ {// Column existiert nicht im Resultset
+ const ::rtl::OUString sError( m_pAnalyzer->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", aColumnName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, NULL );
+ }
+ }
+ catch(Exception &)
+ {
+ OSL_ENSURE(0,"OPredicateCompiler::execute_Operand Exception");
+ }
+ }
+ else if (SQL_ISRULE(pPredicateNode,parameter))
+ {
+ pOperand = new OOperandParam(pPredicateNode, ++m_nParamCounter);
+ }
+ else if (pPredicateNode->getNodeType() == SQL_NODE_STRING ||
+ pPredicateNode->getNodeType() == SQL_NODE_INTNUM ||
+ pPredicateNode->getNodeType() == SQL_NODE_APPROXNUM ||
+ pPredicateNode->getNodeType() == SQL_NODE_NAME ||
+ SQL_ISTOKEN(pPredicateNode,TRUE) ||
+ SQL_ISTOKEN(pPredicateNode,FALSE) ||
+ SQL_ISRULE(pPredicateNode,parameter))
+ {
+ pOperand = new OOperandConst(*pPredicateNode, pPredicateNode->getTokenValue());
+ }
+ else if((pPredicateNode->count() == 2) &&
+ (SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"+") || SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"-")) &&
+ pPredicateNode->getChild(1)->getNodeType() == SQL_NODE_INTNUM)
+ { // falls -1 bzw. +1 vorhanden ist
+ ::rtl::OUString aValue(pPredicateNode->getChild(0)->getTokenValue());
+ aValue += pPredicateNode->getChild(1)->getTokenValue();
+ pOperand = new OOperandConst(*pPredicateNode->getChild(1), aValue);
+ }
+ else if( SQL_ISRULE(pPredicateNode,set_fct_spec) && SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"{") )
+ {
+ const OSQLParseNode* pODBCNode = pPredicateNode->getChild(1);
+ const OSQLParseNode* pODBCNodeChild = pODBCNode->getChild(0);
+
+ // Odbc Date or time
+ if (pODBCNodeChild->getNodeType() == SQL_NODE_KEYWORD && (
+ SQL_ISTOKEN(pODBCNodeChild,D) ||
+ SQL_ISTOKEN(pODBCNodeChild,T) ||
+ SQL_ISTOKEN(pODBCNodeChild,TS) ))
+ {
+ ::rtl::OUString sDateTime = pODBCNode->getChild(1)->getTokenValue();
+ pOperand = new OOperandConst(*pODBCNode->getChild(1), sDateTime);
+ if(SQL_ISTOKEN(pODBCNodeChild,D))
+ {
+ pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(sDateTime)));
+ }
+ else if(SQL_ISTOKEN(pODBCNodeChild,T))
+ {
+ pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(sDateTime)));
+ }
+ else if(SQL_ISTOKEN(pODBCNodeChild,TS))
+ {
+ pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(sDateTime)));
+ }
+ }
+ else
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL);
+
+ }
+ else if( SQL_ISRULE(pPredicateNode,fold) )
+ {
+ execute_Fold(pPredicateNode);
+ }
+ else if( SQL_ISRULE(pPredicateNode,set_fct_spec)
+ || SQL_ISRULE(pPredicateNode,position_exp)
+ || SQL_ISRULE(pPredicateNode,char_substring_fct)
+ )
+ {
+ executeFunction(pPredicateNode);
+ }
+ else if( SQL_ISRULE(pPredicateNode,length_exp) )
+ {
+ executeFunction(pPredicateNode->getChild(0));
+ }
+ else
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL);
+ }
+ if (pOperand)
+ m_aCodeList.push_back(pOperand);
+ return pOperand;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+sal_Bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
+{
+ static sal_Bool bResult;
+
+ OCodeList::iterator aIter = rCodeList.begin();
+ if (!(*aIter))
+ return sal_True; // kein Praedikat
+
+ for(;aIter != rCodeList.end();++aIter)
+ {
+ OOperand* pOperand = PTR_CAST(OOperand,(*aIter));
+ if (pOperand)
+ m_aStack.push(pOperand);
+ else
+ ((OOperator *)(*aIter))->Exec(m_aStack);
+ }
+
+ OOperand* pOperand = m_aStack.top();
+ m_aStack.pop();
+
+ DBG_ASSERT(m_aStack.size() == 0, "StackFehler");
+ DBG_ASSERT(pOperand, "StackFehler");
+
+ bResult = pOperand->isValid();
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+ return bResult;
+}
+// -----------------------------------------------------------------------------
+void OPredicateInterpreter::evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal)
+{
+ OCodeList::iterator aIter = rCodeList.begin();
+ if (!(*aIter))
+ return ; // kein Praedikat
+
+ for(;aIter != rCodeList.end();++aIter)
+ {
+ OOperand* pOperand = PTR_CAST(OOperand,(*aIter));
+ if (pOperand)
+ m_aStack.push(pOperand);
+ else
+ ((OOperator *)(*aIter))->Exec(m_aStack);
+ }
+
+ OOperand* pOperand = m_aStack.top();
+ m_aStack.pop();
+
+ DBG_ASSERT(m_aStack.size() == 0, "StackFehler");
+ DBG_ASSERT(pOperand, "StackFehler");
+
+ (*_rVal) = pOperand->getValue();
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+// -----------------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_Fold(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ sal_Bool bUpper = SQL_ISTOKEN(pPredicateNode->getChild(0),UPPER);
+
+ execute(pPredicateNode->getChild(2));
+ OOperator* pOperator = NULL;
+ if ( bUpper )
+ pOperator = new OOp_Upper();
+ else
+ pOperator = new OOp_Lower();
+
+ m_aCodeList.push_back(pOperator);
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+OOperand* OPredicateCompiler::executeFunction(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ OOperator* pOperator = NULL;
+
+ OSL_ENSURE(pPredicateNode->getChild(0)->isToken(),"The first one must be the name of the function!");
+ sal_Int32 nTokenId = pPredicateNode->getChild(0)->getTokenID();
+ switch ( nTokenId )
+ {
+ case SQL_TOKEN_CHAR_LENGTH:
+ case SQL_TOKEN_CHARACTER_LENGTH:
+ case SQL_TOKEN_LENGTH:
+ case SQL_TOKEN_OCTET_LENGTH:
+ case SQL_TOKEN_ASCII:
+ case SQL_TOKEN_LCASE:
+ case SQL_TOKEN_LTRIM:
+ case SQL_TOKEN_RTRIM:
+ case SQL_TOKEN_SPACE:
+ case SQL_TOKEN_UCASE:
+ case SQL_TOKEN_ABS:
+ case SQL_TOKEN_ACOS:
+ case SQL_TOKEN_ASIN:
+ case SQL_TOKEN_ATAN:
+ case SQL_TOKEN_CEILING:
+ case SQL_TOKEN_COS:
+ case SQL_TOKEN_DEGREES:
+ case SQL_TOKEN_EXP:
+ case SQL_TOKEN_FLOOR:
+ case SQL_TOKEN_LOG10:
+ case SQL_TOKEN_LN:
+ case SQL_TOKEN_RADIANS:
+ case SQL_TOKEN_SIGN:
+ case SQL_TOKEN_SIN:
+ case SQL_TOKEN_SQRT:
+ case SQL_TOKEN_TAN:
+ case SQL_TOKEN_DAYNAME:
+ case SQL_TOKEN_DAYOFMONTH:
+ case SQL_TOKEN_DAYOFWEEK:
+ case SQL_TOKEN_DAYOFYEAR:
+ case SQL_TOKEN_HOUR:
+ case SQL_TOKEN_MINUTE:
+ case SQL_TOKEN_MONTH:
+ case SQL_TOKEN_MONTHNAME:
+ case SQL_TOKEN_QUARTER:
+ case SQL_TOKEN_SECOND:
+ case SQL_TOKEN_YEAR:
+
+ execute(pPredicateNode->getChild(2));
+
+ switch( nTokenId )
+ {
+ case SQL_TOKEN_CHAR_LENGTH:
+ case SQL_TOKEN_CHARACTER_LENGTH:
+ case SQL_TOKEN_LENGTH:
+ case SQL_TOKEN_OCTET_LENGTH:
+ pOperator = new OOp_CharLength();
+ break;
+ case SQL_TOKEN_ASCII:
+ pOperator = new OOp_Ascii();
+ break;
+ case SQL_TOKEN_LCASE:
+ pOperator = new OOp_Lower();
+ break;
+
+ case SQL_TOKEN_LTRIM:
+ pOperator = new OOp_LTrim();
+ break;
+ case SQL_TOKEN_RTRIM:
+ pOperator = new OOp_RTrim();
+ break;
+ case SQL_TOKEN_SPACE:
+ pOperator = new OOp_Space();
+ break;
+ case SQL_TOKEN_UCASE:
+ pOperator = new OOp_Upper();
+ break;
+ case SQL_TOKEN_ABS:
+ pOperator = new OOp_Abs();
+ break;
+ case SQL_TOKEN_ACOS:
+ pOperator = new OOp_ACos();
+ break;
+ case SQL_TOKEN_ASIN:
+ pOperator = new OOp_ASin();
+ break;
+ case SQL_TOKEN_ATAN:
+ pOperator = new OOp_ATan();
+ break;
+ case SQL_TOKEN_CEILING:
+ pOperator = new OOp_Ceiling();
+ break;
+ case SQL_TOKEN_COS:
+ pOperator = new OOp_Cos();
+ break;
+ case SQL_TOKEN_DEGREES:
+ pOperator = new OOp_Degrees();
+ break;
+ case SQL_TOKEN_EXP:
+ pOperator = new OOp_Exp();
+ break;
+ case SQL_TOKEN_FLOOR:
+ pOperator = new OOp_Floor();
+ break;
+ case SQL_TOKEN_LOG10:
+ pOperator = new OOp_Log10();
+ break;
+ case SQL_TOKEN_LN:
+ pOperator = new OOp_Ln();
+ break;
+ case SQL_TOKEN_RADIANS:
+ pOperator = new OOp_Radians();
+ break;
+ case SQL_TOKEN_SIGN:
+ pOperator = new OOp_Sign();
+ break;
+ case SQL_TOKEN_SIN:
+ pOperator = new OOp_Sin();
+ break;
+ case SQL_TOKEN_SQRT:
+ pOperator = new OOp_Sqrt();
+ break;
+ case SQL_TOKEN_TAN:
+ pOperator = new OOp_Tan();
+ break;
+ case SQL_TOKEN_DAYOFWEEK:
+ pOperator = new OOp_DayOfWeek();
+ break;
+ case SQL_TOKEN_DAYOFMONTH:
+ pOperator = new OOp_DayOfMonth();
+ break;
+ case SQL_TOKEN_DAYOFYEAR:
+ pOperator = new OOp_DayOfYear();
+ break;
+ case SQL_TOKEN_MONTH:
+ pOperator = new OOp_Month();
+ break;
+ case SQL_TOKEN_DAYNAME:
+ pOperator = new OOp_DayName();
+ break;
+ case SQL_TOKEN_MONTHNAME:
+ pOperator = new OOp_MonthName();
+ break;
+ case SQL_TOKEN_QUARTER:
+ pOperator = new OOp_Quarter();
+ break;
+ case SQL_TOKEN_YEAR:
+ pOperator = new OOp_Year();
+ break;
+ case SQL_TOKEN_HOUR:
+ pOperator = new OOp_Hour();
+ break;
+ case SQL_TOKEN_MINUTE:
+ pOperator = new OOp_Minute();
+ break;
+ case SQL_TOKEN_SECOND:
+ pOperator = new OOp_Second();
+ break;
+ default:
+ OSL_ENSURE(0,"Error in switch!");
+ }
+ break;
+ case SQL_TOKEN_CHAR:
+ case SQL_TOKEN_CONCAT:
+ case SQL_TOKEN_INSERT:
+ case SQL_TOKEN_LEFT:
+ case SQL_TOKEN_LOCATE:
+ case SQL_TOKEN_LOCATE_2:
+ case SQL_TOKEN_REPEAT:
+ case SQL_TOKEN_REPLACE:
+ case SQL_TOKEN_RIGHT:
+ case SQL_TOKEN_MOD:
+ case SQL_TOKEN_ROUND:
+ case SQL_TOKEN_LOGF:
+ case SQL_TOKEN_LOG:
+ case SQL_TOKEN_POWER:
+ case SQL_TOKEN_ATAN2:
+ case SQL_TOKEN_PI:
+ case SQL_TOKEN_CURDATE:
+ case SQL_TOKEN_CURTIME:
+ case SQL_TOKEN_NOW:
+ case SQL_TOKEN_WEEK:
+ {
+ m_aCodeList.push_back(new OStopOperand);
+ OSQLParseNode* pList = pPredicateNode->getChild(2);
+ for (sal_uInt32 i=0; i < pList->count(); ++i)
+ execute(pList->getChild(i));
+
+ switch( nTokenId )
+ {
+ case SQL_TOKEN_CHAR:
+ pOperator = new OOp_Char();
+ break;
+ case SQL_TOKEN_CONCAT:
+ pOperator = new OOp_Concat();
+ break;
+ case SQL_TOKEN_INSERT:
+ pOperator = new OOp_Insert();
+ break;
+ case SQL_TOKEN_LEFT:
+ pOperator = new OOp_Left();
+ break;
+ case SQL_TOKEN_LOCATE:
+ case SQL_TOKEN_LOCATE_2:
+ pOperator = new OOp_Locate();
+ break;
+ case SQL_TOKEN_REPEAT:
+ pOperator = new OOp_Repeat();
+ break;
+ case SQL_TOKEN_REPLACE:
+ pOperator = new OOp_Replace();
+ break;
+ case SQL_TOKEN_RIGHT:
+ pOperator = new OOp_Right();
+ break;
+ case SQL_TOKEN_MOD:
+ pOperator = new OOp_Mod();
+ break;
+ case SQL_TOKEN_ROUND:
+ pOperator = new OOp_Round();
+ break;
+ case SQL_TOKEN_LOGF:
+ case SQL_TOKEN_LOG:
+ pOperator = new OOp_Log();
+ break;
+ case SQL_TOKEN_POWER:
+ pOperator = new OOp_Pow();
+ break;
+ case SQL_TOKEN_ATAN2:
+ pOperator = new OOp_ATan2();
+ break;
+ case SQL_TOKEN_PI:
+ pOperator = new OOp_Pi();
+ break;
+ case SQL_TOKEN_CURDATE:
+ pOperator = new OOp_CurDate();
+ break;
+ case SQL_TOKEN_CURTIME:
+ pOperator = new OOp_CurTime();
+ break;
+ case SQL_TOKEN_NOW:
+ pOperator = new OOp_Now();
+ break;
+ case SQL_TOKEN_WEEK:
+ pOperator = new OOp_Week();
+ break;
+ default:
+ OSL_ENSURE(0,"Error in switch!");
+ }
+ }
+ break;
+
+ case SQL_TOKEN_SUBSTRING:
+ m_aCodeList.push_back(new OStopOperand);
+ if ( pPredicateNode->count() == 4 ) //char_substring_fct
+ {
+ OSQLParseNode* pList = pPredicateNode->getChild(2);
+ for (sal_uInt32 i=0; i < pList->count(); ++i)
+ execute(pList->getChild(i));
+ }
+ else
+ {
+ execute(pPredicateNode->getChild(2));
+ execute(pPredicateNode->getChild(4));
+ execute(pPredicateNode->getChild(5)->getChild(1));
+ }
+ pOperator = new OOp_SubString();
+ break;
+
+ case SQL_TOKEN_POSITION:
+ m_aCodeList.push_back(new OStopOperand);
+ if ( pPredicateNode->count() == 4 ) //position_exp
+ {
+ OSQLParseNode* pList = pPredicateNode->getChild(2);
+ for (sal_uInt32 i=0; i < pList->count(); ++i)
+ execute(pList->getChild(i));
+ }
+ else
+ {
+ execute(pPredicateNode->getChild(2));
+ execute(pPredicateNode->getChild(4));
+ }
+ pOperator = new OOp_Locate();
+ break;
+ default:
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_FUNCTION_NOT_SUPPORTED,NULL);
+ }
+
+ m_aCodeList.push_back(pOperator);
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/file/file.xml b/connectivity/source/drivers/file/file.xml
new file mode 100644
index 000000000000..9e8fc7e7a095
--- /dev/null
+++ b/connectivity/source/drivers/file/file.xml
@@ -0,0 +1,32 @@
+<?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.sdbc.driver.file.Driver</name>
+ <description>This library implements basic functionallity for file-base drivers.
+</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>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/file/makefile.mk b/connectivity/source/drivers/file/makefile.mk
new file mode 100644
index 000000000000..6cc615a0cc32
--- /dev/null
+++ b/connectivity/source/drivers/file/makefile.mk
@@ -0,0 +1,108 @@
+#*************************************************************************
+#
+# 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=file
+
+USE_DEFFILE=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+CDEFS += -DOOO_DLLIMPLEMENTATION_FILE
+
+# --- Files -------------------------------------
+EXCEPTIONSFILES=\
+ $(SLO)$/FNoException.obj \
+ $(SLO)$/FConnection.obj \
+ $(SLO)$/FResultSetMetaData.obj \
+ $(SLO)$/FColumns.obj \
+ $(SLO)$/FTables.obj \
+ $(SLO)$/FTable.obj \
+ $(SLO)$/FCatalog.obj \
+ $(SLO)$/FResultSet.obj \
+ $(SLO)$/FStatement.obj \
+ $(SLO)$/FPreparedStatement.obj \
+ $(SLO)$/FDatabaseMetaData.obj \
+ $(SLO)$/FDriver.obj \
+ $(SLO)$/fanalyzer.obj \
+ $(SLO)$/fcomp.obj \
+ $(SLO)$/fcode.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/FStringFunctions.obj \
+ $(SLO)$/FDateFunctions.obj \
+ $(SLO)$/FNumericFunctions.obj \
+ $(SLO)$/quotedstring.obj
+
+
+# --- Library -----------------------------------
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(UCBHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt \
+ $(SLB)$/$(TARGET).lib
+DEFLIB1NAME=$(TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
+# --- filter file ------------------------------
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo _TI >$@
+ @echo _real >>$@
+
diff --git a/connectivity/source/drivers/file/quotedstring.cxx b/connectivity/source/drivers/file/quotedstring.cxx
new file mode 100644
index 000000000000..9b315f8cce85
--- /dev/null
+++ b/connectivity/source/drivers/file/quotedstring.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * 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 "file/quotedstring.hxx"
+#include <rtl/logfile.hxx>
+
+namespace connectivity
+{
+ //==================================================================
+ //= QuotedTokenizedString
+ //==================================================================
+ //------------------------------------------------------------------
+ xub_StrLen QuotedTokenizedString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "QuotedTokenizedString::GetTokenCount" );
+ const xub_StrLen nLen = m_sString.Len();
+ if ( !nLen )
+ return 0;
+
+ xub_StrLen nTokCount = 1;
+ BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token?
+ BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String?
+
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ for( xub_StrLen i = 0; i < nLen; ++i )
+ {
+ const sal_Unicode cChar = m_sString.GetChar(i);
+ if (bStart)
+ {
+ bStart = FALSE;
+ // Erstes Zeichen ein String-Delimiter?
+ if ( cChar == cStrDel )
+ {
+ bInString = TRUE; // dann sind wir jetzt INNERHALB des Strings!
+ continue; // dieses Zeichen ueberlesen!
+ }
+ }
+
+ if (bInString)
+ {
+ // Wenn jetzt das String-Delimiter-Zeichen auftritt ...
+ if ( cChar == cStrDel )
+ {
+ if ((i+1 < nLen) && (m_sString.GetChar(i+1) == cStrDel))
+ {
+ // Verdoppeltes String-Delimiter-Zeichen:
+ ++i; // kein String-Ende, naechstes Zeichen ueberlesen.
+ }
+ else
+ {
+ // String-Ende
+ bInString = FALSE;
+ }
+ }
+ } // if (bInString)
+ else
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( cChar == cTok )
+ {
+ ++nTokCount;
+ bStart = TRUE;
+ }
+ }
+ }
+ //OSL_TRACE("QuotedTokenizedString::nTokCount = %d\n", ((OUtoCStr(::rtl::OUString(nTokCount))) ? (OUtoCStr(::rtl::OUString(nTokCount))):("NULL")) );
+
+ return nTokCount;
+ }
+
+ //------------------------------------------------------------------
+ void QuotedTokenizedString::GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel ) const
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "QuotedTokenizedString::GetTokenCount" );
+ _rStr.Erase();
+ const xub_StrLen nLen = m_sString.Len();
+ if ( nLen )
+ {
+ BOOL bInString = (nStartPos < nLen) && (m_sString.GetChar(nStartPos) == cStrDel); // Befinden wir uns INNERHALB eines (cStrDel delimited) String?
+
+ // Erstes Zeichen ein String-Delimiter?
+ if (bInString )
+ ++nStartPos; // dieses Zeichen ueberlesen!
+ if ( nStartPos >= nLen )
+ return;
+
+ sal_Unicode* pData = _rStr.AllocBuffer( nLen - nStartPos + 1 );
+ const sal_Unicode* pStart = pData;
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ for( xub_StrLen i = nStartPos; i < nLen; ++i )
+ {
+ const sal_Unicode cChar = m_sString.GetChar(i);
+ if (bInString)
+ {
+ // Wenn jetzt das String-Delimiter-Zeichen auftritt ...
+ if ( cChar == cStrDel )
+ {
+ if ((i+1 < nLen) && (m_sString.GetChar(i+1) == cStrDel))
+ {
+ // Verdoppeltes String-Delimiter-Zeichen:
+ // kein String-Ende, naechstes Zeichen ueberlesen.
+ ++i;
+ *pData++ = m_sString.GetChar(i); // Zeichen gehoert zum Resultat-String
+ }
+ else
+ {
+ // String-Ende
+ bInString = FALSE;
+ *pData = 0;
+ }
+ }
+ else
+ {
+ *pData++ = cChar; // Zeichen gehoert zum Resultat-String
+ }
+
+ }
+ else
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok
+ if ( cChar == cTok )
+ {
+ // Vorzeitiger Abbruch der Schleife moeglich, denn
+ // wir haben, was wir wollten.
+ nStartPos = i+1;
+ break;
+ }
+ else
+ {
+ *pData++ = cChar; // Zeichen gehoert zum Resultat-String
+ }
+ }
+ } // for( xub_StrLen i = nStartPos; i < nLen; ++i )
+ *pData = 0;
+ _rStr.ReleaseBufferAccess(xub_StrLen(pData - pStart));
+ }
+ }
+}